Skip to content

Instantly share code, notes, and snippets.

@mipsparc
Created September 29, 2023 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mipsparc/767ab4cf59e9e074557cfb5a8ec8138c to your computer and use it in GitHub Desktop.
Save mipsparc/767ab4cf59e9e074557cfb5a8ec8138c to your computer and use it in GitHub Desktop.
バイナリファイル内に特定の繰り返しが、(16bitにalignしていなくても)何個出現するかを探索する
import bitstring
import collections
f = open("result.bin", "rb").read()
b = bitstring.BitArray(bytes=f)
def check(b):
l = []
for i in b.findall("0x7E"):
if str(b[i+72:i+80]) == '0x7e':
l.append(str(b[i:i+80]))
return l
s = check(b)
print(collections.Counter(s))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment