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,77 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/web/server/base'
|
3
|
-
|
4
|
-
require 'web/server/classes/test_app'
|
5
|
-
require 'web/helpers/rack_app'
|
6
|
-
|
7
|
-
describe Web::Server::Base do
|
8
|
-
include Helpers::Web::RackApp
|
9
|
-
|
10
|
-
before(:all) do
|
11
|
-
self.app = TestApp
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should find a suitable Rack::Handler for the web server" do
|
15
|
-
TestApp.handler_class.should_not be_nil
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should still bind blocks to paths" do
|
19
|
-
get '/tests/get'
|
20
|
-
|
21
|
-
last_response.should be_ok
|
22
|
-
last_response.body.should == 'block tested'
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should bind a block to a path for all request types" do
|
26
|
-
post '/tests/any'
|
27
|
-
|
28
|
-
last_response.should be_ok
|
29
|
-
last_response.body.should == 'any tested'
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should have a default response" do
|
33
|
-
get '/totally/non/existant/path'
|
34
|
-
|
35
|
-
last_response.should_not be_ok
|
36
|
-
last_response.body.should be_empty
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should allow for defining custom responses" do
|
40
|
-
TestApp.default do
|
41
|
-
halt 404, 'nothing to see here'
|
42
|
-
end
|
43
|
-
|
44
|
-
get '/whats/here'
|
45
|
-
|
46
|
-
last_response.should_not be_ok
|
47
|
-
last_response.body.should == 'nothing to see here'
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should map paths to sub-apps" do
|
51
|
-
get '/tests/subapp/'
|
52
|
-
|
53
|
-
last_response.should be_ok
|
54
|
-
last_response.body.should == 'SubApp'
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should not modify the path_info as it maps paths to sub-apps" do
|
58
|
-
get '/tests/subapp/hello'
|
59
|
-
|
60
|
-
last_response.should be_ok
|
61
|
-
last_response.body.should == 'SubApp greets you'
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should host static content from public directories" do
|
65
|
-
get '/static1.txt'
|
66
|
-
|
67
|
-
last_response.should be_ok
|
68
|
-
last_response.body.should == "Static file1.\n"
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should host static content from multiple public directories" do
|
72
|
-
get '/static2.txt'
|
73
|
-
|
74
|
-
last_response.should be_ok
|
75
|
-
last_response.body.should == "Static file2.\n"
|
76
|
-
end
|
77
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
Static file1.
|
@@ -1 +0,0 @@
|
|
1
|
-
Static file2.
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'ronin/web/server/base'
|
2
|
-
|
3
|
-
require 'web/server/classes/sub_app'
|
4
|
-
|
5
|
-
class TestApp < Ronin::Web::Server::Base
|
6
|
-
|
7
|
-
get '/tests/get' do
|
8
|
-
'block tested'
|
9
|
-
end
|
10
|
-
|
11
|
-
any '/tests/any' do
|
12
|
-
'any tested'
|
13
|
-
end
|
14
|
-
|
15
|
-
map '/tests/subapp/', SubApp
|
16
|
-
|
17
|
-
public_dir File.join(File.dirname(__FILE__),'public1')
|
18
|
-
public_dir File.join(File.dirname(__FILE__),'public2')
|
19
|
-
|
20
|
-
end
|
data/spec/web/web_spec.rb
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/web/web'
|
3
|
-
|
4
|
-
describe Web do
|
5
|
-
let(:url) { 'http://ronin-ruby.github.com/' }
|
6
|
-
let(:title) { 'Ronin' }
|
7
|
-
|
8
|
-
it "should have a VERSION constant" do
|
9
|
-
Web.const_defined?('VERSION').should == true
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should be able to parse HTML" do
|
13
|
-
doc = Web.html(%{
|
14
|
-
<html>
|
15
|
-
<body>Hello</body>
|
16
|
-
</html>
|
17
|
-
})
|
18
|
-
|
19
|
-
doc.at('body').inner_text.should == "Hello"
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should be able to build HTML documents" do
|
23
|
-
doc = Web.build_html do
|
24
|
-
html {
|
25
|
-
body {
|
26
|
-
div { text("hello") }
|
27
|
-
}
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
doc.to_html.should include("<html><body><div>hello</div></body></html>")
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should be able to parse XML" do
|
35
|
-
doc = Web.html(%{
|
36
|
-
<?xml version="1.0"?>
|
37
|
-
<root>
|
38
|
-
<stuff>Hello</stuff>
|
39
|
-
</root>
|
40
|
-
})
|
41
|
-
|
42
|
-
doc.at('stuff').inner_text.should == "Hello"
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should be able to build XML documents" do
|
46
|
-
doc = Web.build_xml do
|
47
|
-
root {
|
48
|
-
stuff(:name => 'bla') { text("hello") }
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
doc.to_xml.should include("<root>\n <stuff name=\"bla\">hello</stuff>\n</root>")
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should have a default proxy" do
|
56
|
-
Web.proxy.should_not be_nil
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should disable the proxy by default" do
|
60
|
-
Web.proxy.should_not be_enabled
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should provide User-Agent aliases" do
|
64
|
-
Web.user_agent_aliases.should_not be_empty
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should provide a default User-Agent" do
|
68
|
-
Web.user_agent.should be_nil
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should allow setting of the User-Agent string using an alias" do
|
72
|
-
Web.user_agent_alias = 'Mac FireFox'
|
73
|
-
|
74
|
-
Web.user_agent.should == "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6"
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should open URLs as temporary files" do
|
78
|
-
file = Web.open(url)
|
79
|
-
|
80
|
-
file.read.should include(title)
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "agent" do
|
84
|
-
it "should provide Mechanize agents" do
|
85
|
-
Web.agent.class.should == Mechanize
|
86
|
-
end
|
87
|
-
|
88
|
-
describe ":user_agent" do
|
89
|
-
before(:all) do
|
90
|
-
Web.user_agent = 'test'
|
91
|
-
end
|
92
|
-
|
93
|
-
it "should default to Web.user_agent" do
|
94
|
-
Web.agent.user_agent.should == 'test'
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should support using a custom User-Agent string" do
|
98
|
-
agent = Web.agent(:user_agent => 'test2')
|
99
|
-
|
100
|
-
agent.user_agent.should == 'test2'
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should support using a custom User-Agent alias" do
|
104
|
-
agent = Web.agent(:user_agent_alias => 'iPhone')
|
105
|
-
|
106
|
-
agent.user_agent.should == "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C28 Safari/419.3"
|
107
|
-
end
|
108
|
-
|
109
|
-
after(:all) do
|
110
|
-
Web.user_agent = nil
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe ":proxy" do
|
115
|
-
let(:host) { '127.0.0.1' }
|
116
|
-
let(:port) { 8080 }
|
117
|
-
|
118
|
-
before(:all) do
|
119
|
-
Web.proxy = {:host => 'www.example.com', :port => port}
|
120
|
-
end
|
121
|
-
|
122
|
-
it "should default to Web.proxy" do
|
123
|
-
agent = Web.agent
|
124
|
-
|
125
|
-
agent.proxy_addr.should == Web.proxy.host
|
126
|
-
agent.proxy_port.should == Web.proxy.port
|
127
|
-
end
|
128
|
-
|
129
|
-
it "should support using custom proxies" do
|
130
|
-
agent = Web.agent(:proxy => Network::HTTP::Proxy.new(
|
131
|
-
:host => host,
|
132
|
-
:port => port
|
133
|
-
))
|
134
|
-
|
135
|
-
agent.proxy_addr.should == host
|
136
|
-
agent.proxy_port.should == port
|
137
|
-
end
|
138
|
-
|
139
|
-
after(:all) do
|
140
|
-
Web.proxy = nil
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
it "should be able to get Mechanize pages" do
|
146
|
-
page = Web.get(url)
|
147
|
-
|
148
|
-
page.class.should == Mechanize::Page
|
149
|
-
page.at('title').inner_text.should include(title)
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should be able to get the bodies of Mechanize pages" do
|
153
|
-
body = Web.get_body(url)
|
154
|
-
|
155
|
-
body.should include(title)
|
156
|
-
end
|
157
|
-
end
|