1
2
3
4
5
6
7
8
9
10
11
import re

def extract_strings(filename, min_len=4):
    with open(filename, "rb") as f:
        data = f.read()

    pattern = rb"[ -~]{%d,}" % min_len
    return re.findall(pattern, data)

for s in extract_strings("sample.bin"):
    print(s.decode(errors="ignore"))