Skip to content

Commit 591b085

Browse files
committed
Add support for shell sessions in FileDropper
1 parent 3363475 commit 591b085

File tree

2 files changed

+13
-45
lines changed

2 files changed

+13
-45
lines changed

lib/msf/core/exploit/file_dropper.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ def on_new_session(session)
2525
false
2626
end
2727
else
28-
# Need to be platform-independent here. Not sure of the best way
29-
# to do that since we can't be certain that {#target} is
30-
# accurate; exploits with automatic targets frequently change
31-
# it.
32-
false
28+
win_file = file.gsub("/", "\\\\")
29+
win_cmd = %Q|del.exe /f /q "#{win_file}"|
30+
unix_cmd = %Q|rm -f "#{file}" >/dev/null|
31+
32+
# We need to be platform-independent here. Since we can't be
33+
# certain that {#target} is accurate because exploits with
34+
# automatic targets frequently change it, we just go ahead and
35+
# run both a windows and a unixy command in the same line. One
36+
# of them will definitely fail and the other will probably
37+
# succeed. Doing it this way saves us an extra round-trip.
38+
session.shell_command_token(%Q|#{win_cmd} ; #{unix_cmd}|)
39+
print_good("Deleted #{file}")
40+
true
3341
end
3442
end
3543

modules/exploits/multi/http/manageengine_search_sqli.rb

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -97,46 +97,6 @@ def pick_target
9797
return nil
9898
end
9999

100-
101-
=begin
102-
Now covered by FileDropper mixin. Keep it here, commented out, for now
103-
since FileDropper doesn't cover shell sessions yet.
104-
105-
#
106-
# We're in SecurityManager/bin at this point
107-
#
108-
def on_new_session(cli)
109-
if target['Platform'] == 'linux'
110-
print_warning("Malicious executable is removed during payload execution")
111-
end
112-
113-
if cli.type == 'meterpreter'
114-
cli.core.use("stdapi") if not cli.ext.aliases.include?("stdapi")
115-
end
116-
117-
@clean_ups.each { |f|
118-
base = File.basename(f)
119-
f = "../webapps/SecurityManager/#{base}"
120-
print_warning("#{rhost}:#{rport} - Deleting: \"#{base}\"")
121-
122-
begin
123-
if cli.type == 'meterpreter'
124-
cli.fs.file.rm(f)
125-
else
126-
del_cmd = (@my_target['Platform'] == 'linux') ? 'rm' : 'del'
127-
f = f.gsub(/\//, '\\') if @my_target['Platform'] == 'win'
128-
cli.shell_command_token("#{del_cmd} \"#{f}\"")
129-
end
130-
131-
print_good("#{rhost}:#{rport} - \"#{base}\" deleted")
132-
rescue ::Exception => e
133-
print_error("Unable to delete: #{e.message}")
134-
end
135-
}
136-
end
137-
=end
138-
139-
140100
#
141101
# Embeds our executable in JSP
142102
#

0 commit comments

Comments
 (0)