5

J_Dream | PHP文件上传-流量层面WAF绕过

 1 year ago
source link: https://blog.51cto.com/JDream/5445370
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

J_Dream | PHP文件上传-流量层面WAF绕过

今天刷某论坛发现挺新奇的东西(流量层面WAF绕过)但是因为配置环境一点难弄,我就简单写几句php代码,复现一下文件上传绕过原理!!!

简陋环境介绍

一共2页面upload.htmlup.php,工具利用了burp
J_Dream | PHP文件上传-流量层面WAF绕过_绕过waf

<!--上面图片upload.html-->
<html><head><meta charset="utf-8"><title>upload</title></head>
<body>
<p>upload_file -> txt</p>
<form method="post" action="up.php" enctype="multipart/form-data">
<label for="file">upload_file:</label><input type="file" name="upfile" value=""><br>
<input type="submit" name="submit" value="submit">
</form>
</body></html> <!-- 就是简陋的上传页面 -->
<?php
//up.php接收upload.html的数据打印出来,不进行保存文件
var_dump($_POST);
?>

绕过waf小技巧还原

  • \/加入文件名里面可以进行截断,从而绕过流量waf。
  • 例如test.txt\test.php经过php处理后截断成test.php
    J_Dream | PHP文件上传-流量层面WAF绕过_绕过waf_02
    J_Dream | PHP文件上传-流量层面WAF绕过_文件上传_03
  • 这个跟上面差不多,后向就是在文件后面加入00截断
  • 类似test.php(00)aaa的文件名经php处理过后会变成test.php
    J_Dream | PHP文件上传-流量层面WAF绕过_绕过waf_04
  • 绕过步骤 打开Request包Hex页面找到test.phpaaatest.php后面插入一个16进制的00
    J_Dream | PHP文件上传-流量层面WAF绕过_php_05
    J_Dream | PHP文件上传-流量层面WAF绕过_文件上传_06
    J_Dream | PHP文件上传-流量层面WAF绕过_文件上传_07

文件名末尾只加入\字符会被忽略掉

  • 看图吧
    J_Dream | PHP文件上传-流量层面WAF绕过_文件上传_08

文件中;可以影响文件名解析的结果

  • 但是记得要把""去到,不然解析失败哒!
    J_Dream | PHP文件上传-流量层面WAF绕过_php_09

双写filename来绕过

  • 也就是写多一个filename=xxx;filename=xxx
    J_Dream | PHP文件上传-流量层面WAF绕过_绕过waf_10

好啦,就介绍到这里啦!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK