Last active
March 23, 2022 01:25
-
-
Save juliavdkris/107d7b24341759a830f90c6f72e51bf3 to your computer and use it in GitHub Desktop.
Assemble 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 | |
if [[ $# -lt 1 ]]; then | |
echo "Please pass a file to assemble!" | |
exit | |
fi | |
tmpfile=$(mktemp --suffix ".o") | |
yasm -f elf64 $1 -o $tmpfile | |
shellcode=$(objdump -d $tmpfile | grep '^ ' | cut -d$'\t' -f2 | sed -r 's/([a-z0-9]{2})/\\x\1/g' | tr -d '[:space:]') | |
echo $shellcode | |
if [[ $shellcode == *"\x00"* ]]; then | |
printf "\n\t:( \t Your shellcode contains a null byte!\n\n" | |
objdump -d $tmpfile | tail -n +8 | cut -d$'\t' -f2- | grep --color ' 00\|$' | |
else | |
printf "\n\t:) \t Your shellcode does not contain any null bytes!\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment