0

I am reading some file with a binary content:

adb shell cat /data/somefile.dat

On Linux, after pulling the file from the android device, I can do:

$ strings somefile.dat

to read the file content.

Now I am trying to do the same thing on Windows using Python script.

Any help?

2
  • 3
    strings is actually a lot more complicated than just finding runs of printable characters -- it recognizes and parses executable file formats as well (which is the logic where it had security bugs come up recently). Commented Jan 31, 2015 at 0:07
  • 2
    Rather than trying to reimplement this yourself, you might want to get a tool already built for it. See superuser.com/questions/124081/… Commented Jan 31, 2015 at 0:10

2 Answers 2

2

just use re to print everything that looks like a string

print re.findall("[a-zA-Z0-9]+",open("some_file.data","rb").read())
Sign up to request clarification or add additional context in comments.

Comments

0

Here's a version that works for Python3:

print(re.findall("[a-zA-Z0-9]+", open(filename, "rb").read().decode('ISO-8859-1')))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.