国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - Python - Python實現的檢測網站掛馬程序

Python實現的檢測網站掛馬程序

2020-05-16 14:48腳本之家 Python

這篇文章主要介紹了Python實現的檢測網站掛馬程序,需要的朋友可以參考下

系統管理員通常從svn/git中檢索代碼,部署站點后通常首先會生成該站點所有文件的MD5值,如果上線后網站頁面內容被篡改(如掛馬)等,可以比對之前生成MD5值快速查找去那些文件被更改,為了使系統管理員第一時間發現,可結合crontab或nagios等工具。

程序測試如下:

?
1
2
3
4
5
6
7
8
9
10
11
# python check_change.py
 
  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

代碼如下(check_change.py):

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
 
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()

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 欧美成人精品一区二区三区在线看 | 日本久久久久久 | 亚洲成人aaaa | 久久精品成人 | 久久综合伊人77777蜜臀 | 久久三区| 欧美成人精品激情在线观看 | 91在线激情 | 国产精品久久久久久久久免费高清 | 免费视频一区二区 | 国产一区二区综合 | 日韩精品一区二区三区在线播放 | 综合久久99 | 精品国产精品三级精品av网址 | 国产一级高清视频 | 黄色午夜 | 高清一区二区三区 | 亚洲免费影院 | 中文字幕日本一区二区 | 日本一区二区三区视频免费看 | 中文字幕在线免费看 | 午夜免费在线 | 欧美日韩精品在线观看 | 国产精品美女久久久免费 | 一级毛片在线播放 | 伊人春色在线播放 | 欧美午夜一区二区福利视频 | 可以在线观看的av网站 | 亚洲专区中文字幕 | 久久久精品国产 | 久久久久久国产一级毛片高清版 | 一区二区三区在线观看视频 | 免费a视频在线观看 | 不卡视频一二三区 | 欧美日韩在线观看视频 | 亚洲精品成人 | 99国产一区 | 国产免费天天看高清影视在线 | 日本中文字幕在线视频 | 国产在线精品一区 | 黄色大片免费网址 |