-
-
Save atamrawi/be5f2c23641f00c2cba41f0b6c6e7f62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.nio.charset.StandardCharsets; | |
import java.security.MessageDigest; | |
import java.security.NoSuchAlgorithmException; | |
import java.util.Random; | |
public class CrackMe { | |
public static void main(String[] args) throws Exception { | |
long sleepy = 1; | |
while (true) { | |
Thread.sleep(sleepy++); | |
long seed = new Random().nextLong(); | |
Random rnd = new Random(seed); | |
final int range = 26; | |
String prefix = ""; | |
for (int i = 0; i < 80; i++) { | |
int v = rnd.nextInt(range) + 1; | |
char c = (char) ('`' + v); | |
prefix += c; | |
} | |
prefix = prefix.replace("s", "-"); | |
String[] preconditions = prefix.split("-"); | |
if (preconditions.length != 3) { | |
continue; | |
} | |
if (!preconditions[0].equals("xgjv")) { | |
continue; | |
} | |
if (!preconditions[1].equals("xceg")) { | |
continue; | |
} | |
if (!preconditions[2].equals("rtakdmavlctjtnfdwicmliizylrfqynpbolgexazdutylgzrbyrcybzgdmjydylzhrbiml")) { | |
continue; | |
} | |
String suffix = ""; | |
for (int i = 0; i < 20; i++) { | |
int v = rnd.nextInt(range) + 1; | |
char c = (char) ('`' + v); | |
suffix += c; | |
} | |
suffix = suffix.replace("s", "-"); | |
if (SHA256(suffix).startsWith("e9")) { | |
System.out.println("Be the first to email this key [" + suffix.substring(0, 15) | |
+ "] to ahmedtamrawi@gmail.com and include a solution summary to claim a prize!"); | |
break; | |
} | |
} | |
} | |
private static String SHA256(String input) throws NoSuchAlgorithmException { | |
MessageDigest digest = MessageDigest.getInstance("SHA-256"); | |
byte[] hash = digest.digest(input.getBytes(StandardCharsets.UTF_8)); | |
StringBuffer hexString = new StringBuffer(); | |
for (int i = 0; i < hash.length; i++) { | |
String hex = Integer.toHexString(0xff & hash[i]); | |
if (hex.length() == 1) { | |
hexString.append('0'); | |
} | |
hexString.append(hex); | |
} | |
return hexString.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a clone of the gist by Ben Holland: https://gist.github.com/benjholla/89a097622f1692964db3a482ce7b47f7