Created
December 23, 2023 21:37
-
-
Save TheFlash2k/c5de59942293ac60400e49bd059c1bd9 to your computer and use it in GitHub Desktop.
cyclic -l alternate for both hex and ascii ;)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
from pwn import * | |
def find(data): | |
data = data[2:] if data[:2] == "0x" else data | |
offset = -1 | |
try: | |
data = unhex(data)[::-1].decode() | |
except: offset = cyclic_find(data) | |
if offset < 0: | |
offset = cyclic_find(data) | |
if offset >= 0: | |
info(f"Found offset: {offset} [{data}]") | |
return offset | |
warn(f"Unable to find offset of {data}") | |
return -1 | |
if len(sys.argv) != 2: | |
print("Usage: offset <value in hex>") | |
exit(1) | |
find(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment