ronin-web 0.1.0
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.
- data/History.txt +15 -0
- data/Manifest.txt +25 -0
- data/README.txt +74 -0
- data/Rakefile +21 -0
- data/lib/ronin/sessions/web.rb +80 -0
- data/lib/ronin/web/extensions/nokogiri/xml/attr.rb +13 -0
- data/lib/ronin/web/extensions/nokogiri/xml/document.rb +18 -0
- data/lib/ronin/web/extensions/nokogiri/xml/element.rb +23 -0
- data/lib/ronin/web/extensions/nokogiri/xml/node.rb +47 -0
- data/lib/ronin/web/extensions/nokogiri/xml/text.rb +13 -0
- data/lib/ronin/web/extensions/nokogiri/xml.rb +5 -0
- data/lib/ronin/web/extensions/nokogiri.rb +24 -0
- data/lib/ronin/web/extensions.rb +24 -0
- data/lib/ronin/web/server.rb +511 -0
- data/lib/ronin/web/spider.rb +89 -0
- data/lib/ronin/web/version.rb +29 -0
- data/lib/ronin/web/web.rb +305 -0
- data/lib/ronin/web.rb +25 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/web/extensions/nokogiri_spec.rb +38 -0
- data/spec/web/helpers/root/index.html +1 -0
- data/spec/web/helpers/root/test.txt +1 -0
- data/spec/web/helpers/server.rb +2 -0
- data/spec/web/server_spec.rb +142 -0
- data/tasks/spec.rb +9 -0
- metadata +141 -0
data/History.txt
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
=== 0.1.0 / 2009-01-22
|
2
|
+
|
3
|
+
* Initial release.
|
4
|
+
* Provides Web.html and Web.xml methods, which use Nokogiri::HTML and
|
5
|
+
Nokogiri::XML respectively, to parse HTML and XML content.
|
6
|
+
* Supports custom Proxy and User-Agent strings, through
|
7
|
+
the Web.proxy and Web.user_agent methods respectively.
|
8
|
+
* Provides Web.agent, Web.get and Weg.post methods which access
|
9
|
+
WWW::Mechanize.
|
10
|
+
* Integrates Spidr::Agent into Web::Spider.
|
11
|
+
* Provides Web::Server, a customizable Rack web server that supports path
|
12
|
+
and host-name routing.
|
13
|
+
* Web::Server will use Mongrel, only if Mongrel is installed, otherwise
|
14
|
+
WEBrick will be used.
|
15
|
+
|
data/Manifest.txt
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
lib/ronin/sessions/web.rb
|
6
|
+
lib/ronin/web.rb
|
7
|
+
lib/ronin/web/extensions.rb
|
8
|
+
lib/ronin/web/extensions/nokogiri.rb
|
9
|
+
lib/ronin/web/extensions/nokogiri/xml.rb
|
10
|
+
lib/ronin/web/extensions/nokogiri/xml/node.rb
|
11
|
+
lib/ronin/web/extensions/nokogiri/xml/text.rb
|
12
|
+
lib/ronin/web/extensions/nokogiri/xml/attr.rb
|
13
|
+
lib/ronin/web/extensions/nokogiri/xml/element.rb
|
14
|
+
lib/ronin/web/extensions/nokogiri/xml/document.rb
|
15
|
+
lib/ronin/web/server.rb
|
16
|
+
lib/ronin/web/spider.rb
|
17
|
+
lib/ronin/web/web.rb
|
18
|
+
lib/ronin/web/version.rb
|
19
|
+
tasks/spec.rb
|
20
|
+
spec/spec_helper.rb
|
21
|
+
spec/web/helpers/server.rb
|
22
|
+
spec/web/helpers/root/index.html
|
23
|
+
spec/web/helpers/root/test.txt
|
24
|
+
spec/web/extensions/nokogiri_spec.rb
|
25
|
+
spec/web/server_spec.rb
|
data/README.txt
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
= Ronin Web
|
2
|
+
|
3
|
+
* http://ronin.rubyforge.org/web/
|
4
|
+
* http://github.com/postmodern/ronin-web
|
5
|
+
* irc.freenode.net ##ronin
|
6
|
+
* Postmodern (postmodern.mod3 at gmail.com)
|
7
|
+
|
8
|
+
== DESCRIPTION:
|
9
|
+
|
10
|
+
Ronin Web is a Ruby library for Ronin that provides support for web
|
11
|
+
scraping and spidering functionality.
|
12
|
+
|
13
|
+
Ronin is a Ruby platform designed for information security and data
|
14
|
+
exploration tasks. Ronin allows for the rapid development and distribution
|
15
|
+
of code over many of the common Source-Code-Management (SCM) systems.
|
16
|
+
|
17
|
+
=== Free
|
18
|
+
|
19
|
+
All source code within Ronin is licensed under the GPL-2, therefore no user
|
20
|
+
will ever have to pay for Ronin or updates to Ronin. Not only is the
|
21
|
+
source code free, the Ronin project will not sell enterprise grade security
|
22
|
+
snake-oil solutions, give private training classes or later turn Ronin into
|
23
|
+
commercial software.
|
24
|
+
|
25
|
+
=== Modular
|
26
|
+
|
27
|
+
Ronin was not designed as one monolithic framework but instead as a
|
28
|
+
collection of libraries which can be individually installed. This allows
|
29
|
+
users to pick and choose what functionality they want in Ronin.
|
30
|
+
|
31
|
+
=== Decentralized
|
32
|
+
|
33
|
+
Ronin does not have a central repository of exploits and payloads which
|
34
|
+
all developers contribute to. Instead Ronin has Overlays, repositories of
|
35
|
+
code that can be hosted on any CVS/SVN/Git/Rsync server. Users can then use
|
36
|
+
Ronin to quickly install or update Overlays. This allows developers and
|
37
|
+
users to form their own communities, independent of the main developers
|
38
|
+
of Ronin.
|
39
|
+
|
40
|
+
== FEATURES/PROBLEMS:
|
41
|
+
|
42
|
+
* Web access (utilizing Mechanize and Hpricot).
|
43
|
+
* Integrates Spidr into Ronin::Web::Spider.
|
44
|
+
* Provides a custom Rack web-server based on Rack::Builder.
|
45
|
+
|
46
|
+
== REQUIREMENTS:
|
47
|
+
|
48
|
+
* nokogiri >= 1.1.0
|
49
|
+
* mechanize >= 0.9.0
|
50
|
+
* spidr >= 0.1.3
|
51
|
+
* rack >= 0.9.1
|
52
|
+
* ronin >= 0.1.4
|
53
|
+
|
54
|
+
== INSTALL:
|
55
|
+
|
56
|
+
$ sudo gem install ronin-web
|
57
|
+
|
58
|
+
== LICENSE:
|
59
|
+
|
60
|
+
Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
61
|
+
|
62
|
+
This program is free software; you can redistribute it and/or modify
|
63
|
+
it under the terms of the GNU General Public License as published by
|
64
|
+
the Free Software Foundation; either version 2 of the License, or
|
65
|
+
(at your option) any later version.
|
66
|
+
|
67
|
+
This program is distributed in the hope that it will be useful,
|
68
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
69
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
70
|
+
GNU General Public License for more details.
|
71
|
+
|
72
|
+
You should have received a copy of the GNU General Public License
|
73
|
+
along with this program; if not, write to the Free Software
|
74
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './tasks/spec.rb'
|
6
|
+
require './lib/ronin/web/version.rb'
|
7
|
+
|
8
|
+
Hoe.new('ronin-web', Ronin::Web::VERSION) do |p|
|
9
|
+
p.rubyforge_name = 'ronin'
|
10
|
+
p.developer('Postmodern', 'postmodern.mod3@gmail.com')
|
11
|
+
p.remote_rdoc_dir = 'docs/ronin-web'
|
12
|
+
p.extra_deps = [
|
13
|
+
['nokogiri', '>=1.1.0'],
|
14
|
+
['mechanize', '>=0.9.0'],
|
15
|
+
['spidr', '>=0.1.3'],
|
16
|
+
['rack', '>=0.9.1'],
|
17
|
+
['ronin', '>=0.1.4']
|
18
|
+
]
|
19
|
+
end
|
20
|
+
|
21
|
+
# vim: syntax=Ruby
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
# Ronin Web - A Ruby library for Ronin that provides support for web
|
4
|
+
# scraping and spidering functionality.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
#++
|
22
|
+
#
|
23
|
+
|
24
|
+
require 'ronin/sessions/session'
|
25
|
+
require 'ronin/web/web'
|
26
|
+
|
27
|
+
module Ronin
|
28
|
+
module Sessions
|
29
|
+
module Web
|
30
|
+
include Session
|
31
|
+
|
32
|
+
setup_session do
|
33
|
+
parameter :web_proxy,
|
34
|
+
:default => lambda { Ronin::Web.proxy },
|
35
|
+
:description => 'Web Proxy'
|
36
|
+
|
37
|
+
parameter :web_user_agent,
|
38
|
+
:default => lambda { Ronin::Web.user_agent },
|
39
|
+
:description => 'Web User-Agent'
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
def web_agent(options={},&block)
|
45
|
+
options[:proxy] ||= @web_proxy
|
46
|
+
options[:user_agent] ||= @web_user_agent
|
47
|
+
|
48
|
+
return Ronin::Web.agent(options,&block)
|
49
|
+
end
|
50
|
+
|
51
|
+
def web_get(uri,options={},&block)
|
52
|
+
page = web_agent(options).get(uri)
|
53
|
+
|
54
|
+
block.call(page) if block
|
55
|
+
return page
|
56
|
+
end
|
57
|
+
|
58
|
+
def web_get_body(uri,options={},&block)
|
59
|
+
body = web_agent(options).get(uri).body
|
60
|
+
|
61
|
+
block.call(body) if block
|
62
|
+
return body
|
63
|
+
end
|
64
|
+
|
65
|
+
def web_post(uri,options={},&block)
|
66
|
+
page = web_agent(options).post(uri)
|
67
|
+
|
68
|
+
block.call(page) if block
|
69
|
+
return page
|
70
|
+
end
|
71
|
+
|
72
|
+
def web_post_body(uri,options={},&block)
|
73
|
+
body = web_agent(options).post(uri).body
|
74
|
+
|
75
|
+
block.call(body) if block
|
76
|
+
return body
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'nokogiri/xml/document'
|
2
|
+
|
3
|
+
module Nokogiri
|
4
|
+
module XML
|
5
|
+
class Document < Node
|
6
|
+
|
7
|
+
#
|
8
|
+
# Returns the total count of all sub-children of the document.
|
9
|
+
#
|
10
|
+
def total_children
|
11
|
+
return 0 unless root
|
12
|
+
|
13
|
+
1 + root.total_children
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'nokogiri/xml/element'
|
2
|
+
|
3
|
+
module Nokogiri
|
4
|
+
module XML
|
5
|
+
class Element < Node
|
6
|
+
|
7
|
+
def similar?(other)
|
8
|
+
return false unless super(other)
|
9
|
+
return false unless attribute_nodes.length == other.attribute_nodes.length
|
10
|
+
|
11
|
+
(0...attribute_nodes.length).each do |index|
|
12
|
+
attr1 = attribute_nodes[index]
|
13
|
+
attr2 = other.attribute_nodes[index]
|
14
|
+
|
15
|
+
return false unless attr1.similar?(attr2)
|
16
|
+
end
|
17
|
+
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'nokogiri/xml/node'
|
2
|
+
|
3
|
+
module Nokogiri
|
4
|
+
module XML
|
5
|
+
class Node
|
6
|
+
|
7
|
+
#
|
8
|
+
# Returns the total count of all sub-children of the node.
|
9
|
+
#
|
10
|
+
def total_children
|
11
|
+
count = 0
|
12
|
+
first = self.child
|
13
|
+
|
14
|
+
return count unless first
|
15
|
+
|
16
|
+
while first
|
17
|
+
count += (1 + first.total_children)
|
18
|
+
|
19
|
+
first = first.next
|
20
|
+
end
|
21
|
+
|
22
|
+
count
|
23
|
+
end
|
24
|
+
|
25
|
+
def traverse_text(&block)
|
26
|
+
block.call(self) if text?
|
27
|
+
|
28
|
+
first = self.child
|
29
|
+
|
30
|
+
while first
|
31
|
+
first.traverse_text(&block)
|
32
|
+
|
33
|
+
first = first.next
|
34
|
+
end
|
35
|
+
|
36
|
+
self
|
37
|
+
end
|
38
|
+
|
39
|
+
def similar?(other)
|
40
|
+
return false unless other
|
41
|
+
|
42
|
+
(self.type == other.type) && (self.name == other.name)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
# Ronin Web - A Ruby library for Ronin that provides support for web
|
4
|
+
# scraping and spidering functionality.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
#++
|
22
|
+
#
|
23
|
+
|
24
|
+
require 'ronin/web/extensions/nokogiri/xml'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
# Ronin Web - A Ruby library for Ronin that provides support for web
|
4
|
+
# scraping and spidering functionality.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
7
|
+
#
|
8
|
+
# This program is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program; if not, write to the Free Software
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
#++
|
22
|
+
#
|
23
|
+
|
24
|
+
require 'ronin/web/extensions/nokogiri'
|