网站被入侵写的脚本和py清除木马

作者 :
免费
  • 正文
  •  

    还原标题,但这里要注意的是,还原时有识别不了的源码 会卡住。

    import os
    import re

    # 定义要搜索的目录
    root_dir = '/www/wwwroot'

    # 定义要搜索的文件类型
    file_types = ['.html', '.php']

    # 定义要搜索的内容的正则表达式
    search_pattern = re.compile(r'<script>.*?document\.title\s*=\s*\'(.*?)\'.*?</script>', re.DOTALL)

    # 遍历目录及子目录下的文件
    for root, dirs, files in os.walk(root_dir):
    for file in files:
    if file.endswith(tuple(file_types)):
    file_path = os.path.join(root, file)
    # 读取文件内容
    with open(file_path, 'r', encoding='utf-8') as f:
    content = f.read()
    # 在内容中搜索匹配的内容
    match = search_pattern.search(content)
    if match:
    title_content = match.group(1)
    # 构建新的标题内容
    new_title_tag = f"<title>{title_content}</title>"
    # 替换文件中的内容
    modified_content = re.sub(search_pattern, new_title_tag, content)
    # 写入修改后的内容
    with open(file_path, 'w', encoding='utf-8') as f:
    f.write(modified_content)
    print(f"Processed: {file_path}")
    else:
    print(f"No matching script found in: {file_path}")

    END
    如本资源侵犯了您的权益,请联系投诉邮箱admin@wmphp.com进行举报!我们将在收到邮件的1个小时内处理完毕。 本站仅为平台,发布的资源均为用户投稿或转载!所有资源仅供参考学习使用,请在下载后的24小时内删除,禁止商用! Wmphp.com(完美源码)助力正版,如您有自己的原创产品,可以联系客服投稿,代理出售! Wmphp.com(完美源码)客服QQ:136882447 Wmphp.com(完美源码)商务电话(仅对企业客户/个人用户):15120086569 (微信同步) 请注意:本站不提供任何免费的技术咨询服务,为了节约时间,下载前 请确认自己会技术
    完美源码 » 网站被入侵写的脚本和py清除木马
    3518+

    本站勉强运行

    3694+

    用户总数

    692+

    资源总数

    0+

    今日更新

    2024-5-13

    最后更新时间