def save(self, obj, filename, tag, dist_q): data = dict() try: #Create a temporary file object and write to it temp = tempfile.TemporaryFile() temp.write(obj) temp.seek(0) #Hash the file in the file object md5_hash = md5sum(temp.read()).hexdigest() temp.seek(0) sha1_hash = sha1sum(temp.read()).hexdigest() temp.close() #Write the attached file to objs folder open('attachments/'+md5_hash,'wb').write(obj) #Send saved file to MalZoo,Cuckoo and Viper sample = dict() sample['md5'] = md5_hash sample['tag'] = tag sample['filename'] = 'attachments/'+md5_hash dist_q.put(sample) #Setup data dict for return data['id_tag'] = tag data['md5'] = md5_hash data['sha1'] = sha1_hash data['filename'] = filename data['submit_date'] = int(time()) except Exception as e: print "SaveObject: Error on obj saving",e pass finally: return data
def save(self, obj, filename, tag, dist_q): data = dict() try: #Create a temporary file object and write to it temp = tempfile.TemporaryFile() temp.write(obj) temp.seek(0) #Hash the file in the file object md5_hash = md5sum(temp.read()).hexdigest() temp.seek(0) sha1_hash = sha1sum(temp.read()).hexdigest() temp.close() #Write the attached file to objs folder open('attachments/' + md5_hash, 'wb').write(obj) #Send saved file to MalZoo,Cuckoo and Viper sample = dict() sample['md5'] = md5_hash sample['tag'] = tag sample['filename'] = 'attachments/' + md5_hash dist_q.put(sample) #Setup data dict for return data['id_tag'] = tag data['md5'] = md5_hash data['sha1'] = sha1_hash data['filename'] = filename data['submit_date'] = int(time()) except Exception as e: print "SaveObject: Error on obj saving", e pass finally: return data
def token(self): if self._token is None: h = hashlib.sha1sum() h.update(version_string.encode('utf-8')) for z in (self._features + self._applications): h.update(z.encode('utf-8')) self._token = h.hexdigest() return self._token
# how the f**k does the original code even realize that its time to terminate...? Offset = read_byte() Offset |= 0xFFFFFF00 # read a byte from uncompressed data at Offset from current pos # return uncompressed data to current position # write that byte to the current uncompressed position. (incremement currentpos) for i in range(0, Count): source_pos = (len(uncompressed) - 1) + Offset + i print "Attempting to get value from %d, current length is %d" % (source_pos, len(uncompressed)) uncompressed.append(uncompressed[source_pos]) DecBytes+=Count+1 # ------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------ print "ALL DONE!" print hashlib.sha1sum(uncompressed.tostring()).hexdigest() # end: # if (Moduled) # { # if (DecBytes < FullSize) # { # do { fread(&Byte, 1, 1, Src); } while (Byte==0); # fseek(Src, -1, SEEK_CUR); # goto start; # } # } # fclose(Dst); c_fd.close()
def get_sha1(self): """ Generate SHA-1 of the sample """ with open(self.filename, 'rb') as f: sha1_hash = sha1sum(f.read()).hexdigest() return sha1_hash
def sha1hash(self, sample): """ Generate a SHA-1 hash of a sample """ with open(sample, 'rb') as f: sha1_hash = sha1sum(f.read()).hexdigest() return str(sha1_hash)