Compare commits

...

2 Commits

Author SHA1 Message Date
Carlos Polop
7e9c9b4e5b Merge pull request #353 from wangwillian0/master
Fix script download for the Metasploit module
2023-04-25 16:19:03 +02:00
Willian Wang
3e213bd8fd Handle 302 redirects of GitHub release URLs 2023-04-22 14:16:46 -03:00

View File

@@ -220,6 +220,20 @@ class MetasploitModule < Msf::Post
print_good("PEASS script sent")
end
def fetch(uri_str, limit = 10)
raise 'Invalid URL, too many HTTP redirects' if limit == 0
response = Net::HTTP.get_response(URI(uri_str))
case response
when Net::HTTPSuccess then
response
when Net::HTTPRedirection then
location = response['location']
fetch(location, limit - 1)
else
response.value
end
end
def load_peass
# Load the PEASS script from a local file or from Internet
peass_script = ""
@@ -230,7 +244,7 @@ class MetasploitModule < Msf::Post
raise 'Invalid URL' unless target.scheme =~ /https?/
raise 'Invalid URL' if target.host.to_s.eql? ''
res = Net::HTTP.get_response(target)
res = fetch(target)
peass_script = res.body
raise "Something failed downloading PEASS script from #{url_peass}" if peass_script.length < 500