Last active
March 22, 2022 05:19
-
-
Save P1kachu/a1bf1afa2ecfc7c557be to your computer and use it in GitHub Desktop.
Hexdump to shellcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Translate hexdump output to ready_to_send shellcode | |
# C'EST PAS OPTI | |
# MAIS JE M'EN FOUS | |
to_shellcode() | |
{ | |
hexdump -x $1 | |
counter=0 | |
echo -n "TO CORRECT ENDIAN --> " | |
echo -n "\"" | |
IFS=$'\n' # Split for each line | |
for line in `hexdump $1`; do # For each line in hexdump | |
IFS=" " # Split for each space | |
for byte in $(echo "$line" | cut -c 9-); do # For each byte pair in line | |
echo -n "\x" | |
echo -n $byte | cut -c 3- | awk '{printf $0}' # Print the seconde one | |
echo -n "\x" | |
echo -n $byte | cut -c -2 | awk '{printf $0}' # Print the first one | |
counter=$((counter + 2)) # MIGHT COUNT THE LAST NULL | |
# BYTE IF ODD NUMBER OF BYTES | |
done | |
IFS='\n' | |
done | |
echo "\"" | |
echo "Length: $counter" | |
} | |
if [ $# -le 0 ] | |
then | |
echo "Usage: $0 NASM_FILE" | |
exit 1 | |
fi | |
to_shellcode $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment