Simple x86 Assembly to shellcode script

Instead of running running the commands to dump shellcode from assembly code that I write, I made a very simple script to help speed it up a bit. This isn’t anything fancy, but it works for me.

Essentially what it does:
-Compile assembly with nasm
-Linking with ld
-Spits out pretty shellcode with objdump

Usage:

Code up the assembly that you want to convert, then run the following command:

./asm2shell.sh filename.asm

Code:

#!/bin/bash
echo '[-] 32-Bit Assembly to Shellcode converter '
echo ''
echo ''
echo '[+] Assembling with Nasm ... '
nasm -f elf32 -o $1.o $1
echo '[+] Linking ...'
ld -m elf_i386 -o $1.bin $1.o
echo ''
echo '[+] Generating shellcode ...'
for i in $(objdump -d ./$1.bin |grep "^ " |cut -f2); do echo -n '\x'$i >> sc.txt; done; echo
cat sc.txt
echo''
echo '[+] Done.'

Check out the script here on Github.

By with No Comments 0

Related Posts

No posts were found for display

Leave a Reply

Your email address will not be published. Required fields are marked *