-
Notifications
You must be signed in to change notification settings - Fork 5
/
encryptedpreferences_hook.py
71 lines (60 loc) · 2.25 KB
/
encryptedpreferences_hook.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
#
# Hooks EncryptedPreferences (https://github.com/PDDStudio/EncryptedPreferences)
# to dump AES encryption key and plaintext content when read and decrypted out
# of shared preferences.
#
# @Author: Quentin Kaiser <[email protected]
#
###############################################################################
import frida
import sys
def on_message(message, data):
if "payload" in message:
print "[+] {}".format(message["payload"])
else:
print "[!] {}".format(message["description"])
jscode = """
Java.perform(function() {
var EncryptedPreferencesBuilder = Java.use('com.pddstudio.preferences.encrypted.EncryptedPreferences$Builder');
EncryptedPreferencesBuilder.build.implementation = function(encryptionPassword) {
send("EncryptedPreferences key: "+this.encryptionPassword.value);
return this.build();
};
var EncryptedPreferences = Java.use('com.pddstudio.preferences.encrypted.EncryptedPreferences');
EncryptedPreferences.getInt.implementation = function(key, defaultValue) {
var value = this.getInt(key, defaultValue);
send("getInt: " + value);
return value;
};
EncryptedPreferences.getLong.implementation = function(key, defaultValue) {
var value = this.getLong(key, defaultValue);
send("getLong: " + value);
return value;
};
EncryptedPreferences.getBoolean.implementation = function(key, defaultValue) {
var value = this.getBoolean(key, defaultValue);
send("getBoolean: " + value);
return value;
};
EncryptedPreferences.getFloat.implementation = function(key, defaultValue) {
var value = this.getFloat(key, defaultValue);
send("getFloat: " + value);
return value;
};
EncryptedPreferences.getString.implementation = function(key, defaultValue) {
var value = this.getString(key, defaultValue);
send("getString: " + value);
return value;
};
});
"""
if __name__ == "__main__":
if len(sys.argv) < 2:
print "Usage: %s pkg" % (sys.argv[0])
sys.exit(-1)
process = frida.get_usb_device().attach(sys.argv[1])
script = process.create_script(jscode)
script.on('message', on_message)
script.load()
sys.stdin.read()