-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasicSystem.py
40 lines (31 loc) · 958 Bytes
/
BasicSystem.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
import os
from Anastasia.AnastasiaDetector import AnastasiaDetector
from SVM.SVMDetector import SVMDetector
from KNN.KNNDetector import KNNDetector
from Byte3g.Byte3g import Byte3gDetector
detectors=[AnastasiaDetector(),SVMDetector(),KNNDetector(),Byte3gDetector()]
def mainSystem():
file = input("Enter file path: ")
detection=detect(file)
return detection
def mainTestingSystem():
list_detections=[]
for file in os.listdir('Files'):
list_detections.append(detect(file))
return list_detections
'''
this function detect file by all the detectors.
returns 1 if malware and 0 otherwise
'''
def detect(file):
detections=[detector.detect(file) for detector in detectors]
counter_malware=0
for detection in detections:
if detection==1:
counter_malware+=1
if counter_malware>=len(detectors)/2:
return 1
else:
return 0
if __name__=='__main__':
print(mainSystem())