Skip to content

Instantly share code, notes, and snippets.

@TheFlash2k
Created December 23, 2023 21:37
Show Gist options
  • Save TheFlash2k/c5de59942293ac60400e49bd059c1bd9 to your computer and use it in GitHub Desktop.
Save TheFlash2k/c5de59942293ac60400e49bd059c1bd9 to your computer and use it in GitHub Desktop.
cyclic -l alternate for both hex and ascii ;)
#!/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