def run(self): while not self.stop or not self.files.empty(): file = self.files.get() if not file: self.files.task_done() continue path = "%s/%ss/%s_%s/%s/" % (self.outputdir, file.type, file.source, file.destination, file.timestamp) if not os.path.exists(path): os.makedirs(path) number = 1 filename = '%s %d.%s' % (file.name, number, file.fileEnding) while os.path.exists(path + filename): number += 1 filename = '%s %d.%s' % (file.name, number, file.fileEnding) filename = filename.rstrip('.') with open(path + filename, 'wb') as outfile: outfile.write(file.data) Utils.printl("Wrote file: %s%s" % (path, filename)) self.files.task_done()
def run(self): while not self.stop or not self.files.empty(): file = self.files.get() if not file: self.files.task_done() continue #path = "%s/%ss/%s_%s/%s/" % (self.outputdir, file.type, file.source, file.destination, file.timestamp) path = "{}/FileCarve/{}-{}/{}/{}/".format(self.outputdir,file.source,file.destination,file.portSrc,file.type) if not os.path.exists(path): os.makedirs(path) number = 0 if file.filename: filename = file.filename else: filename = '%s %d.%s' % (file.name, number, file.fileEnding) while os.path.exists(path + filename): number += 1 filename = '%s(%d).%s' % (file.name, number, file.fileEnding) filename = filename.rstrip('.') with open(path + filename, 'wb') as outfile: outfile.write(file.data) Utils.printl("Wrote file: %s%s" % (path, filename)) self.files.task_done()
def run(self): while not self.stop or not self.files.empty(): file = self.files.get() if not file: self.files.task_done() continue path = "%s/%ss/%s_%s/%s/" % (self.outputdir, file.type, file.source, file.destination, file.timestamp) if not os.path.exists(path): os.makedirs(path) number = 1 filename = '%s %d.%s' % (file.name, number, file.fileEnding) while os.path.exists(path + filename): number += 1 filename = '%s %d.%s' % (file.name, number, file.fileEnding) filename = filename.rstrip('.') with open(path + filename, 'wb') as outfile: outfile.write(file.data) Utils.printl("Wrote file: %s%s" % (path, filename)) with open(self.outputdir + '/files.csv', 'ab') as outcsv: csvwriter = csv.writer(outcsv, delimiter=',') csvwriter.writerow([file.pcapFile, file.firstPacketNumber, filename, file.fileEnding, file.size, file.md5.hexdigest(), file.source, file.destination, file.timestamp]) self.files.task_done()