Example #1
0
 def find_constone(self, datas):
     wordDic = Converter.convert_raw_to_count(datas)
     wordDic = sorted(wordDic.items(), key=lambda x: x[1])
     if (wordDic[0][1] > self.constThreshold):
         return 1
     else:
         return 0
Example #2
0
 def inferConst(self, datas):
     wordDic = Converter.convert_raw_to_count(datas)
     wordDic = sorted(wordDic.items(), key=lambda x: x[1])
     if (wordDic[-1][1] / len(datas) > self.constThreshold):
         return 1
     else:
         return 0
Example #3
0
 def find_constfunc(self, datas):
     """
     get the feature of the function code
     :param datas: List of bytes
     :return: entry and distinct num of datas
     """
     t_l = Converter.convert_raw_to_count(datas)
     t_en = base_analyzer.get_entry([value for value in t_l.values()])
     return t_en, len(t_l)
Example #4
0
 def getFuncScore(self, Los=None, datas=None):
     if Los != None:
         datas = self.cverter.getDatasByLocs(self.messages, Los)
     datasDic = Converter.convert_raw_to_count(datas)
     sumValue = 0
     for value in datasDic.values():
         sumValue = sumValue + value
     datas = [data / sumValue for data in datasDic.values()]
     datasEntry = base_analyzer.get_entry(datas)
     return datasEntry, len(datasDic)
Example #5
0
 def inferFunc(self, datas):
     datasDic = Converter.convert_raw_to_count(datas)
     sumValue = 0
     for value in datasDic.values():
         sumValue = sumValue + value
     datas = [data / sumValue for data in datasDic.values()]
     datasEntry = base_analyzer.get_entry(datas)
     if len(datasDic) < self.FuncT:
         return 1
     else:
         return 0
Example #6
0
 def inferConst(self, Los=None, datas=None):
     #print(Los)
     if Los != None:
         datas = self.cverter.getDatasByLocs(self.messages, Los)
     #print(datas)
     wordDic = Converter.convert_raw_to_count(datas)
     wordDic = sorted(wordDic.items(), key=lambda x: x[1])
     #print(wordDic)
     if (wordDic[-1][1] / len(datas) > self.constThreshold):
         return 1
     else:
         return 0
Example #7
0
 def split_by_words_type(self, datas, T_max_range):
     fields_set = []
     w_infer = word_infer()
     w_merger = base_merger()
     w_convert = Converter()
     b_analyzer = base_analyzer()
     for i in range(T_max_range):
         lo_datas = get_data_bylo(datas, i)
         w_cnt = w_convert.convert_raw_to_count(lo_datas)
         w_frequent = b_analyzer.convert_num_to_frequent(w_cnt)
         w_type = w_infer.is_const_word(w_frequent, 0.95)
         if w_type:
             t_field = loc_field((i,i), 0)
         else:
             t_field = loc_field((i,i), 4)
         fields_set.append(t_field)
     words_f = w_merger.merge_words(fields_set)
     candidate_borders = [w.loc[0] for w in words_f]
     return words_f, candidate_borders
 def inferFunc(self, datas):
     datasDic = Converter.convert_raw_to_count(datas)
     datasEntry = base_analyzer.get_entry(
         [value for value in datasDic.values()])