python 实现linux命令 strings

来源:互联网 发布:华为 中兴 知乎 编辑:程序博客网 时间:2024/05/16 19:41
def strings(file) : chars = r"A-Za-z0-9/\-:.,_$%'()[\]<> "; shortestReturnChar = 4; regExp = '[%s]{%d,}' % (chars, shortestReturnChar); pattern = re.compile(regExp); with open(file, 'rb') as f:  return pattern.findall(f.read());


 

windows下面没有strings,只能自己山寨一个了

 

refer:http://stackoverflow.com/questions/6804582/extract-strings-from-a-binary-file-in-python