DVWA Contradiction #01
0x01 WooYun-2013-34885
输入1'
,显示了,但是发现被转义了。
尝试宽字节注入,在浏览器中输入1%df%27
,无宽字节注入。
想起之前做的一个题,尝试用\
继续转义
感觉没戏了,而且还试过了整形判断,应该是字符型的,转义了'
,到这其实我已经放弃了。。。跑去看了下提示。
试一波1'
,让人惊喜。。。
报错了,感觉像是&#
被过滤了,其实我也不知道发生了什么。。。尝试了下1' union select 1,2#
。
居然说字段数不一致,看来是,
被过滤了,换一手1' and 1=1 union select * from (select user from users)a join (select password from users)b#
成功拿到数据,挺意外的,看源码去。
0x02 源码分析
WooYun-2013-34885 Source
<?php if(isset($_GET['Submit'])){// Retrieve data$id = addslashes($_GET['id']);$id = RemoveXSS($id);$getid = "SELECT first_name, last_name FROM users WHERE user_id = '$id'";$result = mysql_query($getid) or die('<pre>' . mysql_error() . '</pre>' );$num = mysql_numrows($result);$i = 0;while ($i < $num) {$first = mysql_result($result,$i,"first_name");$last = mysql_result($result,$i,"last_name");echo '<pre>';echo 'ID: ' . $id . '<br>First name: ' . $first . '<br>Surname: ' . $last;echo '</pre>';$i++;}}function RemoveXSS($val) { // remove all non-printable characters. CR(0a) and LF(0b) and TAB(9) are allowed// this prevents some character re-spacing such as <java\0script>// note that you have to handle splits with \n, \r, and \t later since they *are* allowed in some inputs$val = preg_replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/', '', $val); // straight replacements, the user should never need these since they're normal characters// this prevents like <IMG SRC=@avascript:alert('XSS')>$search = 'abcdefghijklmnopqrstuvwxyz'; $search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $search .= '1234567890!@#$%^&*()'; $search .= '~`";:?+/={}[]-_|\'\\'; for ($i = 0; $i < strlen($search); $i++) { // ;? matches the ;, which is optional// 0{0,7} matches any padded zeros, which are optional and go up to 8 chars// @ @ search for the hex values$val = preg_replace('/(&#[xX]0{0,8}'.dechex(ord($search[$i])).';?)/i', $search[$i], $val);//with a ;// @ @ 0{0,7} matches '0' zero to seven times$val = preg_replace('/(�{0,8}'.ord($search[$i]).';?)/', $search[$i], $val); // with a ;} // now the only remaining whitespace attacks are \t, \n, and \r$ra1 = Array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base'); $ra2 = Array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload'); $ra = array_merge($ra1, $ra2); $found = true; // keep replacing as long as the previous round replaced somethingwhile ($found == true) { $val_before = $val; for ($i = 0; $i < sizeof($ra); $i++) { $pattern = '/'; for ($j = 0; $j < strlen($ra[$i]); $j++) { if ($j > 0) { $pattern .= '('; $pattern .= '(&#[xX]0{0,8}([9ab]);)'; $pattern .= '|'; $pattern .= '|(�{0,8}([9|10|13]);)'; $pattern .= ')*'; } $pattern .= $ra[$i][$j]; } $pattern .= '/i'; $replacement = substr($ra[$i], 0, 2).'<x>'.substr($ra[$i], 2); // add in <> to nerf the tag$val = preg_replace($pattern, $replacement, $val); // filter out the hex tagsif ($val_before == $val) { // no replacements were made, so exit the loop$found = false; } } } return $val;
}?>
一看源码,我才知道这居然是防XSS的,如果单纯防注入,那个addslashes()
就够了。
绕过是因为这里,针对十六进制和十进制做了过滤,加上前面的&#
其实就是过滤一些字符实体,至于XSS,JS学的并不好,还是等到以后研究XSS时再回来搞吧,溜了溜了。
DVWA Contradiction #01相关推荐
- DVWA 不跳转_渗透测试入门-DVWA应用渗透软件安装与使用
简介:DVWA是一个用来进行安全脆弱性鉴定的PHP/MySQL Web应用程序,其主要目标是帮助安全专业人员在法律环境中测试他们的技能和工具,帮助运维人员掌握基本的安全测试知识,帮助Web开发人员更 ...
- dvwa如何打开_一篇文章让你搭建自己的Web安全测试平台(Dvwa)
如果要学习Web安全测试,不能纸上谈兵,需要尝试和实践.只有在不断的尝试和实践中,你的技术才会有本质的提升.这篇文章告诉你,如何在自己的电脑上搭建一个Web安全测试平台(Dvwa). 由于Dvwa是用 ...
- DVWA靶场系列1-环境搭建
文章目录 前言 一.DVWA是什么? 二.Kali2022.2下安装 检查完善 前言 基于Kali2022.2搭建的DVWA靶场环境 一.DVWA是什么? https://github.com/dig ...
- 自学渗透测试:使用 DVWA 和 SQLmap 探寻 SQL 注入攻击与防范
数据来源 本文仅用于信息安全学习,请遵守相关法律法规,严禁用于非法途径.若观众因此作出任何危害网络安全的行为,后果自负,与本人无关. 01 耳熟能详的SQ注入是什么? 关于SQL注入漏洞,维基 ...
- 01. Web漏洞靶场的搭建
01. Web漏洞靶场的搭建 Web漏洞靶场的搭建(上) 什么是Web安全? 什么是Web Web是互联网的总称,全称为World Wide Web,缩写WWW,即全球广域网,也称为万维网,它是一种基 ...
- 在php环境下搭建dvwa,CentOS7搭建DVWA测试环境
1.部署环境 CentOS Linux release 7.7.1908 (Core) Apache/2.4.6 (CentOS) 5.5.64-MariaDB MariaDB Server PHP ...
- XSS跨站脚本攻击(DVWA XSS攻击详解、XSS平台搭建)
一.跨站脚本攻击过程 二.XSS攻击定义及危害 三.XSS攻击常见分类 例:反射型 例:存储型 例:DOM型 四.XSS攻击常见编码 例: 编码后: 五.XSS常见测试语句 Script 标签 Scr ...
- DVWA靶场01-系统命令执行漏洞利用及防护(Low/Medium/Hight)
目录 01-Low 01.1 任意文件读取 01.2 小马实现Getshell 01.2.1 获取网站路径 01.2.2 写入一句话木马 01.2.3 连接一句话木马 01.3 设置后门 02-Med ...
- 零起点学算法01——第一个程序Hello World!
零起点学算法01--第一个程序Hello World! Description 题目很简单 输出"Hello World!"(不含引号),并换行. Input 没有输入 Outpu ...
- hdu5296 01字典树
根据二进制建一棵01字典树,每个节点的答案等于左节点0的个数 * 右节点1的个数 * 2,遍历整棵树就能得到答案. AC代码: #include<cstdio> using namespa ...
最新文章
- win服务器管理器“丢失”了怎么办?
- 电脑删除linux系统,我的电脑现在装有XP和Linux两个系统,现在想删除Linux系统,开机不用选直接进入XP。不知怎么做??...
- 腾讯成联合国全球合作伙伴,TDSQL如何支撑史上最大规模全球会议
- 界面原型设计工具Balsamiq、墨刀、Axure、Mockplus
- 60秒验证码倒计时重置
- 计算机存储单位字的英语,计算机存储基本单位,位、字节、字以及KB、MB和GB怎么换算?...
- vuex文档阅读学习1
- Ubuntu下安装Nginx服务器并进行优化
- 2月12 CNN结构特征+Faster R-CNN
- JavaScript 编程精解 中文第三版 四、数据结构:对象和数组
- Garbled Circuits介绍 - 4 混淆电路的优化
- coreldraw梯形校正_CDR绘图教程,教你CorelDRAW如何绘制等腰梯形
- 触摸屏一体机的类型有哪些
- ajax 发http请求吗,使用 Ajax 发送 http 请求 (getpost 请求)
- 关于使用SpringBoot导出Pdf(itextpdf)
- 读余华《活着》,你好,我叫福贵
- 2寸照片尺寸大小是多少,两寸照片多大?
- 影响你选择职业的,跟个人相关的主要的因素
- 文书档案管理系统服务器版,创奇文书档案管理系统客户端官方版
- Windows 10 无法设置代理