Skip to content

Instantly share code, notes, and snippets.

@raddy
Created January 12, 2022 16:21
Show Gist options
  • Save raddy/a49a9038dcf506931856f9894ac133ce to your computer and use it in GitHub Desktop.
Save raddy/a49a9038dcf506931856f9894ac133ce to your computer and use it in GitHub Desktop.
grep out push4 opcodes
import sys
from pyevmasm import disassemble_hex
def four_byte(line):
toks = line.split()
if toks[0] != 'PUSH4':
return
return toks[1]
def main():
if len(sys.argv) < 2:
sys.exit("Usage: <string blob from c'tor>")
with open(sys.argv[1]) as f:
blob = f.read()
opcodes = disassemble_hex(blob).split('\n')
ops = set()
for entry in opcodes:
op = four_byte(entry)
if not op:
continue
ops.add(op)
print(ops)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment