mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-09-11 17:08:02 +02:00
Land #4654, test module fixes
This commit is contained in:
commit
3954c0e3aa
@ -354,21 +354,13 @@ module Msf::Post::File
|
||||
# @param old_file [String] Remote file name to move
|
||||
# @param new_file [String] The new name for the remote file
|
||||
def rename_file(old_file, new_file)
|
||||
if session.respond_to? :commands && session.commands.include?("stdapi_fs_file_move")
|
||||
if session.type == "meterpreter"
|
||||
return (session.fs.file.mv(old_file, new_file).result == 0)
|
||||
else
|
||||
if session.platform =~ /win/
|
||||
if cmd_exec(%Q|move /y "#{old_file}" "#{new_file}"|) =~ /moved/
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
cmd_exec(%Q|move /y "#{old_file}" "#{new_file}"|) =~ /moved/
|
||||
else
|
||||
if cmd_exec(%Q|mv -f "#{old_file}" "#{new_file}"|).empty?
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
cmd_exec(%Q|mv -f "#{old_file}" "#{new_file}"|).empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -10,7 +10,7 @@ class Metasploit3 < Msf::Exploit::Remote
|
||||
# =( need more targets and perhaps more OS specific return values OS specific would be preferred
|
||||
|
||||
include Msf::Exploit::Remote::HttpClient
|
||||
include Rex::Exploitation::CmdStagerVBS
|
||||
include Msf::Exploit::CmdStager
|
||||
|
||||
def initialize(info = {})
|
||||
super(update_info(info,
|
||||
|
@ -32,7 +32,7 @@ class Metasploit4 < Msf::Post
|
||||
#
|
||||
def setup
|
||||
@old_pwd = pwd
|
||||
tmp = (directory?("/tmp")) ? "/tmp" : "%TMP%"
|
||||
tmp = (directory?("/tmp")) ? "/tmp" : "%TEMP%"
|
||||
vprint_status("Setup: changing working directory to #{tmp}")
|
||||
cd(tmp)
|
||||
|
||||
|
@ -35,7 +35,7 @@ class Metasploit4 < Msf::Post
|
||||
if (stat and stat.directory?)
|
||||
tmp = "/tmp"
|
||||
else
|
||||
tmp = session.fs.file.expand_path("%TMP%")
|
||||
tmp = session.fs.file.expand_path("%TEMP%")
|
||||
end
|
||||
vprint_status("Setup: changing working directory to #{tmp}")
|
||||
session.fs.dir.chdir(tmp)
|
||||
@ -164,10 +164,11 @@ class Metasploit4 < Msf::Post
|
||||
end
|
||||
|
||||
it "should create and remove a dir" do
|
||||
res = create_directory("meterpreter-test")
|
||||
session.fs.dir.rmdir("meterpreter-test-dir") rescue nil
|
||||
res = create_directory("meterpreter-test-dir")
|
||||
if (res)
|
||||
session.fs.dir.rmdir("meterpreter-test")
|
||||
res &&= !session.fs.dir.entries.include?("meterpreter-test")
|
||||
session.fs.dir.rmdir("meterpreter-test-dir")
|
||||
res &&= !session.fs.dir.entries.include?("meterpreter-test-dir")
|
||||
vprint_status("Directory removed successfully")
|
||||
end
|
||||
|
||||
@ -175,16 +176,17 @@ class Metasploit4 < Msf::Post
|
||||
end
|
||||
|
||||
it "should change directories" do
|
||||
res = create_directory("meterpreter-test")
|
||||
session.fs.dir.rmdir("meterpreter-test-dir") rescue nil
|
||||
res = create_directory("meterpreter-test-dir")
|
||||
|
||||
old_wd = session.fs.dir.pwd
|
||||
vprint_status("Old CWD: #{old_wd}")
|
||||
|
||||
if res
|
||||
session.fs.dir.chdir("meterpreter-test")
|
||||
session.fs.dir.chdir("meterpreter-test-dir")
|
||||
new_wd = session.fs.dir.pwd
|
||||
vprint_status("New CWD: #{new_wd}")
|
||||
res &&= (new_wd =~ /meterpreter-test$/)
|
||||
res &&= (new_wd =~ /meterpreter-test-dir$/)
|
||||
|
||||
if res
|
||||
session.fs.dir.chdir("..")
|
||||
@ -192,8 +194,8 @@ class Metasploit4 < Msf::Post
|
||||
vprint_status("Back to old CWD: #{wd}")
|
||||
end
|
||||
end
|
||||
session.fs.dir.rmdir("meterpreter-test")
|
||||
res &&= !session.fs.dir.entries.include?("meterpreter-test")
|
||||
session.fs.dir.rmdir("meterpreter-test-dir")
|
||||
res &&= !session.fs.dir.entries.include?("meterpreter-test-dir")
|
||||
vprint_status("Directory removed successfully")
|
||||
|
||||
res
|
||||
@ -220,8 +222,9 @@ class Metasploit4 < Msf::Post
|
||||
|
||||
it "should upload a file" do
|
||||
res = true
|
||||
remote = "HACKING.remote.txt"
|
||||
local = "HACKING"
|
||||
|
||||
remote = "meterpreter-test-file.txt"
|
||||
local = __FILE__
|
||||
vprint_status("uploading")
|
||||
session.fs.file.upload_file(remote, local)
|
||||
vprint_status("done")
|
||||
@ -270,8 +273,8 @@ class Metasploit4 < Msf::Post
|
||||
|
||||
it "should do md5 and sha1 of files" do
|
||||
res = true
|
||||
remote = "HACKING.remote.txt"
|
||||
local = "HACKING"
|
||||
remote = "meterpreter-test-file.txt"
|
||||
local = __FILE__
|
||||
vprint_status("uploading")
|
||||
session.fs.file.upload_file(remote, local)
|
||||
vprint_status("done")
|
||||
|
Loading…
Reference in New Issue
Block a user