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
data/lib/ronin/web.rb
CHANGED
|
@@ -1,33 +1,392 @@
|
|
|
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/web/
|
|
24
|
-
require 'ronin/web/
|
|
20
|
+
require 'ronin/web/html'
|
|
21
|
+
require 'ronin/web/xml'
|
|
25
22
|
require 'ronin/web/spider'
|
|
26
23
|
require 'ronin/web/server'
|
|
27
|
-
require 'ronin/web/
|
|
24
|
+
require 'ronin/web/user_agents'
|
|
25
|
+
require 'ronin/web/mechanize'
|
|
28
26
|
require 'ronin/web/version'
|
|
29
|
-
require 'ronin/
|
|
27
|
+
require 'ronin/support/network/http'
|
|
28
|
+
|
|
29
|
+
require 'uri'
|
|
30
|
+
require 'open-uri'
|
|
31
|
+
require 'nokogiri'
|
|
32
|
+
require 'nokogiri/ext'
|
|
33
|
+
require 'nokogiri/diff'
|
|
34
|
+
require 'open_namespace'
|
|
30
35
|
|
|
31
36
|
module Ronin
|
|
32
|
-
|
|
37
|
+
module Web
|
|
38
|
+
include OpenNamespace
|
|
39
|
+
|
|
40
|
+
#
|
|
41
|
+
# Parses the body of a document into a HTML document object.
|
|
42
|
+
#
|
|
43
|
+
# @param [String, IO] body
|
|
44
|
+
# The body of the document to parse.
|
|
45
|
+
#
|
|
46
|
+
# @yield [doc]
|
|
47
|
+
# If a block is given, it will be passed the newly created document
|
|
48
|
+
# object.
|
|
49
|
+
#
|
|
50
|
+
# @yieldparam [Nokogiri::HTML::Document] doc
|
|
51
|
+
# The new HTML document object.
|
|
52
|
+
#
|
|
53
|
+
# @return [Nokogiri::HTML::Document]
|
|
54
|
+
# The new HTML document object.
|
|
55
|
+
#
|
|
56
|
+
# @see http://rubydoc.info/gems/nokogiri/Nokogiri/HTML/Document
|
|
57
|
+
#
|
|
58
|
+
# @api public
|
|
59
|
+
#
|
|
60
|
+
def self.html(body,&block)
|
|
61
|
+
HTML.parse(body,&block)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
#
|
|
65
|
+
# Creates a new Nokogiri::HTML::Builder.
|
|
66
|
+
#
|
|
67
|
+
# @yield []
|
|
68
|
+
# The block that will be used to construct the HTML document.
|
|
69
|
+
#
|
|
70
|
+
# @return [Nokogiri::HTML::Builder]
|
|
71
|
+
# The new HTML builder object.
|
|
72
|
+
#
|
|
73
|
+
# @example
|
|
74
|
+
# Web.build_html do
|
|
75
|
+
# html {
|
|
76
|
+
# body {
|
|
77
|
+
# div(style: 'display:none;') {
|
|
78
|
+
# object(classid: 'blabla')
|
|
79
|
+
# }
|
|
80
|
+
# }
|
|
81
|
+
# }
|
|
82
|
+
# end
|
|
83
|
+
#
|
|
84
|
+
# @see http://rubydoc.info/gems/nokogiri/Nokogiri/HTML/Builder
|
|
85
|
+
#
|
|
86
|
+
# @api public
|
|
87
|
+
#
|
|
88
|
+
def self.build_html(&block)
|
|
89
|
+
HTML.build(&block)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
#
|
|
93
|
+
# Parses the body of a document into a XML document object.
|
|
94
|
+
#
|
|
95
|
+
# @param [String, IO] body
|
|
96
|
+
# The body of the document to parse.
|
|
97
|
+
#
|
|
98
|
+
# @yield [doc]
|
|
99
|
+
# If a block is given, it will be passed the newly created document
|
|
100
|
+
# object.
|
|
101
|
+
#
|
|
102
|
+
# @yieldparam [Nokogiri::XML::Document] doc
|
|
103
|
+
# The new XML document object.
|
|
104
|
+
#
|
|
105
|
+
# @return [Nokogiri::XML::Document]
|
|
106
|
+
# The new XML document object.
|
|
107
|
+
#
|
|
108
|
+
# @see http://rubydoc.info/gems/nokogiri/Nokogiri/XML/Document
|
|
109
|
+
#
|
|
110
|
+
# @api public
|
|
111
|
+
#
|
|
112
|
+
def self.xml(body,&block)
|
|
113
|
+
XML.parse(body,&block)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
#
|
|
117
|
+
# Creates a new Nokogiri::XML::Builder.
|
|
118
|
+
#
|
|
119
|
+
# @yield []
|
|
120
|
+
# The block that will be used to construct the XML document.
|
|
121
|
+
#
|
|
122
|
+
# @return [Nokogiri::XML::Builder]
|
|
123
|
+
# The new XML builder object.
|
|
124
|
+
#
|
|
125
|
+
# @example
|
|
126
|
+
# Web.build_xml do
|
|
127
|
+
# post(id: 2) {
|
|
128
|
+
# title { text('some example') }
|
|
129
|
+
# body { text('this is one contrived example.') }
|
|
130
|
+
# }
|
|
131
|
+
# end
|
|
132
|
+
#
|
|
133
|
+
# @see http://rubydoc.info/gems/nokogiri/Nokogiri/XML/Builder
|
|
134
|
+
#
|
|
135
|
+
# @api public
|
|
136
|
+
#
|
|
137
|
+
def self.build_xml(&block)
|
|
138
|
+
XML.build(&block)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
#
|
|
142
|
+
# Opens a URL as a temporary file.
|
|
143
|
+
#
|
|
144
|
+
# @param [String, :random, :chrome, :chrome_linux, :chrome_macos,
|
|
145
|
+
# :chrome_windows, :chrome_iphone, :chrome_ipad,
|
|
146
|
+
# :chrome_android, :firefox, :firefox_linux, :firefox_macos,
|
|
147
|
+
# :firefox_windows, :firefox_iphone, :firefox_ipad,
|
|
148
|
+
# :firefox_android, :safari, :safari_macos, :safari_iphone,
|
|
149
|
+
# :safari_ipad, :edge, :linux, :macos, :windows, :iphone,
|
|
150
|
+
# :ipad, :android, nil] user_agent
|
|
151
|
+
# The `User-Agent` string to use.
|
|
152
|
+
#
|
|
153
|
+
# @param [String, URI::HTTP, nil] proxy
|
|
154
|
+
# The proxy URI to use.
|
|
155
|
+
#
|
|
156
|
+
# @param [String, URI::HTTP, nil] referer
|
|
157
|
+
# The optional `Referer` header to send.
|
|
158
|
+
#
|
|
159
|
+
# @param [String, Ronin::Support::Network::HTTP::Cookie, nil] cookie
|
|
160
|
+
# The optional `Cookie` header to send.
|
|
161
|
+
#
|
|
162
|
+
# @param [Hash{Symbol => Object}] kwargs
|
|
163
|
+
# Additional keyword arguments.
|
|
164
|
+
#
|
|
165
|
+
# @option kwargs [String] :user
|
|
166
|
+
# The HTTP Basic Authentication user name.
|
|
167
|
+
#
|
|
168
|
+
# @option kwargs [String] :password
|
|
169
|
+
# The HTTP Basic Authentication password.
|
|
170
|
+
#
|
|
171
|
+
# @option kwargs [Proc] :content_length_proc
|
|
172
|
+
# A callback which will be passed the content-length of the HTTP
|
|
173
|
+
# response.
|
|
174
|
+
#
|
|
175
|
+
# @option kwargs [Proc] :progress_proc
|
|
176
|
+
# A callback which will be passed the size of each fragment, once
|
|
177
|
+
# received from the server.
|
|
178
|
+
#
|
|
179
|
+
# @return [File]
|
|
180
|
+
# The contents of the URL.
|
|
181
|
+
#
|
|
182
|
+
# @example Open a given URL.
|
|
183
|
+
# Web.open('https://www.example.com/')
|
|
184
|
+
#
|
|
185
|
+
# @example Open a given URL, using a built-in User-Agent:
|
|
186
|
+
# Web.open('https://www.example.com/', user_agent: :linux)
|
|
187
|
+
#
|
|
188
|
+
# @example Open a given URL, using a custom User-Agent string:
|
|
189
|
+
# Web.open('https://www.example.com/', user_agent: '...')
|
|
190
|
+
#
|
|
191
|
+
# @example Open a given URL, using a custom User-Agent string.
|
|
192
|
+
# Web.open('https://www.example.com/', user_agent: 'the future')
|
|
193
|
+
#
|
|
194
|
+
# @see http://rubydoc.info/stdlib/open-uri
|
|
195
|
+
#
|
|
196
|
+
# @api public
|
|
197
|
+
#
|
|
198
|
+
def self.open(url, proxy: Support::Network::HTTP.proxy,
|
|
199
|
+
user_agent: Support::Network::HTTP.user_agent,
|
|
200
|
+
referer: nil,
|
|
201
|
+
cookie: nil,
|
|
202
|
+
**kwargs)
|
|
203
|
+
options = {proxy: proxy, **kwargs}
|
|
204
|
+
|
|
205
|
+
if user_agent
|
|
206
|
+
options['User-Agent'] = case user_agent
|
|
207
|
+
when Symbol
|
|
208
|
+
Support::Network::HTTP::UserAgents[user_agent]
|
|
209
|
+
else
|
|
210
|
+
user_agent
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
options['Referer'] = referer if referer
|
|
215
|
+
options['Cookie'] = cookie if cookie
|
|
216
|
+
|
|
217
|
+
return URI.open(url,options)
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
#
|
|
221
|
+
# A persistent Mechanize Agent.
|
|
222
|
+
#
|
|
223
|
+
# @return [Mechanize]
|
|
224
|
+
# The persistent Mechanize Agent.
|
|
225
|
+
#
|
|
226
|
+
# @see Mechanize
|
|
227
|
+
#
|
|
228
|
+
# @api public
|
|
229
|
+
#
|
|
230
|
+
def self.agent
|
|
231
|
+
@agent ||= Mechanize.new
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
#
|
|
235
|
+
# Creates a Mechanize Page for the contents at a given URL.
|
|
236
|
+
#
|
|
237
|
+
# @param [URI::Generic, String] url
|
|
238
|
+
# The URL to request.
|
|
239
|
+
#
|
|
240
|
+
# @param [Array, Hash] parameters
|
|
241
|
+
# Additional parameters for the GET request.
|
|
242
|
+
#
|
|
243
|
+
# param [Hash] headers
|
|
244
|
+
# Additional headers for the GET request.
|
|
245
|
+
#
|
|
246
|
+
# @yield [page]
|
|
247
|
+
# If a block is given, it will be passed the page for the requested
|
|
248
|
+
# URL.
|
|
249
|
+
#
|
|
250
|
+
# @yieldparam [Mechanize::Page] page
|
|
251
|
+
# The requested page.
|
|
252
|
+
#
|
|
253
|
+
# @return [Mechanize::Page]
|
|
254
|
+
# The requested page.
|
|
255
|
+
#
|
|
256
|
+
# @example
|
|
257
|
+
# Web.get('http://www.rubyinside.com')
|
|
258
|
+
# # => Mechanize::Page
|
|
259
|
+
#
|
|
260
|
+
# @example
|
|
261
|
+
# Web.get('http://www.rubyinside.com') do |page|
|
|
262
|
+
# page.search('div.post/h2/a').each do |title|
|
|
263
|
+
# puts title.inner_text
|
|
264
|
+
# end
|
|
265
|
+
# end
|
|
266
|
+
#
|
|
267
|
+
# @see http://rubydoc.info/gems/mechanize/Mechanize/Page
|
|
268
|
+
#
|
|
269
|
+
# @api public
|
|
270
|
+
#
|
|
271
|
+
def self.get(url,parameters={},headers={},&block)
|
|
272
|
+
agent.get(url,parameters,nil,headers,&block)
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
#
|
|
276
|
+
# Requests the body of the Mechanize Page created from the response
|
|
277
|
+
# of the given URL.
|
|
278
|
+
#
|
|
279
|
+
# @param [URI::Generic, String] url
|
|
280
|
+
# The URL to request.
|
|
281
|
+
#
|
|
282
|
+
# @param [Array, Hash] parameters
|
|
283
|
+
# Additional parameters for the GET request.
|
|
284
|
+
#
|
|
285
|
+
# param [Hash] headers
|
|
286
|
+
# Additional headers for the GET request.
|
|
287
|
+
#
|
|
288
|
+
# @yield [body]
|
|
289
|
+
# If a block is given, it will be passed the body of the page.
|
|
290
|
+
#
|
|
291
|
+
# @yieldparam [String] body
|
|
292
|
+
# The requested body of the page.
|
|
293
|
+
#
|
|
294
|
+
# @return [String]
|
|
295
|
+
# The requested body of the page.
|
|
296
|
+
#
|
|
297
|
+
# @example
|
|
298
|
+
# Web.get_body('http://www.rubyinside.com') # => String
|
|
299
|
+
#
|
|
300
|
+
# @example
|
|
301
|
+
# Web.get_body('http://www.rubyinside.com') do |body|
|
|
302
|
+
# puts body
|
|
303
|
+
# end
|
|
304
|
+
#
|
|
305
|
+
# @see get
|
|
306
|
+
#
|
|
307
|
+
# @api public
|
|
308
|
+
#
|
|
309
|
+
def self.get_body(url,parameters={},headers={})
|
|
310
|
+
body = get(url,parameters,headers).body
|
|
311
|
+
|
|
312
|
+
yield body if block_given?
|
|
313
|
+
return body
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
#
|
|
317
|
+
# Posts to a given URL and creates a Mechanize Page from the response.
|
|
318
|
+
#
|
|
319
|
+
# @param [URI::Generic, String] url
|
|
320
|
+
# The URL to request.
|
|
321
|
+
#
|
|
322
|
+
# @param [Hash] query
|
|
323
|
+
# Additional query parameters for the POST request.
|
|
324
|
+
#
|
|
325
|
+
# @param [Hash] headers
|
|
326
|
+
# Additional headers for the POST request.
|
|
327
|
+
#
|
|
328
|
+
# @yield [page]
|
|
329
|
+
# If a block is given, it will be passed the page for the requested
|
|
330
|
+
# URL.
|
|
331
|
+
#
|
|
332
|
+
# @yieldparam [Mechanize::Page] page
|
|
333
|
+
# The requested page.
|
|
334
|
+
#
|
|
335
|
+
# @return [Mechanize::Page]
|
|
336
|
+
# The requested page.
|
|
337
|
+
#
|
|
338
|
+
# @example
|
|
339
|
+
# Web.post('http://www.rubyinside.com')
|
|
340
|
+
# # => Mechanize::Page
|
|
341
|
+
#
|
|
342
|
+
# @see http://rubydoc.info/gems/mechanize/Mechanize/Page
|
|
343
|
+
#
|
|
344
|
+
# @api public
|
|
345
|
+
#
|
|
346
|
+
def self.post(url,query={},headers={},&block)
|
|
347
|
+
agent.post(url,query,headers={},&block)
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
#
|
|
351
|
+
# Posts to a given URL and returns the body of the Mechanize Page
|
|
352
|
+
# created from the response.
|
|
353
|
+
#
|
|
354
|
+
# @param [URI::Generic, String] url
|
|
355
|
+
# The URL to request.
|
|
356
|
+
#
|
|
357
|
+
# @param [Hash] query
|
|
358
|
+
# Additional query parameters for the POST request.
|
|
359
|
+
#
|
|
360
|
+
# @param [Hash] headers
|
|
361
|
+
# Additional headers for the POST request.
|
|
362
|
+
#
|
|
363
|
+
# @yield [body]
|
|
364
|
+
# If a block is given, it will be passed the body of the page.
|
|
365
|
+
#
|
|
366
|
+
# @yieldparam [Mechanize::Page] page
|
|
367
|
+
# The body of the requested page.
|
|
368
|
+
#
|
|
369
|
+
# @return [Mechanize::Page]
|
|
370
|
+
# The body of the requested page.
|
|
371
|
+
#
|
|
372
|
+
# @example
|
|
373
|
+
# Web.post_body('http://www.rubyinside.com')
|
|
374
|
+
# # => String
|
|
375
|
+
#
|
|
376
|
+
# @example
|
|
377
|
+
# Web.post_body('http://www.rubyinside.com') do |body|
|
|
378
|
+
# puts body
|
|
379
|
+
# end
|
|
380
|
+
#
|
|
381
|
+
# @see post
|
|
382
|
+
#
|
|
383
|
+
# @api public
|
|
384
|
+
#
|
|
385
|
+
def self.post_body(url,query={},headers={})
|
|
386
|
+
body = post(url,query,headers).body
|
|
387
|
+
|
|
388
|
+
yield body if block_given?
|
|
389
|
+
return body
|
|
390
|
+
end
|
|
391
|
+
end
|
|
33
392
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.\" Generated by kramdown-man 0.1.8
|
|
2
|
+
.\" https://github.com/postmodern/kramdown-man#readme
|
|
3
|
+
.TH ronin-web-diff 1 "2022-01-01" Ronin Web "User Manuals"
|
|
4
|
+
.LP
|
|
5
|
+
.SH SYNOPSIS
|
|
6
|
+
.LP
|
|
7
|
+
.HP
|
|
8
|
+
\fBronin-web-diff\fR \[lB]\fIoptions\fP\[rB] \[lC]\fIURL\fP \[or] \fIFILE\fP\[rC] \[lC]\fIURL\fP \[or] \fIFILE\fP\[rC]
|
|
9
|
+
.LP
|
|
10
|
+
.SH DESCRIPTION
|
|
11
|
+
.LP
|
|
12
|
+
.PP
|
|
13
|
+
Diffs two separate webpages and prints the HTML nodes which change changed\.
|
|
14
|
+
.LP
|
|
15
|
+
.SH ARGUMENTS
|
|
16
|
+
.LP
|
|
17
|
+
.TP
|
|
18
|
+
\fIURL\fP
|
|
19
|
+
A \fBhttps://\fR or \fBhttp://\fR URL of the web page to diff\.
|
|
20
|
+
.LP
|
|
21
|
+
.TP
|
|
22
|
+
\fIFILE\fP
|
|
23
|
+
A path to the local HTML file to diff\.
|
|
24
|
+
.LP
|
|
25
|
+
.SH OPTIONS
|
|
26
|
+
.LP
|
|
27
|
+
.TP
|
|
28
|
+
\fB-h\fR, \fB--help\fR
|
|
29
|
+
Print help information
|
|
30
|
+
.LP
|
|
31
|
+
.SH AUTHOR
|
|
32
|
+
.LP
|
|
33
|
+
.PP
|
|
34
|
+
Postmodern
|
|
35
|
+
.MT postmodern\.mod3\[at]gmail\.com
|
|
36
|
+
.ME
|
|
37
|
+
.LP
|
|
38
|
+
.SH SEE ALSO
|
|
39
|
+
.LP
|
|
40
|
+
.PP
|
|
41
|
+
ronin\-web\-html(1)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# ronin-web-diff 1 "2022-01-01" Ronin Web "User Manuals"
|
|
2
|
+
|
|
3
|
+
## SYNOPSIS
|
|
4
|
+
|
|
5
|
+
`ronin-web-diff` [*options*] {*URL* \| *FILE*} {*URL* \| *FILE*}
|
|
6
|
+
|
|
7
|
+
## DESCRIPTION
|
|
8
|
+
|
|
9
|
+
Diffs two separate webpages and prints the HTML nodes which change changed.
|
|
10
|
+
|
|
11
|
+
## ARGUMENTS
|
|
12
|
+
|
|
13
|
+
*URL*
|
|
14
|
+
A `https://` or `http://` URL of the web page to diff.
|
|
15
|
+
|
|
16
|
+
*FILE*
|
|
17
|
+
A path to the local HTML file to diff.
|
|
18
|
+
|
|
19
|
+
## OPTIONS
|
|
20
|
+
|
|
21
|
+
`-h`, `--help`
|
|
22
|
+
Print help information
|
|
23
|
+
|
|
24
|
+
## AUTHOR
|
|
25
|
+
|
|
26
|
+
Postmodern <postmodern.mod3@gmail.com>
|
|
27
|
+
|
|
28
|
+
## SEE ALSO
|
|
29
|
+
|
|
30
|
+
ronin-web-html(1)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
.\" Generated by kramdown-man 0.1.8
|
|
2
|
+
.\" https://github.com/postmodern/kramdown-man#readme
|
|
3
|
+
.TH ronin-web-html 1 "2022-01-01" Ronin "User Manuals"
|
|
4
|
+
.LP
|
|
5
|
+
.SH SYNOPSIS
|
|
6
|
+
.LP
|
|
7
|
+
.HP
|
|
8
|
+
\fBronin-web html\fR \[lB]\fIoptions\fP\[rB] \[lC]\fIURL\fP \[or] \fIFILE\fP\[rC] \[lB]\fIXPATH\fP \[or] \fICSS\-path\fP\[rB]
|
|
9
|
+
.LP
|
|
10
|
+
.SH DESCRIPTION
|
|
11
|
+
.LP
|
|
12
|
+
.PP
|
|
13
|
+
Performs XPath\[sl]CSS\-path queries on a URL or HTML file\.
|
|
14
|
+
.LP
|
|
15
|
+
.SH ARGUMENTS
|
|
16
|
+
.LP
|
|
17
|
+
.TP
|
|
18
|
+
\fIURL\fP
|
|
19
|
+
The \fBhttp://\fR or \fBhttps://\fR URL to fetch and parse\.
|
|
20
|
+
.LP
|
|
21
|
+
.TP
|
|
22
|
+
\fIFILE\fP
|
|
23
|
+
The local HTML file to parse\.
|
|
24
|
+
.LP
|
|
25
|
+
.TP
|
|
26
|
+
\fIXPATH\fP
|
|
27
|
+
The XPath query expression\.
|
|
28
|
+
.LP
|
|
29
|
+
.TP
|
|
30
|
+
\fICSS\-path\fP
|
|
31
|
+
The CSS\-path query expression\.
|
|
32
|
+
.LP
|
|
33
|
+
.SH OPTIONS
|
|
34
|
+
.LP
|
|
35
|
+
.TP
|
|
36
|
+
\fB-X\fR, \fB--xpath\fR \fIXPATH\fP
|
|
37
|
+
The XPath query to perform\.
|
|
38
|
+
.LP
|
|
39
|
+
.TP
|
|
40
|
+
\fB-C\fR, \fB--css-path\fR \fICSS\-path\fP
|
|
41
|
+
The CSS\-path query to perform\.
|
|
42
|
+
.LP
|
|
43
|
+
.TP
|
|
44
|
+
\fB-M\fR, \fB--meta-tags\fR
|
|
45
|
+
Searches for all \fB<meta ...>\fR tags\.
|
|
46
|
+
.LP
|
|
47
|
+
.TP
|
|
48
|
+
\fB-l\fR, \fB--links\fR
|
|
49
|
+
Searches for all \fB<a href="...">\fR URLs\.
|
|
50
|
+
.LP
|
|
51
|
+
.TP
|
|
52
|
+
\fB-S\fR, \fB--style\fR
|
|
53
|
+
Dumps all \fB<style>\fR tags\.
|
|
54
|
+
.LP
|
|
55
|
+
.TP
|
|
56
|
+
\fB-s\fR, \fB--stylesheet-urls\fR
|
|
57
|
+
Searches for all \fB<link type="text/css" href="..."/>\fR URLs\.
|
|
58
|
+
.LP
|
|
59
|
+
.TP
|
|
60
|
+
\fB-J\fR, \fB--javascript\fR
|
|
61
|
+
Dumps all javascript source code\.
|
|
62
|
+
.LP
|
|
63
|
+
.TP
|
|
64
|
+
\fB-j\fR, \fB--javascript-urls\fR
|
|
65
|
+
Searches for all \fB<script src="...">\fR URLs\.
|
|
66
|
+
.LP
|
|
67
|
+
.TP
|
|
68
|
+
\fB-f\fR, \fB--form-urls\fR
|
|
69
|
+
Searches for all \fB<form action="...">\fR URLS\.
|
|
70
|
+
.LP
|
|
71
|
+
.TP
|
|
72
|
+
\fB-u\fR, \fB--urls\fR
|
|
73
|
+
Dumps all URLs in the page\.
|
|
74
|
+
.LP
|
|
75
|
+
.TP
|
|
76
|
+
\fB-F\fR, \fB--first\fR
|
|
77
|
+
Only print the first match\.
|
|
78
|
+
.LP
|
|
79
|
+
.TP
|
|
80
|
+
\fB-h\fR, \fB--help\fR
|
|
81
|
+
Print help information\.
|
|
82
|
+
.LP
|
|
83
|
+
.SH AUTHOR
|
|
84
|
+
.LP
|
|
85
|
+
.PP
|
|
86
|
+
Postmodern
|
|
87
|
+
.MT postmodern\.mod3\[at]gmail\.com
|
|
88
|
+
.ME
|
|
89
|
+
.LP
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# ronin-web-html 1 "2022-01-01" Ronin "User Manuals"
|
|
2
|
+
|
|
3
|
+
## SYNOPSIS
|
|
4
|
+
|
|
5
|
+
`ronin-web html` [*options*] {*URL* \| *FILE*} [*XPATH* \| *CSS-path*]
|
|
6
|
+
|
|
7
|
+
## DESCRIPTION
|
|
8
|
+
|
|
9
|
+
Performs XPath/CSS-path queries on a URL or HTML file.
|
|
10
|
+
|
|
11
|
+
## ARGUMENTS
|
|
12
|
+
|
|
13
|
+
*URL*
|
|
14
|
+
The `http://` or `https://` URL to fetch and parse.
|
|
15
|
+
|
|
16
|
+
*FILE*
|
|
17
|
+
The local HTML file to parse.
|
|
18
|
+
|
|
19
|
+
*XPATH*
|
|
20
|
+
The XPath query expression.
|
|
21
|
+
|
|
22
|
+
*CSS-path*
|
|
23
|
+
The CSS-path query expression.
|
|
24
|
+
|
|
25
|
+
## OPTIONS
|
|
26
|
+
|
|
27
|
+
`-X`, `--xpath` *XPATH*
|
|
28
|
+
The XPath query to perform.
|
|
29
|
+
|
|
30
|
+
`-C`, `--css-path` *CSS-path*
|
|
31
|
+
The CSS-path query to perform.
|
|
32
|
+
|
|
33
|
+
`-M`, `--meta-tags`
|
|
34
|
+
Searches for all `<meta ...>` tags.
|
|
35
|
+
|
|
36
|
+
`-l`, `--links`
|
|
37
|
+
Searches for all `<a href="...">` URLs.
|
|
38
|
+
|
|
39
|
+
`-S`, `--style`
|
|
40
|
+
Dumps all `<style>` tags.
|
|
41
|
+
|
|
42
|
+
`-s`, `--stylesheet-urls`
|
|
43
|
+
Searches for all `<link type="text/css" href="..."/>` URLs.
|
|
44
|
+
|
|
45
|
+
`-J`, `--javascript`
|
|
46
|
+
Dumps all javascript source code.
|
|
47
|
+
|
|
48
|
+
`-j`, `--javascript-urls`
|
|
49
|
+
Searches for all `<script src="...">` URLs.
|
|
50
|
+
|
|
51
|
+
`-f`, `--form-urls`
|
|
52
|
+
Searches for all `<form action="...">` URLS.
|
|
53
|
+
|
|
54
|
+
`-u`, `--urls`
|
|
55
|
+
Dumps all URLs in the page.
|
|
56
|
+
|
|
57
|
+
`-F`, `--first`
|
|
58
|
+
Only print the first match.
|
|
59
|
+
|
|
60
|
+
`-h`, `--help`
|
|
61
|
+
Print help information.
|
|
62
|
+
|
|
63
|
+
## AUTHOR
|
|
64
|
+
|
|
65
|
+
Postmodern <postmodern.mod3@gmail.com>
|
|
66
|
+
|
data/man/ronin-web-irb.1
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.\" Generated by kramdown-man 0.1.8
|
|
2
|
+
.\" https://github.com/postmodern/kramdown-man#readme
|
|
3
|
+
.TH ronin-web-irb 1 "May 2022" Ronin "User Manuals"
|
|
4
|
+
.LP
|
|
5
|
+
.SH SYNOPSIS
|
|
6
|
+
.LP
|
|
7
|
+
.HP
|
|
8
|
+
\fBronin-web irb\fR \[lB]\fIoptions\fP\[rB]
|
|
9
|
+
.LP
|
|
10
|
+
.SH DESCRIPTION
|
|
11
|
+
.LP
|
|
12
|
+
.PP
|
|
13
|
+
Starts an interactive Ruby shell with \fBronin/web\fR loaded\.
|
|
14
|
+
.LP
|
|
15
|
+
.SH OPTIONS
|
|
16
|
+
.LP
|
|
17
|
+
.TP
|
|
18
|
+
\fB-h\fR, \fB--help\fR
|
|
19
|
+
Print help information
|
|
20
|
+
.LP
|
|
21
|
+
.SH AUTHOR
|
|
22
|
+
.LP
|
|
23
|
+
.PP
|
|
24
|
+
Postmodern
|
|
25
|
+
.MT postmodern\.mod3\[at]gmail\.com
|
|
26
|
+
.ME
|
|
27
|
+
.LP
|
|
28
|
+
.SH SEE ALSO
|
|
29
|
+
.LP
|
|
30
|
+
.PP
|
|
31
|
+
ronin\-web(1)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# ronin-web-irb 1 "May 2022" Ronin "User Manuals"
|
|
2
|
+
|
|
3
|
+
## SYNOPSIS
|
|
4
|
+
|
|
5
|
+
`ronin-web irb` [*options*]
|
|
6
|
+
|
|
7
|
+
## DESCRIPTION
|
|
8
|
+
|
|
9
|
+
Starts an interactive Ruby shell with `ronin/web` loaded.
|
|
10
|
+
|
|
11
|
+
## OPTIONS
|
|
12
|
+
|
|
13
|
+
`-h`, `--help`
|
|
14
|
+
Print help information
|
|
15
|
+
|
|
16
|
+
## AUTHOR
|
|
17
|
+
|
|
18
|
+
Postmodern <postmodern.mod3@gmail.com>
|
|
19
|
+
|
|
20
|
+
## SEE ALSO
|
|
21
|
+
|
|
22
|
+
ronin-web(1)
|