Skip to content

Commit 3ae3d56

Browse files
committed
Land rapid7#4745, fixes rapid7#4711, BrowserAutoPwn failing due to getpeername
2 parents 55f57e0 + 05d2703 commit 3ae3d56

File tree

6 files changed

+39
-29
lines changed

6 files changed

+39
-29
lines changed

lib/rex/socket.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,15 @@ def getlocalname
732732
# Return peer connection information.
733733
#
734734
def getpeername
735-
return Socket.from_sockaddr(super)
735+
peer_name = nil
736+
begin
737+
peer_name = Socket.from_sockaddr(super)
738+
rescue ::Errno::EINVAL => e
739+
# Ruby's getpeername method may call rb_sys_fail("getpeername(2)")
740+
elog("#{e.message} (#{e.class})#{e.backtrace * "\n"}\n", 'core', LEV_3)
741+
end
742+
743+
return peer_name
736744
end
737745

738746
#

lib/rex/socket/tcp_server.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ def accept(opts = {})
5656

5757
pn = t.getpeername
5858

59+
# We hit a "getpeername(2)" from Ruby
60+
return nil unless pn
61+
5962
t.peerhost = pn[1]
6063
t.peerport = pn[2]
6164
end

modules/auxiliary/server/browser_autopwn.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,14 @@ def setup
236236
print_debug("NOTE: Debug Mode; javascript will not be obfuscated")
237237
else
238238
pre = Time.now
239-
print_status("Obfuscating initial javascript #{pre}")
240-
@init_js.obfuscate
241-
print_status "Done in #{Time.now - pre} seconds"
239+
240+
#
241+
# 2/12/2015: Obfuscation is disabled because this is currently breaking BrowserAutoPwn
242+
#
243+
244+
#print_status("Obfuscating initial javascript #{pre}")
245+
#@init_js.obfuscate
246+
#print_status "Done in #{Time.now - pre} seconds"
242247
end
243248

244249
#@init_js << "window.onload = #{@init_js.sym("bodyOnLoad")};";
@@ -826,8 +831,12 @@ def build_script_response(cli, request)
826831
js << "#{js_debug("'starting exploits (' + global_exploit_list.length + ' total)<br>'")}\n"
827832
js << "window.next_exploit(0);\n"
828833

829-
js = ::Rex::Exploitation::JSObfu.new(js)
830-
js.obfuscate unless datastore["DEBUG"]
834+
#
835+
# 2/12/2015: Obfuscation is disabled because this is currently breaking BrowserAutoPwn
836+
#
837+
838+
#js = ::Rex::Exploitation::JSObfu.new(js)
839+
#js.obfuscate unless datastore["DEBUG"]
831840

832841
response.body = "#{js}"
833842
print_status("Responding with #{sploit_cnt} exploits")

modules/exploits/windows/browser/ms12_004_midi.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,6 @@ class Metasploit3 < Msf::Exploit::Remote
1010

1111
include Msf::Exploit::Remote::HttpServer::HTML
1212
include Msf::Exploit::RopDb
13-
include Msf::Exploit::Remote::BrowserAutopwn
14-
autopwn_info({
15-
:ua_name => HttpClients::IE,
16-
:ua_minver => "6.0",
17-
:ua_maxver => "8.0",
18-
:javascript => true,
19-
:os_name => OperatingSystems::Match::WINDOWS,
20-
:vuln_test => %Q|
21-
var v = window.os_detect.getVersion();
22-
var os_name = v['os_name'];
23-
if (os_name.indexOf('Windows XP') == 0) {is_vuln = true;} else { is_vuln = false; }
24-
|,
25-
})
2613

2714
def initialize(info={})
2815
super(update_info(info,

modules/exploits/windows/browser/ms13_090_cardspacesigninhelper.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ class Metasploit3 < Msf::Exploit::Remote
99
Rank = NormalRanking
1010

1111
include Msf::Exploit::Remote::BrowserExploitServer
12+
include Msf::Exploit::Remote::BrowserAutopwn
13+
autopwn_info({
14+
:ua_name => HttpClients::IE,
15+
:ua_minver => "8.0",
16+
:ua_maxver => "8.0",
17+
:javascript => true,
18+
:os_name => OperatingSystems::Match::WINDOWS_XP,
19+
# BrowserAutoPwn currently has a syntax error bug so we can't use classid and method,
20+
# so we have these commented out for now. But it's not so bad because by default
21+
# Windows XP has this ActiveX, and BrowserExploitServer's check will kick in.
22+
# :classid => "{19916E01-B44E-4E31-94A4-4696DF46157B}",
23+
# :method => "requiredClaims"
24+
})
1225

1326
def initialize(info={})
1427
super(update_info(info,

modules/exploits/windows/browser/ms14_064_ole_code_execution.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,8 @@ class Metasploit4 < Msf::Exploit::Remote
1111
Rank = ExcellentRanking
1212

1313
include Msf::Exploit::Remote::BrowserExploitServer
14-
include Msf::Exploit::Remote::BrowserAutopwn
1514
include Msf::Exploit::Powershell
1615

17-
autopwn_info({
18-
:ua_name => HttpClients::IE,
19-
:ua_minver => "3.0",
20-
:ua_maxver => "10.0",
21-
:javascript => true,
22-
:os_name => OperatingSystems::Match::WINDOWS,
23-
:rank => ExcellentRanking
24-
})
25-
2616
def initialize(info={})
2717
super(update_info(info,
2818
'Name' => "Microsoft Internet Explorer Windows OLE Automation Array Remote Code Execution",

0 commit comments

Comments
 (0)