binutils "strings" like functionality?
kent37 at tds.net
Thu Mar 3 17:49:25 CET 2005
> Hey all:
> I am working on a little script that needs to pull the strings out of a
> binary file, and then manipulate them with python.
> The command line utility "strings" (part of binutils) has exactly the
> functionality I need, but I was thinking about trying to implement this
> in pure python.
> I did some reading on opening and reading binary files, etc., and was
> just wondering if people think this is possible, or worth my time (as a
> learning exercise), or if something like this already exists.
I think a bare-bones version is pretty simple:
- read the file
- use re.split() to split on non-printable characters (string.printable could be handy here)
- print anything in the resulting list that is at least 4 characters
Since you mention this as a learning exercise I'll refrain from posting code but it's only a handful
of lines...of course implementing all of 'strings' is a bit more work.
More information about the Python-list