Added the option to incude entropy in file/directory names to support
automated testingbug/bundler_fix
parent
09c9e9b1f9
commit
941f87fa83
|
@ -21,6 +21,7 @@ class MetasploitModule < Msf::Post
|
||||||
))
|
))
|
||||||
register_options(
|
register_options(
|
||||||
[
|
[
|
||||||
|
OptBool.new("AddEntropy" , [false, "Add entropy token to file and directory names.", false]),
|
||||||
OptString.new("BaseFileName" , [true, "File/dir base name", "meterpreter-test"])
|
OptString.new("BaseFileName" , [true, "File/dir base name", "meterpreter-test"])
|
||||||
], self.class)
|
], self.class)
|
||||||
end
|
end
|
||||||
|
@ -132,6 +133,11 @@ class MetasploitModule < Msf::Post
|
||||||
|
|
||||||
def test_fs
|
def test_fs
|
||||||
vprint_status("Starting filesystem tests")
|
vprint_status("Starting filesystem tests")
|
||||||
|
if datastore["AddEntropy"]
|
||||||
|
entropy_value = '-' + ('a'..'z').to_a.shuffle[0,8].join
|
||||||
|
else
|
||||||
|
entropy_value = ""
|
||||||
|
end
|
||||||
|
|
||||||
it "should return the proper directory separator" do
|
it "should return the proper directory separator" do
|
||||||
sysinfo = session.sys.config.sysinfo
|
sysinfo = session.sys.config.sysinfo
|
||||||
|
@ -167,7 +173,8 @@ class MetasploitModule < Msf::Post
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should create and remove a dir" do
|
it "should create and remove a dir" do
|
||||||
dir_name = "#{datastore["BaseFileName"]}-dir"
|
dir_name = "#{datastore["BaseFileName"]}-dir#{entropy_value}"
|
||||||
|
vprint_status("Directory Name: #{dir_name}")
|
||||||
session.fs.dir.rmdir(dir_name) rescue nil
|
session.fs.dir.rmdir(dir_name) rescue nil
|
||||||
res = create_directory(dir_name)
|
res = create_directory(dir_name)
|
||||||
if (res)
|
if (res)
|
||||||
|
@ -180,7 +187,8 @@ class MetasploitModule < Msf::Post
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should change directories" do
|
it "should change directories" do
|
||||||
dir_name = "#{datastore["BaseFileName"]}-dir"
|
dir_name = "#{datastore["BaseFileName"]}-dir#{entropy_value}"
|
||||||
|
vprint_status("Directory Name: #{dir_name}")
|
||||||
session.fs.dir.rmdir(dir_name) rescue nil
|
session.fs.dir.rmdir(dir_name) rescue nil
|
||||||
res = create_directory(dir_name)
|
res = create_directory(dir_name)
|
||||||
|
|
||||||
|
@ -208,7 +216,8 @@ class MetasploitModule < Msf::Post
|
||||||
|
|
||||||
it "should create and remove files" do
|
it "should create and remove files" do
|
||||||
res = true
|
res = true
|
||||||
file_name = datastore["BaseFileName"]
|
file_name = "#{datastore["BaseFileName"]}#{entropy_value}"
|
||||||
|
vprint_status("File Name: #{file_name}")
|
||||||
res &&= session.fs.file.open(file_name, "wb") { |fd|
|
res &&= session.fs.file.open(file_name, "wb") { |fd|
|
||||||
fd.write("test")
|
fd.write("test")
|
||||||
}
|
}
|
||||||
|
@ -228,7 +237,8 @@ class MetasploitModule < Msf::Post
|
||||||
|
|
||||||
it "should upload a file" do
|
it "should upload a file" do
|
||||||
res = true
|
res = true
|
||||||
remote = "#{datastore["BaseFileName"]}-file.txt"
|
remote = "#{datastore["BaseFileName"]}-file#{entropy_value}.txt"
|
||||||
|
vprint_status("Remote File Name: #{remote}")
|
||||||
local = __FILE__
|
local = __FILE__
|
||||||
vprint_status("uploading")
|
vprint_status("uploading")
|
||||||
session.fs.file.upload_file(remote, local)
|
session.fs.file.upload_file(remote, local)
|
||||||
|
@ -254,8 +264,10 @@ class MetasploitModule < Msf::Post
|
||||||
|
|
||||||
it "should move files" do
|
it "should move files" do
|
||||||
res = true
|
res = true
|
||||||
src_name = datastore["BaseFileName"]
|
src_name = "#{datastore["BaseFileName"]}#{entropy_value}"
|
||||||
dst_name = "#{datastore["BaseFileName"]}-moved"
|
vprint_status("Source File Name: #{src_name}")
|
||||||
|
dst_name = "#{src_name}-moved"
|
||||||
|
vprint_status("Destination File Name: #{dst_name}")
|
||||||
|
|
||||||
# Make sure we don't have leftovers from a previous run
|
# Make sure we don't have leftovers from a previous run
|
||||||
session.fs.file.rm(src_name) rescue nil
|
session.fs.file.rm(src_name) rescue nil
|
||||||
|
@ -279,8 +291,10 @@ class MetasploitModule < Msf::Post
|
||||||
|
|
||||||
it "should copy files" do
|
it "should copy files" do
|
||||||
res = true
|
res = true
|
||||||
src_name = datastore["BaseFileName"]
|
src_name = "#{datastore["BaseFileName"]}#{entropy_value}"
|
||||||
dst_name = "#{datastore["BaseFileName"]}-copied"
|
vprint_status("Source File Name: #{src_name}")
|
||||||
|
dst_name = "#{src_name}-copied"
|
||||||
|
vprint_status("Destination File Name: #{dst_name}")
|
||||||
|
|
||||||
# Make sure we don't have leftovers from a previous run
|
# Make sure we don't have leftovers from a previous run
|
||||||
session.fs.file.rm(src_name) rescue nil
|
session.fs.file.rm(src_name) rescue nil
|
||||||
|
@ -304,7 +318,8 @@ class MetasploitModule < Msf::Post
|
||||||
|
|
||||||
it "should do md5 and sha1 of files" do
|
it "should do md5 and sha1 of files" do
|
||||||
res = true
|
res = true
|
||||||
remote = "#{datastore["BaseFileName"]}-file.txt"
|
remote = "#{datastore["BaseFileName"]}-file#{entropy_value}.txt"
|
||||||
|
vprint_status("Remote File Name: #{remote}")
|
||||||
local = __FILE__
|
local = __FILE__
|
||||||
vprint_status("uploading")
|
vprint_status("uploading")
|
||||||
session.fs.file.upload_file(remote, local)
|
session.fs.file.upload_file(remote, local)
|
||||||
|
|
Loading…
Reference in New Issue