Skip to content

Instantly share code, notes, and snippets.

@ProfAvery
Created December 8, 2022 23:16
Show Gist options
  • Select an option

  • Save ProfAvery/0292e5059369b8b55288bd2de2dbcedb to your computer and use it in GitHub Desktop.

Select an option

Save ProfAvery/0292e5059369b8b55288bd2de2dbcedb to your computer and use it in GitHub Desktop.
CPSC 458 - Disassemble arbitrary code from a hex dump
#!/bin/bash
set -euo pipefail
TMP_HEX=$(mktemp)
TMP_BIN=$(mktemp)
# Listing 19-1
cat > "$TMP_HEX" <<EOF
83 EC 20
31 D2
E8 0D 00 00 00
48 65 6C 6C 6F
20 57 6F 72 6C
64 21 00
5F
52
57
57
52
B8 EA 07 45 7E
FF D0
52
B8 FA CA 81 7C
FF D0
EOF
xxd -r -p "$TMP_HEX" "$TMP_BIN"
objdump --disassemble-all --target=binary --architecture=i386 "$TMP_BIN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment