javac Main.java
java -cp . Main [EVERBOOK FILE NAME] [extra arg if you want it compressed]
Talia12/Hexal (Everbook.kt)
Talia12/Hexal (FileEncryptorDecryptor.kt)
import javax.crypto.Cipher; | |
import javax.crypto.spec.IvParameterSpec; | |
import javax.crypto.spec.SecretKeySpec; | |
import java.io.*; | |
import java.nio.ByteBuffer; | |
import java.util.Arrays; | |
import java.util.UUID; | |
import java.util.stream.Collectors; | |
import java.util.zip.GZIPInputStream; | |
public class Main { | |
static String get(byte[] bytes) { | |
StringBuilder out = new StringBuilder(); | |
for (byte b : bytes) out.append(String.format("%02X", b)); | |
return out.toString(); | |
} | |
public static void main(String[] args) throws Throwable { | |
if (args.length < 1) { | |
System.out.println("java -cp . Main [everbook file name]"); | |
return; | |
} | |
File book = new File(args[0]); | |
String uuid = Arrays.stream(book.getName().split("-")).skip(1).collect(Collectors.joining("-")).substring(0, 36); | |
UUID uid = UUID.fromString(uuid); | |
System.out.println("Your UUID: " + uid); | |
ByteBuffer buffer = ByteBuffer.allocate(16); | |
buffer.putLong(uid.getMostSignificantBits()); | |
buffer.putLong(uid.getLeastSignificantBits()); | |
System.out.println("Your key: " + get(buffer.array())); | |
DataInputStream ins = new DataInputStream(new FileInputStream(book)); | |
byte[] iv = new byte[16]; | |
ins.read(iv); | |
byte[] rest = ins.readAllBytes(); | |
System.out.println("Your IV: " + get(iv)); | |
SecretKeySpec spec = new SecretKeySpec(buffer.array(), "AES"); | |
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); | |
cipher.init(Cipher.DECRYPT_MODE, spec, new IvParameterSpec(iv)); | |
byte[] output = cipher.doFinal(rest); | |
if (args.length != 2) { | |
output = new GZIPInputStream(new ByteArrayInputStream(output)).readAllBytes(); // for comfort | |
if (!(output[0] == 0x0A && output[1] == 0x00 && output[2] == 0x00)) | |
System.err.println("Decryption may have failed, no unnamed root compound tag."); | |
} | |
FileOutputStream stream = new FileOutputStream("decrypted.dat"); | |
stream.write(output); | |
stream.flush(); | |
} | |
} |
javac Main.java
java -cp . Main [EVERBOOK FILE NAME] [extra arg if you want it compressed]
Talia12/Hexal (Everbook.kt)
Talia12/Hexal (FileEncryptorDecryptor.kt)