Skip to content

Instantly share code, notes, and snippets.

@Jongy
Created July 13, 2021 17:15
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 Jongy/0e2fa4e4e1a135b43c145487ea553bf2 to your computer and use it in GitHub Desktop.
Save Jongy/0e2fa4e4e1a135b43c145487ea553bf2 to your computer and use it in GitHub Desktop.
dis.py - quickly disassemble short binary sequences
import subprocess
import binascii
import tempfile
def dis(s):
if not isinstance(s, bytes):
s = binascii.unhexlify(s.replace(" ", "").strip())
with tempfile.NamedTemporaryFile("wb") as f:
f.write(s)
f.flush()
print()
print("x86_64")
subprocess.run(["objdump", "-D", "-M", "intel,x86_64", "-m", "i386", "-b", "binary", f.name])
print()
print()
print("ARM")
subprocess.run(["arm-none-eabi-objdump", "-D", "-m", "arm", "-b", "binary", f.name])
print()
print()
print("Aarch64")
subprocess.run(["aarch64-linux-gnu-objdump", "-D", "-m", "aarch64", "-b", "binary", f.name])
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment