-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a
URI::HTTP#vulns/has_vulns?
core-ext methods
- Loading branch information
1 parent
35b01f2
commit 68deebd
Showing
6 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
# | ||
# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com) | ||
# | ||
# ronin-support is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# ronin-support is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with ronin-support. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
require_relative "core_ext/uri" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
# | ||
# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com) | ||
# | ||
# ronin-support is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# ronin-support is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with ronin-support. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
require_relative "uri/http" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# frozen_string_literal: true | ||
# | ||
# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com) | ||
# | ||
# ronin-support is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# ronin-support is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with ronin-support. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
require_relative "../../../vulns/url_scanner" | ||
|
||
module URI | ||
# | ||
# Provides helper methods for HTTP | ||
# | ||
# ## Core-Ext Methods | ||
# | ||
# * { URI::HTTP#vulns } | ||
# * { URI::HTTP#has_vulns? } | ||
# | ||
# @api public | ||
# | ||
class HTTP | ||
|
||
# | ||
# Return all vulnerabilities found for URI | ||
# | ||
# @param [Hash{Symbol => Object}] kwargs | ||
# Additional keyword arguments for | ||
# {Ronin::Vulns::URLScanner.scan}. | ||
# | ||
# @return [Array<LFI, RFI, SQLI, SSTI, ReflectedXSS, OpenRedirect>] | ||
# All discovered Web vulnerabilities | ||
# | ||
# @example | ||
# URI('https://testphp.vulnweb.com/').vulns | ||
# # => [#<Ronin::Vulns::RFI: ...>, ...] | ||
# | ||
# @see Ronin::Vulns::URLScanner.scan | ||
# | ||
def vulns(**kwargs) | ||
Ronin::Vulns::URLScanner.scan(self, **kwargs) | ||
end | ||
|
||
# | ||
# Checks if the URI contains any vulnerabilities | ||
# | ||
# @param [Hash{Symbol => Object}] kwargs | ||
# Additional keyword arguments for | ||
# {Ronin::Vulns::URLScanner.test}. | ||
# | ||
# @return [Boolean] | ||
# | ||
# @example | ||
# URI('https://testphp.vulnweb.com/').has_vulns? | ||
# # => true | ||
# | ||
# @see Ronin::Vulns::URLScanner.test | ||
# | ||
def has_vulns?(**kwargs) | ||
Ronin::Vulns::URLScanner.test(self, **kwargs) != nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require 'spec_helper' | ||
require 'ronin/vulns/core_ext/uri/http' | ||
|
||
describe URI::HTTP do | ||
let(:url) { 'https://example.com/' } | ||
|
||
subject { URI(url) } | ||
|
||
let(:web_vuln1) { Ronin::Vulns::LFI.new(url) } | ||
let(:web_vuln2) { Ronin::Vulns::SQLI.new(url) } | ||
|
||
describe "#vulns" do | ||
context "when URI contains vulnerabilities" do | ||
it "must return array with vulnerabilities" do | ||
expect(Ronin::Vulns::URLScanner).to receive(:scan).and_return([web_vuln1, web_vuln2]) | ||
|
||
expect(subject.vulns).to match_array([web_vuln1, web_vuln2]) | ||
end | ||
end | ||
|
||
context "when URI does not contain any vulnerabilities" do | ||
it "must return an empty array" do | ||
expect(Ronin::Vulns::URLScanner).to receive(:scan).and_return([]) | ||
|
||
expect(subject.vulns).to be_empty | ||
end | ||
end | ||
end | ||
|
||
describe "#has_vulns?" do | ||
context "when URI contains vulnerabilities" do | ||
it "must return true" do | ||
expect(Ronin::Vulns::URLScanner).to receive(:test).and_return(web_vuln1) | ||
|
||
expect(subject.has_vulns?).to be(true) | ||
end | ||
end | ||
|
||
context "when URI does not contain any vulnerabilities" do | ||
it "must return false" do | ||
expect(Ronin::Vulns::URLScanner).to receive(:test).and_return(nil) | ||
|
||
expect(subject.has_vulns?).to be(false) | ||
end | ||
end | ||
end | ||
end |