123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package QuickVerifyCrap;
- import javax.crypto.BadPaddingException;
- import javax.crypto.Cipher;
- import javax.crypto.IllegalBlockSizeException;
- import javax.crypto.NoSuchPaddingException;
- import javax.crypto.spec.SecretKeySpec;
- import java.io.*;
- import java.security.InvalidKeyException;
- import java.security.MessageDigest;
- import java.security.NoSuchAlgorithmException;
- import java.security.Security;
- import java.util.Locale;
- import org.bouncycastle.jce.provider.BouncyCastleProvider;
- public class SonyUnXml {
- public static void main(String[] args) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, IOException, IllegalBlockSizeException, BadPaddingException {
- Security.addProvider(new BouncyCastleProvider());
- byte[] c = new byte[] {
- 79, -94, 121, -103, -1, -48, -117, 31, -28, -46,
- 96, -43, 123, 109, 60, 23 };
- SecretKeySpec secretKeySpec = new SecretKeySpec(c, "AES");
- Cipher cipher = Cipher.getInstance("AES/ECB/ZeroBytePadding");
- cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
- File f = new File("/home/tgoerner/Downloads/sony-FWH/info3/info.xml");
- RandomAccessFile f2 = new RandomAccessFile(f,"r");
- //f2.seek(0x4A);
- int fl = (int)f.length();
- byte[] file = new byte[fl];
- int read = f2.read(file);
- System.out.println(bytesToHex(MessageDigest.getInstance("SHA-1").digest(file)));
- if(read<fl)
- {
- System.err.println("ZARF");
- }
- byte[] out = cipher.doFinal(file);
- System.out.println(bytesToHex(MessageDigest.getInstance("SHA-1").digest(out)));
- FileOutputStream os = new FileOutputStream(new File("/home/tgoerner/Downloads/sony-FWH/info3/info.xml.dec"));
- os.write(out);
- }
- public static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
- public static String bytesToHex(byte[] bytes) {
- char[] hexChars = new char[bytes.length * 2];
- for (int j = 0; j < bytes.length; j++) {
- int v = bytes[j] & 0xFF;
- hexChars[j * 2] = HEX_ARRAY[v >>> 4];
- hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
- }
- String hexxit = new String(hexChars).toLowerCase(Locale.ROOT);
- //hexxit = hexxit.replaceAll("^0+", "");
- return hexxit;
- }
- }
|