ronin-web 0.3.0.pre2 → 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- 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 -67
- data/Gemfile +42 -37
- data/README.md +159 -144
- data/Rakefile +16 -7
- data/bin/ronin-web +10 -18
- 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 +32 -17
- 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 +44 -0
- data/lib/ronin/web/html.rb +85 -0
- data/lib/ronin/web/mechanize.rb +79 -0
- 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 +57 -11
- 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 +237 -217
- data/.gemtest +0 -0
- data/lib/ronin/network/mixins/web.rb +0 -256
- 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 -115
- data/lib/ronin/web/web.rb +0 -573
- data/spec/helpers/output.rb +0 -3
- data/spec/web/extensions/nokogiri_spec.rb +0 -38
- data/spec/web/helpers/rack_app.rb +0 -31
- 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/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/web_spec.rb +0 -157
@@ -1,256 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin Web - A Ruby library for Ronin that provides support for web
|
3
|
-
# scraping and spidering functionality.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
-
#
|
7
|
-
# This file is part of Ronin Web.
|
8
|
-
#
|
9
|
-
# Ronin is free software: you can redistribute it and/or modify
|
10
|
-
# it under the terms of the GNU General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# Ronin is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU General Public License
|
20
|
-
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
21
|
-
#
|
22
|
-
|
23
|
-
require 'ronin/ui/output/helpers'
|
24
|
-
require 'ronin/network/http/proxy'
|
25
|
-
require 'ronin/web/web'
|
26
|
-
require 'ronin/mixin'
|
27
|
-
|
28
|
-
require 'parameters'
|
29
|
-
|
30
|
-
module Ronin
|
31
|
-
module Network
|
32
|
-
module Mixins
|
33
|
-
module Web
|
34
|
-
|
35
|
-
mixin UI::Output::Helpers, Parameters
|
36
|
-
|
37
|
-
mixin do
|
38
|
-
# The Web Proxy host to connect to
|
39
|
-
parameter :web_proxy_host, :type => String,
|
40
|
-
:description => 'Web Proxy host'
|
41
|
-
|
42
|
-
# The Web Proxy port to connect to
|
43
|
-
parameter :web_proxy_port, :type => Integer,
|
44
|
-
:description => 'Web Proxy port'
|
45
|
-
|
46
|
-
# The Web Proxy user to authenticate with
|
47
|
-
parameter :web_proxy_user, :type => String,
|
48
|
-
:description => 'Web Proxy authentication user'
|
49
|
-
|
50
|
-
# The Web Proxy password to authenticate with
|
51
|
-
parameter :web_proxy_password, :type => String,
|
52
|
-
:description => 'Web Proxy authentication password'
|
53
|
-
end
|
54
|
-
|
55
|
-
protected
|
56
|
-
|
57
|
-
#
|
58
|
-
# Combines the proxy information set by the `web_proxy_host`,
|
59
|
-
# `web_proxy_port`, `web_proxy_user` and `web_proxy_password`
|
60
|
-
# parameters.
|
61
|
-
#
|
62
|
-
# @return [Network::HTTP::Proxy]
|
63
|
-
# The current proxy information.
|
64
|
-
#
|
65
|
-
# @api semipublic
|
66
|
-
#
|
67
|
-
def web_proxy
|
68
|
-
HTTP::Proxy.new(
|
69
|
-
:host => @web_proxy_host,
|
70
|
-
:port => @web_proxy_port,
|
71
|
-
:user => @web_proxy_user,
|
72
|
-
:password => @web_proxy_password
|
73
|
-
)
|
74
|
-
end
|
75
|
-
|
76
|
-
#
|
77
|
-
# Provides a persistant Mechanize agent.
|
78
|
-
#
|
79
|
-
# @param [Hash] options
|
80
|
-
# Additional options for initializing the agent.
|
81
|
-
#
|
82
|
-
# @option options [Hash] :proxy (web_proxy)
|
83
|
-
# Proxy information.
|
84
|
-
#
|
85
|
-
# @option options [String] :user_agent (web_user_agent)
|
86
|
-
# User-Agent string to use.
|
87
|
-
#
|
88
|
-
# @return [Mechanize]
|
89
|
-
# The agent.
|
90
|
-
#
|
91
|
-
# @api semipublic
|
92
|
-
#
|
93
|
-
def web_agent(options={},&block)
|
94
|
-
unless @web_agent
|
95
|
-
options[:proxy] ||= web_proxy
|
96
|
-
options[:user_agent] ||= @web_user_agent
|
97
|
-
|
98
|
-
@web_agent = Ronin::Web.agent(options,&block)
|
99
|
-
end
|
100
|
-
|
101
|
-
return @web_agent
|
102
|
-
end
|
103
|
-
|
104
|
-
#
|
105
|
-
# Creates a Mechanize Page for the contents at a given URL.
|
106
|
-
#
|
107
|
-
# @param [URI::Generic, String] url
|
108
|
-
# The URL to request.
|
109
|
-
#
|
110
|
-
# @param [Hash] options
|
111
|
-
# Additional options to initialize the agent with.
|
112
|
-
#
|
113
|
-
# @option options [Hash] :proxy (web_proxy)
|
114
|
-
# Proxy information.
|
115
|
-
#
|
116
|
-
# @option options [String] :user_agent (web_user_agent)
|
117
|
-
# User-Agent string to use.
|
118
|
-
#
|
119
|
-
# @yield [page]
|
120
|
-
# If a block is given, it will be passed the page for the
|
121
|
-
# requested URL.
|
122
|
-
#
|
123
|
-
# @yieldparam [Mechanize::Page] page
|
124
|
-
# The requested page.
|
125
|
-
#
|
126
|
-
# @return [Mechanize::Page]
|
127
|
-
# The requested page.
|
128
|
-
#
|
129
|
-
# @api semipublic
|
130
|
-
#
|
131
|
-
def web_get(url,options={})
|
132
|
-
print_info "Requesting #{url}"
|
133
|
-
page = web_agent(options).get(url)
|
134
|
-
|
135
|
-
yield page if block_given?
|
136
|
-
return page
|
137
|
-
end
|
138
|
-
|
139
|
-
#
|
140
|
-
# Requests the body of the Mechanize Page created from the response
|
141
|
-
# of the given URL.
|
142
|
-
#
|
143
|
-
# @param [URI::Generic, String] url
|
144
|
-
# The URL to request.
|
145
|
-
#
|
146
|
-
# @param [Hash] options
|
147
|
-
# Additional options to initialize the agent with.
|
148
|
-
#
|
149
|
-
# @option options [Hash] :proxy (web_proxy)
|
150
|
-
# Proxy information.
|
151
|
-
#
|
152
|
-
# @option options [String] :user_agent (web_user_agent)
|
153
|
-
# User-Agent string to use.
|
154
|
-
#
|
155
|
-
# @yield [body]
|
156
|
-
# If a block is given, it will be passed the body of the page.
|
157
|
-
#
|
158
|
-
# @yieldparam [String] body
|
159
|
-
# The requested body of the page.
|
160
|
-
#
|
161
|
-
# @return [String]
|
162
|
-
# The requested body of the page.
|
163
|
-
#
|
164
|
-
# @api semipublic
|
165
|
-
#
|
166
|
-
def web_get_body(url,options={})
|
167
|
-
page = web_get(url,options)
|
168
|
-
body = page.body
|
169
|
-
|
170
|
-
yield body if block_given?
|
171
|
-
return body
|
172
|
-
end
|
173
|
-
|
174
|
-
#
|
175
|
-
# Posts to a given URL and creates a Mechanize Page from the
|
176
|
-
# response.
|
177
|
-
#
|
178
|
-
# @param [URI::Generic, String] url
|
179
|
-
# The URL to post to.
|
180
|
-
#
|
181
|
-
# @param [Hash] options
|
182
|
-
# Additional options to initialize the agent with.
|
183
|
-
#
|
184
|
-
# @option options [Hash] :query
|
185
|
-
# Additional query parameters to post with.
|
186
|
-
#
|
187
|
-
# @option options [Hash] :proxy (web_proxy)
|
188
|
-
# Proxy information.
|
189
|
-
#
|
190
|
-
# @option options [String] :user_agent (web_user_agent)
|
191
|
-
# User-Agent string to use.
|
192
|
-
#
|
193
|
-
# @yield [page]
|
194
|
-
# If a block is given, it will be passed the page for the
|
195
|
-
# requested URL.
|
196
|
-
#
|
197
|
-
# @yieldparam [Mechanize::Page] page
|
198
|
-
# The requested page.
|
199
|
-
#
|
200
|
-
# @return [Mechanize::Page]
|
201
|
-
# The requested page.
|
202
|
-
#
|
203
|
-
# @api semipublic
|
204
|
-
#
|
205
|
-
def web_post(url,options={})
|
206
|
-
query = {}
|
207
|
-
query.merge!(options[:query]) if options[:query]
|
208
|
-
|
209
|
-
print_info "Posting #{url}"
|
210
|
-
page = web_agent(options).post(url)
|
211
|
-
|
212
|
-
yield page if block_given?
|
213
|
-
return page
|
214
|
-
end
|
215
|
-
|
216
|
-
#
|
217
|
-
# Posts to a given URL and returns the body of the Mechanize Page
|
218
|
-
# created from the response.
|
219
|
-
#
|
220
|
-
# @param [URI::Generic, String] url
|
221
|
-
# The URL to post to.
|
222
|
-
#
|
223
|
-
# @param [Hash] options
|
224
|
-
# Additional options to initialize the agent with.
|
225
|
-
#
|
226
|
-
# @option options [Hash] :query
|
227
|
-
# Additional query parameters to post with.
|
228
|
-
#
|
229
|
-
# @option options [Hash] :proxy (web_proxy)
|
230
|
-
# Proxy information.
|
231
|
-
#
|
232
|
-
# @option options [String] :user_agent (web_user_agent)
|
233
|
-
# User-Agent string to use.
|
234
|
-
#
|
235
|
-
# @yield [body]
|
236
|
-
# If a block is given, it will be passed the body of the page.
|
237
|
-
#
|
238
|
-
# @yieldparam [Mechanize::Page] page
|
239
|
-
# The body of the requested page.
|
240
|
-
#
|
241
|
-
# @return [String]
|
242
|
-
# The requested body of the page.
|
243
|
-
#
|
244
|
-
# @api semipublic
|
245
|
-
#
|
246
|
-
def web_post_body(url,options={})
|
247
|
-
page = web_post(url,options)
|
248
|
-
body = page.body
|
249
|
-
|
250
|
-
yield body if block_given?
|
251
|
-
return body
|
252
|
-
end
|
253
|
-
end
|
254
|
-
end
|
255
|
-
end
|
256
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin Web - A Ruby library for Ronin that provides support for web
|
3
|
-
# scraping and spidering functionality.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
-
#
|
7
|
-
# This file is part of Ronin Web.
|
8
|
-
#
|
9
|
-
# Ronin is free software: you can redistribute it and/or modify
|
10
|
-
# it under the terms of the GNU General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# Ronin is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU General Public License
|
20
|
-
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
21
|
-
#
|
22
|
-
|
23
|
-
require 'nokogiri'
|
24
|
-
|
25
|
-
module Nokogiri
|
26
|
-
module XML
|
27
|
-
class Attr < Node
|
28
|
-
|
29
|
-
#
|
30
|
-
# Determines if the attribute is similar to another attribute.
|
31
|
-
#
|
32
|
-
# @param [Nokogiri::XML::Attr] other
|
33
|
-
# The other attribute.
|
34
|
-
#
|
35
|
-
# @return [Boolean]
|
36
|
-
# Specifies if the attribute is similar, in indentity or value,
|
37
|
-
# to the other attribute.
|
38
|
-
#
|
39
|
-
# @api public
|
40
|
-
#
|
41
|
-
def ==(other)
|
42
|
-
super(other) && (self.value == other.value)
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin Web - A Ruby library for Ronin that provides support for web
|
3
|
-
# scraping and spidering functionality.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
-
#
|
7
|
-
# This file is part of Ronin Web.
|
8
|
-
#
|
9
|
-
# Ronin is free software: you can redistribute it and/or modify
|
10
|
-
# it under the terms of the GNU General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# Ronin is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU General Public License
|
20
|
-
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
21
|
-
#
|
22
|
-
|
23
|
-
require 'nokogiri'
|
24
|
-
|
25
|
-
module Nokogiri
|
26
|
-
module XML
|
27
|
-
class Document < Node
|
28
|
-
|
29
|
-
#
|
30
|
-
# Calculates the sum of all sub-children of the document.
|
31
|
-
#
|
32
|
-
# @return [Integer]
|
33
|
-
# The total number of children and sub-children of the document.
|
34
|
-
# Returns `0` if the document has no root element.
|
35
|
-
#
|
36
|
-
# @api public
|
37
|
-
#
|
38
|
-
def total_children
|
39
|
-
if root
|
40
|
-
1 + root.total_children
|
41
|
-
else
|
42
|
-
0
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin Web - A Ruby library for Ronin that provides support for web
|
3
|
-
# scraping and spidering functionality.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
-
#
|
7
|
-
# This file is part of Ronin Web.
|
8
|
-
#
|
9
|
-
# Ronin is free software: you can redistribute it and/or modify
|
10
|
-
# it under the terms of the GNU General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# Ronin is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU General Public License
|
20
|
-
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
21
|
-
#
|
22
|
-
|
23
|
-
require 'nokogiri'
|
24
|
-
|
25
|
-
module Nokogiri
|
26
|
-
module XML
|
27
|
-
class Element < Node
|
28
|
-
|
29
|
-
#
|
30
|
-
# Determines if the element is similar to another element.
|
31
|
-
#
|
32
|
-
# @param [Nokogiri::XML::Element] other
|
33
|
-
# The other element.
|
34
|
-
#
|
35
|
-
# @return [Boolean]
|
36
|
-
# Specifies whether the element is equal, in identity or value, to
|
37
|
-
# another element.
|
38
|
-
#
|
39
|
-
# @api public
|
40
|
-
#
|
41
|
-
def ==(other)
|
42
|
-
return false unless super(other)
|
43
|
-
return false unless attribute_nodes.length == other.attribute_nodes.length
|
44
|
-
|
45
|
-
(0...attribute_nodes.length).each do |index|
|
46
|
-
attr1 = attribute_nodes[index]
|
47
|
-
attr2 = other.attribute_nodes[index]
|
48
|
-
|
49
|
-
return false unless attr1.similar?(attr2)
|
50
|
-
end
|
51
|
-
|
52
|
-
return true
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin Web - A Ruby library for Ronin that provides support for web
|
3
|
-
# scraping and spidering functionality.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
-
#
|
7
|
-
# This file is part of Ronin Web.
|
8
|
-
#
|
9
|
-
# Ronin is free software: you can redistribute it and/or modify
|
10
|
-
# it under the terms of the GNU General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# Ronin is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU General Public License
|
20
|
-
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
21
|
-
#
|
22
|
-
|
23
|
-
require 'nokogiri'
|
24
|
-
|
25
|
-
module Nokogiri
|
26
|
-
module XML
|
27
|
-
class Node
|
28
|
-
|
29
|
-
#
|
30
|
-
# Calculates the sum of all children of the node.
|
31
|
-
#
|
32
|
-
# @return [Integer]
|
33
|
-
# The total number of children of the node.
|
34
|
-
#
|
35
|
-
# @api public
|
36
|
-
#
|
37
|
-
def total_children
|
38
|
-
count = 0
|
39
|
-
|
40
|
-
traverse { |node| count += 1 }
|
41
|
-
|
42
|
-
return count - 1
|
43
|
-
end
|
44
|
-
|
45
|
-
#
|
46
|
-
# Traverses all text nodes which are children of the node.
|
47
|
-
#
|
48
|
-
# @yield [node]
|
49
|
-
# A block will be passed each text node.
|
50
|
-
#
|
51
|
-
# @yieldparam [Nokogiri::XML::Text] node
|
52
|
-
# A text node.
|
53
|
-
#
|
54
|
-
# @return [Enumerator]
|
55
|
-
# If no block is given, an Enumerator object will be returned.
|
56
|
-
#
|
57
|
-
# @api public
|
58
|
-
#
|
59
|
-
def traverse_text
|
60
|
-
return enum_for(:traverse_text) unless block_given?
|
61
|
-
|
62
|
-
yield self if text?
|
63
|
-
|
64
|
-
traverse do |node|
|
65
|
-
yield node if node.text?
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
#
|
70
|
-
# Determines if the node is similar to another node.
|
71
|
-
#
|
72
|
-
# @return [Boolean]
|
73
|
-
# Specifies whether the node is equal, in identity or value, to
|
74
|
-
# another node.
|
75
|
-
#
|
76
|
-
# @api public
|
77
|
-
#
|
78
|
-
def ==(other)
|
79
|
-
return false unless other
|
80
|
-
|
81
|
-
(self.type == other.type) && (self.name == other.name)
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin Web - A Ruby library for Ronin that provides support for web
|
3
|
-
# scraping and spidering functionality.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
-
#
|
7
|
-
# This file is part of Ronin Web.
|
8
|
-
#
|
9
|
-
# Ronin is free software: you can redistribute it and/or modify
|
10
|
-
# it under the terms of the GNU General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# Ronin is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU General Public License
|
20
|
-
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
21
|
-
#
|
22
|
-
|
23
|
-
require 'nokogiri'
|
24
|
-
|
25
|
-
module Nokogiri
|
26
|
-
module XML
|
27
|
-
class Text < CharacterData
|
28
|
-
|
29
|
-
#
|
30
|
-
# Determines if the text node is similar to another text node.
|
31
|
-
#
|
32
|
-
# @param [Nokogiri::XML::Text] other
|
33
|
-
# The other text node.
|
34
|
-
#
|
35
|
-
# @return [Boolean]
|
36
|
-
# Specifies if the text node is similar, in indentity or value,
|
37
|
-
# to the other text node.
|
38
|
-
#
|
39
|
-
# @api public
|
40
|
-
#
|
41
|
-
def ==(other)
|
42
|
-
super(other) && (self.content == other.content)
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin Web - A Ruby library for Ronin that provides support for web
|
3
|
-
# scraping and spidering functionality.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
-
#
|
7
|
-
# This file is part of Ronin Web.
|
8
|
-
#
|
9
|
-
# Ronin is free software: you can redistribute it and/or modify
|
10
|
-
# it under the terms of the GNU General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# Ronin is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU General Public License
|
20
|
-
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
21
|
-
#
|
22
|
-
|
23
|
-
require 'ronin/web/extensions/nokogiri/xml/node'
|
24
|
-
require 'ronin/web/extensions/nokogiri/xml/text'
|
25
|
-
require 'ronin/web/extensions/nokogiri/xml/attr'
|
26
|
-
require 'ronin/web/extensions/nokogiri/xml/element'
|
27
|
-
require 'ronin/web/extensions/nokogiri/xml/document'
|
@@ -1,23 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin Web - A Ruby library for Ronin that provides support for web
|
3
|
-
# scraping and spidering functionality.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
-
#
|
7
|
-
# This file is part of Ronin Web.
|
8
|
-
#
|
9
|
-
# Ronin is free software: you can redistribute it and/or modify
|
10
|
-
# it under the terms of the GNU General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# Ronin is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU General Public License
|
20
|
-
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
21
|
-
#
|
22
|
-
|
23
|
-
require 'ronin/web/extensions/nokogiri/xml'
|
data/lib/ronin/web/extensions.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin Web - A Ruby library for Ronin that provides support for web
|
3
|
-
# scraping and spidering functionality.
|
4
|
-
#
|
5
|
-
# Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
-
#
|
7
|
-
# This file is part of Ronin Web.
|
8
|
-
#
|
9
|
-
# Ronin is free software: you can redistribute it and/or modify
|
10
|
-
# it under the terms of the GNU General Public License as published by
|
11
|
-
# the Free Software Foundation, either version 3 of the License, or
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
# Ronin is distributed in the hope that it will be useful,
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU General Public License
|
20
|
-
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
21
|
-
#
|
22
|
-
|
23
|
-
require 'ronin/web/extensions/nokogiri'
|