[文档]classCustomStrings(KnowledgeBasePlugin):""" Store new strings that are recovered during various analysis. Each string has a unique ID associated. """
[文档]defallocate(self,s:bytes)->int:# de-duplication# TODO: Use a reverse map if this becomes a bottle-neck in the futureforidx,stringinself.strings.items():ifstring==s:returnidxstring_id=self.string_idself.strings[string_id]=sself.string_id+=1returnstring_id