コード例 #1
0
    def set_file_data(self, file_data):
        self.file_data = file_data

        # Tmp-File erzeugen
        try:
            self.temp_file = getTmpFileName()

            file = open(self.temp_file, 'wb')
            file.write(file_data)
            file.seek(0)
            file.close

            # File consistency check
            tempMd5 = self._get_md5(self.temp_file)
            dataMd5 = hashlib.md5(file_data).hexdigest()

            log.debug("DataMd5=%s and TempFileMd5=%s" % (dataMd5, tempMd5))

            if dataMd5 != tempMd5:
                log.error("File not consistent DataMd5=%s and TempFileMd5=%s" %
                          (dataMd5, tempMd5))
                raise Exception(
                    "File not consistent DataMd5=%s and TempFileMd5=%s" %
                    (dataMd5, tempMd5))

            log.debug("temp_file=%s" % self.temp_file)
        except Exception, e:
            log.error("Error - Unable to create tempFile")
            raise Exception("Error - Unable to create tempFile")
コード例 #2
0
ファイル: objfile.py プロジェクト: Beercow/malware-crawler
 def set_file_data(self, file_data):
     self.file_data = file_data
     
     # Tmp-File erzeugen
     try:        
         self.temp_file = getTmpFileName()
         
         file = open(self.temp_file, 'wb')
         file.write(file_data)
         file.seek(0)
         file.close
         
         # File consistency check
         tempMd5 = self._get_md5(self.temp_file)
         dataMd5 = hashlib.md5(file_data).hexdigest()
         
         log.debug("DataMd5=%s and TempFileMd5=%s" % (dataMd5, tempMd5))
         
         if dataMd5 != tempMd5:
             log.error("File not consistent DataMd5=%s and TempFileMd5=%s" % (dataMd5, tempMd5))
             raise Exception("File not consistent DataMd5=%s and TempFileMd5=%s" % (dataMd5, tempMd5))             
         
         log.debug("temp_file=%s" % self.temp_file)  
     except Exception, e:
         log.error("Error - Unable to create tempFile")
         raise Exception("Error - Unable to create tempFile") 
コード例 #3
0
ファイル: objfile.py プロジェクト: Beercow/malware-crawler
 def set_raw_file(self, raw_file):
     # Copy File to ragpicker-temp and save in 
     tmpFile = getTmpFileName()
     shutil.copy2(raw_file, tmpFile)
     self.temp_file = tmpFile
     self.file_data = open(self.temp_file, "rb").read()
     
     # File consistency check
     tempMd5 = self._get_md5(self.temp_file)
     dataMd5 = hashlib.md5(self.file_data).hexdigest()
     
     log.debug("DataMd5=%s and TempFileMd5=%s" % (dataMd5, tempMd5))
     
     if dataMd5 != tempMd5:
         log.error("File not consistent DataMd5=%s and TempFileMd5=%s" % (dataMd5, tempMd5))
         raise Exception("File not consistent DataMd5=%s and TempFileMd5=%s" % (dataMd5, tempMd5)) 
コード例 #4
0
    def set_raw_file(self, raw_file):
        # Copy File to ragpicker-temp and save in
        tmpFile = getTmpFileName()
        shutil.copy2(raw_file, tmpFile)
        self.temp_file = tmpFile
        self.file_data = open(self.temp_file, "rb").read()

        # File consistency check
        tempMd5 = self._get_md5(self.temp_file)
        dataMd5 = hashlib.md5(self.file_data).hexdigest()

        log.debug("DataMd5=%s and TempFileMd5=%s" % (dataMd5, tempMd5))

        if dataMd5 != tempMd5:
            log.error("File not consistent DataMd5=%s and TempFileMd5=%s" %
                      (dataMd5, tempMd5))
            raise Exception(
                "File not consistent DataMd5=%s and TempFileMd5=%s" %
                (dataMd5, tempMd5))