-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathclassifyNotVirus.py
42 lines (29 loc) · 1.12 KB
/
classifyNotVirus.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
import os
import sys
import shutil
import re
import collections
import pprint
walk_dir = sys.argv[1]
print('walk_dir = ' + walk_dir)
# If your current working directory may change during script execution, it's recommended to
# immediately convert program arguments to an absolute path. Then the variable root below will
# be an absolute path as well. Example:
walk_dir = os.path.abspath(walk_dir)
print('walk_dir (absolute) = ' + os.path.abspath(walk_dir))
cnt = 0
for root, subdirs, files in os.walk(walk_dir):
list_file_path = os.path.join(root, '')
filename = "virustotal.txt"
if filename in files:
file_path = os.path.join(root, filename)
print('\n+++++++++++++New File Full path: %s' % (file_path))
with open(file_path) as f:
words = re.findall(r"\bnot-a-virus\b", f.read().lower())
if words:
print "==================================> NOT A VIRUS with words:"
print words
cnt+= 1
shutil.move(root, "/home/tarun/Documents/Classified/not-a-virus")
#break;
print cnt #print all identified keywords