lucasribeiroc

commonsrc

May 17th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import sys
  3. from subprocess import *
  4. if len(sys.argv) != 3:
  5.     print >>sys.stderr, 'Usage: %s binary source_bundle'%sys.argv[0]
  6.     sys.exit(1)
  7. def readstrings(binfile):
  8.     proc = Popen(['strings', binfile], stdout=PIPE)
  9.     strings = proc.stdout.readlines()
  10.     exitcode = proc.wait()
  11.     if exitcode != 0:
  12.         sys.exit(exitcode)
  13.     return set([s.strip() for s in strings])
  14. str1 = readstrings(sys.argv[1])
  15. str2 = open(sys.argv[2]).read()
  16. common = []
  17. for s in str1:
  18.     if s in str2:
  19.         common.append(s)
  20. common.sort()
  21. for s in common:
  22.     print s
Advertisement
Add Comment
Please, Sign In to add comment