From 75962f249ee85b749fbc39f6630bd4216bc7ac62 Mon Sep 17 00:00:00 2001 From: rootkit Date: Fri, 25 Aug 2023 10:51:08 +0800 Subject: [PATCH] fix https://github.com/FunnyWolf/Viper/issues/163 --- .../post/multi/manage/upload_and_exec_api.rb | 6 +++--- .../gather/forensics/browser_history_api.rb | 18 +++++++++--------- modules/post/windows/gather/hashdump_api.rb | 3 +-- .../windows/manage/execute_pe_in_memory_api.rb | 2 +- .../post/windows/manage/payload_inject_api.rb | 2 +- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/modules/post/multi/manage/upload_and_exec_api.rb b/modules/post/multi/manage/upload_and_exec_api.rb index 13f01645e..5a955b1a0 100644 --- a/modules/post/multi/manage/upload_and_exec_api.rb +++ b/modules/post/multi/manage/upload_and_exec_api.rb @@ -54,7 +54,7 @@ def run tmprpath = rpath unless session.fs.file.exist?(tmprpath) session.fs.file.upload_file(tmprpath, script_path) do |step, src, dst| - print_status_redis("#{step.ljust(11)}: #{src} -> #{dst}") + print_status_redis("#{step.ljust(11)}: #{src.force_encoding("utf-8")} -> #{dst.force_encoding("utf-8")}") end end @@ -81,14 +81,14 @@ def run localpath = File.join(Msf::Config.loot_directory, localfile) begin # Download the remote file to the temporary file - print_status_redis("Downloading #{resultfilepath} to #{localpath}") + print_status_redis("Downloading #{resultfilepath.force_encoding("utf-8")} to #{localpath.force_encoding("utf-8")}") opts = { :block_size => 24 * 1024, :tries => true, :tries_no => 10, } session.fs.file.download_file(localpath, resultfilepath, opts) do |step, src, dst| - print_status_redis("#{step.ljust(11)}: #{src} -> #{dst}") + print_status_redis("#{step.ljust(11)}: #{src.force_encoding("utf-8")} -> #{dst.force_encoding("utf-8")}") end register_file_for_cleanup(resultfilepath) diff --git a/modules/post/windows/gather/forensics/browser_history_api.rb b/modules/post/windows/gather/forensics/browser_history_api.rb index cd499fb09..b1540e0c5 100644 --- a/modules/post/windows/gather/forensics/browser_history_api.rb +++ b/modules/post/windows/gather/forensics/browser_history_api.rb @@ -70,32 +70,32 @@ def check_artifact(profile, opts={}) def download_artifact(profile, opts={}) name = opts[:name] - print_status("Checking for #{name} artifacts...") + print_status("Checking for #{name.force_encoding("utf-8")} artifacts...") if !check_artifact(profile, opts) - print_error("#{name} directory not found for #{profile['UserName']}") + print_error("#{name.force_encoding("utf-8")} directory not found for #{profile['UserName'].force_encoding("utf-8")}") return false end - print_good("#{name} directory found #{profile['UserName']}") + print_good("#{name.force_encoding("utf-8")} directory found #{profile['UserName'].force_encoding("utf-8")}") fname = opts[:fname] dir = opts[:dir] path = opts[:path] - artifact_path = "#{profile[path]}\\#{dir}" - file = session.fs.file.search(artifact_path, "#{fname}", true) + artifact_path = "#{profile[path].force_encoding("utf-8")}\\#{dir.force_encoding("utf-8")}" + file = session.fs.file.search(artifact_path, "#{fname.force_encoding("utf-8")}", true) return false unless file file.each do |db| guid = db['path'].split('\\') # Using store_local for full control of output filename. Forensics software can be picky about the files it's given. - locatfilename = "#{Time.now.to_i.to_s}_#{profile['UserName']}_#{name}_#{guid.last}_#{fname}" + locatfilename = "#{Time.now.to_i.to_s}_#{profile['UserName'].force_encoding("utf-8")}_#{name.force_encoding("utf-8")}_#{guid.last}_#{fname.force_encoding("utf-8")}" localpath = File.join(Msf::Config.loot_directory, locatfilename) - remotepath = "#{db['path']}#{session.fs.file.separator}#{db['name']}" - print_status("Downloading #{remotepath}") + remotepath = "#{db['path'].force_encoding("utf-8")}#{session.fs.file.separator}#{db['name'].force_encoding("utf-8")}" + print_status("Downloading #{remotepath.force_encoding("utf-8")}") client.fs.file.download_file(localpath, remotepath) - print_good("#{name} artifact file saved to #{localpath}") + print_good("#{name.force_encoding("utf-8")} artifact file saved to #{localpath.force_encoding("utf-8")}") @result << {:name => name, :remotepath => remotepath, :localpath => localpath,:locatfilename => locatfilename} end return true diff --git a/modules/post/windows/gather/hashdump_api.rb b/modules/post/windows/gather/hashdump_api.rb index 28f8a350d..55e944a4c 100644 --- a/modules/post/windows/gather/hashdump_api.rb +++ b/modules/post/windows/gather/hashdump_api.rb @@ -79,8 +79,7 @@ def run end end - - print_status("Running module against #{sysinfo['Computer']}") + print_status("Running module against #{sysinfo['Computer'].force_encoding("utf-8")}") data = session.priv.sam_hashes pub_json_result(true, diff --git a/modules/post/windows/manage/execute_pe_in_memory_api.rb b/modules/post/windows/manage/execute_pe_in_memory_api.rb index 092d33d1d..66c9678e1 100644 --- a/modules/post/windows/manage/execute_pe_in_memory_api.rb +++ b/modules/post/windows/manage/execute_pe_in_memory_api.rb @@ -34,7 +34,7 @@ def initialize(info = {}) # Run Method for when run command is issued def run # syinfo is only on meterpreter sessions - print_status("Running module against #{sysinfo['Computer']}") if not sysinfo.nil? + print_status("Running module against #{sysinfo['Computer'].force_encoding("utf-8")}") if not sysinfo.nil? if File.file?(File.join(Msf::Config.loot_directory, datastore['PE'])) pe = File.join(Msf::Config.loot_directory, datastore['PE']) diff --git a/modules/post/windows/manage/payload_inject_api.rb b/modules/post/windows/manage/payload_inject_api.rb index e6c425230..c93546b1e 100644 --- a/modules/post/windows/manage/payload_inject_api.rb +++ b/modules/post/windows/manage/payload_inject_api.rb @@ -37,7 +37,7 @@ def initialize(info = {}) def run # syinfo is only on meterpreter sessions - print_status("Running module against #{sysinfo['Computer']}") if not sysinfo.nil? + print_status("Running module against #{sysinfo['Computer'].force_encoding("utf-8")}") if not sysinfo.nil? if File.file?(File.join(Msf::Config.loot_directory, datastore['SHELLCODE_FILE'])) @shellcode_path = File.join(Msf::Config.loot_directory, datastore['SHELLCODE_FILE'])