Skip to content

Instantly share code, notes, and snippets.

Created Jun 29, 2015
What would you like to do?
the "strings" command implemented in Python
from mmap import mmap, PROT_READ
import re
import sys
def strings(fname, n=6):
with open(fname, 'rb') as f, mmap(f.fileno(), 0, prot=PROT_READ) as m:
for match in re.finditer(('([\w/]{%s}[\w/]*)' % n).encode(), m):
if __name__ == '__main__':
for word in strings(sys.argv[1]):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment