import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;
public class extbasic11 {
static int[] primes = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101};
static char[] chars = {'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'};
private static Scanner s;
private static final long MAGIC_NUMBER = /*i'll never tell!*/;
public static void main(String[] a) {
s = new Scanner(System.in);
System.out.print("attempt: ");
String in = s.next();
System.out.print("\n");
if(in.matches("[a-z]*")) {
int val = 1;
for(char check : in.toCharArray())
val *= primes[Arrays.binarySearch(chars, check)];
System.out.print("return: " + val + "\n");
int diff = 32 - ("" + Integer.toBinaryString(val)).length();
System.out.print("result: ");
for(int i = 0; i < diff; i++)
System.out.print("0");
System.out.print(Integer.toBinaryString(val) + "\n");
System.out.println("target: 00" + Integer.toBinaryString((int)MAGIC_NUMBER) + "\n");
main(null);
} else if(in.matches("[0-9]*")) {
if(in.length() > 18) {
System.out.println("too long!\n");
main(null);
}
int val = (int)Long.parseLong(in);
boolean primecheck = true;
for(int pcheck : getPrimeFactors(Long.parseLong(in)))
if(pcheck > 101)
primecheck = false;
if(primecheck) {
System.out.print("return: ");
for(int pcheck : getPrimeFactors(Long.parseLong(in)))
System.out.print(chars[Arrays.binarySearch(primes, pcheck)]);
System.out.print("\n");
} else
System.out.println("return: cannot translate to password");
int diff = 32 - ("" + Integer.toBinaryString(val)).length();
System.out.print("result: ");
for(int i = 0; i < diff; i++)
System.out.print("0");
System.out.print(Integer.toBinaryString(val) + "\n");
System.out.println("target: 00" + Integer.toBinaryString((int)MAGIC_NUMBER) + "\n");
main(null);
} else
System.exit(0);
}
public static ArrayList<Integer> getPrimeFactors(long n) {
ArrayList<Integer> ret = new ArrayList<Integer>();
if(n==1)
ret.add(102);
while(n%2 == 0) {
ret.add(2);
n = n/2;
}
for(int i = 3; i <= Math.sqrt(n); i = i+2) {
while(n%i == 0) {
ret.add(i);
n = n/i;
}
}
if(n>2)
ret.add((int)n);
return ret;
}
}
Marcinnnn wrote:I have different problem. I have password and when I execute script and put it then it shows me welcome message, so it should be ok. But when I put it on the page then it doesn't work. Who can help me with it?
UPDATE: I have 2 passwords which work on my computer with this script but they don't work on site.
cyberdrain wrote:Marcinnnn wrote:I have different problem. I have password and when I execute script and put it then it shows me welcome message, so it should be ok. But when I put it on the page then it doesn't work. Who can help me with it?
UPDATE: I have 2 passwords which work on my computer with this script but they don't work on site.
As far as I remember this challenge, you need to find one of the lowest possible numbers.
Marcinnnn wrote:Thanks. I fixed my program and get few more valid password with the lowest possible included.
However in my opinion the lowest is to easy to brute force.
cyberdrain wrote:Marcinnnn wrote:Thanks. I fixed my program and get few more valid password with the lowest possible included.
However in my opinion the lowest is to easy to brute force.
Looks like you did it, well done!
Users browsing this forum: No registered users and 0 guests