summaryrefslogtreecommitdiff
path: root/modules/scanmodule.py
diff options
context:
space:
mode:
authorJulien Voisin2015-03-03 15:58:59 +0100
committerJulien Voisin2015-03-03 15:58:59 +0100
commit807248f9343a4cabb48c3be1a512b27f6377e871 (patch)
tree20e8de5615e900c6bb312d2e8b9446630d4400c5 /modules/scanmodule.py
First commit!
Diffstat (limited to 'modules/scanmodule.py')
-rw-r--r--modules/scanmodule.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/modules/scanmodule.py b/modules/scanmodule.py
new file mode 100644
index 0000000..6ace387
--- /dev/null
+++ b/modules/scanmodule.py
@@ -0,0 +1,56 @@
1import ConfigParser
2import pickle
3
4
5class ScanModule(object):
6 def __init__(self):
7 self.config = ConfigParser.ConfigParser()
8 self.config.read('modules.conf')
9
10 self.samples = dict()
11
12 try:
13 self.populate(self.config.get(self.name, 'samples'))
14 except ConfigParser.NoOptionError:
15 pass
16
17 try:
18 self.load(self.config.get(self.name, 'persistence'))
19 except ConfigParser.NoOptionError:
20 pass
21
22 def is_disable(self):
23 try:
24 return self.config.getboolean(self.name, 'disable')
25 except ConfigParser.NoOptionError:
26 return False
27
28 def evaluate(self, path):
29 ''' Return in percent, the probability that
30 the file is a malware
31 @param path File to evaluate
32 '''
33 raise NotImplemented
34
35 def populate(self, path):
36 ''' Populate the module's internal database
37 with data from the given path
38 @param path Path to the data
39 '''
40 raise NotImplemented
41
42
43 def load(self, path):
44 ''' Unpickle the given path, and updates the samples dict with it.
45 @param path Path to the dict to unpickle
46 '''
47 with open(path, 'r') as f:
48 self.samples.update(pickle.load(f))
49
50 def save(self, path):
51 ''' Save the database to the given file
52 @param path Path where to save the database
53 '''
54 with open(path, 'w') as f:
55 pickle.dump(self.samples, f)
56