WCU / Cybersecurity
~/CSC 472/Class 04/KP 09
Class 04 · KP 09 / 18

Option A: pwntools shellcraft + asm

  • pwntools can generate and assemble shellcode for you.
  • shellcraft is a library of ready-made snippets; asm() assembles raw assembly to bytes.
from pwn import *
context.arch = 'amd64'          # target architecture

# Ready-made execve("/bin/sh") shellcode:
sc = asm(shellcraft.sh())
print(len(sc), "bytes")
print(enhex(sc))                # inspect the byte string

# Assemble your own snippet:
mine = asm('xor rax, rax; mov al, 59; syscall')
Key Takeaway

shellcraft.sh() plus asm() is the fastest way to get correct, tested bytes for lab exercises.