Os dejo mi último intento por si veis alguna forma de arreglarlo o conoceis algun algoritmo que me sea sencillo de implementar o copiar.
Código
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <script> function bruteforce(mainUrl, longitud, dictio) { var directories = []; var increaseSize = false; var tmpUrl = mainUrl; var permanecerEnBucle = true; var posicionCambio = ""; var dict = dictio || " abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890/-.?=_"; /* var dict = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890/-.?=_"; dict = "abcdefghijklmnñopqrstuvwxyz"; */var tmp, fuck = "", sigChar, wtf; dict = dict.split(""); /* longitud *= dict.length; */ /* Max Length of the directory without domain */ for(var i = 0, j=0, k=0; i < longitud; ++i, ++j) { directories[i] = mainUrl + dict[j]; /* Append current character to base url */ tmp = directories[i].substring((mainUrl.length-k), directories[i].length); /* current directory without path */ if (j == (dict.length-1)) { /* Last character of the dictionary */ j = -1; /* Reset dictionary itherator. j = 0 next ither */ if(tmp[(tmp.length-1)] == dict[(dict.length-1)]) { /* Check lf Last char of current directory without path matches last dictionary char */ permanecerEnBucle=true; /* reset loop */ posicionCambio = ""; /* reset diff ocurrences */ for(var a = 0; a < tmp.length; ++a) { /* Loop over directories no path included */ if((tmp[a] == dict[(dict.length-1)]) && (permanecerEnBucle == true)) { /* if all characters in the directorie name match last dictionary character */ increaseSize = true; } else { posicionCambio += a.toString(); /* Log first non dictionary end char possition */ increaseSize = false; permanecerEnBucle = false; /* Force increaseSize to remain false */ } } if (increaseSize) { for(var c = 0, restart=""; c < tmp.length; ++c) { /* for each char in tmp */ restart += dict[0]; /* Add first dictionary ocurrence */ } mainUrl = tmpUrl + restart; /* Add the new generated path to main url */ ++k; /* Count size increased */ increaseSize = false; /* done */ } else { /* If all chars not matching last dicctionary char */ if (tmp === undefined) { /* need to debug */ alert("tmp undefined"); tmp = ""; } /*alert(tmp);*/ sigChar = dict.indexOf(tmp[(posicionCambio[0])]); /* sigChar = dict.indexOf(tmp[0]);*/ /* Get actual character position inside dictionary */ ++sigChar; /* Get next character */ /*alert("Char actual = " + sigChar);*/ /*alert("Current: "+ directories[i] + "\n\nnext char " + dict[sigChar] + "\n\nPosition: " + posicionCambio[((posicionCambio.length-1)-1)]);*/ for(var d = 0, fuck = ""; d < (tmp.length-1); ++d) { if(d != posicionCambio[0] ) { /* get path characters */ fuck += tmp[d]; /*alert("if fuck = "+ fuck);*/ } else { fuck += dict[sigChar]; /* get next character in rigth position */ /*alert("else fuck = "+ fuck);*/ } } wtf = fuck.split("").reverse().join(""); /* Reversing string trying to fix the character in rigth position */ mainUrl = tmpUrl + wtf; /* Appending reversed dirname to url */ } } } } alert("Número de combinaciones generadas: " + directories.length); alert("Número de letras en total: " + directories.join("").length); return directories; /* Return all urls generated. */ } var url = prompt("URL.\n\nExample: https://facebook.com/"); var lengt = prompt("Number os results.\n\nExample: 10"); var dictionary = prompt("Dictionary.\n\nExample: abcde12345!@#$ or accept to use default"); var arrDirs = bruteforce(url, lengt, dictionary); document.write(arrDirs); </script> </body> </html>