"""Search a binary as UTF-16 LE, return regex matches.""" import re, sys, pathlib, glob pattern = sys.argv[1] paths = sys.argv[2:] rx = re.compile(pattern) found = {} for pat in paths: for p in glob.glob(pat): try: data = pathlib.Path(p).read_bytes().decode("utf-16-le", errors="ignore") except Exception as e: print(f"[skip] {p}: {e}", file=sys.stderr) continue for m in rx.findall(data): key = m if isinstance(m, str) else m[0] found.setdefault(key, []).append(p) for key in sorted(found.keys()): files = sorted(set(pathlib.Path(f).name for f in found[key])) print(f"{','.join(files):20s} {key}")