Skip to content

Instantly share code, notes, and snippets.

@rugameuser
Forked from mar-v-in/decrypt.java
Created August 16, 2021 14:48
Show Gist options
  • Select an option

  • Save rugameuser/e5914dd3bbe8c80aa4f00927264611cf to your computer and use it in GitHub Desktop.

Select an option

Save rugameuser/e5914dd3bbe8c80aa4f00927264611cf to your computer and use it in GitHub Desktop.

Revisions

  1. @mar-v-in mar-v-in revised this gist Sep 19, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion decrypt.java
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    // Usage: java decrypt assets/droidguard/droidguasso.enc droidguasso.jar
    // Compile: javac decrypt.java
    // Usage: java decrypt path-to/assets/droidguard/droidguasso.enc droidguasso.jar

    import java.io.InputStream;
    import java.io.ByteArrayOutputStream;
  2. @mar-v-in mar-v-in created this gist Sep 19, 2016.
    44 changes: 44 additions & 0 deletions decrypt.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    // Usage: java decrypt assets/droidguard/droidguasso.enc droidguasso.jar

    import java.io.InputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.security.spec.AlgorithmParameterSpec;
    import java.security.Key;
    import javax.crypto.spec.IvParameterSpec;
    import javax.crypto.spec.SecretKeySpec;
    import javax.crypto.Cipher;
    import java.io.File;
    import java.io.IOException;

    public class decrypt {
    public static void main(String[] args) throws Exception {
    IvParameterSpec iv = new IvParameterSpec(new byte[] { 1, 33, 13, 28, 87, 122, 25, 5, 4, 30, 22, 101, 5, 50, 12, 0 });
    byte[] key = new byte[16];
    byte[] bytes = "96a176a2e35d8ae4".getBytes();
    for (int n = 0; n < 16 && n < bytes.length; ++n) {
    key[n] = bytes[n];
    }
    SecretKeySpec k = new SecretKeySpec(key, "AES");
    Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");
    c.init(2, k, iv);
    byte[] res = c.doFinal(readStreamToEnd(new FileInputStream(new File(args[0]))));
    FileOutputStream fos = new FileOutputStream(new File(args[1]));
    fos.write(res);
    fos.close();
    }

    public static byte[] readStreamToEnd(final InputStream is) throws IOException {
    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    if (is != null) {
    final byte[] buff = new byte[1024];
    int read;
    do {
    bos.write(buff, 0, (read = is.read(buff)) < 0 ? 0 : read);
    } while (read >= 0);
    is.close();
    }
    return bos.toByteArray();
    }
    }