diff --git a/test/modules/post/test/meterpreter.rb b/test/modules/post/test/meterpreter.rb index ca69d1013b..df4ca7fa63 100644 --- a/test/modules/post/test/meterpreter.rb +++ b/test/modules/post/test/meterpreter.rb @@ -21,6 +21,7 @@ class MetasploitModule < Msf::Post )) 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"]) ], self.class) end @@ -132,7 +133,12 @@ class MetasploitModule < Msf::Post def test_fs 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 sysinfo = session.sys.config.sysinfo if sysinfo["OS"] =~ /windows/i @@ -167,7 +173,8 @@ class MetasploitModule < Msf::Post end 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 res = create_directory(dir_name) if (res) @@ -180,7 +187,8 @@ class MetasploitModule < Msf::Post end 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 res = create_directory(dir_name) @@ -208,7 +216,8 @@ class MetasploitModule < Msf::Post it "should create and remove files" do 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| fd.write("test") } @@ -228,7 +237,8 @@ class MetasploitModule < Msf::Post it "should upload a file" do res = true - remote = "#{datastore["BaseFileName"]}-file.txt" + remote = "#{datastore["BaseFileName"]}-file#{entropy_value}.txt" + vprint_status("Remote File Name: #{remote}") local = __FILE__ vprint_status("uploading") session.fs.file.upload_file(remote, local) @@ -254,8 +264,10 @@ class MetasploitModule < Msf::Post it "should move files" do res = true - src_name = datastore["BaseFileName"] - dst_name = "#{datastore["BaseFileName"]}-moved" + src_name = "#{datastore["BaseFileName"]}#{entropy_value}" + 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 session.fs.file.rm(src_name) rescue nil @@ -279,8 +291,10 @@ class MetasploitModule < Msf::Post it "should copy files" do res = true - src_name = datastore["BaseFileName"] - dst_name = "#{datastore["BaseFileName"]}-copied" + src_name = "#{datastore["BaseFileName"]}#{entropy_value}" + 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 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 res = true - remote = "#{datastore["BaseFileName"]}-file.txt" + remote = "#{datastore["BaseFileName"]}-file#{entropy_value}.txt" + vprint_status("Remote File Name: #{remote}") local = __FILE__ vprint_status("uploading") session.fs.file.upload_file(remote, local)