Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BrowserExploitServer mixin #2613

Merged
merged 74 commits into from
Nov 12, 2013
Merged
Show file tree
Hide file tree
Changes from 73 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
00efad5
Initial commit for BrowserExploitServer mixin
wchen-r7 Oct 31, 2013
735b879
Add an example/testcase for BrowserExploitServer
wchen-r7 Oct 31, 2013
6e7e5a0
Put postInfo() in the js directory
wchen-r7 Oct 31, 2013
10fd892
Fix a "undefined method to_sym" bug
wchen-r7 Oct 31, 2013
8a0ebcb
Adds method get_module_resource
wchen-r7 Oct 31, 2013
391360d
Update xmlhttprequest
wchen-r7 Oct 31, 2013
828ef9c
Adds target-specific payload generator
wchen-r7 Oct 31, 2013
94d6261
Pretty much done with these, remove these comments.
wchen-r7 Nov 1, 2013
21891a8
Make sure the browser can't retry by going to the first URL
wchen-r7 Nov 1, 2013
5851d50
Rename some stuff
wchen-r7 Nov 1, 2013
7a33c48
No double slash
wchen-r7 Nov 1, 2013
d54c8a3
Fix bug in proxy detection
wchen-r7 Nov 1, 2013
5fb261a
Change var name
wchen-r7 Nov 1, 2013
abc06aa
Use mutex
wchen-r7 Nov 1, 2013
a806b1a
Update test example
wchen-r7 Nov 1, 2013
094abdd
rspec this
wchen-r7 Nov 1, 2013
c7c1fcf
Pull shared XHR shim out, add option to static Js module method.
joevennix Nov 2, 2013
90d8da6
Fix some bugs in my edits, add a spec.
joevennix Nov 2, 2013
5f85ede
Prevent xhr shim from leaking.
joevennix Nov 2, 2013
bccbed2
Rename :use_xhr_shim to :inject_xhr_shim.
joevennix Nov 2, 2013
7d975df
Fix spec to refer to postInfo().
joevennix Nov 2, 2013
1d5643d
Match Rspec terminology
wchen-r7 Nov 4, 2013
34b5136
use let for requirements
wchen-r7 Nov 4, 2013
8bfa252
Restate this test
wchen-r7 Nov 4, 2013
480b876
non_existent_profile
wchen-r7 Nov 4, 2013
6e06907
let 'random'
wchen-r7 Nov 4, 2013
f985871
let 'linux'
wchen-r7 Nov 4, 2013
9a8e45f
be_nil
wchen-r7 Nov 4, 2013
bed2ea9
rename some stuff
wchen-r7 Nov 4, 2013
03ee1d0
fix server.start_service
wchen-r7 Nov 4, 2013
dc07627
Add another test for profile
wchen-r7 Nov 4, 2013
0337e6f
Do yard documentation
wchen-r7 Nov 4, 2013
c3d9f40
They are symbols not strings
wchen-r7 Nov 4, 2013
016e686
super chomp
wchen-r7 Nov 4, 2013
c6fb570
Correct bad method naming
wchen-r7 Nov 4, 2013
25787fb
Change has_proxy?
wchen-r7 Nov 4, 2013
e83f4e5
Use a warning
wchen-r7 Nov 4, 2013
23e5a9f
Force on_request_exploit override
wchen-r7 Nov 4, 2013
ed572d9
Merge joev's PR for Rex::Exploitation::Js::Network
wchen-r7 Nov 4, 2013
d970925
Fix encoding bug
wchen-r7 Nov 4, 2013
9c8ecd2
Fix encoding order
wchen-r7 Nov 4, 2013
ef57a38
Move documentation about profile structure
wchen-r7 Nov 4, 2013
054a525
Change profile data structure
wchen-r7 Nov 4, 2013
844daf0
No regex for get_resource checking
wchen-r7 Nov 4, 2013
5f2d835
Be more browser specific with Javascript generation
wchen-r7 Nov 5, 2013
73e72a6
Update the detect_spec testcase
wchen-r7 Nov 5, 2013
8fb2b94
Add ActiveX detection
wchen-r7 Nov 5, 2013
9d1742a
Fix typos
wchen-r7 Nov 5, 2013
0513dad
-_-
wchen-r7 Nov 5, 2013
9c6b187
stuff
wchen-r7 Nov 5, 2013
90b91ec
Add testcase for on_request_exploit
wchen-r7 Nov 5, 2013
7370146
Fix ActiveX. Use ERB for Javascript detection code.
wchen-r7 Nov 5, 2013
63d3c7e
Put proxy headers in a constant
wchen-r7 Nov 5, 2013
65c96a1
Allow the module to be target specific
wchen-r7 Nov 6, 2013
636adc8
Add rop_junk and rop_nop
wchen-r7 Nov 6, 2013
f2e4d55
More rspec
wchen-r7 Nov 6, 2013
c921160
Forgot to rm this line
wchen-r7 Nov 6, 2013
cf5d9c7
Add case for IE10 + Win 7 SP1 detection
wchen-r7 Nov 6, 2013
c338f7a
Change how requirements are defined, rspec, etc
wchen-r7 Nov 6, 2013
23996ec
Fix up some things
wchen-r7 Nov 7, 2013
3e1771a
Being able to pass binding when we need to
wchen-r7 Nov 7, 2013
991240a
Support java version detection
wchen-r7 Nov 7, 2013
b34b4ac
Update the java stuff again
wchen-r7 Nov 7, 2013
d9d04fa
Correct test file
wchen-r7 Nov 7, 2013
32b1260
Forgot to pass optional headers
wchen-r7 Nov 7, 2013
866f240
A little update on documentation
wchen-r7 Nov 7, 2013
6a840fc
Move file to get a matching name
wchen-r7 Nov 11, 2013
8515082
rename again
wchen-r7 Nov 11, 2013
cf8f294
Oops, this is the right filename
wchen-r7 Nov 11, 2013
922f0eb
Switch aladdin_choosefilepath_bof2 to use BrowserExploitServer
jvazquez-r7 Nov 11, 2013
30de611
Support heap spray obfuscation
jvazquez-r7 Nov 11, 2013
b01d8c5
Restore module crash documentation
jvazquez-r7 Nov 11, 2013
f16aa91
mv rspec
wchen-r7 Nov 12, 2013
fbe1b92
Good bye get_resource
wchen-r7 Nov 12, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 40 additions & 2 deletions data/js/detect/addons.js → data/js/detect/ie_addons.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,47 @@
window.addons_detect = { };
window.ie_addons_detect = { };

/**
* Returns true if this ActiveX is available, otherwise false.
* Grabbed this directly from browser_autopwn.rb
**/
window.ie_addons_detect.hasActiveX = function (axo_name, method) {
var axobj = null;
if (axo_name.substring(0,1) == String.fromCharCode(123)) {
axobj = document.createElement("object");
axobj.setAttribute("classid", "clsid:" + axo_name);
axobj.setAttribute("id", axo_name);
axobj.setAttribute("style", "visibility: hidden");
axobj.setAttribute("width", "0px");
axobj.setAttribute("height", "0px");
document.body.appendChild(axobj);
if (typeof(axobj[method]) == 'undefined') {
var attributes = 'id="' + axo_name + '"';
attributes += ' classid="clsid:' + axo_name + '"';
attributes += ' style="visibility: hidden"';
attributes += ' width="0px" height="0px"';
document.body.innerHTML += "<object " + attributes + "></object>";
axobj = document.getElementById(axo_name);
}
} else {
try {
axobj = new ActiveXObject(axo_name);
} catch(e) {
// If we can't build it with an object tag and we can't build it
// with ActiveXObject, it can't be built.
return false;
};
}
if (typeof(axobj[method]) != 'undefined') {
return true;
}

return false;
};

/**
* Returns the version of Microsoft Office. If not found, returns null.
**/
window.addons_detect.getMsOfficeVersion = function () {
window.ie_addons_detect.getMsOfficeVersion = function () {
var version;
var types = new Array();
for (var i=1; i <= 5; i++) {
Expand Down
64 changes: 64 additions & 0 deletions data/js/detect/misc_addons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
window.misc_addons_detect = { };

/**
* Returns the Java version
**/
window.misc_addons_detect.getJavaVersion = function () {
var foundVersion = null;

//
// This finds the Java version from Java WebStart's ActiveX control
// This is specific to Windows
//
for (var i1=0; i1 < 10; i1++) {
for (var i2=0; i2 < 10; i2++) {
for (var i3=0; i3 < 10; i3++) {
for (var i4=0; i4 < 10; i4++) {
var version = String(i1) + "." + String(i2) + "." + String(i3) + "." + String(i4);
var progId = "JavaWebStart.isInstalled." + version;
try {
new ActiveXObject(progId);
return version;
}
catch (e) {
continue;
}
}}}}

//
// This finds the Java version from window.navigator.mimeTypes
// This seems to work pretty well for most browsers except for IE
//
if (foundVersion == null) {
var mimes = window.navigator.mimeTypes;
for (var i=0; i<mimes.length; i++) {
var m = /java.+;version=(.+)/.exec(mimes[i].type);
if (m) {
var version = parseFloat(m[1]);
if (version > foundVersion) {
foundVersion = version;
}
}
}
}

//
// This finds the Java version from navigator plugins
// This is necessary for Windows + Firefox setup, but the check isn't as good as the mime one.
// So we do this last.
//
if (foundVersion == null) {
var foundJavaString = "";
var pluginsCount = navigator.plugins.length;
for (i=0; i < pluginsCount; i++) {
var pluginName = navigator.plugins[i].name;
var pluginVersion = navigator.plugins[i].version;
if (/Java/.test(pluginName) && pluginVersion != undefined) {
foundVersion = navigator.plugins[i].version;
break;
}
}
}

return foundVersion;
}
6 changes: 6 additions & 0 deletions data/js/detect/os.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,12 @@ window.os_detect.getVersion = function(){
os_flavor = "7";
os_sp = "SP1";
break;
case "10016720":
// IE 10.0.9200.16721 / Windows 7 SP1
ua_version = "10.0";
os_flavor = "7";
os_sp = "SP1";
break;
case "1000":
// IE 10.0.8400.0 (Pre-release + KB2702844), Windows 8 x86 English Pre-release
ua_version = "10.0";
Expand Down
21 changes: 6 additions & 15 deletions data/js/network/ajax_download.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
function ajax_download(oArg) {
var method = oArg.method;
var path = oArg.path;
var data = oArg.data;
if (!oArg.method) { oArg.method = "GET"; }
if (!oArg.path) { throw "Missing parameter 'path'"; }
if (!oArg.data) { oArg.data = null; }

if (method == undefined) { method = "GET"; }
if (method == path) { throw "Missing parameter 'path'"; }
if (data == undefined) { data = null; }

if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
else {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
var xmlHttp = new XMLHttpRequest();

if (xmlHttp.overrideMimeType) {
xmlHttp.overrideMimeType("text/plain; charset=x-user-defined");
}

xmlHttp.open(method, path, false);
xmlHttp.send(data);
xmlHttp.open(oArg.method, oArg.path, false);
xmlHttp.send(oArg.data);
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
return xmlHttp.responseText;
}
Expand Down
10 changes: 10 additions & 0 deletions data/js/network/ajax_post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function postInfo(path, data) {
var xmlHttp = new XMLHttpRequest();

if (xmlHttp.overrideMimeType) {
xmlHttp.overrideMimeType("text/plain; charset=x-user-defined");
}

xmlHttp.open('POST', path, false);
xmlHttp.send(data);
}
15 changes: 15 additions & 0 deletions data/js/network/xhr_shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if (!window.XMLHTTPRequest) {
(function() {
var idx, activeObjs = ["Microsoft.XMLHTTP", "Msxml2.XMLHTTP", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0"];
for (idx = 0; idx < activeObjs.length; idx++) {
try {
new ActiveXObject(activeObjs[idx]);
window.XMLHttpRequest = function() {
return new ActiveXObject(activeObjs[idx]);
};
break;
}
catch (e) {}
}
})();
}
24 changes: 16 additions & 8 deletions lib/msf/core/exploit/http/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -678,14 +678,6 @@ def initialize(info = {})
OptEnum.new('HTML::base64', [false, 'Enable HTML obfuscation via an embeded base64 html object (IE not supported)', 'none', ['none', 'plain', 'single_pad', 'double_pad', 'random_space_injection']]),
OptInt.new('HTML::javascript::escape', [false, 'Enable HTML obfuscation via HTML escaping (number of iterations)', 0]),
], Exploit::Remote::HttpServer::HTML)

# Cache Javascript
@cache_base64 = nil
@cache_ajax_download = nil
@cache_mstime_malloc = nil
@cache_property_spray = nil
@cache_heap_spray = nil
@cache_os_detect = nil
end

#
Expand Down Expand Up @@ -744,6 +736,14 @@ def js_ajax_download
end


#
# Transfers data using a POST request
#
def js_ajax_post
@cache_ajax_post ||= Rex::Exploitation::Js::Network.ajax_post
end


#
# This function takes advantage of MSTIME's CTIMEAnimationBase::put_values function that's
# suitable for a no-spray technique. There should be an allocation that contains an array of
Expand Down Expand Up @@ -813,6 +813,14 @@ def js_os_detect
@cache_os_detect ||= ::Rex::Exploitation::Js::Detect.os
end

def js_ie_addons_detect
@cache_ie_addons_detect ||= ::Rex::Exploitation::Js::Detect.ie_addons
end

def js_misc_addons_detect
@cache_misc_addons_detect ||= ::Rex::Exploitation::Js::Detect.misc_addons
end

# Transmits a html response to the supplied client
#
# HTML evasions are implemented here.
Expand Down
2 changes: 2 additions & 0 deletions lib/msf/core/exploit/mixins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@

# WebApp
require 'msf/core/exploit/web'

require 'msf/core/exploit/remote/browser_exploit_server'