2
How is it done to make the billions of possible combinations without wasting time?
I made a system to generate random letters (he can make all the combinations), but he spends a lot of time checking results already made by the fact of being random, and then I made a system with for
but I can only get up to 2 characters.
That’s what I got, like I said, I only got it in two digits.
public class Main
{
static boolean terminar = false;
public static void main(String[] args)
{
long init = System.currentTimeMillis();
if(bruteForce(true, true, "0dd", 10, 10000) != "Senha não encontrada")
{
System.out.println("A senha é: " + bruteForce(true, true, "0dd", 10, 10000));
}
else
{
System.out.println("Senha não encontrada");
}
long end = System.currentTimeMillis();
long diff = end - init;
System.out.println("Demorou " + (diff / 1000) + " segundos");
}
public static String bruteForce(boolean numeros, boolean letras, String busca,int maxCaracteres, int limite)
{
String[] todos = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "a", "b", "c", "d", "e", "f", "g"
, "h", "i", "j", "k", "l", "m", "n", "o", "p", "k", "r", "s", "t", "u", "v", "w", "x", "y", "z"
, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U"
, "V", "W", "X", "Y", "Z", "'", "!", "@", "#", "$", "£", "%", "¢", "¨", "¬", "&", "*", "(", ")", "_", "-"
, "+", "=", "§", "/", ".", "[", "]", "`", "´", "{", "}", "º", "^", "~", "<", ">", ":", ";", "?", "°", "ª",
"|", "¹", "²", "³"};
String combinacao = "";
int quantCaracteres = 2;
double teste = Math.pow(todos.length, 16);
System.out.println(teste);
for(int i = 1; i <= quantCaracteres; i++)
{
for(int h = 0; h <= todos.length -1; h++)
{
for(int j = 0; j <= todos.length -1; j++)
{
combinacao = todos[h] + todos[j];
System.out.println(combinacao);
if(combinacao.equals(busca))
{
return combinacao;
}
combinacao = "";
}
}
//quantCaracteres ++;
}
return "Senha não encontrada";
}
}
Post the code you already have, we can help you correct it. As for the technique to choose the combinations, there are several answers. The simplest way is to iterate a-z, aa-zz (going through ab, ac, etc.) aaa-zzz... so on.
– RSinohara
Could you explain better what you want? I couldn’t get it right...
– Felipe Avelar
@Felipeavelar I would like an explanation of what is the best way (that waste less time) to make a brute force attack, the best way to make billions of combinations.
– Lucas Caresia
@Rsinohara I edited the question with the code I have so far.
– Lucas Caresia
I meant that the simplest way is to make the combinations a, b, c, d, etc., with a character, then aa, ab, ac, ..., fg, Fh, ... zz. Then with 3, etc. Of course there are ways to avoid useless combinations (using a dictionary), but the point is that doing it randomly is not feasible (you start repeating sequences).
– RSinohara