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
|
@@ -1,79 +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/network/http/http'
|
|
24
|
-
|
|
25
|
-
require 'rack'
|
|
26
|
-
|
|
27
|
-
module Ronin
|
|
28
|
-
module Web
|
|
29
|
-
module Middleware
|
|
30
|
-
class Request < Rack::Request
|
|
31
|
-
|
|
32
|
-
#
|
|
33
|
-
# Returns the remote IP address and port for the request.
|
|
34
|
-
#
|
|
35
|
-
# @param [Hash] env
|
|
36
|
-
# The request env Hash.
|
|
37
|
-
#
|
|
38
|
-
# @return [String]
|
|
39
|
-
# The IP address and port number.
|
|
40
|
-
#
|
|
41
|
-
# @since 0.3.0
|
|
42
|
-
#
|
|
43
|
-
# @api semipublic
|
|
44
|
-
#
|
|
45
|
-
def address
|
|
46
|
-
if env.has_key?('REMOTE_PORT')
|
|
47
|
-
"#{ip}:#{env['REMOTE_PORT']}"
|
|
48
|
-
else
|
|
49
|
-
ip
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
#
|
|
54
|
-
# The HTTP Headers for the request.
|
|
55
|
-
#
|
|
56
|
-
# @return [Hash{String => String}]
|
|
57
|
-
# The HTTP Headers of the request.
|
|
58
|
-
#
|
|
59
|
-
# @since 0.3.0
|
|
60
|
-
#
|
|
61
|
-
# @api public
|
|
62
|
-
#
|
|
63
|
-
def headers
|
|
64
|
-
headers = {}
|
|
65
|
-
|
|
66
|
-
env.each do |name,value|
|
|
67
|
-
if name =~ /^HTTP_/
|
|
68
|
-
header_name = Network::HTTP.header_name(name.sub('HTTP_',''))
|
|
69
|
-
headers[header_name] = value
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
return headers
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
@@ -1,33 +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 'rack'
|
|
24
|
-
|
|
25
|
-
module Ronin
|
|
26
|
-
module Web
|
|
27
|
-
module Middleware
|
|
28
|
-
class Response < Rack::Response
|
|
29
|
-
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,167 +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/middleware/rule'
|
|
24
|
-
require 'ronin/web/middleware/base'
|
|
25
|
-
|
|
26
|
-
module Ronin
|
|
27
|
-
module Web
|
|
28
|
-
module Middleware
|
|
29
|
-
#
|
|
30
|
-
# A Rack middleware for routing requests based on predefined rules.
|
|
31
|
-
#
|
|
32
|
-
# use Ronin::Web::Middleware::Router do |router|
|
|
33
|
-
# # route requests by source IP address
|
|
34
|
-
# router.draw :ip => '212.18.45.0/24', :to => BannedApp
|
|
35
|
-
# router.draw :ip => '192.168.0.0/16' do |request|
|
|
36
|
-
# response ['Nothing here'], 404
|
|
37
|
-
# end
|
|
38
|
-
#
|
|
39
|
-
# # route requests by Referer URL
|
|
40
|
-
# router.draw :referer => 'http://www.sexy.com/', :to => TrapApp
|
|
41
|
-
# router.draw :referer => /\.google\./ do |request|
|
|
42
|
-
# response ['Nothing to see here.'], 404
|
|
43
|
-
# end
|
|
44
|
-
#
|
|
45
|
-
# # route requests by User-Agent
|
|
46
|
-
# router.draw :user_agent => /Microsoft/, :to => IEApp
|
|
47
|
-
#
|
|
48
|
-
# # mix route options together
|
|
49
|
-
# router.draw :ip => '212.18.45.0/24',
|
|
50
|
-
# :user_agent => /Microsoft/, :to => PwnApp
|
|
51
|
-
# end
|
|
52
|
-
#
|
|
53
|
-
class Router < Base
|
|
54
|
-
|
|
55
|
-
# The routes of the router
|
|
56
|
-
attr_reader :routes
|
|
57
|
-
|
|
58
|
-
#
|
|
59
|
-
# Creates a new Router middleware.
|
|
60
|
-
#
|
|
61
|
-
# @param [#call] app
|
|
62
|
-
# The application that the router sits in front of.
|
|
63
|
-
#
|
|
64
|
-
# @param [Hash] options
|
|
65
|
-
# Additional options.
|
|
66
|
-
#
|
|
67
|
-
# @yield [router]
|
|
68
|
-
# If a block is given, it will be passed the newly created
|
|
69
|
-
# router middleware.
|
|
70
|
-
#
|
|
71
|
-
# @yieldparam [Router] router
|
|
72
|
-
# The new router middleware object.
|
|
73
|
-
#
|
|
74
|
-
# @since 0.3.0
|
|
75
|
-
#
|
|
76
|
-
# @api public
|
|
77
|
-
#
|
|
78
|
-
def initialize(app,options={},&block)
|
|
79
|
-
@routes = {}
|
|
80
|
-
|
|
81
|
-
super(app,options,&block)
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
#
|
|
85
|
-
# Defines a rule to route requests by.
|
|
86
|
-
#
|
|
87
|
-
# @param [Hash] options
|
|
88
|
-
# Filter options.
|
|
89
|
-
#
|
|
90
|
-
# @option options [String] :campaign
|
|
91
|
-
# The name of the campaign who's targetted hosts will be routed.
|
|
92
|
-
#
|
|
93
|
-
# @option options [String, Regexp] :vhost
|
|
94
|
-
# The Virtual-Host to route.
|
|
95
|
-
#
|
|
96
|
-
# @option options [String, IPAddr] :ip
|
|
97
|
-
# The IP address or IP range to route.
|
|
98
|
-
#
|
|
99
|
-
# @option options [String, Regexp] :referer
|
|
100
|
-
# The Referer URL or pattern to route.
|
|
101
|
-
#
|
|
102
|
-
# @option options [String, Regexp] :user_agent
|
|
103
|
-
# The User-Agent string to route.
|
|
104
|
-
#
|
|
105
|
-
# @option options [Proc] :when
|
|
106
|
-
# Custom logic to route requests by.
|
|
107
|
-
#
|
|
108
|
-
# @option options [#call] :to
|
|
109
|
-
# The application that will receive routed requests.
|
|
110
|
-
#
|
|
111
|
-
# @yield [request]
|
|
112
|
-
# If a block is given, it will receive routed requests.
|
|
113
|
-
#
|
|
114
|
-
# @yieldparam [Rack::Request] request
|
|
115
|
-
# A routed request.
|
|
116
|
-
#
|
|
117
|
-
# @return [#call]
|
|
118
|
-
# The application that is being routed.
|
|
119
|
-
#
|
|
120
|
-
# @example Route requests going to an application.
|
|
121
|
-
# router.draw :ip => '210.18.0.0/16', :to => BannedApp
|
|
122
|
-
#
|
|
123
|
-
# @example Accept routed requests using a block.
|
|
124
|
-
# router.draw :ip => '210.18.0.0/16' do |request|
|
|
125
|
-
# response ['Banned!']
|
|
126
|
-
# end
|
|
127
|
-
#
|
|
128
|
-
# @since 0.3.0
|
|
129
|
-
#
|
|
130
|
-
# @api public
|
|
131
|
-
#
|
|
132
|
-
def draw(options={},&block)
|
|
133
|
-
app = (options.delete(:to) || block)
|
|
134
|
-
|
|
135
|
-
return @routes[Rule.new(options)] = app
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
#
|
|
139
|
-
# Filters requests based on the defined routes.
|
|
140
|
-
#
|
|
141
|
-
# @param [Hash, Rack::Request] env
|
|
142
|
-
# An incoming request.
|
|
143
|
-
#
|
|
144
|
-
# @return [Array, Response]
|
|
145
|
-
# A response.
|
|
146
|
-
#
|
|
147
|
-
# @since 0.3.0
|
|
148
|
-
#
|
|
149
|
-
# @api public
|
|
150
|
-
#
|
|
151
|
-
def call(env)
|
|
152
|
-
request = Request.new(env)
|
|
153
|
-
|
|
154
|
-
@routes.each do |rule,app|
|
|
155
|
-
if rule.match?(request)
|
|
156
|
-
print_info "Routing #{request.url} for #{request.address}"
|
|
157
|
-
return app.call(env)
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
super(env)
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
end
|
|
@@ -1,103 +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/middleware/filters'
|
|
24
|
-
|
|
25
|
-
module Ronin
|
|
26
|
-
module Web
|
|
27
|
-
module Middleware
|
|
28
|
-
#
|
|
29
|
-
# Matches requests against one or more filters.
|
|
30
|
-
#
|
|
31
|
-
class Rule
|
|
32
|
-
|
|
33
|
-
# Registered filters
|
|
34
|
-
FILTERS = {
|
|
35
|
-
:ip => Filters::IPFilter,
|
|
36
|
-
:campaign => Filters::CampaignFilter,
|
|
37
|
-
:path => Filters::PathFilter,
|
|
38
|
-
:vhost => Filters::VHostFilter,
|
|
39
|
-
:referer => Filters::RefererFilter,
|
|
40
|
-
:user_agent => Filters::UserAgentFilter
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
#
|
|
44
|
-
# Creates a new rule.
|
|
45
|
-
#
|
|
46
|
-
# @param [Hash] options
|
|
47
|
-
# Additional filtering options for the rule.
|
|
48
|
-
#
|
|
49
|
-
# @option options [String] :campaign
|
|
50
|
-
# The name of the campaign who's targetted hosts will be
|
|
51
|
-
# filtered by.
|
|
52
|
-
#
|
|
53
|
-
# @option options [String, Regexp] :vhost
|
|
54
|
-
# The Virtual-Host to filter.
|
|
55
|
-
#
|
|
56
|
-
# @option options [String, IPAddr] :ip
|
|
57
|
-
# The IP address or IP range to filter.
|
|
58
|
-
#
|
|
59
|
-
# @option options [String, Regexp] :referer
|
|
60
|
-
# The Referer URL or pattern to filter.
|
|
61
|
-
#
|
|
62
|
-
# @option options [String, Regexp] :user_agent
|
|
63
|
-
# The User-Agent string to filter.
|
|
64
|
-
#
|
|
65
|
-
# @option options [Proc] :when
|
|
66
|
-
# Custom logic to filter requests by.
|
|
67
|
-
#
|
|
68
|
-
# @since 0.3.0
|
|
69
|
-
#
|
|
70
|
-
# @api public
|
|
71
|
-
#
|
|
72
|
-
def initialize(options={},&block)
|
|
73
|
-
@filters = []
|
|
74
|
-
@when_block = options.delete(:when)
|
|
75
|
-
|
|
76
|
-
options.each do |name,value|
|
|
77
|
-
if FILTERS.has_key?(name)
|
|
78
|
-
@filters << FILTERS[name].new(value)
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
#
|
|
84
|
-
# Matches a request against the rule.
|
|
85
|
-
#
|
|
86
|
-
# @param [Rack::Request] request
|
|
87
|
-
# The request to match.
|
|
88
|
-
#
|
|
89
|
-
# @return [Boolean]
|
|
90
|
-
# Specifies if the request matches all of the filters.
|
|
91
|
-
#
|
|
92
|
-
# @api public
|
|
93
|
-
#
|
|
94
|
-
def match?(request)
|
|
95
|
-
@filters.all? { |filter|
|
|
96
|
-
filter.match?(request)
|
|
97
|
-
} && (@when_block.nil? || (@when_block.call(request) ? true : false))
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
data/lib/ronin/web/middleware.rb
DELETED
|
@@ -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/middleware/base'
|
|
24
|
-
require 'ronin/web/middleware/files'
|
|
25
|
-
require 'ronin/web/middleware/directories'
|
|
26
|
-
require 'ronin/web/middleware/router'
|
|
27
|
-
require 'ronin/web/middleware/proxy'
|
data/lib/ronin/web/proxy/app.rb
DELETED
|
@@ -1,32 +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/proxy/base'
|
|
24
|
-
|
|
25
|
-
module Ronin
|
|
26
|
-
module Web
|
|
27
|
-
module Proxy
|
|
28
|
-
class App < Base
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
data/lib/ronin/web/proxy/base.rb
DELETED
|
@@ -1,46 +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/server/base'
|
|
24
|
-
require 'ronin/web/middleware/proxy'
|
|
25
|
-
|
|
26
|
-
module Ronin
|
|
27
|
-
module Web
|
|
28
|
-
module Proxy
|
|
29
|
-
#
|
|
30
|
-
# The base-class for all Ronin Web Proxies. Extends
|
|
31
|
-
# [Sinatra::Base](http://rubydoc.info/gems/sinatra/Sinatra/Base)
|
|
32
|
-
# with {Middleware::Proxy}.
|
|
33
|
-
#
|
|
34
|
-
class Base < Server::Base
|
|
35
|
-
|
|
36
|
-
# The default port to run the Web Proxy on
|
|
37
|
-
DEFAULT_PORT = 8080
|
|
38
|
-
|
|
39
|
-
set :port, DEFAULT_PORT
|
|
40
|
-
|
|
41
|
-
use Middleware::Proxy
|
|
42
|
-
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
data/lib/ronin/web/proxy/web.rb
DELETED
|
@@ -1,46 +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/proxy/app'
|
|
24
|
-
|
|
25
|
-
module Ronin
|
|
26
|
-
module Web
|
|
27
|
-
#
|
|
28
|
-
# Returns the Ronin Web Proxy. When called for the first time
|
|
29
|
-
# the proxy will be started in the background.
|
|
30
|
-
#
|
|
31
|
-
# @see Server::Base.run!
|
|
32
|
-
#
|
|
33
|
-
# @api public
|
|
34
|
-
#
|
|
35
|
-
def Web.proxy_server(options={},&block)
|
|
36
|
-
unless class_variable_defined?('@@ronin_web_proxy')
|
|
37
|
-
@@ronin_web_proxy = Proxy::App
|
|
38
|
-
@@ronin_web_proxy.run!(options.merge(:background => true))
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
@@ronin_web_proxy.class_eval(&block)
|
|
42
|
-
|
|
43
|
-
return @@ronin_web_proxy
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
data/lib/ronin/web/proxy.rb
DELETED
|
@@ -1,25 +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/proxy/base'
|
|
24
|
-
require 'ronin/web/proxy/app'
|
|
25
|
-
require 'ronin/web/proxy/web'
|
data/lib/ronin/web/server/app.rb
DELETED
|
@@ -1,32 +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/server/base'
|
|
24
|
-
|
|
25
|
-
module Ronin
|
|
26
|
-
module Web
|
|
27
|
-
module Server
|
|
28
|
-
class App < Base
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|