blob: 4b4368aa780f3aa5432572eefaea25f0bcfef0bd [file] [log] [blame]
Nolen Johnson802fd002019-08-07 23:56:48 -04001
2WARNING:
3
4This project is no longer actively maintained, because the vulnerability that
5it leverages was patched several years ago. No new updates will be provided.
6The current codebase will remain here for reference purposes.
7
8
9=============================
10Loki
11by Dan Rosenberg (@djrbliss)
12=============================
13
14Loki is a set of tools for creating and flashing custom kernels and recoveries
15on the AT&T and Verizon branded Samsung Galaxy S4, the Samsung Galaxy Stellar,
16and various locked LG devices. For an explanation of how the exploit works,
17please see the technical blog post at:
18
19http://blog.azimuthsecurity.com/2013/05/exploiting-samsung-galaxy-s4-secure-boot.html
20
21Devices must be rooted in order to flash custom kernels and recoveries.
22
23loki_tool:
24[patch] option is primarily intended for developers to create custom
25kernels and recoveries. It's designed to take a specific aboot image and an
26unmodified boot or recovery image, and it generates an output image in a new
27file format, ".lok". The resulting .lok image is specifically tailored for the
28device build it was created with, and can be flashed directly to the recovery
29or boot partition on the target device.
30
31[flash] option can be used to flash a .lok image to an actual device.
32It will verify that the provided .lok image is safe to flash for a given target
33and then perform the flashing if validation is successful. It is also possible
34to simply use "dd" to flash a .lok image directly to the boot or recovery partition,
35but using [flash] option is recommended in order to validate that the .lok matches
36the target device.
37
38
39=============
40Sample usage
41=============
42
43First, a developer must pull the aboot image from a target device:
44
45
46dan@pc:~$ adb shell
47shell@android:/ $ su
48shell@android:/ # dd if=/dev/block/platform/msm_sdcc.1/by-name/aboot of=/data/local/tmp/aboot.img
49shell@android:/ # chmod 644 /data/local/tmp/aboot.img
50shell@android:/ # exit
51shell@android:/ $ exit
52dan@pc:~$ adb pull /data/local/tmp/aboot.img
533293 KB/s (2097152 bytes in 0.621s)
54
55
56Next, a .lok image can be prepared using loki_tool [patch]:
57
58
59dan@pc:~$ loki_tool patch
60Usage: ./loki_tool [patch] [boot|recovery] [aboot.img] [in.img] [out.lok]
61dan@pc:~$ loki_tool patch recovery aboot.img cwm.img cwm.lok
62[+] Detected target AT&T build JDQ39.I337UCUAMDB or JDQ39.I337UCUAMDL
63[+] Output file written to cwm.lok
64
65
66Finally, the .lok image can be flashed using loki_tool [flash]:
67
68
69dan@pc:~$ adb push cwm.lok /data/local/tmp
70dan@pc:~$ adb push loki_tool /data/local/tmp
71dan@pc:~$ adb shell
72shell@android:/ $ su
73shell@android:/ # chmod 755 /data/local/tmp/loki_tool
74shell@android:/ # /data/local/tmp/loki_tool
75Usage: /data/local/tmp/loki_tool [flash] [boot|recovery] [in.lok]
76shell@android:/ # /data/local/tmp/loki_tool flash recovery /data/local/tmp/cwm.lok
77[+] Loki validation passed, flashing image.
782253+1 records in
792253+1 records out
809230848 bytes transferred in 0.656 secs (14071414 bytes/sec)
81[+] Loki flashing complete!