天天看点

linux系统 网站木马后门Webshell查杀工具源码

后门这东西好让人头疼,第一文件太多了,不容易找,第二,难找,需要特征匹配啊。搞了一个python版查杀php webshell后门工具,大家可以增加后门的特征码,然后甩到后台给他查杀就可以了。适合Linux系统服务器的站长们

这个代码比较简单,大家可以自己继续完善下。主要是根据特征来匹配查找网站木马后门文件。

01

#!/usr/bin/python

02

# -*- coding: utf-8 -*-

03

#blog:www.sinesafe.com

04

05

import

os

06

import

sys

07

import

re

08

09

rulelist 

=

[

10

'(\$_(GET|POST|REQUEST)\[.{0,15}\]\(\$_(GET|POST|REQUEST)\[.{0,15}\]\))'

,

11

'(base64_decode\([\'"][\w\+/=]{200,}[\'"]\))'

,

12

'eval\(base64_decode\('

,

13

'(eval\(\$_(POST|GET|REQUEST)\[.{0,15}\]\))'

,

14

'(assert\(\$_(POST|GET|REQUEST)\[.{0,15}\]\))'

,

15

'(\$[\w_]{0,15}\(\$_(POST|GET|REQUEST)\[.{0,15}\]\))'

,

16

'(wscript\.shell)'

,

17

'(gethostbyname\()'

,

18

'(cmd\.exe)'

,

19

'(shell\.application)'

,

20

'(documents\s+and\s+settings)'

,

21

'(system32)'

,

22

'(serv-u)'

,

23

'(提权)'

,

24

'(phpspy)'

,

25

'(后门)'

,

26

'(webshell)'

,

27

'(Program\s+Files)'

28

]

29

30

def

Scan(path):

31

for

root,dirs,files 

in

os.walk(path):

32

for

filespath 

in

files:

33

isover 

=

False

34

if

'.'

in

filespath:

35

ext 

=

filespath[(filespath.rindex(

'.'

)

+

1

):]

36

if

ext

=

=

'php'

:

37

file

=

open

(os.path.join(root,filespath))

38

filestr 

=

file

.read()

39

file

.close()

40

for

rule 

in

rulelist:

41

result 

=

re.

compile

(rule).findall(filestr)

42

if

result:

43

print

'文件:'

+

os.path.join(root,filespath)

44

print

'恶意代码:'

+

str

(result[

])

45

print

'\n\n'

46

break

47

48

if

os.path.lexists(sys.argv[

1

]):

49

print

(

'\n\n开始扫描:'

+

sys.argv[

1

])

50

print

(

'               可疑文件                 '

)

51

print

(

'########################################'

)

52

Scan(sys.argv[

1

])

53

print

(

'提示:扫描完成-- O(∩_∩)O哈哈~'

)

54

else

:

55

print

'提示:指定的扫描目录不存在---  我靠( \'o′)!!凸'

查到后门文件后 直接删除掉,光删除是不行的得找到问题的根源到底是从哪里的漏洞上传上来的,那就有必须要对程序代码进行安全审计了建议大家找专业做安全的来做深入的安全部署(建议找专业做安全的国内公司如:Sinesafe,绿盟,启明星辰等等都是比较不错的专业做网站安全的公司)