ronin-web 0.3.0.rc1 → 1.0.0.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.editorconfig +11 -0
- data/.github/workflows/ruby.yml +31 -0
- data/.gitignore +13 -0
- data/.mailmap +1 -0
- data/.ruby-version +1 -0
- data/COPYING.txt +3 -3
- data/ChangeLog.md +115 -70
- data/Gemfile +42 -37
- data/README.md +160 -145
- data/Rakefile +12 -3
- data/bin/ronin-web +9 -17
- data/data/new/nokogiri.rb.erb +12 -0
- data/data/new/server.rb.erb +22 -0
- data/data/new/spider.rb.erb +26 -0
- data/data/new/webapp/.gitignore +15 -0
- data/data/new/webapp/.ruby-version.erb +1 -0
- data/data/new/webapp/Dockerfile.erb +11 -0
- data/data/new/webapp/Gemfile +6 -0
- data/data/new/webapp/app.rb.erb +15 -0
- data/data/new/webapp/config.ru +4 -0
- data/data/new/webapp/docker-compose.yml.erb +9 -0
- data/gemspec.yml +38 -16
- data/lib/ronin/web/cli/command.rb +36 -0
- data/lib/ronin/web/cli/commands/diff.rb +106 -0
- data/lib/ronin/web/cli/commands/html.rb +174 -0
- data/lib/ronin/web/cli/commands/irb.rb +56 -0
- data/lib/ronin/web/cli/commands/new/nokogiri.rb +85 -0
- data/lib/ronin/web/cli/commands/new/server.rb +96 -0
- data/lib/ronin/web/cli/commands/new/spider.rb +315 -0
- data/lib/ronin/web/cli/commands/new/webapp.rb +123 -0
- data/lib/ronin/web/cli/commands/new.rb +64 -0
- data/lib/ronin/web/cli/commands/reverse_proxy.rb +215 -0
- data/lib/ronin/web/cli/commands/server.rb +155 -0
- data/lib/ronin/web/cli/commands/spider.rb +822 -0
- data/lib/ronin/web/cli/ruby_shell.rb +50 -0
- data/lib/ronin/web/cli.rb +49 -0
- data/lib/ronin/web/html.rb +85 -0
- data/lib/ronin/web/mechanize.rb +34 -36
- data/lib/ronin/web/root.rb +27 -0
- data/lib/ronin/web/version.rb +7 -10
- data/lib/ronin/web/xml.rb +85 -0
- data/lib/ronin/web.rb +372 -13
- data/man/ronin-web-diff.1 +41 -0
- data/man/ronin-web-diff.1.md +30 -0
- data/man/ronin-web-html.1 +89 -0
- data/man/ronin-web-html.1.md +66 -0
- data/man/ronin-web-irb.1 +31 -0
- data/man/ronin-web-irb.1.md +22 -0
- data/man/ronin-web-new-nokogiri.1 +41 -0
- data/man/ronin-web-new-nokogiri.1.md +30 -0
- data/man/ronin-web-new-server.1 +45 -0
- data/man/ronin-web-new-server.1.md +33 -0
- data/man/ronin-web-new-spider.1 +173 -0
- data/man/ronin-web-new-spider.1.md +129 -0
- data/man/ronin-web-new-webapp.1 +53 -0
- data/man/ronin-web-new-webapp.1.md +39 -0
- data/man/ronin-web-new.1 +59 -0
- data/man/ronin-web-new.1.md +44 -0
- data/man/ronin-web-reverse-proxy.1 +63 -0
- data/man/ronin-web-reverse-proxy.1.md +47 -0
- data/man/ronin-web-server.1 +59 -0
- data/man/ronin-web-server.1.md +43 -0
- data/man/ronin-web-spider.1 +225 -0
- data/man/ronin-web-spider.1.md +168 -0
- data/man/ronin-web.1 +41 -0
- data/man/ronin-web.1.md +30 -0
- data/ronin-web.gemspec +39 -109
- data/spec/cli/ruby_shell_spec.rb +14 -0
- data/spec/html_spec.rb +43 -0
- data/spec/mechanize_spec.rb +72 -0
- data/spec/spec_helper.rb +5 -3
- data/spec/web_spec.rb +97 -0
- data/spec/xml_spec.rb +42 -0
- metadata +236 -224
- data/.gemtest +0 -0
- data/data/ronin/web/user_agents.yml +0 -247
- data/lib/ronin/network/mixins/web.rb +0 -258
- data/lib/ronin/web/config.rb +0 -34
- data/lib/ronin/web/extensions/nokogiri/xml/attr.rb +0 -47
- data/lib/ronin/web/extensions/nokogiri/xml/document.rb +0 -48
- data/lib/ronin/web/extensions/nokogiri/xml/element.rb +0 -57
- data/lib/ronin/web/extensions/nokogiri/xml/node.rb +0 -86
- data/lib/ronin/web/extensions/nokogiri/xml/text.rb +0 -47
- data/lib/ronin/web/extensions/nokogiri/xml.rb +0 -27
- data/lib/ronin/web/extensions/nokogiri.rb +0 -23
- data/lib/ronin/web/extensions.rb +0 -23
- data/lib/ronin/web/middleware/base.rb +0 -144
- data/lib/ronin/web/middleware/directories.rb +0 -179
- data/lib/ronin/web/middleware/files.rb +0 -144
- data/lib/ronin/web/middleware/filters/campaign_filter.rb +0 -77
- data/lib/ronin/web/middleware/filters/ip_filter.rb +0 -73
- data/lib/ronin/web/middleware/filters/path_filter.rb +0 -73
- data/lib/ronin/web/middleware/filters/referer_filter.rb +0 -71
- data/lib/ronin/web/middleware/filters/user_agent_filter.rb +0 -71
- data/lib/ronin/web/middleware/filters/vhost_filter.rb +0 -71
- data/lib/ronin/web/middleware/filters.rb +0 -28
- data/lib/ronin/web/middleware/helpers.rb +0 -145
- data/lib/ronin/web/middleware/proxy.rb +0 -265
- data/lib/ronin/web/middleware/proxy_request.rb +0 -262
- data/lib/ronin/web/middleware/request.rb +0 -79
- data/lib/ronin/web/middleware/response.rb +0 -33
- data/lib/ronin/web/middleware/router.rb +0 -167
- data/lib/ronin/web/middleware/rule.rb +0 -103
- data/lib/ronin/web/middleware.rb +0 -27
- data/lib/ronin/web/proxy/app.rb +0 -32
- data/lib/ronin/web/proxy/base.rb +0 -46
- data/lib/ronin/web/proxy/web.rb +0 -46
- data/lib/ronin/web/proxy.rb +0 -25
- data/lib/ronin/web/server/app.rb +0 -32
- data/lib/ronin/web/server/base.rb +0 -461
- data/lib/ronin/web/server/web.rb +0 -66
- data/lib/ronin/web/server.rb +0 -25
- data/lib/ronin/web/spider.rb +0 -120
- data/lib/ronin/web/user_agents.rb +0 -196
- data/lib/ronin/web/web.rb +0 -560
- data/spec/helpers/output.rb +0 -3
- data/spec/web/extensions/nokogiri_spec.rb +0 -38
- data/spec/web/helpers/rack_app.rb +0 -24
- data/spec/web/helpers/root/test1/index.html +0 -1
- data/spec/web/helpers/root/test1/test1.txt +0 -1
- data/spec/web/helpers/root/test1.txt +0 -1
- data/spec/web/helpers/root/test2/test2.txt +0 -1
- data/spec/web/helpers/root/test2.txt +0 -1
- data/spec/web/helpers/root/test3/test3.txt +0 -1
- data/spec/web/helpers/root/test3.txt +0 -1
- data/spec/web/helpers/root.rb +0 -15
- data/spec/web/mechanize_spec.rb +0 -62
- data/spec/web/middleware/directories_spec.rb +0 -86
- data/spec/web/middleware/files_spec.rb +0 -57
- data/spec/web/middleware/filters/campaign_filter_spec.rb +0 -30
- data/spec/web/middleware/filters/ip_filter_spec.rb +0 -25
- data/spec/web/middleware/filters/path_filter_spec.rb +0 -29
- data/spec/web/middleware/filters/referer_filter_spec.rb +0 -25
- data/spec/web/middleware/filters/user_agent_filter_spec.rb +0 -25
- data/spec/web/middleware/filters/vhost_filter_spec.rb +0 -23
- data/spec/web/middleware/proxy_spec.rb +0 -67
- data/spec/web/middleware/response_spec.rb +0 -20
- data/spec/web/middleware/router_spec.rb +0 -65
- data/spec/web/middleware/rule_spec.rb +0 -37
- data/spec/web/proxy/base_spec.rb +0 -8
- data/spec/web/server/base_spec.rb +0 -77
- data/spec/web/server/classes/public1/static1.txt +0 -1
- data/spec/web/server/classes/public2/static2.txt +0 -1
- data/spec/web/server/classes/sub_app.rb +0 -13
- data/spec/web/server/classes/test_app.rb +0 -20
- data/spec/web/user_agents_spec.rb +0 -56
- data/spec/web/web_spec.rb +0 -101
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#
|
|
2
|
+
# ronin-web - A collection of useful web helper methods and commands.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
5
|
+
#
|
|
6
|
+
# ronin-web is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# ronin-web is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with ronin-web. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
require 'ronin/core/cli/ruby_shell'
|
|
21
|
+
|
|
22
|
+
module Ronin
|
|
23
|
+
module Web
|
|
24
|
+
class CLI
|
|
25
|
+
#
|
|
26
|
+
# The interactive Ruby shell for {Ronin::Web}.
|
|
27
|
+
#
|
|
28
|
+
class RubyShell < Core::CLI::RubyShell
|
|
29
|
+
|
|
30
|
+
#
|
|
31
|
+
# Initializes the `ronin-web` Ruby shell.
|
|
32
|
+
#
|
|
33
|
+
# @param [String] name
|
|
34
|
+
# The name of the IRB shell.
|
|
35
|
+
#
|
|
36
|
+
# @param [Object] context
|
|
37
|
+
# Custom context to launch IRB from within.
|
|
38
|
+
#
|
|
39
|
+
# @param [Hash{Symbol => Object}] kwargs
|
|
40
|
+
# Additional keyword arguments for
|
|
41
|
+
# `Ronin::Core::CLI::RubyShell#initialize`.
|
|
42
|
+
#
|
|
43
|
+
def initialize(name: 'ronin-web', context: Web, **kwargs)
|
|
44
|
+
super(name: name, context: context, **kwargs)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#
|
|
2
|
+
# ronin-web - A collection of useful web helper methods and commands.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
5
|
+
#
|
|
6
|
+
# ronin-web is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# ronin-web is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with ronin-web. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
require 'ronin/web/version'
|
|
21
|
+
|
|
22
|
+
require 'command_kit/commands'
|
|
23
|
+
require 'command_kit/commands/auto_load'
|
|
24
|
+
require 'command_kit/options/version'
|
|
25
|
+
|
|
26
|
+
module Ronin
|
|
27
|
+
module Web
|
|
28
|
+
#
|
|
29
|
+
# The `ronin-web` command-line interface (CLI).
|
|
30
|
+
#
|
|
31
|
+
# @api private
|
|
32
|
+
#
|
|
33
|
+
# @since 1.0.0
|
|
34
|
+
#
|
|
35
|
+
class CLI
|
|
36
|
+
|
|
37
|
+
include CommandKit::Commands
|
|
38
|
+
include CommandKit::Commands::AutoLoad.new(
|
|
39
|
+
dir: "#{__dir__}/cli/commands",
|
|
40
|
+
namespace: "#{self}::Commands"
|
|
41
|
+
)
|
|
42
|
+
include CommandKit::Options::Version
|
|
43
|
+
|
|
44
|
+
command_name 'ronin-web'
|
|
45
|
+
version Ronin::Web::VERSION
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#
|
|
2
|
+
# ronin-web - A collection of useful web helper methods and commands.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
5
|
+
#
|
|
6
|
+
# ronin-web is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# ronin-web is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with ronin-web. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
require 'nokogiri'
|
|
21
|
+
|
|
22
|
+
module Ronin
|
|
23
|
+
module Web
|
|
24
|
+
#
|
|
25
|
+
# HTML helper methods.
|
|
26
|
+
#
|
|
27
|
+
# @since 1.0.0
|
|
28
|
+
#
|
|
29
|
+
module HTML
|
|
30
|
+
#
|
|
31
|
+
# Parses the body of a document into a HTML document object.
|
|
32
|
+
#
|
|
33
|
+
# @param [String, IO] html
|
|
34
|
+
# The HTML to parse.
|
|
35
|
+
#
|
|
36
|
+
# @yield [doc]
|
|
37
|
+
# If a block is given, it will be passed the newly created document
|
|
38
|
+
# object.
|
|
39
|
+
#
|
|
40
|
+
# @yieldparam [Nokogiri::HTML::Document] doc
|
|
41
|
+
# The new HTML document object.
|
|
42
|
+
#
|
|
43
|
+
# @return [Nokogiri::HTML::Document]
|
|
44
|
+
# The new HTML document object.
|
|
45
|
+
#
|
|
46
|
+
# @see http://rubydoc.info/gems/nokogiri/Nokogiri/HTML/Document
|
|
47
|
+
#
|
|
48
|
+
# @api public
|
|
49
|
+
#
|
|
50
|
+
def self.parse(html)
|
|
51
|
+
doc = Nokogiri::HTML.parse(html)
|
|
52
|
+
yield doc if block_given?
|
|
53
|
+
return doc
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
#
|
|
57
|
+
# Creates a new `Nokogiri::HTML::Builder`.
|
|
58
|
+
#
|
|
59
|
+
# @yield []
|
|
60
|
+
# The block that will be used to construct the HTML document.
|
|
61
|
+
#
|
|
62
|
+
# @return [Nokogiri::HTML::Builder]
|
|
63
|
+
# The new HTML builder object.
|
|
64
|
+
#
|
|
65
|
+
# @example
|
|
66
|
+
# HTML.build do
|
|
67
|
+
# html {
|
|
68
|
+
# body {
|
|
69
|
+
# div(style: 'display:none;') {
|
|
70
|
+
# object(classid: 'blabla')
|
|
71
|
+
# }
|
|
72
|
+
# }
|
|
73
|
+
# }
|
|
74
|
+
# end
|
|
75
|
+
#
|
|
76
|
+
# @see http://rubydoc.info/gems/nokogiri/Nokogiri/HTML/Builder
|
|
77
|
+
#
|
|
78
|
+
# @api public
|
|
79
|
+
#
|
|
80
|
+
def self.build(&block)
|
|
81
|
+
Nokogiri::HTML::Builder.new(&block)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
data/lib/ronin/web/mechanize.rb
CHANGED
|
@@ -1,49 +1,50 @@
|
|
|
1
1
|
#
|
|
2
|
-
#
|
|
3
|
-
# scraping and spidering functionality.
|
|
2
|
+
# ronin-web - A collection of useful web helper methods and commands.
|
|
4
3
|
#
|
|
5
|
-
# Copyright (c) 2006-
|
|
4
|
+
# Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
5
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
# Ronin is free software: you can redistribute it and/or modify
|
|
6
|
+
# ronin-web is free software: you can redistribute it and/or modify
|
|
10
7
|
# it under the terms of the GNU General Public License as published by
|
|
11
8
|
# the Free Software Foundation, either version 3 of the License, or
|
|
12
9
|
# (at your option) any later version.
|
|
13
10
|
#
|
|
14
|
-
#
|
|
11
|
+
# ronin-web is distributed in the hope that it will be useful,
|
|
15
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
14
|
# GNU General Public License for more details.
|
|
18
15
|
#
|
|
19
16
|
# You should have received a copy of the GNU General Public License
|
|
20
|
-
# along with
|
|
17
|
+
# along with ronin-web. If not, see <https://www.gnu.org/licenses/>.
|
|
21
18
|
#
|
|
22
19
|
|
|
23
|
-
require 'ronin/
|
|
24
|
-
require 'ronin/network/http/proxy'
|
|
20
|
+
require 'ronin/support/network/http'
|
|
25
21
|
|
|
26
22
|
require 'mechanize'
|
|
27
23
|
|
|
28
24
|
module Ronin
|
|
29
25
|
module Web
|
|
26
|
+
#
|
|
27
|
+
# Convenience class based on Mechanize.
|
|
28
|
+
#
|
|
29
|
+
# @see http://rubydoc.info/gems/mechanize/Mechanize
|
|
30
|
+
#
|
|
30
31
|
class Mechanize < ::Mechanize
|
|
31
32
|
|
|
32
33
|
#
|
|
33
34
|
# Creates a new [Mechanize](http://mechanize.rubyforge.org/) Agent.
|
|
34
35
|
#
|
|
35
|
-
# @param [Hash]
|
|
36
|
-
# Additional options.
|
|
37
|
-
#
|
|
38
|
-
# @option options [String] :user_agent
|
|
39
|
-
# The User-Agent string to use.
|
|
40
|
-
#
|
|
41
|
-
# @option options [String] :user_agent_alias
|
|
42
|
-
# The User-Agent Alias to use.
|
|
43
|
-
#
|
|
44
|
-
# @option options [Network::HTTP::Proxy, Hash, String] :proxy (Web.proxy)
|
|
36
|
+
# @param [Network::HTTP::Proxy, Hash, String] proxy
|
|
45
37
|
# Proxy information.
|
|
46
38
|
#
|
|
39
|
+
# @param [String, :random, :chrome, :chrome_linux, :chrome_macos,
|
|
40
|
+
# :chrome_windows, :chrome_iphone, :chrome_ipad,
|
|
41
|
+
# :chrome_android, :firefox, :firefox_linux, :firefox_macos,
|
|
42
|
+
# :firefox_windows, :firefox_iphone, :firefox_ipad,
|
|
43
|
+
# :firefox_android, :safari, :safari_macos, :safari_iphone,
|
|
44
|
+
# :safari_ipad, :edge, :linux, :macos, :windows, :iphone,
|
|
45
|
+
# :ipad, :android, nil] user_agent
|
|
46
|
+
# The `User-Agent` string to use.
|
|
47
|
+
#
|
|
47
48
|
# @yield [agent]
|
|
48
49
|
# If a block is given, it will be passed the newly created Mechanize
|
|
49
50
|
# agent.
|
|
@@ -51,26 +52,23 @@ module Ronin
|
|
|
51
52
|
# @yieldparam [Mechanize] agent
|
|
52
53
|
# The new Mechanize agent.
|
|
53
54
|
#
|
|
54
|
-
def initialize(
|
|
55
|
+
def initialize(proxy: Support::Network::HTTP.proxy,
|
|
56
|
+
user_agent: Support::Network::HTTP.user_agent)
|
|
55
57
|
super()
|
|
56
58
|
|
|
57
|
-
if
|
|
58
|
-
|
|
59
|
-
elsif options[:user_agent]
|
|
60
|
-
self.user_agent = options[:user_agent]
|
|
61
|
-
elsif Web.user_agent
|
|
62
|
-
self.user_agent = Web.user_agent
|
|
63
|
-
end
|
|
59
|
+
if proxy
|
|
60
|
+
proxy = URI(proxy)
|
|
64
61
|
|
|
65
|
-
|
|
62
|
+
set_proxy(proxy.host,proxy.port,proxy.user,proxy.password)
|
|
63
|
+
end
|
|
66
64
|
|
|
67
|
-
if
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
if user_agent
|
|
66
|
+
self.user_agent = case user_agent
|
|
67
|
+
when Symbol
|
|
68
|
+
Support::Network::HTTP::UserAgents[user_agent]
|
|
69
|
+
else
|
|
70
|
+
user_agent
|
|
71
|
+
end
|
|
74
72
|
end
|
|
75
73
|
|
|
76
74
|
yield self if block_given?
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#
|
|
2
|
+
# ronin-web - A collection of useful web helper methods and commands.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
5
|
+
#
|
|
6
|
+
# ronin-web is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# ronin-web is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with ronin-web. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
module Ronin
|
|
21
|
+
module Web
|
|
22
|
+
# Path to `ronin-web` root directory.
|
|
23
|
+
#
|
|
24
|
+
# @api private
|
|
25
|
+
ROOT = File.expand_path(File.join(__dir__,'..','..','..'))
|
|
26
|
+
end
|
|
27
|
+
end
|
data/lib/ronin/web/version.rb
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
#
|
|
2
|
-
#
|
|
3
|
-
# scraping and spidering functionality.
|
|
2
|
+
# ronin-web - A collection of useful web helper methods and commands.
|
|
4
3
|
#
|
|
5
|
-
# Copyright (c) 2006-
|
|
4
|
+
# Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
5
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
# Ronin is free software: you can redistribute it and/or modify
|
|
6
|
+
# ronin-web is free software: you can redistribute it and/or modify
|
|
10
7
|
# it under the terms of the GNU General Public License as published by
|
|
11
8
|
# the Free Software Foundation, either version 3 of the License, or
|
|
12
9
|
# (at your option) any later version.
|
|
13
10
|
#
|
|
14
|
-
#
|
|
11
|
+
# ronin-web is distributed in the hope that it will be useful,
|
|
15
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
14
|
# GNU General Public License for more details.
|
|
18
15
|
#
|
|
19
16
|
# You should have received a copy of the GNU General Public License
|
|
20
|
-
# along with
|
|
17
|
+
# along with ronin-web. If not, see <https://www.gnu.org/licenses/>.
|
|
21
18
|
#
|
|
22
19
|
|
|
23
20
|
module Ronin
|
|
24
21
|
module Web
|
|
25
|
-
#
|
|
26
|
-
VERSION = '0.
|
|
22
|
+
# ronin-web Version
|
|
23
|
+
VERSION = '1.0.0.beta2'
|
|
27
24
|
end
|
|
28
25
|
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#
|
|
2
|
+
# ronin-web - A collection of useful web helper methods and commands.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
5
|
+
#
|
|
6
|
+
# ronin-web is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# ronin-web is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with ronin-web. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
require 'nokogiri'
|
|
21
|
+
|
|
22
|
+
module Ronin
|
|
23
|
+
module Web
|
|
24
|
+
#
|
|
25
|
+
# XML helper methods.
|
|
26
|
+
#
|
|
27
|
+
# @since 1.0.0
|
|
28
|
+
#
|
|
29
|
+
module XML
|
|
30
|
+
#
|
|
31
|
+
# Parses the body of a document into a HTML document object.
|
|
32
|
+
#
|
|
33
|
+
# @param [String, IO] xml
|
|
34
|
+
# The XML to parse.
|
|
35
|
+
#
|
|
36
|
+
# @yield [doc]
|
|
37
|
+
# If a block is given, it will be passed the newly created document
|
|
38
|
+
# object.
|
|
39
|
+
#
|
|
40
|
+
# @yieldparam [Nokogiri::XML::Document] doc
|
|
41
|
+
# The new XML document object.
|
|
42
|
+
#
|
|
43
|
+
# @return [Nokogiri::XML::Document]
|
|
44
|
+
# The new HTML document object.
|
|
45
|
+
#
|
|
46
|
+
# @see http://rubydoc.info/gems/nokogiri/Nokogiri/XML/Document
|
|
47
|
+
#
|
|
48
|
+
# @api public
|
|
49
|
+
#
|
|
50
|
+
def self.parse(xml)
|
|
51
|
+
doc = Nokogiri::XML.parse(xml)
|
|
52
|
+
yield doc if block_given?
|
|
53
|
+
return doc
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
#
|
|
57
|
+
# Creates a new `Nokogiri::XML::Builder`.
|
|
58
|
+
#
|
|
59
|
+
# @yield []
|
|
60
|
+
# The block that will be used to construct the XML document.
|
|
61
|
+
#
|
|
62
|
+
# @return [Nokogiri::XML::Builder]
|
|
63
|
+
# The new XML builder object.
|
|
64
|
+
#
|
|
65
|
+
# @example
|
|
66
|
+
# HTML.build do
|
|
67
|
+
# html {
|
|
68
|
+
# body {
|
|
69
|
+
# div(style: 'display:none;') {
|
|
70
|
+
# object(classid: 'blabla')
|
|
71
|
+
# }
|
|
72
|
+
# }
|
|
73
|
+
# }
|
|
74
|
+
# end
|
|
75
|
+
#
|
|
76
|
+
# @see http://rubydoc.info/gems/nokogiri/Nokogiri/XML/Builder
|
|
77
|
+
#
|
|
78
|
+
# @api public
|
|
79
|
+
#
|
|
80
|
+
def self.build(&block)
|
|
81
|
+
Nokogiri::XML::Builder.new(&block)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|