Advertisement
joxeankoret

Untitled

Nov 30th, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. #!/usr/bin/env python2.7
  2.  
  3. """
  4. Example IDA Python script to get "names" (functions, variables, etc...) from string constants
  5. using Natural Language Processing.
  6. """
  7.  
  8. from __future__ import print_function
  9.  
  10. import pprint
  11. import idautils
  12.  
  13. import nltk
  14. from nltk.tokenize import word_tokenize
  15. from nltk.tag import pos_tag
  16.  
  17. def preprocess(sent):
  18.   sent = nltk.word_tokenize(sent)
  19.   sent = nltk.pos_tag(sent)
  20.   return sent
  21.  
  22. strings = Strings()
  23. strings.setup(strtypes=[0, 1])
  24.  
  25. s = "\n".join(map(str, list(strings)))
  26. results = preprocess(s)
  27. for value, type in results:
  28.   if len(value) > 4 and (type == "NN" or type.startswith("VB")):
  29.     print("Found", value, "type", type)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement