extract the strings in an exe

Dietrich Epp dietrich at zdome.net
Fri Nov 21 06:24:19 EST 2003


On Nov 21, 2003, at 2:52 AM, Fernando Rodriguez wrote:

> How can I extract all the strings in an exe with python? O:-)

 >>> CTRL-D
$ strings foo.exe

--- OR ---

import os
os.exec1p('strings', 'foo.exe')

--- OR ---

import re
fooExe = file('foo.exe', 'r').read()
strings = re.findall("[\x1f-\x7e]{4,}", fooExe)

---

If you're looking for something a little more discriminating, you'll 
need to ask someone who cares about executable formats.  This will 
probably print out the function names as well.  Basically, the code 
finds strings of printing characters at least four characters long.

If you're looking for the definitive list of strings, you're going to 
hit your head against the cold, hard reality of executable formats not 
usually storying that information.  It just isn't there.






More information about the Python-list mailing list