Skip to content

Commit 98457c0

Browse files
author
jvazquez-r7
committed
Merge branch 'sonicwall_gms' of https://github.com/jlee-r7/metasploit-framework into jlee-r7-sonicwall_gms
2 parents 0ad548a + 9b6f2fc commit 98457c0

File tree

6 files changed

+183
-154
lines changed

6 files changed

+183
-154
lines changed

lib/msf/core/exploit/file_dropper.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def on_new_session(session)
2222
# Meterpreter should do this automatically as part of
2323
# fs.file.rm(). Until that has been implemented, remove the
2424
# read-only flag with a command.
25-
session.shell_command_token(%Q|attrib.exe -r "#{win_file}"|)
25+
if session.platform =~ /win/
26+
session.shell_command_token(%Q|attrib.exe -r #{win_file}|)
27+
end
2628
session.fs.file.rm(file)
2729
print_good("Deleted #{file}")
2830
true

lib/msf/core/payload/java.rb

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@ def generate
3535
end
3636

3737
#
38-
# Used by stagers to create a jar file as a Rex::Zip::Jar. Stagers define
39-
# a list of class files in @class_files which are pulled from
40-
# Msf::Config.data_directory. The configuration file is created by the
41-
# payload's #config method.
42-
#
43-
# +opts+ can include:
44-
# +:main_class+:: the name of the Main-Class attribute in the manifest.
45-
# Defaults to "metasploit.Payload"
38+
# Used by stagers to create a jar file as a {Rex::Zip::Jar}. Stagers
39+
# define a list of class files in @class_files which are pulled from
40+
# {Msf::Config.data_directory}. The configuration file is created by
41+
# the payload's #config method.
4642
#
43+
# @option opts :main_class [String] the name of the Main-Class
44+
# attribute in the manifest. Defaults to "metasploit.Payload"
45+
# @return [Rex::Zip::Jar]
4746
def generate_jar(opts={})
4847
raise if not respond_to? :config
4948
# Allow changing the jar's Main Class in the manifest so wrappers
@@ -63,12 +62,12 @@ def generate_jar(opts={})
6362
end
6463

6564
#
66-
# Like #generate_jar, this method is used by stagers to create a war file
65+
# Like {#generate_jar}, this method is used by stagers to create a war file
6766
# as a Rex::Zip::Jar object.
6867
#
69-
# +opts+ can include:
70-
# +:app_name+:: the name of the \<servlet-name> attribute in the web.xml.
71-
# Defaults to "NAME"
68+
# @param opts [Hash]
69+
# @option :app_name [String] Name of the \<servlet-name> attribute in the
70+
# web.xml. Defaults to random
7271
#
7372
def generate_war(opts={})
7473
raise if not respond_to? :config

lib/msf/core/post/file.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def append_file(file_name, data)
274274
end
275275

276276
#
277-
# Read a local file +local+ and write it as +remote+ on the remote file
277+
# Read a local file +local+ and write it as +remote+ on the remote file
278278
# system
279279
#
280280
def upload_file(remote, local)
@@ -304,7 +304,7 @@ def rm_f(*remote_files)
304304
#
305305
def rename_file(new_file, old_file)
306306
#TODO: this is not ideal as the file contents are sent to meterp server and back to the client
307-
write_file(new_file, read_file(old_file))
307+
write_file(new_file, read_file(old_file))
308308
rm_f(old_file)
309309
end
310310
alias :move_file :rename_file
@@ -315,7 +315,7 @@ def rename_file(new_file, old_file)
315315
# Meterpreter-specific file read. Returns contents of remote file
316316
# +file_name+ as a String or nil if there was an error
317317
#
318-
# You should never call this method directly. Instead, call #read_file
318+
# You should never call this method directly. Instead, call {#read_file}
319319
# which will call this if it is appropriate for the given session.
320320
#
321321
def _read_file_meterpreter(file_name)

lib/msf/util/exe.rb

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
# -*- coding: binary -*-
2-
##
3-
# $Id: exe.rb 14286 2011-11-20 01:41:04Z rapid7 $
4-
##
52

6-
###
7-
#
8-
# framework-util-exe
9-
# --------------
3+
module Msf
4+
module Util
5+
106
#
117
# The class provides methods for creating and encoding executable file
128
# formats for various platforms. It is a replacement for the previous
139
# code in Rex::Text
1410
#
15-
###
16-
17-
module Msf
18-
module Util
1911
class EXE
2012

2113
require 'rex'
@@ -609,6 +601,7 @@ def self.to_osx_x64_macho(framework, code, opts={})
609601
end
610602

611603
# Create an ELF executable containing the payload provided in +code+
604+
#
612605
# For the default template, this method just appends the payload, checks if
613606
# the template is 32 or 64 bit and adjusts the offsets accordingly
614607
# For user-provided templates, modifies the header to mark all executable
@@ -1187,8 +1180,9 @@ def self.to_win32pe_aspx(framework, code, opts={})
11871180
# Creates a jar file that drops the provided +exe+ into a random file name
11881181
# in the system's temp dir and executes it.
11891182
#
1190-
# See also: +Msf::Core::Payload::Java+
1183+
# @see Msf::Payload::Java
11911184
#
1185+
# @return [Rex::Zip::Jar]
11921186
def self.to_jar(exe, opts={})
11931187
spawn = opts[:spawn] || 2
11941188
exe_name = Rex::Text.rand_text_alpha(8) + ".exe"
@@ -1205,8 +1199,30 @@ def self.to_jar(exe, opts={})
12051199
zip
12061200
end
12071201

1208-
# Creates a Web Archive (WAR) file from the provided jsp code. Additional options
1209-
# can be provided via the "opts" hash.
1202+
# Creates a Web Archive (WAR) file from the provided jsp code.
1203+
#
1204+
# On Tomcat, WAR files will be deployed into a directory with the same name
1205+
# as the archive, e.g. +foo.war+ will be extracted into +foo/+. If the
1206+
# server is in a default configuration, deoployment will happen
1207+
# automatically. See
1208+
# {http://tomcat.apache.org/tomcat-5.5-doc/config/host.html the Tomcat
1209+
# documentation} for a description of how this works.
1210+
#
1211+
# @param jsp_raw [String] JSP code to be added in a file called +jsp_name+
1212+
# in the archive. This will be compiled by the victim servlet container
1213+
# (e.g., Tomcat) and act as the main function for the servlet.
1214+
# @param opts [Hash]
1215+
# @option opts :jsp_name [String] Name of the <jsp-file> in the archive
1216+
# _without the .jsp extension_. Defaults to random.
1217+
# @option opts :app_name [String] Name of the app to put in the <servlet-name>
1218+
# tag. Mostly irrelevant, except as an identifier in web.xml. Defaults to
1219+
# random.
1220+
# @option opts :extra_files [Array<String,String>] Additional files to add
1221+
# to the archive. First elment is filename, second is data
1222+
#
1223+
# @todo Refactor to return a {Rex::Zip::Archive} or {Rex::Zip::Jar}
1224+
#
1225+
# @return [String]
12101226
def self.to_war(jsp_raw, opts={})
12111227
jsp_name = opts[:jsp_name]
12121228
jsp_name ||= Rex::Text.rand_text_alpha_lower(rand(8)+8)
@@ -1247,9 +1263,15 @@ def self.to_war(jsp_raw, opts={})
12471263
return zip.pack
12481264
end
12491265

1250-
# Creates a Web Archive (WAR) file containing a jsp page and hexdump of a payload.
1251-
# The jsp page converts the hexdump back to a normal .exe file and places it in
1252-
# the temp directory. The payload .exe file is then executed.
1266+
# Creates a Web Archive (WAR) file containing a jsp page and hexdump of a
1267+
# payload. The jsp page converts the hexdump back to a normal binary file
1268+
# and places it in the temp directory. The payload file is then executed.
1269+
#
1270+
# @see to_war
1271+
# @param exe [String] Executable to drop and run.
1272+
# @param opts (see to_war)
1273+
# @option opts (see to_war)
1274+
# @return (see to_war)
12531275
def self.to_jsp_war(exe, opts={})
12541276

12551277
# begin <payload>.jsp

lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def webcam_list
2828
names
2929
end
3030

31-
# Starts recording video from video source of index #{cam}
31+
# Starts recording video from video source of index +cam+
3232
def webcam_start(cam)
3333
request = Packet.create_request('webcam_start')
3434
request.add_tlv(TLV_TYPE_WEBCAM_INTERFACE_ID, cam)
@@ -48,7 +48,7 @@ def webcam_stop
4848
true
4949
end
5050

51-
# Record from default audio source for #{duration} seconds;
51+
# Record from default audio source for +duration+ seconds;
5252
# returns a low-quality wav file
5353
def record_mic(duration)
5454
request = Packet.create_request('webcam_audio_record')

0 commit comments

Comments
 (0)