Skip to content

Instantly share code, notes, and snippets.

@endeveit
Created April 9, 2014 04:53
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 endeveit/10227184 to your computer and use it in GitHub Desktop.
Save endeveit/10227184 to your computer and use it in GitHub Desktop.
WhatsApp msgstore crypt5 decryptor
package net.endeveit.wad;
import javax.crypto.*;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.*;
/**
* WhatsApp msgstore crypt5 decryptor
*/
public class Main {
public static void main(String[] args) throws NoSuchPaddingException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, InvalidKeyException, IOException, BadPaddingException, IllegalBlockSizeException {
String account = "user@example.org";
FileInputStream fis = new FileInputStream(new File("/path/to/msgstore.db.crypt5"));
FileOutputStream fos = new FileOutputStream(new File("/path/to/msgstore.db"));
decrypt(account, fis, fos);
}
static void decrypt(String account, FileInputStream fis, FileOutputStream fos) throws IOException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException {
byte[] accountBytes = account.getBytes("UTF-8");
byte[] key = {(byte) 141, (byte) 75, (byte) 21, (byte) 92, (byte) 201, (byte) 255, (byte) 129, (byte) 229, (byte) 203, (byte) 246, (byte) 250, (byte) 120, (byte) 25, (byte) 54, (byte) 106, (byte) 62, (byte) 198, (byte) 33, (byte) 166, (byte) 86, (byte) 65, (byte) 108, (byte) 215, (byte) 147};
byte[] iv = {(byte) 0x1E, (byte) 0x39, (byte) 0xF3, (byte) 0x69, (byte) 0xE9, (byte) 0xD, (byte) 0xB3, (byte) 0x3A, (byte) 0xA7, (byte) 0x3B, (byte) 0x44, (byte) 0x2B, (byte) 0xBB, (byte) 0xB6, (byte) 0xB0, (byte) 0xB9};
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] md5 = md.digest(accountBytes);
for (int i = 0; i < 24; i++) {
key[i] ^= md5[i & 0xF];
}
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"), new IvParameterSpec(iv, 0, cipher.getBlockSize()));
CipherInputStream cis = new CipherInputStream(fis, cipher);
int b;
byte[] d = new byte[8];
while ((b = cis.read(d)) != -1) {
fos.write(d, 0, b);
}
fos.flush();
fos.close();
cis.close();
}
}
@Visvis634
Copy link

IMG-20220316-WA0003

@Visvis634
Copy link

int32_t AImageDecoderHeaderInfo_getHeight(
const AImageDecoderHeaderInfo *_Nonnull
)

@Visvis634
Copy link

javax.crypto.spec.SecretKeySpec;

@Visvis634
Copy link

byte

@Visvis634
Copy link

FileInputStream;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment