Skip to content

Commit 834c0e5

Browse files
committed
Update multi modules
1 parent a30144f commit 834c0e5

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

lib/msf/core/post/common.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ def cmd_exec(cmd, args=nil, time_out=15)
122122

123123
process.close
124124
when /shell/
125-
o = session.shell_command_token("#{cmd} #{args}", time_out)
125+
if args.nil? || args.empty?
126+
o = session.shell_command_token("#{cmd}", time_out)
127+
else
128+
o = session.shell_command_token("#{cmd} #{args}", time_out)
129+
end
126130
o.chomp! if o
127131
end
128132
return "" if o.nil?

modules/post/multi/gather/multi_command.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def initialize(info={})
1616
'License' => MSF_LICENSE,
1717
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>'],
1818
'Platform' => %w{ bsd linux osx unix win },
19-
'SessionTypes' => [ 'meterpreter','shell' ]
19+
'SessionTypes' => ['meterpreter']
2020
))
2121
register_options(
2222
[
@@ -27,7 +27,6 @@ def initialize(info={})
2727

2828
# Run Method for when run command is issued
2929
def run
30-
session_type = session.type
3130
print_status("Running module against #{sysinfo['Computer']}")
3231
if not ::File.exists?(datastore['RESOURCE'])
3332
raise "Resource File does not exists!"
@@ -41,11 +40,7 @@ def run
4140
tmpout << " Output of #{cmd}\n"
4241
tmpout << "*****************************************\n"
4342
print_status "Running command #{cmd.chomp}"
44-
if session_type =~ /meterpreter/
45-
tmpout << cmd_exec(cmd.chomp)
46-
elsif session_type =~ /shell/
47-
tmpout << session.shell_command_token(cmd.chomp).chomp
48-
end
43+
tmpout << cmd_exec(cmd.chomp)
4944
vprint_status tmpout
5045
command_log = store_loot("host.command", "text/plain", session,tmpout ,
5146
"#{cmd.gsub(/\.|\/|\s/,"_")}.txt", "Command Output \'#{cmd.chomp}\'")

modules/post/multi/manage/shell_to_meterpreter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ def transmit_payload(exe)
196196
sent = 0
197197
aborted = false
198198
cmds.each { |cmd|
199-
ret = session.shell_command_token(cmd)
199+
ret = cmd_exec(cmd)
200200
if !ret
201201
aborted = true
202202
else
203203
ret.strip!
204-
aborted = true if !ret.empty?
204+
aborted = true if !ret.empty? && ret !~ /The process tried to write to a nonexistent pipe./
205205
end
206206
if aborted
207207
print_error('Error: Unable to execute the following command: ' + cmd.inspect)

modules/post/multi/manage/system_session.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def run
5959

6060
if not cmd.empty?
6161
print_status("Executing reverse tcp shel to #{lhost} on port #{lport}")
62-
session.shell_command_token("(#{cmd} &)")
62+
cmd_exec("(#{cmd} &)")
6363
end
6464
end
6565

0 commit comments

Comments
 (0)