-
Notifications
You must be signed in to change notification settings - Fork 2
/
FindProcess.py
57 lines (40 loc) · 1.05 KB
/
FindProcess.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
47
48
49
50
51
52
53
54
55
56
57
# -*-coding:utf-8-*-
import os
import sys
ANTIVIRUS = 'Antivirus.txt'
def LoadTraitTxtToDict(FilePath):
try:
File = open(FilePath, 'r')
except IOError:
print "File is not accessible."
txtDict = {} #create Dict
while True:
line = File.readline()
if line == '':
break
index = line.find('|')
key = line[:index]
value = line[index+1:]
txtDict[key] = value[:-1]
File.close()
return txtDict
if __name__=="__main__":
i = 0
dstDict = LoadTraitTxtToDict(ANTIVIRUS)
try:
srcFile = open(sys.argv[1], 'r')
except IOError:
print "File is not accessible."
while True:
proLine = srcFile.readline()
if proLine == '':
break
index = proLine.find(' ')
key = proLine[:index]
if '.exe' not in key.lower():
continue
if dstDict.has_key(key):
print '%d %s %s' % (i, key, dstDict[key])
i += 1
if i == 0:
print 'Dont find Antivirus process! '