使用data伪协议绕过圆括号、反引号被过滤

本文探讨在特定环境中如何利用data协议绕过常见的代码过滤技术,如中括号、圆括号和反引号过滤,尤其是在编码绕过不可行的情况下。通过一个具体的测试平台示例,展示了使用伪协议进行XSS攻击的有效性。

data协议常用数据格式

在这里插入图片描述

不使用编码的方式绕过圆括号过滤

环境是https://xss.haozi.me/#/0x04 ,其中代码过滤了中括号、圆括号、反引号。于是尝试了编码绕过,使用实体编码之后很容易就绕过了。

function render (input) {
  const stripBracketsRe = /[()`]/g
  input = input.replace(stripBracketsRe, '')
  return input
}

在这里插入图片描述但是是不是还有其他的方法可以绕过呢,因为在实际测试中很可能编码绕过不可行。然后就想到了伪协议,之后通过搜索发现确实有在过滤了圆括号且编码绕过不可行的例子,例子中使用了data协议进行弹窗测试。在https://xss.haozi.me/#/0x04 测试之后弹窗了。
在这里插入图片描述

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> <title>Upload</title> <style> body { font-family: Arial, sans-serif; background-color: #f2f2f2; } .container { max-width: 400px; margin: 0 auto; padding: 20px; background-color: #fff; border-radius: 5px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); } .form-group { margin-bottom: 20px; } .form-group label { display: block; font-weight: bold; margin-bottom: 5px; } .form-group input[type="file"] { padding: 10px; border: 1px solid #ccc; border-radius: 5px; background-color: #fff; } .form-group input[type="submit"] { padding: 10px 20px; background-color: #4CAF50; color: #fff; border: none; border-radius: 5px; cursor: pointer; } .form-group input[type="submit"]:hover { background-color: #45a049; } </style> </head> <body> <div class="container"> <h2>文件上传</h2> <form action="index.php" method="POST" enctype="multipart/form-data"> <div class="form-group"> <label for="file">选择文件</label> <input type="file" name="file" id="file" /> </div> <div class="form-group"> <input type="submit" value="上传" /> </div> </form> </div> </body> </html> <!-- class.php --> Hacker? 这是它的源代码, 这是一道web题目,我该怎么找到flag,详细 http://160.30.231.222:33337/index.php 这是一开始的网站 <?php error_reporting(0); highlight_file(__FILE__); class hacker{ public $cmd; public $a; public function __destruct(){ if('hahaha' === preg_replace('/;+/','hahaha',preg_replace('/[A-Za-z_\(\)]+/','',$this->cmd))){ eval($this->cmd.'hahaha!'); } else { echo 'nonono'; } } } if(isset($_POST['file'])) { if(preg_match('/^phar:\/\//i',$_POST['file'])) { die("nonono"); } file_get_contents($_POST['file']); } ?> 在网站末尾加class.php找到源代码了
10-05
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值