Advertisement
Guest User

RestoreStrings

a guest
Aug 26th, 2012
1,053
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys, os
  2.  
  3. if len(sys.argv) < 3:
  4.     print "Usage:  %s auPath outputPath" % os.path.split(sys.argv[0])[-1]
  5.     sys.exit(-1)
  6.  
  7. f = open(sys.argv[1])
  8. s=f.read()
  9. f.close()
  10. BinaryToStrings = s.split('BinaryToString')
  11. outString = BinaryToStrings[0]
  12.  
  13. for i in range(1,len(BinaryToStrings)):
  14.     stringStart = BinaryToStrings[i].find('0x')
  15.     tmpString = BinaryToStrings[i][stringStart+2:]
  16.     endString = tmpString.find('"') + len('("0x')
  17.     tmpString = tmpString.split('"')[0]
  18.  
  19.     outString += BinaryToStrings[i][0:stringStart]
  20.     string = ''
  21.     for byte in range(len(tmpString)/2):
  22.         string += chr(int(tmpString[byte*2:byte*2 + 2],16))
  23.     print string
  24.     outString += string + BinaryToStrings[i][endString:]
  25.  
  26. f = open(sys.argv[2],'wb')
  27. s=f.write(outString)
  28. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement