Esempio n. 1
0
 def __init__(self, internLog, terminalLog, type, offset, image_path,
              mount_path):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = [
         "mount", "-t", type, "-o",
         "r,force,loop,offset=%i" % (offset), image_path, mount_path
     ]
Esempio n. 2
0
 def __init__(self, internLog, terminalLog, image, dumpDir):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["foremost", "-i", image, "-o", dumpDir]
Esempio n. 3
0
 def __init__(self, internLog, terminalLog, drive, image, log, retry=3):
     Launcher.__init__(self, internLog, terminalLog)
     if retry == 0:
         self.cmd_ = ["ddrescue", drive, image, log]
     else:
         self.cmd_ = ["ddrescue", "-r%i" % retry, drive, image, log]
Esempio n. 4
0
 def __init__(self, internLog, terminalLog):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["yes"]
Esempio n. 5
0
 def __init__(self, internLog, terminalLog, drive, image, log, retry=3):
     Launcher.__init__(self, internLog, terminalLog)
     if retry == 0:
         self.cmd_ = ["ddrescue", drive, image, log]
     else:
         self.cmd_ = ["ddrescue", "-r%i" % retry, drive, image, log]
Esempio n. 6
0
 def __init__(self, internLog, terminalLog, drive):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["smartctl", "--info", drive]
     self.serial_ = ""
     self.size_ = ""
Esempio n. 7
0
 def __init__(self, internLog, terminalLog, mount_path):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["umount", mount_path]
Esempio n. 8
0
 def __init__(self, internLog, terminalLog, drive):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["blkid", drive]
     self.uuid_ = ""
Esempio n. 9
0
 def __init__(self, internLog, terminalLog, drive):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["blkid", drive]
     self.uuid_ = ""
Esempio n. 10
0
 def __init__(self, internLog, terminalLog, image_path):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["mmls", image_path]
     self.partitions_ = []
Esempio n. 11
0
 def __init__(self, internLog, terminalLog, drive):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["hdparm", "-i", drive]
     self.serial_ = ""
Esempio n. 12
0
 def __init__(self, internLog, terminalLog, file):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["python", "/media/raid0/Owade/ivan/LsaMemParser.py", file]
Esempio n. 13
0
 def __init__(self, internLog, terminalLog, image_path):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["mmls", image_path]
     self.partitions_ = []
Esempio n. 14
0
 def __init__(self, internLog, terminalLog):
     Thread.__init__(self)
     self.internLog_ = internLog
     self.terminalLog_ = terminalLog
     self.interupt_ = False
     self.launcher_ = Launcher(internLog, terminalLog)
Esempio n. 15
0
class Process(Thread):
    ## Constructor
    # @param internLog An instance of the Log class, replace stdout and stderr for a Process
    # @param terminalLog An instance of the Log class, only usefull if a Launcher is used
    def __init__(self, internLog, terminalLog):
        Thread.__init__(self)
        self.internLog_ = internLog
        self.terminalLog_ = terminalLog
        self.interupt_ = False
        self.launcher_ = Launcher(internLog, terminalLog)

    ## Define the main behaviour of your process (Abstract method)
    def run(self):
        raise NotImplementedError("Subclasses should implement this!")

    ## Set everything to start an instance of the Launcher class
    # @param launcher The instance of the Launcher class
    # @return Boolean The result of the Launcher execution
    def launch(self, launcher):
        self.launcher_ = launcher
        launcher.start()
        launcher.join()
        return launcher.success_

    ## Interupt the Process
    # @return Boolean Success or failure or the interuption
    def interupt(self):
        self.interupt_ = True
        if self.launcher_.is_alive():
            self.launcher_.interupt()
            self.launcher_.join(10)
        else:
            return True
        if self.launcher_.is_alive():
            return False
        else:
            return True

    ## Update an instance of Model in the database, catch exception
    # @param obj The instance of the Model class
    def updateDb(self, obj):
        try:
            obj.save()
        except Exception as exp:
            try:
                self.internLog_.addLog("Update database failed, obj: %s, exception: %s" % (str(obj), str(exp)), 2)
            except Exception as exp2:
                self.internLog_.addLog("Update database failed: exception: %s" % (str(exp)), 2)
            return False
        return True

    descriptionToken = 'O_DESCRIPTION'
    def recurseUpdateDbGenericDic(self, dic, partition, father):
        for key in dic:
            if key == self.descriptionToken:
                continue
            value = dic[key]
            if type(value) == dict:
                #New category
                description = ""
                if self.descriptionToken in value:
                    description = value[self.descriptionToken]
                category = Category(name=key, description=description, partition=partition, father=father)
                category.save()
                self.recurseUpdateDbGenericDic(value, None, category)
            else:
                #New key value
                valueModel = Value(key=key, value=value, category=father)
                valueModel.save()


    def updateDbGenericDic(self, dic, partition):
        try:
            self.recurseUpdateDbGenericDic(dic, partition, None)
        except Exception as exp:
            print exp.message
            self.internLog_.addLog("Update database failed for dic %s" % (str(dic)), 2)
            return False
        self.internLog_.addLog("Update database success", 1)
        return True

    def recurseGetDbGenericDic(self, father):
        dic = {}
        for category in father.category_set.all():
            dic[category.name] = self.recurseGetDbGenericDic(category)
        for value in father.value_set.all():
            dic[value.key] = value.value
        return dic

    def getDbGenericDic(self, name, partition, father=None):
        try:
            father = Category.objects.select_related().get(name__iexact=name, partition=partition, father=father)
        except Exception as exp:
            print exp
            return None
        return self.recurseGetDbGenericDic(father)

    def overWriteCategory(self, partition, name, overWrite):
        try:
            category = Category.objects.get(partition=partition, name__iexact=name)
            if not overWrite:
                self.internLog_.addLog("%s already done" % name, 2)
                return False
            self.internLog_.addLog("Deleting old database content because of overwrite option (%s)" % name, 1)
            category.delete()
            return True
        except Exception as exp:
            return True

    def getHives(self, fileInfos, names):
        hives = fileInfos.filter(dir_path__iexact="/windows/system32/config/")
        paths = []
        if len(hives) == 0:
            print 'Error in getHives: no hives found'
            return None
        try:
            for name in names:
                paths.append(hives.get(name__iexact=name).file.file_path())
        except Exception as exp:
            print 'Exception in getHives: %s' % exp.message
            return None
        return paths

    def getUserHives(self, fileInfos):
        hives = fileInfos.filter(dir_path__istartswith="/Documents and Settings/", name__iexact="ntuser.dat")
        if len(hives) == 0:
            print 'Error in getUserHives: no hives found'
            return None
        paths = {}
        for hive in hives:
            user = re.search(r'^/[^/]*/([^/]*)/$', hive.dir_path).group(1)
            paths[user] = hive
        return paths

    ## An instance of the Log class, replace stdout and stderr for a Process
    internLog_ = None
    ## An instance of the Log class, only usefull if a Launcher is used
    terminalLog_ = None
    ## Has the process been interupted (initial = False)
    interupt_ = None
    ## An instance of the Launcher class, needed for user interuption
    launcher_ = None
Esempio n. 16
0
 def __init__(self, internLog, terminalLog, image, dumpDir):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["foremost", "-i", image, "-o", dumpDir]
Esempio n. 17
0
 def __init__(self, internLog, terminalLog, mount_path):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["umount", mount_path]
Esempio n. 18
0
 def __init__(self, internLog, terminalLog, path):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["md5sum", path]
     self.hash_ = ""
Esempio n. 19
0
 def __init__(self, internLog, terminalLog, path):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["md5sum", path]
     self.hash_ = ""
Esempio n. 20
0
 def __init__(self, internLog, terminalLog, type, offset, image_path, mount_path):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["mount", "-t", type, "-o", "r,force,loop,offset=%i" % (offset), image_path, mount_path]
Esempio n. 21
0
 def __init__(self, internLog, terminalLog, drive):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["hdparm", "-i", drive]
     self.serial_ = ""
Esempio n. 22
0
 def __init__(self, internLog, terminalLog, file):
     Launcher.__init__(self, internLog, terminalLog)
     self.cmd_ = ["python", "/media/raid0/Owade/ivan/LsaMemParser.py", file]