-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmqtt_hook.py
41 lines (37 loc) · 1.19 KB
/
mqtt_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
#!/usr/bin/env python
#
# Frida hook that dumps MQTT credentials used by hooked Android application.
#
# @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 MqttConnectOptions = Java.use('org.eclipse.paho.client.mqttv3.MqttConnectOptions');
MqttConnectOptions.setUserName.implementation = function(username) {
send("Username: "+username);
return this.setUserName(username);
};
MqttConnectOptions.setPassword.implementation = function(password) {
send("Password: "+password);
return this.setPassword(password);
};
send("All set !");
});
"""
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()