def testMutatedData(self, mutation, seed_files): mutator = self.op_dict[mutation].mOP() seed_dep = mutator.__seed_dependency__[0] resource_file = None for i in seed_files: if "." + seed_dep in i: seed_file = i break output = { 'filename': utils.extract_filename(seed_file), 'fileext': utils.extract_fileext(seed_file), 'filetype': utils.extract_filetype(seed_file), 'content': utils.extract_content(seed_file) } origin = { 'filename': utils.extract_filename(seed_file), 'fileext': utils.extract_fileext(seed_file), 'filetype': utils.extract_filetype(seed_file), 'content': utils.extract_content(seed_file) } mutator.operation(output, seed_file, resource_file) seed_type = seed_file.split(".")[-1] write_content(seed_type, output) """ if output['filename'] != origin['filename']: print "[+] Mutation succeed ( {} ) - filename".format(mutation) return True el """ if output['fileext'] != origin['fileext']: print "[+] Mutation succeed ( {} ) - fileext( {} -> {} )".format( mutation, origin["fileext"], output["fileext"]) return True elif output['filetype'] != origin['filetype']: print "[+] Mutation succeed ( {} ) - filetype( {} -> {} )".format( mutation, origin["filetype"], output["filetype"]) return True elif output['content'] != origin['content']: print "[+] Mutation succeed ( {} ) - content( {} b -> {} b )".format( mutation, len(origin["content"]), len(output["content"])) elif output['filename'][0] == '.': print "[+] Mutation succeed ( {} ) - filename( {} -> {} )".format( mutation, origin["filename"], output["filename"]) return True return False
def operation(self, output, seed_file, resource_file=None): if resource_file == None: resource_file = self.__resource__["gif"] if output['filename'] != None and len(output['filename']) > 0: filename = output['filename'] else: filename = utils.extract_filename(seed_file) output['filename'] = filename + '_M1GIF' output['content'] = utils.extract_content(resource_file)[:1024] + \ output['content']
def makeMutatedData(self, mutate_list, seed_file, resource_file): output = { 'filename': utils.extract_filename(seed_file), 'fileext': utils.extract_fileext(seed_file), 'filetype': utils.extract_filetype(seed_file), 'content': utils.extract_content(seed_file) } # insert specific data for hash output['content'] = output['content'].replace( "%unique#", os.urandom(8).encode('hex')) for mutation in mutate_list: mutator = self.op_dict[mutation].mOP() mutator.operation(output, seed_file, resource_file) # XXX: Finally, use output variable to make request return output
print (logtag + "%d rows returned from database" % (cursor.rowcount)) #============================================================================== # parse message time and content # store into data structure pandas.dataframe #============================================================================== parsing_start = time.clock() date_position_end = 10 time_position_end = 23 column_name = ['data-time', 'date', 'time', 'category', 'message'] msgls = [] # [[datatime, date, time, category, msg], ...] for line in query_ret: msg_date_time = line[2] msgdate = msg_date_time.date() msgtime = msg_date_time.time() msg = utils.extract_content(line[0][time_position_end+1:]) msgls.append([msg_date_time, msgdate, msgtime, line[1], msg]) msg_stat = utils.MsgStats(msgls) msg_stat.plot_disconnection_plotly() #msg_stat.print_msg() parsing_end = time.clock() print ("time elapsed for parsing " + str(parsing_end - parsing_start))