Skip to content

Commit 3f60288

Browse files
author
Amit Raut
committed
Minor changes
1 parent dc3fe56 commit 3f60288

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

classifierWindows.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from collections import Counter
77
from datetime import datetime as dt
88

9+
count = int(os.sys.argv[5])
910
# Usage Message
1011
if len(os.sys.argv) < 5:
1112
print "Usage: ./classifier -i [path to malware sample] -t [path to training set directory]"
@@ -67,15 +68,15 @@ def compair(unknownFeatureList, trainingFeatureList):
6768
return result
6869

6970
def main(inSample):
70-
global trainingSetPath
71+
global trainingSetPath, count
7172

7273
# Generate nttrace file for given input sample
7374

7475
cmd = 'nttrace ' + str(inSample)
7576
with open('C:\Users\user\AppData\Local\mlmc\\' + os.path.splitext(os.path.basename(str(inSample)))[0] + '.trace', 'w') as traceFile:
7677
ps = sp.Popen(cmd, stderr=sp.PIPE, stdout=traceFile, shell=True)
7778

78-
time.sleep(2)
79+
time.sleep(1)
7980
ps.terminate()
8081

8182
featureLists = [] # [[3gramList],[4gramList], [5gramList], ...]
@@ -114,23 +115,24 @@ def main(inSample):
114115
# print 'Similarity with 3,4,5,6,7-gram feature = {0:3.2f} %'.format(sum(finalResult) / float(len(finalResult)) * 100)
115116

116117
# Combine output for many samples in to a file
117-
with open('Z:\Desktop\output.txt', 'a') as outFile:
118-
outFile.write("{0:2.5f} \t + {1:s} \n".format(sum(finalResult) / float(len(finalResult)) * 100, inSample))
119-
print "{0:2.5f} \t {1:s} \n".format(sum(finalResult) / float(len(finalResult)) * 100, inSample)
118+
with open('Z:\Desktop\output7000.txt', 'a') as outFile:
119+
outFile.write("{0:2.5f} \t {1:s} \n".format(sum(finalResult) / float(len(finalResult)) * 100, inSample))
120+
print "{0:2.5f} \t {1:s} \t".format(sum(finalResult) / float(len(finalResult)) * 100, inSample), count, '\n'
121+
count += 1
120122

121123
# Kill the dangling NtTrace process if any
122124
os.system("taskkill /IM NtTrace.exe /F")
125+
# os.system("taskkill /IM 979971590.exe /F")
126+
123127

124128
def test():
125129
global inSample
126130
if os.path.isfile(inSample):
127-
print inSample
128131
main(inSample)
129132
elif os.path.isdir(inSample):
130133
filelist = os.listdir(inSample)
131-
for sample in filelist:
134+
for sample in sorted(filelist)[count:]:
132135
if sample.endswith('.malware'):
133-
print inSample + sample
134136
main(inSample + sample)
135137

136138
if __name__ == '__main__':

0 commit comments

Comments
 (0)