I have a simple script to automatically download Android firmware and decrypt it. However I need to use correct decryption type of the file enc2 or enc4.
Here is a most likely the script I will write:
#!/bin/bash
# Check update
samloader -m GT-I8190N -r BTU checkupdate
# Download
samloader -m GT-I8190N -r BTU download -v I8190NXXAMJ2/I8190NBTUAMJ1/I8190NXXAMJ2/I8190NXXAMJ2 -O .
# Decrypt
#
# THIS IS THE PROBLEM
samloader -m GT-I8190N -r BTU decrypt -v I8190NXXAMJ2/I8190NBTUAMJ1/I8190NXXAMJ2/I8190NXXAMJ2 **-V 2** -i GT-I8190N_BTU_1_20131118100230_9ae3yzkqmu_fac.zip.**enc2** -o GT-I8190N_BTU_1_20131118100230_9ae3yzkqmu_fac.zip
Take a look at the code with (** **)
The decrypted file is either *.enc2 or *.enc4. My problem is how can I detect the format (2 or 4)?. Like using sed, or awk, etc.
If enc2, then I specify -V 2 as well as enc4, -V 4
Thanks! Let me know if you need more info
The script: https://github.com/nlscc/samloader