From 807248f9343a4cabb48c3be1a512b27f6377e871 Mon Sep 17 00:00:00 2001 From: Julien Voisin Date: Tue, 3 Mar 2015 15:58:59 +0100 Subject: First commit! --- modules/scanmodule.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 modules/scanmodule.py (limited to 'modules/scanmodule.py') 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 @@ +import ConfigParser +import pickle + + +class ScanModule(object): + def __init__(self): + self.config = ConfigParser.ConfigParser() + self.config.read('modules.conf') + + self.samples = dict() + + try: + self.populate(self.config.get(self.name, 'samples')) + except ConfigParser.NoOptionError: + pass + + try: + self.load(self.config.get(self.name, 'persistence')) + except ConfigParser.NoOptionError: + pass + + def is_disable(self): + try: + return self.config.getboolean(self.name, 'disable') + except ConfigParser.NoOptionError: + return False + + def evaluate(self, path): + ''' Return in percent, the probability that + the file is a malware + @param path File to evaluate + ''' + raise NotImplemented + + def populate(self, path): + ''' Populate the module's internal database + with data from the given path + @param path Path to the data + ''' + raise NotImplemented + + + def load(self, path): + ''' Unpickle the given path, and updates the samples dict with it. + @param path Path to the dict to unpickle + ''' + with open(path, 'r') as f: + self.samples.update(pickle.load(f)) + + def save(self, path): + ''' Save the database to the given file + @param path Path where to save the database + ''' + with open(path, 'w') as f: + pickle.dump(self.samples, f) + -- cgit v1.3