Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sit;
- import java.security.MessageDigest;
- import java.security.NoSuchAlgorithmException;
- public class CarHack {
- public static String calculateSalt(String ownid, String id, String n, String hashToFind) throws NoSuchAlgorithmException {
- MessageDigest md = MessageDigest.getInstance("SHA-256");
- String firstPart = ownid + id + n;
- for (int i = 1; i < 10000000; i++) {
- String toCheck = firstPart.concat(String.valueOf(i));
- md.update(toCheck.getBytes());
- byte byteData[] = md.digest();
- StringBuffer sb = new StringBuffer();
- for (int j = 0; j < byteData.length; j++) {
- sb.append(Integer.toString((byteData[j] & 0xff) + 0x100, 16).substring(1));
- }
- if (sb.toString().equals(hashToFind)) {
- System.out.println("Salt = " + i);
- return sb.toString();
- }
- if (i % 1000 == 0) {
- System.out.println(i);
- }
- }
- throw new RuntimeException("Salt not found");
- }
- private static void calculateNewHash(String ownid, String id, String n, String salt) throws NoSuchAlgorithmException {
- MessageDigest md = MessageDigest.getInstance("SHA-256");
- String rawData = ownid + id + n + salt;
- md.update(rawData.getBytes());
- byte byteData[] = md.digest();
- StringBuffer sb = new StringBuffer();
- for (int j = 0; j < byteData.length; j++) {
- sb.append(Integer.toString((byteData[j] & 0xff) + 0x100, 16).substring(1));
- }
- System.out.println("New Hash: " + sb.toString());
- }
- public static void main(String[] args) throws NoSuchAlgorithmException {
- //calculateNewHash bekommt die Werte aus der Aufgabenstellung
- //calculateSalt bekommt die Werte aus dem JavaScript Quellcode der Seite
- calculateNewHash("19d64efd69","door", "4887", calculateSalt("40d120326a", "door", "565", "5e4ca2a4d9d3b94994859ac72dbb97b4d73698c5ff2c3d020a4f89f65cb707e7"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement