• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > 用Python和MD5实现网站挂马检测程序

用Python和MD5实现网站挂马检测程序

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了挂马程序,挂马,网页挂马,挂马是什么意思,网站挂马等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

一、程序测试

    Usage: python check_change.py update /home/wwwroot
           python check_change.py check /home/wwwroot

# python check_change.py update /data/www #生成站点的md5值
# echo ' ' > /data/www/sitemap.html #测试清空文件
# rm -rf /data/www/sitemap.xml #测试删除文件
# python check_change.py check /data/www  #查找那些文件被篡改
/data/www/sitemap.xml
/data/www/sitemap.html</div>
二、实现代码如下(check_change.py)

import os,sys,subprocess

def update(path):
    f = open(file,'w')
    for root,dirs,files in os.walk(path):
        for name in files:
            line = os.path.join(root, name)
            (stdin,stderr) = subprocess.Popen(['md5sum',line],stdout=subprocess.PIPE).communicate()
            f.write(stdin)
    f.close()

def check(path):
    f = open(file,'r')
    for line in f:
        check_ok = """echo '%s' | md5sum -c > /dev/null 2>&1""" % line
        #print check_ok
        if not subprocess.call(check_ok, shell = True) == 0:
            abnormal = line.split()
            print abnormal[1]
    f.close()

def Usage():
    print '''
    Usage: python %s update /home/wwwroot
           python %s check /home/wwwroot
    ''' % (sys.argv[0],sys.argv[0])
    sys.exit()

if len(sys.argv) != 3:
    Usage()

file = 'file.key'
model = sys.argv[1]
path = sys.argv[2]

if os.path.exists(path) == False:
    print "\033[;31mThe directory or file does not exist\033[0m"
    sys.exit()
elif model == 'update':
    update(path)
elif model == 'check':
    check(path)
else:
    Usage()</div>

</div>

您可能想查找下面的文章:

  • Python实现的检测网站挂马程序
  • 用Python和MD5实现网站挂马检测程序

相关文章

  • Python实现3行代码解简单的一元一次方程
  • Python常见格式化字符串方法小结【百分号与format方法】
  • Python批量转换文件编码格式
  • python实现马耳可夫链算法实例分析
  • python中的hashlib和base64加密模块使用实例
  • python抓取并保存html页面时乱码问题的解决方法
  • 跟老齐学Python之关于类的初步认识
  • Python实现的二维码生成小软件
  • Python的Django框架中模板碎片缓存简介
  • python获取文件扩展名的方法

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • python抓取网页图片并放到指定文件夹
    • Python入门篇之编程习惯与特点
    • 举例讲解Python中装饰器的用法
    • 玩转python爬虫之cookie使用方法
    • Python打印scrapy蜘蛛抓取树结构的方法
    • Python 文件和输入输出小结
    • python字符串的常用操作方法小结
    • Python 创建子进程模块subprocess详解
    • 详谈Python2.6和Python3.0中对除法操作的异同
    • python实现的守护进程(Daemon)用法实例

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有