Skip to content

Instantly share code, notes, and snippets.

@ctian1
Created May 3, 2016 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctian1/e64059e4eb4f9c8a808ecfc6dcbfc0fe to your computer and use it in GitHub Desktop.
Save ctian1/e64059e4eb4f9c8a808ecfc6dcbfc0fe to your computer and use it in GitHub Desktop.
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
class Blacklist {
public static MessageDigest CRYPT;
public static String[] HASHES = new String[] {"879f1dea801746b51a2a908b04f7fe6fff5f7a47", "5f2eceb54f642fb5f58abca0b52f7f0349f06cef", "a2e2be30dc9be014f171c8a3bbe955e55fd66d87"};
public static String sha1(String str) throws NoSuchAlgorithmException, UnsupportedEncodingException {
if (CRYPT == null)
CRYPT = MessageDigest.getInstance("SHA-1");
CRYPT.reset();
CRYPT.update(str.getBytes("UTF-8"));
return new BigInteger(1, CRYPT.digest()).toString(16);
}
public static void check(String ip) throws NoSuchAlgorithmException, UnsupportedEncodingException {
String hash = sha1(ip);
// System.out.println(String.format("%1$14s | %2$s", ip, hash));
for (String str : HASHES) {
if (str.equals(hash)) {
System.out.println("Found: " + hash + " | " + ip);
}
}
}
public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException {
for (int a = 0; a <= 255; a++) {
String aa = a + ".";
for (int b = 0; b <= 255; b++) {
String bb = aa + b + ".";
for (int c = 0; c <= 255; c++) {
// System.out.println(hash);
check(bb + c);
}
check(bb + "*");
}
check(aa + "*");
System.out.println(a);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment