Skip to content

Commit

Permalink
Fix an issue where info would raise an exception
Browse files Browse the repository at this point in the history
Fix instances where the `info` command would raise an exception while
generating the payload to calculate its length.
  • Loading branch information
zeroSteiner committed Jan 5, 2024
1 parent 0730392 commit 17b034b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/msf/core/payload/adapter/fetch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def initialize(*args)
Msf::OptBool.new('FETCH_DELETE', [true, 'Attempt to delete the binary after execution', false]),
Msf::OptString.new('FETCH_FILENAME', [ false, 'Name to use on remote system when storing payload; cannot contain spaces or slashes', Rex::Text.rand_text_alpha(rand(8..12))], regex: /^[^\s\/\\]*$/),
Msf::OptPort.new('FETCH_SRVPORT', [true, 'Local port to use for serving payload', 8080]),
Msf::OptAddressRoutable.new('FETCH_SRVHOST', [ false, 'Local IP to use for serving payload']),
# FETCH_SRVHOST defaults to LHOST, but if the payload doesn't connect back to Metasploit (e.g. adduser, messagebox, etc.) then FETCH_SRVHOST needs to be set
Msf::OptAddressRoutable.new('FETCH_SRVHOST', [ !options['LHOST']&.required, 'Local IP to use for serving payload']),
Msf::OptString.new('FETCH_URIPATH', [ false, 'Local URI to use for serving payload', '']),
Msf::OptString.new('FETCH_WRITABLE_DIR', [ true, 'Remote writable dir to store payload; cannot contain spaces', ''], regex:/^[\S]*$/)
]
Expand Down Expand Up @@ -80,8 +81,6 @@ def fetch_bindnetloc
end

def generate(opts = {})
datastore['FETCH_SRVHOST'] = datastore['LHOST'] if datastore['FETCH_SRVHOST'].blank?
fail_with(Msf::Module::Failure::BadConfig, 'FETCH_SRVHOST required') if datastore['FETCH_SRVHOST'].blank?
opts[:arch] ||= module_info['AdaptedArch']
opts[:code] = super
@srvexe = generate_payload_exe(opts)
Expand Down Expand Up @@ -128,7 +127,10 @@ def handle_connection(conn, opts = {})
end

def srvhost
datastore['FETCH_SRVHOST']
host = datastore['FETCH_SRVHOST']
host = datastore['LHOST'] if host.blank?
host = '127.127.127.127' if host.blank?
host
end

def srvnetloc
Expand Down

0 comments on commit 17b034b

Please sign in to comment.