-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathdecrypt_kernel
executable file
·29 lines (24 loc) · 1 KB
/
decrypt_kernel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
source common
kernelcache_decrypted="$out_dir"/kernelcache.decrypted
if test -f "$kernelcache_decrypted"; then
if_no_exit "Decrypted kernelcache file $kernelcache_decrypted already exists, a previous decryption may have already taken place."
fi
kernelcache_files=("$out_dir"/kernelcache.release*)
num=${#kernelcache_files[@]}
if test "$num" -eq 0; then
error "No kernelcache.release files in $out_dir"
exit 1
elif test ${#kernelcache_files[@]} -eq 1; then
kernelcache_crypted=${kernelcache_files[0]}
else
info "More than one kernelcache files in $out_dir. Using the last one."
num=$((${#kernelcache_files[@]}-1))
kernelcache_crypted=${kernelcache_files[$num]}
fi
iv=$(cat "$metadata" | grep '^kernelcache_iv:' | sed 's/^[^:]*://' | tr -d ' ')
key=$(cat "$metadata" | grep '^kernelcache_key:' | sed 's/^[^:]*://' | tr -d ' ')
debug "Change working directory to bin/"
cd ../bin
debug "./decrypt_kernel $kernelcache_crypted $iv $key"
./decrypt_kernel "$kernelcache_crypted" "$iv" "$key"