Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
FunnyWolf committed Aug 25, 2023
1 parent 3c73fe0 commit 75962f2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
6 changes: 3 additions & 3 deletions modules/post/multi/manage/upload_and_exec_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions modules/post/windows/gather/forensics/browser_history_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions modules/post/windows/gather/hashdump_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion modules/post/windows/manage/execute_pe_in_memory_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
2 changes: 1 addition & 1 deletion modules/post/windows/manage/payload_inject_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down

0 comments on commit 75962f2

Please sign in to comment.