@@ -29,15 +29,26 @@ def __init__(self):
29
29
def check_system_integrity (self ):
30
30
suspicious , malice = False , False
31
31
32
+ system_file = ["depmod" , "fsck" , "fuser" , "ifconfig" , "ifdown" , "ifup" , "init" , "insmod" , "ip" , "lsmod" ,
33
+ "modinfo" , "modprobe" , "nologin" , "rmmod" , "route" , "rsyslogd" , "runlevel" , "sulogin" , "sysctl" ,
34
+ "awk" , "basename" , "bash" , "cat" , "chmod" , "chown" , "cp" , "cut" , "date" , "df" , "dmesg" , "echo" ,
35
+ "egrep" , "env" , "fgrep" , "find" , "grep" , "kill" , "logger" , "login" , "ls" , "mail" , "mktemp" ,
36
+ "more" , "mount" , "mv" , "netstat" , "ping" , "ps" , "pwd" , "readlink" , "rpm" , "sed" , "sh" , "sort" ,
37
+ "su" , "touch" , "uname" , "gawk" , "mailx" , "adduser" , "chroot" , "groupadd" , "groupdel" , "groupmod" ,
38
+ "grpck" , "lsof" , "pwck" , "sestatus" , "sshd" , "useradd" , "userdel" , "usermod" , "vipw" , "chattr" ,
39
+ "curl" , "diff" , "dirname" , "du" , "file" , "groups" , "head" , "id" , "ipcs" , "killall" , "last" ,
40
+ "lastlog" , "ldd" , "less" , "lsattr" , "md5sum" , "newgrp" , "passwd" , "perl" , "pgrep" , "pkill" ,
41
+ "pstree" , "runcon" , "sha1sum" , "sha224sum" , "sha256sum" , "sha384sum" , "sha512sum" , "size" , "ssh" ,
42
+ "stat" , "strace" , "strings" , "sudo" , "tail" , "test" , "top" , "tr" , "uniq" , "users" , "vmstat" , "w" ,
43
+ "watch" , "wc" , "wget" , "whereis" , "which" , "who" , "whoami" ]
44
+
32
45
binary_list = ['/bin/' , '/sbin/' , '/usr/bin/' , '/usr/sbin/' , '/usr/local/sbin/' , '/usr/local/bin/' ]
33
46
try :
34
47
for dir in binary_list :
35
48
if not os .path .exists (dir ): continue
36
49
for file in gci (dir ):
37
- if not os .path .exists (file ): continue
38
- if os .path .isdir (file ): continue
39
- if (os .path .getsize (file ) == 0 ) or (
40
- round (os .path .getsize (file ) / float (1024 * 1024 )) > 10 ): continue
50
+ filename = os .path .basename (file )
51
+ if not filename in system_file : continue
41
52
malware = self .analysis_file (file )
42
53
if malware :
43
54
self .file_malware .append (
@@ -135,7 +146,7 @@ def check_contents_ip(self, contents):
135
146
# 分析文件是否包含恶意特征、反弹shell特征、境外ip类信息
136
147
def analysis_file (self , file ):
137
148
try :
138
- time .sleep (0.01 )
149
+ time .sleep (0.05 )
139
150
if not os .path .exists (file ): return ""
140
151
if os .path .isdir (file ): return ""
141
152
if " " in file : return ""
0 commit comments