// Brute force password cracker 1.0 // Copyright (C) 2020 Henrik Riskær // This program was written for the Essential Programming course at Roskilde // University as part of the curricular coding assignments. // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import java.util.Arrays; import java.util.Random; public class Main { public static void main(String[] args){ int[] pw = pwGen(4); System.out.println("Starting bruteforce of array..."); printArray(pw); int solution = attack(pw); System.out.println("Password Successfully brute forced. password is: " + solution); } public static int[] pwGen(int digits){ Random rand = new Random(123); int[] pw = new int[digits]; for(int i = 0; i < digits; i++){ pw[i] = rand.nextInt(10); } return pw; } public static void printArray(int[] diller){ System.out.print("["); for(int i = 0; i < diller.length; i++){ System.out.print(diller[i]); System.out.print(", "); } System.out.print("]"); } public static int arrayToInt(int[] intKassen){ int res = 0; for (int i=0; i < intKassen.length; i++){ res = res*10; res = res+intKassen[i]; } return res; } public static int attack(int[] pw){ int n = arrayToInt(pw); int i = 0; for (i = 0; i < n; i++){ if(i != n){ System.out.println("it wasn't " + i); } } return i; } }