Skip to content

Commit

Permalink
Land #18044, Add MIPS64 Linux Fetch Payloads
Browse files Browse the repository at this point in the history
Merge branch 'land-18044' into upstream-master
  • Loading branch information
bwatters-r7 committed Jun 2, 2023
2 parents 9361451 + a6f1be8 commit 1e9d286
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 13 deletions.
12 changes: 2 additions & 10 deletions lib/msf/core/payload/adapter/fetch.rb
Expand Up @@ -36,14 +36,6 @@ def check_srvhost
end
end

def compatible?(mod)
if mod.type == Msf::MODULE_PAYLOAD && (mod.class.const_defined?(:CachedSize) && mod.class::CachedSize != :dynamic) && (mod.class::CachedSize >= 120_000) # echo does not have an unlimited amount of space
return false
end
super
end


# If no fetch URL is provided, we generate one based off the underlying payload data
# This is because if we use a randomly-generated URI, the URI generated by venom and
# Framework will not match. This way, we can build a payload in venom and a listener
Expand Down Expand Up @@ -310,7 +302,7 @@ def _generate_wget_command
end
cmd + _execute_add
end

def _remote_destination
return _remote_destination_win if windows?
return _remote_destination_nix
Expand Down Expand Up @@ -339,4 +331,4 @@ def _remote_destination_win
@remote_destination_win = payload_path
@remote_destination_win
end
end
end
25 changes: 25 additions & 0 deletions modules/payloads/adapters/cmd/linux/http/mips64.rb
@@ -0,0 +1,25 @@
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

module MetasploitModule
include Msf::Payload::Adapter::Fetch::HTTP
include Msf::Payload::Adapter::Fetch::LinuxOptions

def initialize(info = {})
super(
update_info(
info,
'Name' => 'HTTP Fetch',
'Description' => 'Fetch and execute a MIPS64 payload from an HTTP server.',
'Author' => ['Brendan Watters', 'Spencer McIntyre'],
'Platform' => 'linux',
'Arch' => ARCH_CMD,
'License' => MSF_LICENSE,
'AdaptedArch' => ARCH_MIPS64,
'AdaptedPlatform' => 'linux'
)
)
end
end
2 changes: 1 addition & 1 deletion modules/payloads/adapters/cmd/linux/http/x64.rb
Expand Up @@ -12,7 +12,7 @@ def initialize(info = {})
update_info(
info,
'Name' => 'HTTP Fetch',
'Description' => 'Fetch and Execute an x64 payload from an http server',
'Description' => 'Fetch and execute an x64 payload from an HTTP server.',
'Author' => 'Brendan Watters',
'Platform' => 'linux',
'Arch' => ARCH_CMD,
Expand Down
25 changes: 25 additions & 0 deletions modules/payloads/adapters/cmd/linux/https/mips64.rb
@@ -0,0 +1,25 @@
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

module MetasploitModule
include Msf::Payload::Adapter::Fetch::Https
include Msf::Payload::Adapter::Fetch::LinuxOptions

def initialize(info = {})
super(
update_info(
info,
'Name' => 'HTTPS Fetch',
'Description' => 'Fetch and execute an x64 payload from an HTTPS server.',
'Author' => ['Brendan Watters', 'Spencer McIntyre'],
'Platform' => 'linux',
'Arch' => ARCH_CMD,
'License' => MSF_LICENSE,
'AdaptedArch' => ARCH_MIPS64,
'AdaptedPlatform' => 'linux'
)
)
end
end
2 changes: 1 addition & 1 deletion modules/payloads/adapters/cmd/linux/https/x64.rb
Expand Up @@ -12,7 +12,7 @@ def initialize(info = {})
update_info(
info,
'Name' => 'HTTPS Fetch',
'Description' => 'Fetch and Execute an x64 payload from an https server',
'Description' => 'Fetch and execute an x64 payload from an HTTPS server.',
'Author' => 'Brendan Watters',
'Platform' => 'linux',
'Arch' => ARCH_CMD,
Expand Down
25 changes: 25 additions & 0 deletions modules/payloads/adapters/cmd/linux/tftp/mips64.rb
@@ -0,0 +1,25 @@
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

module MetasploitModule
include Msf::Payload::Adapter::Fetch::TFTP
include Msf::Payload::Adapter::Fetch::LinuxOptions

def initialize(info = {})
super(
update_info(
info,
'Name' => 'TFTP Fetch',
'Description' => 'Fetch and execute a MIPS64 payload from a TFTP server.',
'Author' => ['Brendan Watters', 'Spencer McIntyre'],
'Platform' => 'linux',
'Arch' => ARCH_CMD,
'License' => MSF_LICENSE,
'AdaptedArch' => ARCH_MIPS64,
'AdaptedPlatform' => 'linux'
)
)
end
end
2 changes: 1 addition & 1 deletion modules/payloads/adapters/cmd/linux/tftp/x64.rb
Expand Up @@ -12,7 +12,7 @@ def initialize(info = {})
update_info(
info,
'Name' => 'TFTP Fetch',
'Description' => 'Fetch and Execute an x64 payload from a TFTP server',
'Description' => 'Fetch and execute an x64 payload from a TFTP server.',
'Author' => 'Brendan Watters',
'Platform' => 'linux',
'Arch' => ARCH_CMD,
Expand Down
24 changes: 24 additions & 0 deletions spec/modules/payloads_spec.rb
Expand Up @@ -508,6 +508,30 @@
reference_name: 'bsdi/x86/shell_reverse_tcp'
end

context 'cmd/linux/http/mips64' do
it_should_behave_like 'payload is not cached',
ancestor_reference_names: [
'adapters/cmd/linux/http/mips64'
],
reference_name: 'cmd/linux/http/mips64'
end

context 'cmd/linux/https/mips64' do
it_should_behave_like 'payload is not cached',
ancestor_reference_names: [
'adapters/cmd/linux/https/mips64'
],
reference_name: 'cmd/linux/https/mips64'
end

context 'cmd/linux/tftp/mips64' do
it_should_behave_like 'payload is not cached',
ancestor_reference_names: [
'adapters/cmd/linux/tftp/mips64'
],
reference_name: 'cmd/linux/tftp/mips64'
end

context 'cmd/linux/http/x64' do
it_should_behave_like 'payload is not cached',
ancestor_reference_names: [
Expand Down

0 comments on commit 1e9d286

Please sign in to comment.