ronin-web 1.0.1 → 2.0.0.rc1
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 +4 -4
- data/.github/workflows/ruby.yml +3 -2
- data/.gitignore +1 -0
- data/.rubocop.yml +5 -0
- data/ChangeLog.md +46 -1
- data/Gemfile +25 -12
- data/README.md +486 -39
- data/Rakefile +9 -0
- data/data/completions/ronin-web +203 -0
- data/gemspec.yml +18 -5
- data/lib/ronin/web/cli/browser_options.rb +92 -0
- data/lib/ronin/web/cli/browser_shell.rb +448 -0
- data/lib/ronin/web/cli/command.rb +1 -1
- data/lib/ronin/web/cli/commands/browser.rb +373 -0
- data/lib/ronin/web/cli/commands/completion.rb +63 -0
- data/lib/ronin/web/cli/commands/diff.rb +60 -8
- data/lib/ronin/web/cli/commands/html.rb +21 -33
- data/lib/ronin/web/cli/commands/irb.rb +1 -1
- data/lib/ronin/web/cli/commands/new/{webapp.rb → app.rb} +8 -8
- data/lib/ronin/web/cli/commands/new/nokogiri.rb +4 -4
- data/lib/ronin/web/cli/commands/new/server.rb +1 -1
- data/lib/ronin/web/cli/commands/new/spider.rb +1 -1
- data/lib/ronin/web/cli/commands/new.rb +5 -3
- data/lib/ronin/web/cli/commands/reverse_proxy.rb +1 -1
- data/lib/ronin/web/cli/commands/screenshot.rb +186 -0
- data/lib/ronin/web/cli/commands/server.rb +3 -3
- data/lib/ronin/web/cli/commands/session_cookie.rb +265 -0
- data/lib/ronin/web/cli/commands/spider.rb +60 -466
- data/lib/ronin/web/cli/commands/user_agent.rb +177 -0
- data/lib/ronin/web/cli/commands/vulns.rb +463 -0
- data/lib/ronin/web/cli/commands/wordlist.rb +484 -0
- data/lib/ronin/web/cli/commands/xml.rb +149 -0
- data/lib/ronin/web/cli/js_shell.rb +69 -0
- data/lib/ronin/web/cli/ruby_shell.rb +1 -1
- data/lib/ronin/web/cli/spider_options.rb +919 -0
- data/lib/ronin/web/cli.rb +3 -1
- data/lib/ronin/web/html.rb +1 -1
- data/lib/ronin/web/root.rb +1 -1
- data/lib/ronin/web/version.rb +2 -2
- data/lib/ronin/web/xml.rb +1 -1
- data/lib/ronin/web.rb +4 -364
- data/man/ronin-web-browser.1 +92 -0
- data/man/ronin-web-browser.1.md +96 -0
- data/man/ronin-web-completion.1 +76 -0
- data/man/ronin-web-completion.1.md +78 -0
- data/man/ronin-web-diff.1 +14 -21
- data/man/ronin-web-diff.1.md +13 -6
- data/man/ronin-web-html.1 +30 -46
- data/man/ronin-web-html.1.md +27 -17
- data/man/ronin-web-irb.1 +9 -16
- data/man/ronin-web-irb.1.md +6 -2
- data/man/ronin-web-new-app.1.md +39 -0
- data/man/ronin-web-new-nokogiri.1 +9 -20
- data/man/ronin-web-new-nokogiri.1.md +5 -5
- data/man/ronin-web-new-server.1 +11 -23
- data/man/ronin-web-new-server.1.md +5 -5
- data/man/ronin-web-new-spider.1 +44 -88
- data/man/ronin-web-new-spider.1.md +37 -37
- data/man/ronin-web-new.1 +18 -30
- data/man/ronin-web-new.1.md +15 -11
- data/man/ronin-web-reverse-proxy.1 +33 -38
- data/man/ronin-web-reverse-proxy.1.md +20 -14
- data/man/ronin-web-screenshot.1 +56 -0
- data/man/ronin-web-screenshot.1.md +56 -0
- data/man/ronin-web-server.1 +15 -29
- data/man/ronin-web-server.1.md +13 -9
- data/man/ronin-web-session-cookie.1 +38 -0
- data/man/ronin-web-session-cookie.1.md +41 -0
- data/man/ronin-web-spider.1 +121 -130
- data/man/ronin-web-spider.1.md +115 -66
- data/man/ronin-web-user-agent.1 +44 -0
- data/man/ronin-web-user-agent.1.md +46 -0
- data/man/ronin-web-vulns.1 +175 -0
- data/man/ronin-web-vulns.1.md +177 -0
- data/man/ronin-web-wordlist.1 +258 -0
- data/man/ronin-web-wordlist.1.md +263 -0
- data/man/ronin-web-xml.1 +43 -0
- data/man/ronin-web-xml.1.md +46 -0
- data/man/ronin-web.1 +67 -18
- data/man/ronin-web.1.md +55 -4
- data/scripts/setup +58 -0
- metadata +122 -31
- data/lib/ronin/web/mechanize.rb +0 -82
- data/man/ronin-web-new-webapp.1.md +0 -39
- /data/data/new/{webapp → app}/.gitignore +0 -0
- /data/data/new/{webapp → app}/.ruby-version.erb +0 -0
- /data/data/new/{webapp → app}/Dockerfile.erb +0 -0
- /data/data/new/{webapp → app}/Gemfile +0 -0
- /data/data/new/{webapp → app}/app.rb.erb +0 -0
- /data/data/new/{webapp → app}/config.ru +0 -0
- /data/data/new/{webapp → app}/docker-compose.yml.erb +0 -0
data/README.md
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
* [Issues](https://github.com/ronin-rb/ronin-web/issues)
|
|
9
9
|
* [Documentation](https://ronin-rb.dev/docs/ronin-web/frames)
|
|
10
10
|
* [Discord](https://discord.gg/6WAb3PsVX9) |
|
|
11
|
-
[Twitter](https://twitter.com/ronin_rb) |
|
|
12
11
|
[Mastodon](https://infosec.exchange/@ronin_rb)
|
|
13
12
|
|
|
14
13
|
## Description
|
|
@@ -25,7 +24,6 @@ research and development.
|
|
|
25
24
|
* Also provides additional extensions to [Nokogiri][nokogiri] using
|
|
26
25
|
[nokogiri-ext].
|
|
27
26
|
* Supports diffing HTML/XML documents using [nokogiri-diff].
|
|
28
|
-
* Automated Web Browsing using [Mechanize][mechanize].
|
|
29
27
|
* Supports random `User-Agent` generation using [ronin-web-user_agents].
|
|
30
28
|
* Provides an easy to use [Sinatra][sinatra] based web server using
|
|
31
29
|
[ronin-web-server].
|
|
@@ -47,55 +45,345 @@ Arguments:
|
|
|
47
45
|
[ARGS ...] Additional arguments for the command
|
|
48
46
|
|
|
49
47
|
Commands:
|
|
48
|
+
completion
|
|
50
49
|
diff
|
|
51
50
|
help
|
|
52
51
|
html
|
|
53
52
|
irb
|
|
54
53
|
new
|
|
55
54
|
reverse-proxy
|
|
55
|
+
screenshot
|
|
56
56
|
server
|
|
57
|
+
session-cookie
|
|
57
58
|
spider
|
|
59
|
+
user-agent
|
|
60
|
+
vulns
|
|
61
|
+
wordlist
|
|
62
|
+
xml
|
|
58
63
|
```
|
|
59
64
|
|
|
60
|
-
|
|
65
|
+
Open the `ronin-web` Ruby REPL:
|
|
66
|
+
|
|
67
|
+
```shell
|
|
68
|
+
$ ronin-web irb
|
|
69
|
+
```
|
|
61
70
|
|
|
62
|
-
|
|
71
|
+
Diff two HTML files:
|
|
63
72
|
|
|
64
|
-
```
|
|
65
|
-
|
|
73
|
+
```shell
|
|
74
|
+
$ ronin-web diff index1.html index2.html
|
|
75
|
+
+
|
|
76
|
+
|
|
77
|
+
+ <div>hax</div>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Diff two URLs:
|
|
81
|
+
|
|
82
|
+
```shell
|
|
83
|
+
$ ronin-web diff http://example.com/index.html http://example.com/index2.html
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Perform an XPath query on an HTML file:
|
|
87
|
+
|
|
88
|
+
```shell
|
|
89
|
+
$ ronin-web html --xpath //meta index.html
|
|
90
|
+
<meta charset="utf-8">
|
|
91
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
|
92
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Perform an XPath query on a URL:
|
|
96
|
+
|
|
97
|
+
```shell
|
|
98
|
+
$ ronin-web html --xpath //meta https://example.com/
|
|
99
|
+
<meta charset="utf-8">
|
|
100
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
|
101
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Dump all links from a web page:
|
|
105
|
+
|
|
106
|
+
```shell
|
|
107
|
+
$ ronin-web html --links https://www.google.com/
|
|
108
|
+
https://www.google.com/imghp?hl=en&tab=wi
|
|
109
|
+
https://maps.google.com/maps?hl=en&tab=wl
|
|
110
|
+
https://play.google.com/?hl=en&tab=w8
|
|
111
|
+
https://www.youtube.com/?tab=w1
|
|
112
|
+
https://news.google.com/?tab=wn
|
|
113
|
+
https://mail.google.com/mail/?tab=wm
|
|
114
|
+
https://drive.google.com/?tab=wo
|
|
115
|
+
https://www.google.com/intl/en/about/products?tab=wh
|
|
116
|
+
http://www.google.com/history/optout?hl=en
|
|
117
|
+
/preferences?hl=en
|
|
118
|
+
https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/&ec=GAZAAQ
|
|
119
|
+
/advanced_search?hl=en&authuser=0
|
|
120
|
+
https://www.google.com/url?q=https://blog.google/products/search/google-search-new-fact-checking-misinformation/&source=hpp&id=19034203&ct=3&usg=AOvVaw3UxG35a-5UX1Rl8M_VwPbd&sa=X&ved=0ahUKEwjM4Iq--JD-AhVtGTQIHXMBBaYQ8IcBCAU
|
|
121
|
+
/intl/en/ads/
|
|
122
|
+
/services/
|
|
123
|
+
/intl/en/about.html
|
|
124
|
+
/intl/en/policies/privacy/
|
|
125
|
+
/intl/en/policies/terms/
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Spiders a host and print all visited URLs:
|
|
129
|
+
|
|
130
|
+
```shell
|
|
131
|
+
$ ronin-web spider --host www.ruby-lang.org
|
|
132
|
+
http://www.ruby-lang.org/
|
|
133
|
+
http://www.ruby-lang.org/en/
|
|
134
|
+
http://www.ruby-lang.org/en/downloads/
|
|
135
|
+
http://www.ruby-lang.org/en/documentation/
|
|
136
|
+
http://www.ruby-lang.org/en/libraries/
|
|
137
|
+
http://www.ruby-lang.org/en/community/
|
|
138
|
+
https://www.ruby-lang.org/en/news/
|
|
139
|
+
https://www.ruby-lang.org/en/security/
|
|
140
|
+
https://www.ruby-lang.org/en/about/
|
|
141
|
+
...
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Spiders the domain and sub-domains and print every visited URL:
|
|
145
|
+
|
|
146
|
+
```shell
|
|
147
|
+
$ ronin-web spider --domain ruby-lang.org
|
|
148
|
+
http://ruby-lang.org/
|
|
149
|
+
https://www.ruby-lang.org/
|
|
150
|
+
https://www.ruby-lang.org/en/
|
|
151
|
+
https://www.ruby-lang.org/en/downloads/
|
|
152
|
+
https://www.ruby-lang.org/en/documentation/
|
|
153
|
+
https://www.ruby-lang.org/en/libraries/
|
|
154
|
+
https://www.ruby-lang.org/en/community/
|
|
155
|
+
https://www.ruby-lang.org/en/news/
|
|
156
|
+
https://www.ruby-lang.org/en/security/
|
|
157
|
+
https://www.ruby-lang.org/en/about/
|
|
158
|
+
...
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Spiders a specific web-site and print every visited URL:
|
|
162
|
+
|
|
163
|
+
```shell
|
|
164
|
+
$ ronin-web spider --site https://www.ruby-lang.org/
|
|
165
|
+
https://www.ruby-lang.org/
|
|
166
|
+
https://www.ruby-lang.org/en/
|
|
167
|
+
https://www.ruby-lang.org/en/downloads/
|
|
168
|
+
https://www.ruby-lang.org/en/documentation/
|
|
169
|
+
https://www.ruby-lang.org/en/libraries/
|
|
170
|
+
https://www.ruby-lang.org/en/community/
|
|
171
|
+
https://www.ruby-lang.org/en/news/
|
|
172
|
+
https://www.ruby-lang.org/en/security/
|
|
173
|
+
https://www.ruby-lang.org/en/about/
|
|
174
|
+
...
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Spider a host and print the response statuses:
|
|
178
|
+
|
|
179
|
+
```shell
|
|
180
|
+
200 http://www.ruby-lang.org/
|
|
181
|
+
200 http://www.ruby-lang.org/en/
|
|
182
|
+
200 http://www.ruby-lang.org/en/downloads/
|
|
183
|
+
200 http://www.ruby-lang.org/en/documentation/
|
|
184
|
+
200 http://www.ruby-lang.org/en/libraries/
|
|
185
|
+
200 http://www.ruby-lang.org/en/community/
|
|
186
|
+
200 http://www.ruby-lang.org/en/news/
|
|
187
|
+
200 http://www.ruby-lang.org/en/security/
|
|
188
|
+
200 http://www.ruby-lang.org/en/about/
|
|
189
|
+
...
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Spider a host and print the response status and headers:
|
|
193
|
+
|
|
194
|
+
```shell
|
|
195
|
+
ronin-web spider --print-headers --host www.ruby-lang.org
|
|
196
|
+
200 http://www.ruby-lang.org/
|
|
197
|
+
Connection: close
|
|
198
|
+
Content-Length: 887
|
|
199
|
+
Server: Cowboy
|
|
200
|
+
Strict-Transport-Security: max-age=31536000
|
|
201
|
+
Content-Type: text/html
|
|
202
|
+
Etag: W/"496ac7fab29a6094e490da28025c5857"
|
|
203
|
+
X-Frame-Options: SAMEORIGIN
|
|
204
|
+
Via: 1.1 vegur, 1.1 varnish
|
|
205
|
+
Accept-Ranges: bytes
|
|
206
|
+
Date: Tue, 04 Apr 2023 19:42:51 GMT
|
|
207
|
+
Age: 155
|
|
208
|
+
X-Served-By: cache-pdx12330-PDX
|
|
209
|
+
X-Cache: HIT
|
|
210
|
+
X-Cache-Hits: 1
|
|
211
|
+
X-Timer: S1680637372.808609,VS0,VE1
|
|
212
|
+
Vary: Accept-Encoding
|
|
213
|
+
...
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Start a debug web server on http://localhost:8000/:
|
|
217
|
+
|
|
218
|
+
```shell
|
|
219
|
+
$ ronin-web server
|
|
220
|
+
[2023-04-04 12:26:59] INFO WEBrick 1.7.0
|
|
221
|
+
[2023-04-04 12:26:59] INFO ruby 3.1.3 (2022-11-24) [x86_64-linux]
|
|
222
|
+
== Sinatra (v3.0.4) has taken the stage on 8000 for development with backup from WEBrick
|
|
223
|
+
[2023-04-04 12:26:59] INFO WEBrick::HTTPServer#start: pid=8966 port=8000
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Start a debug web server on a different address and port:
|
|
227
|
+
|
|
228
|
+
```shell
|
|
229
|
+
$ ronin-web server --host 0.0.0.0 --port 1337
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Host the files in a directory on http://localhost:8000/:
|
|
233
|
+
|
|
234
|
+
```shell
|
|
235
|
+
$ ronin-web server --root .
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Mount a specific file at a specific HTTP path:
|
|
239
|
+
|
|
240
|
+
```shell
|
|
241
|
+
$ ronin-web server --dir /dir/index.html:./index.html
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Mount a specific directory at a specific HTTP path:
|
|
245
|
+
|
|
246
|
+
```shell
|
|
247
|
+
$ ronin-web server --dir /dir:.
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Add a redirect to the web server:
|
|
251
|
+
|
|
252
|
+
```shell
|
|
253
|
+
$ ronin-web server --redirect /redirect:https://example.com/
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Start a HTTP reverse proxy that rewrites HTTP responses on http://localhost:8080:
|
|
257
|
+
|
|
258
|
+
```shell
|
|
259
|
+
$ ronin-web reverse-proxy --rewrite-response Example:Hax
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Test the reverse proxy:
|
|
263
|
+
|
|
264
|
+
```shell
|
|
265
|
+
$ curl -H "Host: example.com" http://localhost:8080/
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Generate a new Ruby script for parsing HTML/XML:
|
|
269
|
+
|
|
270
|
+
```shell
|
|
271
|
+
$ ronin-web new nokogiri parse.rb
|
|
272
|
+
erb nokogiri.rb.erb parse.rb
|
|
273
|
+
chmod parse.rb
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Generate a new web spider script:
|
|
277
|
+
|
|
278
|
+
```shell
|
|
279
|
+
$ ronin-web new spider --host=www.example.com spider.rb
|
|
280
|
+
erb spider.rb.erb spider.rb
|
|
281
|
+
chmod spider.rb
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Generate a new web server script:
|
|
285
|
+
|
|
286
|
+
```shell
|
|
287
|
+
$ ronin-web new server server.rb
|
|
288
|
+
erb server.rb.erb server.rb
|
|
289
|
+
chmod server.rb
|
|
66
290
|
```
|
|
67
291
|
|
|
68
|
-
|
|
292
|
+
Generate a new web app:
|
|
293
|
+
|
|
294
|
+
```shell
|
|
295
|
+
$ ronin-web new app myapp
|
|
296
|
+
mkdir myapp
|
|
297
|
+
mkdir myapp/lib
|
|
298
|
+
mkdir myapp/views
|
|
299
|
+
mkdir myapp/public
|
|
300
|
+
erb .ruby-version.erb myapp/.ruby-version
|
|
301
|
+
cp Gemfile myapp
|
|
302
|
+
erb app.rb.erb myapp/app.rb
|
|
303
|
+
cp config.ru myapp
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Open the Ronin Web Ruby REPL:
|
|
307
|
+
|
|
308
|
+
```
|
|
309
|
+
$ ronin-web irb
|
|
310
|
+
, Jµ ▓▓█▓
|
|
311
|
+
J▌ ▐▓██▌ ████ ██ ▐███D
|
|
312
|
+
╓▄▓▓█████▌ ██µ ████ ▄███ÖJ██▌ ███▌
|
|
313
|
+
,╓µ▄▄▄▄▄▄▄▄µ;, ,▄▓██████████ ▐███ ▐███▀ ███▌ ████µ ▄███
|
|
314
|
+
¬∞MÆ▓███████████████████████▓M ▄██████▀▀╙████▌ ████▌ ████ ▄███ J█████ ███▌
|
|
315
|
+
`█████▀▀▀▀▀███████ -████▀└ ████ ▐█████n ▄███O ███▌ ██████████
|
|
316
|
+
▓████L ████▀ ▓████ ▓███Ö ███████ ███▌ ▓███ ▐█████████▀
|
|
317
|
+
▄████▀ ,╓▄▄▄█████ J████Ü ,███▌ ▄███████████ J███▀ ████ █████
|
|
318
|
+
J█████████████████─ ████▌ ████ ████`██████▌ ████ ▐███Ü ▐███Ü
|
|
319
|
+
███████████▀▀▀╙└ ▐████ J███▌ ▓███▌ ²█████ J███Ü ███▌ ▀█▌
|
|
320
|
+
▓██████████▌ ████▌ ████ ;████ ▀███▀ ███▌ J▀▀▀- █
|
|
321
|
+
▄█████▀ ▀█████µ ▐████ ,▄▓████▀ ████▀ ███ J███ `
|
|
322
|
+
J█████- ╙▀███▄ ████████████▀╙ J█▀▀▀ █U ▀█▌
|
|
323
|
+
████▀ ▀███ ▄████████▀▀ ╨ █
|
|
324
|
+
▓██▀ ²▀█▄ █▀▀▀╙└
|
|
325
|
+
▄██╜ ╙W
|
|
326
|
+
J█▀
|
|
327
|
+
▌└
|
|
328
|
+
┘
|
|
329
|
+
|
|
330
|
+
irb(ronin-web)>
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## Examples
|
|
334
|
+
|
|
335
|
+
### HTML
|
|
336
|
+
|
|
337
|
+
Parse an HTML string:
|
|
69
338
|
|
|
70
339
|
```ruby
|
|
71
|
-
|
|
340
|
+
doc = html_parse("<html>\n <body>\n <p>Hello world</p>\n </body>\n</html>\n")
|
|
341
|
+
# =>
|
|
342
|
+
# #(Document:0x6ab8 {
|
|
343
|
+
# name = "document",
|
|
344
|
+
# children = [
|
|
345
|
+
# #(DTD:0x6be4 { name = "html" }),
|
|
346
|
+
# #(Element:0x6cd4 {
|
|
347
|
+
# name = "html",
|
|
348
|
+
# children = [
|
|
349
|
+
# #(Text "\n "),
|
|
350
|
+
# #(Element:0x6e64 {
|
|
351
|
+
# name = "body",
|
|
352
|
+
# children = [
|
|
353
|
+
# #(Text "\n "),
|
|
354
|
+
# #(Element:0x6ff4 { name = "p", children = [ #(Text "Hello world")] }),
|
|
355
|
+
# #(Text "\n ")]
|
|
356
|
+
# }),
|
|
357
|
+
# #(Text "\n")]
|
|
358
|
+
# })]
|
|
359
|
+
# })
|
|
72
360
|
```
|
|
73
361
|
|
|
74
|
-
|
|
362
|
+
Parse a HTML file:
|
|
75
363
|
|
|
76
364
|
```ruby
|
|
77
|
-
|
|
365
|
+
doc = html_open("index.html")
|
|
366
|
+
# => #<Nokogiri::HTML::Document:...>
|
|
78
367
|
```
|
|
79
368
|
|
|
80
|
-
|
|
369
|
+
Searching an HTML document using [XPath] or CSS-path:
|
|
81
370
|
|
|
82
371
|
```ruby
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
#
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
#
|
|
89
|
-
# </html>
|
|
372
|
+
nodes = doc.search('//div/p')
|
|
373
|
+
nodes = doc.search('div p.class')
|
|
374
|
+
# => [#<Nokogiri::HTML::Element:...>, ...]
|
|
375
|
+
|
|
376
|
+
node = doc.at('#id')
|
|
377
|
+
# => #<Nokogiri::HTML::Element:...>
|
|
90
378
|
```
|
|
91
379
|
|
|
92
380
|
Build a HTML document:
|
|
93
381
|
|
|
94
382
|
```ruby
|
|
95
|
-
doc =
|
|
383
|
+
doc = html_build do
|
|
96
384
|
html {
|
|
97
385
|
head {
|
|
98
|
-
script(:
|
|
386
|
+
script(type: 'text/javascript', src: 'redirect.js')
|
|
99
387
|
}
|
|
100
388
|
}
|
|
101
389
|
end
|
|
@@ -105,23 +393,56 @@ puts doc.to_html
|
|
|
105
393
|
# <html><head><script src="redirect.js" type="text/javascript"></script></head></html>
|
|
106
394
|
```
|
|
107
395
|
|
|
108
|
-
|
|
396
|
+
### XML
|
|
397
|
+
|
|
398
|
+
Parse an XML response body:
|
|
399
|
+
|
|
400
|
+
```ruby
|
|
401
|
+
xml_parse("<?xml version=\"1.0\"?>\n<users>\n <user>\n <name>admin</name>\n <password>0mni</password>\n <user>\n</users>\n")
|
|
402
|
+
# =>
|
|
403
|
+
# #(Document:0xdebc {
|
|
404
|
+
# name = "document",
|
|
405
|
+
# children = [
|
|
406
|
+
# #(Element:0xdfe8 {
|
|
407
|
+
# name = "users",
|
|
408
|
+
# children = [
|
|
409
|
+
# #(Text "\n "),
|
|
410
|
+
# #(Element:0xe178 {
|
|
411
|
+
# name = "user",
|
|
412
|
+
# children = [
|
|
413
|
+
# #(Text "\n "),
|
|
414
|
+
# #(Element:0xe308 { name = "name", children = [ #(Text "admin")] }),
|
|
415
|
+
# #(Text "\n "),
|
|
416
|
+
# #(Element:0xe538 { name = "password", children = [ #(Text "0mni")] }),
|
|
417
|
+
# #(Text "\n "),
|
|
418
|
+
# #(Element:0xe768 { name = "user", children = [ #(Text "\n")] }),
|
|
419
|
+
# #(Text "\n")]
|
|
420
|
+
# })]
|
|
421
|
+
# })]
|
|
422
|
+
# })
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
Parse a XML file:
|
|
109
426
|
|
|
110
427
|
```ruby
|
|
111
|
-
|
|
112
|
-
# =>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
428
|
+
doc = html_open("data.xml")
|
|
429
|
+
# => #<Nokogiri:XML:::Document:...>
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
Searching an XML document using [XPath]:
|
|
433
|
+
|
|
434
|
+
```ruby
|
|
435
|
+
users = doc.search('//user')
|
|
436
|
+
# => [#<Nokogiri::XML::Element:...>, ...]
|
|
437
|
+
|
|
438
|
+
admin = doc.at('//user[@name="admin"]')
|
|
439
|
+
# => #<Nokogiri::XML::Element:...>
|
|
119
440
|
```
|
|
120
441
|
|
|
121
442
|
Build a XML document:
|
|
122
443
|
|
|
123
444
|
```ruby
|
|
124
|
-
doc =
|
|
445
|
+
doc = xml_build do
|
|
125
446
|
playlist {
|
|
126
447
|
mp3 {
|
|
127
448
|
file { text('02 THE WAIT.mp3') }
|
|
@@ -144,19 +465,143 @@ puts doc.to_xml
|
|
|
144
465
|
# </playlist>
|
|
145
466
|
```
|
|
146
467
|
|
|
468
|
+
### Web Requests
|
|
469
|
+
|
|
470
|
+
Gets a URL and follows any redirects:
|
|
471
|
+
|
|
472
|
+
```ruby
|
|
473
|
+
get 'https://example.com/'
|
|
474
|
+
# => #<Net::HTTPResponse:...>
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
Gets a URL and parses the HTML response:
|
|
478
|
+
|
|
479
|
+
```ruby
|
|
480
|
+
get_html 'https://example.com/'
|
|
481
|
+
# => #<Nokogiri::HTML::Document:...>
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
Gets a URL and parses the XML response:
|
|
485
|
+
|
|
486
|
+
```ruby
|
|
487
|
+
get_xml 'https://example.com/sitemap.xml'
|
|
488
|
+
# => #<Nokogiri::XML::Document:...>
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
Gets a URL and parses the JSON response:
|
|
492
|
+
|
|
493
|
+
```ruby
|
|
494
|
+
get_json 'https://example.com/api/endpoint.json'
|
|
495
|
+
# => {...}
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
POSTs to a URL and follows any redirects:
|
|
499
|
+
|
|
500
|
+
```ruby
|
|
501
|
+
post 'https://example.com/form', form_data: {'foo' => 'bar'}
|
|
502
|
+
# => #<Net::HTTPResponse:...>
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
POSTs to a URL and parses the HTML response:
|
|
506
|
+
|
|
507
|
+
```ruby
|
|
508
|
+
post_html 'https://example.com/form', form_data: {'foo' => 'bar'}
|
|
509
|
+
# => #<Nokogiri::HTML::Document:...>
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
POSTs to a URL and parses the XML response:
|
|
513
|
+
|
|
514
|
+
```ruby
|
|
515
|
+
post_xml 'https://example.com/form', form_data: {'foo' => 'bar'}
|
|
516
|
+
# => #<Nokogiri::XML::Document:...>
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
POSTs to a URL and parses the JSON response:
|
|
520
|
+
|
|
521
|
+
```ruby
|
|
522
|
+
post_json 'https://example.com/api/endpoint.json', json: {foo: 'bar'}
|
|
523
|
+
# => {...}
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
### User Agents
|
|
527
|
+
|
|
528
|
+
Get a random `User-Agent` string:
|
|
529
|
+
|
|
530
|
+
```ruby
|
|
531
|
+
user_agent = UserAgents.random
|
|
532
|
+
# => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.230 Safari/537.36"
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
For more examples, see [ronin-web-user_agents][ronin-web-user_agents-examples].
|
|
536
|
+
|
|
537
|
+
[ronin-web-user_agents-examples]: https://github.com/ronin-rb/ronin-web-user_agents#examples
|
|
538
|
+
|
|
539
|
+
### Session Cookie
|
|
540
|
+
|
|
541
|
+
Parse a Django JSON session cookie:
|
|
542
|
+
|
|
543
|
+
```ruby
|
|
544
|
+
SessionCookie.parse('sessionid=eyJmb28iOiJiYXIifQ:1pQcTx:UufiSnuPIjNs7zOAJS0UpqnyvRt7KET7BVes0I8LYbA')
|
|
545
|
+
# =>
|
|
546
|
+
# #<Ronin::Web::SessionCookie::Django:0x00007f29bb9c6b70
|
|
547
|
+
# @hmac=
|
|
548
|
+
# "R\xE7\xE2J{\x8F\"3l\xEF3\x80%-\x14\xA6\xA9\xF2\xBD\e{(D\xFB\x05W\xAC\xD0\x8F\va\xB0",
|
|
549
|
+
# @params={"foo"=>"bar"},
|
|
550
|
+
# @salt=1676070425>
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
For more examples, see [ronin-web-session_cookie][ronin-web-session_cookie-examples].
|
|
554
|
+
|
|
555
|
+
[ronin-web-session_cookie-examples]: https://github.com/ronin-rb/ronin-web-session_cookie#examples
|
|
556
|
+
|
|
557
|
+
### Spider
|
|
558
|
+
|
|
559
|
+
Spider a website and print out visited URLs:
|
|
560
|
+
|
|
561
|
+
```ruby
|
|
562
|
+
Spider.site('http://www.rubyinside.com/') do |spider|
|
|
563
|
+
spider.every_url { |url| puts url }
|
|
564
|
+
end
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
For more examples, see [ronin-web-spider][ronin-web-spider-examples].
|
|
568
|
+
|
|
569
|
+
[ronin-web-spider-examples]: https://github.com/ronin-rb/ronin-web-spider#examples
|
|
570
|
+
|
|
571
|
+
### Browser
|
|
572
|
+
|
|
573
|
+
Open a visible web browser and intercept all requests:
|
|
574
|
+
|
|
575
|
+
```ruby
|
|
576
|
+
browser = Ronin::Web::Browser.new(visible: true)
|
|
577
|
+
browser.every_request do |request|
|
|
578
|
+
puts "> #{request.method} #{request.url}"
|
|
579
|
+
end
|
|
580
|
+
|
|
581
|
+
browser.go_to("https://twitter.com/login")
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
For more examples, see [ronin-web-browser][ronin-web-browser-examples].
|
|
585
|
+
|
|
586
|
+
[ronin-web-browser-examples]: https://github.com/ronin-rb/ronin-web-browser#examples
|
|
587
|
+
|
|
147
588
|
## Requirements
|
|
148
589
|
|
|
149
590
|
* [Ruby] >= 3.0.0
|
|
150
591
|
* [nokogiri] ~> 1.4
|
|
151
|
-
* [nokogiri-ext] ~> 0.1
|
|
152
592
|
* [nokogiri-diff] ~> 0.2
|
|
153
|
-
* [
|
|
593
|
+
* [robots] ~> 0.10
|
|
154
594
|
* [open_namespace] ~> 0.4
|
|
155
|
-
* [
|
|
595
|
+
* [wordlist] ~> 1.0, >= 1.0.1
|
|
596
|
+
* [ronin-support] ~> 1.1
|
|
597
|
+
* [ronin-support-web] ~> 0.1
|
|
598
|
+
* [ronin-web-browser] ~> 0.1
|
|
156
599
|
* [ronin-web-server] ~> 0.1
|
|
157
|
-
* [ronin-web-spider] ~> 0.
|
|
600
|
+
* [ronin-web-spider] ~> 0.2
|
|
158
601
|
* [ronin-web-user_agents] ~> 0.1
|
|
159
|
-
* [ronin-
|
|
602
|
+
* [ronin-web-session_cookie] ~> 0.1
|
|
603
|
+
* [ronin-core] ~> 0.2
|
|
604
|
+
* [ronin-vulns] ~> 0.2
|
|
160
605
|
|
|
161
606
|
## Install
|
|
162
607
|
|
|
@@ -169,7 +614,7 @@ $ gem install ronin-web
|
|
|
169
614
|
1. [Fork It!](https://github.com/ronin-rb/ronin-web/fork)
|
|
170
615
|
2. Clone It!
|
|
171
616
|
3. `cd ronin-web`
|
|
172
|
-
4. `
|
|
617
|
+
4. `./scripts/setup`
|
|
173
618
|
5. `git checkout -b my_feature`
|
|
174
619
|
6. Code It!
|
|
175
620
|
7. `bundle exec rake spec`
|
|
@@ -179,7 +624,7 @@ $ gem install ronin-web
|
|
|
179
624
|
|
|
180
625
|
ronin-web - A collection of useful web helper methods and commands.
|
|
181
626
|
|
|
182
|
-
Copyright (c) 2006-
|
|
627
|
+
Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
183
628
|
|
|
184
629
|
ronin-web is free software: you can redistribute it and/or modify
|
|
185
630
|
it under the terms of the GNU General Public License as published by
|
|
@@ -198,14 +643,16 @@ along with ronin-web. If not, see <https://www.gnu.org/licenses/>.
|
|
|
198
643
|
[Ruby]: https://www.ruby-lang.org
|
|
199
644
|
|
|
200
645
|
[nokogiri]: https://nokogiri.org/
|
|
201
|
-
[nokogiri-ext]: https://github.com/postmodern/nokogiri-ext#readme
|
|
202
646
|
[nokogiri-diff]: https://github.com/postmodern/nokogiri-diff#readme
|
|
203
|
-
[mechanize]: https://github.com/sparklemotion/mechanize#readme
|
|
204
647
|
[open_namespace]: https://github.com/postmodern/open_namespace#readme
|
|
205
648
|
[ronin-support]: https://github.com/ronin-rb/ronin-support#readme
|
|
649
|
+
[ronin-support-web]: https://github.com/ronin-rb/ronin-support-web#readme
|
|
206
650
|
[ronin-core]: https://github.com/ronin-rb/ronin-core#readme
|
|
651
|
+
[ronin-web-browser]: https://github.com/ronin-rb/ronin-web-browser#readme
|
|
207
652
|
[ronin-web-server]: https://github.com/ronin-rb/ronin-web-server#readme
|
|
208
653
|
[ronin-web-spider]: https://github.com/ronin-rb/ronin-web-spider#readme
|
|
209
654
|
[ronin-web-user_agents]: https://github.com/ronin-rb/ronin-web-user_agents#readme
|
|
210
655
|
[ronin]: https://github.com/ronin-rb/ronin#readme
|
|
211
656
|
[sinatra]: https://sinatrarb.com/
|
|
657
|
+
|
|
658
|
+
[XPath]: https://developer.mozilla.org/en-US/docs/Web/XPath
|
data/Rakefile
CHANGED
|
@@ -37,3 +37,12 @@ YARD::Rake::YardocTask.new
|
|
|
37
37
|
|
|
38
38
|
require 'kramdown/man/task'
|
|
39
39
|
Kramdown::Man::Task.new
|
|
40
|
+
|
|
41
|
+
require 'command_kit/completion/task'
|
|
42
|
+
CommandKit::Completion::Task.new(
|
|
43
|
+
class_file: 'ronin/web/cli',
|
|
44
|
+
class_name: 'Ronin::Web::CLI',
|
|
45
|
+
output_file: 'data/completions/ronin-web'
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
task :setup => %w[man command_kit:completion]
|