Skip to content

Commit df80d56

Browse files
author
Tod Beardsley
committed
Land rapid7#4898, prefer URI to open-uri
2 parents 6c71ae7 + d729595 commit df80d56

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

data/exploits/capture/http/forms/extractforms.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
require 'rubygems' # install rubygems
1313
require 'hpricot' # gem install hpricot
14-
require 'open-uri'
1514
require 'timeout'
1615

1716
def usage

data/exploits/capture/http/forms/grabforms.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
require 'rubygems' # install rubygems
1313
require 'hpricot' # gem install hpricot
14-
require 'open-uri'
14+
require 'uri'
1515
require 'timeout'
1616

1717
def usage
@@ -26,17 +26,17 @@ def usage
2626
site.strip!
2727
next if site.length == 0
2828
next if site =~ /^#/
29-
29+
3030
out = File.join(output, site + ".txt")
3131
File.unlink(out) if File.exists?(out)
32-
32+
3333
fd = File.open(out, "a")
34-
34+
3535

3636
["", "www."].each do |prefix|
3737
begin
38-
Timeout.timeout(10) do
39-
doc = Hpricot(open("http://#{prefix}#{site}/"))
38+
Timeout.timeout(10) do
39+
doc = Hpricot(URI.parse("http://#{prefix}#{site}/").open)
4040
doc.search("//form").each do |form|
4141

4242
# Extract the form
@@ -78,9 +78,9 @@ def usage
7878
$stderr.puts "#{prefix}#{site} #{e.class} #{e}"
7979
end
8080
end
81-
81+
8282
fd.close
83-
83+
8484
File.unlink(out) if (File.size(out) == 0)
8585

8686
end

modules/auxiliary/gather/apple_safari_webarchive_uxss.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
##
55

66
require 'msf/core'
7-
require 'open-uri'
7+
require 'uri'
88

99
class Metasploit3 < Msf::Auxiliary
1010

@@ -732,7 +732,7 @@ def all_script_urls(pages)
732732
results = []
733733
print_status "Fetching URL #{url}..."
734734
# fetch and parse the HTML document
735-
doc = Nokogiri::HTML(open(url))
735+
doc = Nokogiri::HTML(URI.parse(url).open)
736736
# recursively add scripts from iframes
737737
doc.css('iframe').each do |iframe|
738738
print_status "Checking iframe..."
@@ -771,7 +771,7 @@ def find_cached_scripts
771771
if url.to_s.starts_with? '//'
772772
url = "#{page_uri.scheme}:#{url}"
773773
end
774-
io = open(url)
774+
io = URI.parse(url).open
775775
rescue URI::InvalidURIError, OpenURI::HTTPError
776776
next
777777
end

modules/auxiliary/gather/flash_rosetta_jsonp_url_disclosure.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
##
55

66
require 'msf/core'
7-
require 'open-uri'
87
require 'uri'
98

109
class Metasploit3 < Msf::Auxiliary
@@ -66,7 +65,7 @@ def run
6665

6766
def check
6867
test_string = Rex::Text.rand_text_alphanumeric(encoded_swf.length)
69-
io = open(exploit_url(test_string))
68+
io = URI.parse(exploit_url(test_string)).open
7069
if io.read.start_with? test_string
7170
Msf::Exploit::CheckCode::Vulnerable
7271
else

0 commit comments

Comments
 (0)