ronin 0.0.9
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/COPYING.txt +339 -0
- data/History.txt +34 -0
- data/Manifest.txt +157 -0
- data/README.txt +131 -0
- data/Rakefile +23 -0
- data/TODO.txt +6 -0
- data/bin/ronin +12 -0
- data/lib/ronin.rb +35 -0
- data/lib/ronin/arch.rb +86 -0
- data/lib/ronin/author.rb +88 -0
- data/lib/ronin/cache.rb +27 -0
- data/lib/ronin/cache/config.rb +34 -0
- data/lib/ronin/cache/exceptions.rb +25 -0
- data/lib/ronin/cache/exceptions/extension_not_found.rb +29 -0
- data/lib/ronin/cache/exceptions/overlay_cached.rb +29 -0
- data/lib/ronin/cache/exceptions/overlay_not_found.rb +29 -0
- data/lib/ronin/cache/extension.rb +706 -0
- data/lib/ronin/cache/extension_cache.rb +108 -0
- data/lib/ronin/cache/overlay.rb +418 -0
- data/lib/ronin/cache/overlay_cache.rb +228 -0
- data/lib/ronin/cache/ronin.rb +50 -0
- data/lib/ronin/chars.rb +25 -0
- data/lib/ronin/chars/char_set.rb +121 -0
- data/lib/ronin/chars/chars.rb +180 -0
- data/lib/ronin/config.rb +31 -0
- data/lib/ronin/console.rb +127 -0
- data/lib/ronin/context.rb +233 -0
- data/lib/ronin/database.rb +122 -0
- data/lib/ronin/environment.rb +39 -0
- data/lib/ronin/exceptions/context_not_found.rb +27 -0
- data/lib/ronin/exceptions/invalid_database_config.rb +27 -0
- data/lib/ronin/exceptions/object_context_not_found.rb +27 -0
- data/lib/ronin/exceptions/unknown_context.rb +27 -0
- data/lib/ronin/exceptions/unknown_object_context.rb +27 -0
- data/lib/ronin/extensions.rb +28 -0
- data/lib/ronin/extensions/hash.rb +62 -0
- data/lib/ronin/extensions/kernel.rb +34 -0
- data/lib/ronin/extensions/meta.rb +24 -0
- data/lib/ronin/extensions/meta/object.rb +24 -0
- data/lib/ronin/extensions/string.rb +37 -0
- data/lib/ronin/extensions/uri.rb +24 -0
- data/lib/ronin/extensions/uri/http.rb +78 -0
- data/lib/ronin/extensions/uri/query_params.rb +97 -0
- data/lib/ronin/formatting.rb +29 -0
- data/lib/ronin/formatting/binary.rb +24 -0
- data/lib/ronin/formatting/digest.rb +24 -0
- data/lib/ronin/formatting/extensions.rb +26 -0
- data/lib/ronin/formatting/extensions/binary.rb +25 -0
- data/lib/ronin/formatting/extensions/binary/integer.rb +59 -0
- data/lib/ronin/formatting/extensions/binary/string.rb +73 -0
- data/lib/ronin/formatting/extensions/digest.rb +24 -0
- data/lib/ronin/formatting/extensions/digest/string.rb +65 -0
- data/lib/ronin/formatting/extensions/html.rb +24 -0
- data/lib/ronin/formatting/extensions/html/string.rb +75 -0
- data/lib/ronin/formatting/extensions/http.rb +24 -0
- data/lib/ronin/formatting/extensions/http/string.rb +69 -0
- data/lib/ronin/formatting/extensions/text.rb +24 -0
- data/lib/ronin/formatting/extensions/text/string.rb +96 -0
- data/lib/ronin/formatting/html.rb +24 -0
- data/lib/ronin/formatting/http.rb +24 -0
- data/lib/ronin/formatting/text.rb +24 -0
- data/lib/ronin/license.rb +87 -0
- data/lib/ronin/model.rb +44 -0
- data/lib/ronin/models.rb +34 -0
- data/lib/ronin/network.rb +31 -0
- data/lib/ronin/network/esmtp.rb +24 -0
- data/lib/ronin/network/extensions.rb +31 -0
- data/lib/ronin/network/extensions/esmtp.rb +24 -0
- data/lib/ronin/network/extensions/esmtp/net.rb +68 -0
- data/lib/ronin/network/extensions/http.rb +24 -0
- data/lib/ronin/network/extensions/http/net.rb +303 -0
- data/lib/ronin/network/extensions/imap.rb +24 -0
- data/lib/ronin/network/extensions/imap/net.rb +92 -0
- data/lib/ronin/network/extensions/pop3.rb +24 -0
- data/lib/ronin/network/extensions/pop3/net.rb +65 -0
- data/lib/ronin/network/extensions/smtp.rb +24 -0
- data/lib/ronin/network/extensions/smtp/net.rb +80 -0
- data/lib/ronin/network/extensions/tcp.rb +24 -0
- data/lib/ronin/network/extensions/tcp/net.rb +94 -0
- data/lib/ronin/network/extensions/telnet.rb +24 -0
- data/lib/ronin/network/extensions/telnet/net.rb +132 -0
- data/lib/ronin/network/extensions/udp.rb +24 -0
- data/lib/ronin/network/extensions/udp/net.rb +99 -0
- data/lib/ronin/network/http.rb +128 -0
- data/lib/ronin/network/http/exceptions.rb +24 -0
- data/lib/ronin/network/http/exceptions/unknown_request.rb +31 -0
- data/lib/ronin/network/imap.rb +47 -0
- data/lib/ronin/network/pop3.rb +47 -0
- data/lib/ronin/network/smtp.rb +26 -0
- data/lib/ronin/network/smtp/email.rb +126 -0
- data/lib/ronin/network/smtp/smtp.rb +55 -0
- data/lib/ronin/network/tcp.rb +24 -0
- data/lib/ronin/network/telnet.rb +95 -0
- data/lib/ronin/network/udp.rb +24 -0
- data/lib/ronin/object_context.rb +257 -0
- data/lib/ronin/objects.rb +29 -0
- data/lib/ronin/parameters.rb +27 -0
- data/lib/ronin/parameters/class_param.rb +45 -0
- data/lib/ronin/parameters/exceptions.rb +25 -0
- data/lib/ronin/parameters/exceptions/missing_param.rb +29 -0
- data/lib/ronin/parameters/exceptions/param_not_found.rb +29 -0
- data/lib/ronin/parameters/instance_param.rb +57 -0
- data/lib/ronin/parameters/param.rb +45 -0
- data/lib/ronin/parameters/parameters.rb +275 -0
- data/lib/ronin/path.rb +70 -0
- data/lib/ronin/pending_context.rb +42 -0
- data/lib/ronin/persistence.rb +32 -0
- data/lib/ronin/platform.rb +95 -0
- data/lib/ronin/product.rb +56 -0
- data/lib/ronin/ronin.rb +49 -0
- data/lib/ronin/rpc.rb +27 -0
- data/lib/ronin/rpc/call.rb +75 -0
- data/lib/ronin/rpc/client.rb +91 -0
- data/lib/ronin/rpc/console.rb +79 -0
- data/lib/ronin/rpc/exceptions.rb +25 -0
- data/lib/ronin/rpc/exceptions/not_implemented.rb +29 -0
- data/lib/ronin/rpc/exceptions/response_missing.rb +29 -0
- data/lib/ronin/rpc/interactive.rb +55 -0
- data/lib/ronin/rpc/interactive_console.rb +58 -0
- data/lib/ronin/rpc/interactive_shell.rb +59 -0
- data/lib/ronin/rpc/response.rb +57 -0
- data/lib/ronin/rpc/service.rb +69 -0
- data/lib/ronin/rpc/shell.rb +66 -0
- data/lib/ronin/runner.rb +24 -0
- data/lib/ronin/runner/program.rb +26 -0
- data/lib/ronin/runner/program/command.rb +204 -0
- data/lib/ronin/runner/program/commands.rb +33 -0
- data/lib/ronin/runner/program/commands/add.rb +73 -0
- data/lib/ronin/runner/program/commands/help.rb +52 -0
- data/lib/ronin/runner/program/commands/install.rb +65 -0
- data/lib/ronin/runner/program/commands/list.rb +81 -0
- data/lib/ronin/runner/program/commands/remove.rb +57 -0
- data/lib/ronin/runner/program/commands/uninstall.rb +57 -0
- data/lib/ronin/runner/program/commands/update.rb +55 -0
- data/lib/ronin/runner/program/exceptions.rb +24 -0
- data/lib/ronin/runner/program/exceptions/unknown_command.rb +31 -0
- data/lib/ronin/runner/program/options.rb +205 -0
- data/lib/ronin/runner/program/program.rb +173 -0
- data/lib/ronin/runner/program/runner.rb +35 -0
- data/lib/ronin/sessions.rb +32 -0
- data/lib/ronin/sessions/esmtp.rb +76 -0
- data/lib/ronin/sessions/imap.rb +73 -0
- data/lib/ronin/sessions/pop3.rb +70 -0
- data/lib/ronin/sessions/session.rb +52 -0
- data/lib/ronin/sessions/smtp.rb +76 -0
- data/lib/ronin/sessions/tcp.rb +111 -0
- data/lib/ronin/sessions/telnet.rb +76 -0
- data/lib/ronin/sessions/udp.rb +99 -0
- data/lib/ronin/sessions/web.rb +83 -0
- data/lib/ronin/shell.rb +81 -0
- data/lib/ronin/target.rb +40 -0
- data/lib/ronin/version.rb +27 -0
- data/lib/ronin/web.rb +24 -0
- data/lib/ronin/web/web.rb +265 -0
- data/spec/spec_helper.rb +9 -0
- data/tasks/spec.rb +7 -0
- metadata +324 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#
|
|
2
|
+
#--
|
|
3
|
+
# Ronin - A Ruby platform designed for information security and data
|
|
4
|
+
# exploration tasks.
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2006-2008 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/network/extensions/pop3'
|
|
25
|
+
|
|
26
|
+
module Ronin
|
|
27
|
+
module Network
|
|
28
|
+
module POP3
|
|
29
|
+
# Default pop3 port
|
|
30
|
+
DEFAULT_PORT = 110
|
|
31
|
+
|
|
32
|
+
#
|
|
33
|
+
# Returns the default Ronin POP3 port.
|
|
34
|
+
#
|
|
35
|
+
def POP3.default_port
|
|
36
|
+
@@pop3_default_port ||= DEFAULT_PORT
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
#
|
|
40
|
+
# Sets the default Ronin POP3 port to the specified _port_.
|
|
41
|
+
#
|
|
42
|
+
def POP3.default_port=(port)
|
|
43
|
+
@@pop3_default_port = port
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#
|
|
2
|
+
#--
|
|
3
|
+
# Ronin - A Ruby platform designed for information security and data
|
|
4
|
+
# exploration tasks.
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2006-2008 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/network/smtp/email'
|
|
25
|
+
require 'ronin/network/smtp/smtp'
|
|
26
|
+
require 'ronin/network/extensions/smtp'
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#
|
|
2
|
+
#--
|
|
3
|
+
# Ronin - A Ruby platform designed for information security and data
|
|
4
|
+
# exploration tasks.
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2006-2008 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
|
+
module Ronin
|
|
25
|
+
module Network
|
|
26
|
+
module SMTP
|
|
27
|
+
class Email
|
|
28
|
+
|
|
29
|
+
# Sender of the email
|
|
30
|
+
attr_accessor :from
|
|
31
|
+
|
|
32
|
+
# Recipient of the email
|
|
33
|
+
attr_accessor :to
|
|
34
|
+
|
|
35
|
+
# Subject of the email
|
|
36
|
+
attr_accessor :subject
|
|
37
|
+
|
|
38
|
+
# Date of the email
|
|
39
|
+
attr_accessor :date
|
|
40
|
+
|
|
41
|
+
# Unique message-id string
|
|
42
|
+
attr_accessor :message_id
|
|
43
|
+
|
|
44
|
+
# Body of the email
|
|
45
|
+
attr_accessor :body
|
|
46
|
+
|
|
47
|
+
#
|
|
48
|
+
# Creates a new Email object with the given _options_. If a _block_
|
|
49
|
+
# is given, it will be passed the newly created Email object.
|
|
50
|
+
#
|
|
51
|
+
# _options_ must contain the following keys:
|
|
52
|
+
# <tt>:from</tt>:: The address the email is from.
|
|
53
|
+
# <tt>:to</tt>:: The address that the email should be sent to.
|
|
54
|
+
# <tt>:subject</tt>:: The subject of the email.
|
|
55
|
+
# <tt>:message_id</tt>::
|
|
56
|
+
#
|
|
57
|
+
# _options_ may contain the following keys:
|
|
58
|
+
# <tt>:date</tt>:: The date the email was sent on. Defaults to
|
|
59
|
+
# <tt>Time.now</tt>.
|
|
60
|
+
# <tt>:body</tt>:: The body of the email. Can be a String or an
|
|
61
|
+
# Array of Strings.
|
|
62
|
+
#
|
|
63
|
+
def initialize(options={},&block)
|
|
64
|
+
@from = options[:from]
|
|
65
|
+
@to = options[:to]
|
|
66
|
+
@subject = options[:subject]
|
|
67
|
+
@date = options[:date] || Time.now
|
|
68
|
+
@message_id = options[:message_id]
|
|
69
|
+
@body = []
|
|
70
|
+
|
|
71
|
+
if options[:body].kind_of?(Array)
|
|
72
|
+
@body += options[:body]
|
|
73
|
+
else
|
|
74
|
+
@body << options[:body]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
block.call(self) if block
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
#
|
|
81
|
+
# Formats the email into a SMTP message as described in
|
|
82
|
+
# http://www.ruby-doc.org/stdlib/libdoc/net/smtp/rdoc/classes/Net/SMTP.html
|
|
83
|
+
#
|
|
84
|
+
def to_s
|
|
85
|
+
address = lambda { |info|
|
|
86
|
+
if info.kind_of?(Array)
|
|
87
|
+
return "#{info[0]} <#{info[1]}>"
|
|
88
|
+
elsif info.kind_of?(Hash)
|
|
89
|
+
return "#{info[:name]} <#{info[:email]}>"
|
|
90
|
+
else
|
|
91
|
+
return info
|
|
92
|
+
end
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
message = []
|
|
96
|
+
|
|
97
|
+
if @from
|
|
98
|
+
message << "From: #{address.call(@from)}"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
if @to
|
|
102
|
+
message << "To: #{address.call(@to)}"
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
if @subject
|
|
106
|
+
message << "Subject: #{@subject}"
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
if @date
|
|
110
|
+
message << "Date: #{@date}"
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
if @message_id
|
|
114
|
+
message << "Message-Id: <#{@message_id}>"
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
message << ''
|
|
118
|
+
message += @body
|
|
119
|
+
|
|
120
|
+
return message.join("\n")
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#
|
|
2
|
+
#--
|
|
3
|
+
# Ronin - A Ruby platform designed for information security and data
|
|
4
|
+
# exploration tasks.
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2006-2008 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/network/smtp/email'
|
|
25
|
+
|
|
26
|
+
module Ronin
|
|
27
|
+
module Network
|
|
28
|
+
module SMTP
|
|
29
|
+
# Default smtp port
|
|
30
|
+
DEFAULT_PORT = 25
|
|
31
|
+
|
|
32
|
+
#
|
|
33
|
+
# Returns the default Ronin SMTP port.
|
|
34
|
+
#
|
|
35
|
+
def SMTP.default_port
|
|
36
|
+
@@smtp_default_port ||= DEFAULT_PORT
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
#
|
|
40
|
+
# Sets the default Ronin SMTP port.
|
|
41
|
+
#
|
|
42
|
+
def SMTP.default_port=(port)
|
|
43
|
+
@@smtp_default_port = port
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
#
|
|
47
|
+
# Returns the String form of an Email object with the given _options_
|
|
48
|
+
# and _block_.
|
|
49
|
+
#
|
|
50
|
+
def SMTP.message(options={},&block)
|
|
51
|
+
Email.new(options,&block).to_s
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#
|
|
2
|
+
#--
|
|
3
|
+
# Ronin - A Ruby platform designed for information security and data
|
|
4
|
+
# exploration tasks.
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2006-2008 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/network/extensions/tcp'
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#
|
|
2
|
+
#--
|
|
3
|
+
# Ronin - A Ruby platform designed for information security and data
|
|
4
|
+
# exploration tasks.
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2006-2008 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/network/extensions/telnet'
|
|
25
|
+
|
|
26
|
+
module Ronin
|
|
27
|
+
module Network
|
|
28
|
+
module Telnet
|
|
29
|
+
# Default telnet port
|
|
30
|
+
DEFAULT_PORT = 23
|
|
31
|
+
|
|
32
|
+
# The default prompt regular expression
|
|
33
|
+
DEFAULT_PROMPT = /[$%#>] \z/n
|
|
34
|
+
|
|
35
|
+
# The default timeout
|
|
36
|
+
DEFAULT_TIMEOUT = 10
|
|
37
|
+
|
|
38
|
+
#
|
|
39
|
+
# Returns the default Ronin Telnet port.
|
|
40
|
+
#
|
|
41
|
+
def Telnet.default_port
|
|
42
|
+
@@telnet_default_port ||= DEFAULT_PORT
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
#
|
|
46
|
+
# Sets the default Ronin Telnet port to the specified _port_.
|
|
47
|
+
#
|
|
48
|
+
def Telnet.default_port=(port)
|
|
49
|
+
@@telnet_default_port = port
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
#
|
|
53
|
+
# Returns the default Ronin Telnet prompt.
|
|
54
|
+
#
|
|
55
|
+
def Telnet.default_prompt
|
|
56
|
+
@@telnet_default_prompt ||= DEFAULT_PROMPT
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
#
|
|
60
|
+
# Sets the default Ronin Telnet prompt to the specified _prompt_.
|
|
61
|
+
#
|
|
62
|
+
def Telnet.default_prompt=(prompt)
|
|
63
|
+
@@telnet_default_prompt = prompt
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
#
|
|
67
|
+
# Returns the default Ronin Telnet timeout.
|
|
68
|
+
#
|
|
69
|
+
def Telnet.default_timeout
|
|
70
|
+
@@telnet_default_timeout ||= DEFAULT_TIMEOUT
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
#
|
|
74
|
+
# Sets the default Ronin Telnet timeout to the specified _timeout_.
|
|
75
|
+
#
|
|
76
|
+
def Telnet.default_timeout=(timeout)
|
|
77
|
+
@@telnet_default_timeout = timeout
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
#
|
|
81
|
+
# Returns the Ronin Telnet proxy.
|
|
82
|
+
#
|
|
83
|
+
def Telnet.proxy
|
|
84
|
+
@@telnet_proxy ||= nil
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
#
|
|
88
|
+
# Sets the Ronin Telnet proxy to _new_proxy_.
|
|
89
|
+
#
|
|
90
|
+
def Telnet.proxy=(new_proxy)
|
|
91
|
+
@@telnet_proxy = new_proxy
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#
|
|
2
|
+
#--
|
|
3
|
+
# Ronin - A Ruby platform designed for information security and data
|
|
4
|
+
# exploration tasks.
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2006-2008 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/network/extensions/udp'
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
#
|
|
2
|
+
#--
|
|
3
|
+
# Ronin - A Ruby platform designed for information security and data
|
|
4
|
+
# exploration tasks.
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2006-2008 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/exceptions/unknown_object_context'
|
|
25
|
+
require 'ronin/exceptions/object_context_not_found'
|
|
26
|
+
require 'ronin/extensions/meta'
|
|
27
|
+
require 'ronin/context'
|
|
28
|
+
|
|
29
|
+
require 'dm-core'
|
|
30
|
+
|
|
31
|
+
module Ronin
|
|
32
|
+
module ObjectContext
|
|
33
|
+
include DataMapper::Types
|
|
34
|
+
|
|
35
|
+
def self.included(base)
|
|
36
|
+
base.class_eval do
|
|
37
|
+
include Model
|
|
38
|
+
include Context
|
|
39
|
+
|
|
40
|
+
metaclass_def(:object_contextify) do |name|
|
|
41
|
+
ObjectContext.object_contexts[name] = self
|
|
42
|
+
|
|
43
|
+
contextify name
|
|
44
|
+
|
|
45
|
+
# The Path to the object context
|
|
46
|
+
property :object_path, String, :key => true
|
|
47
|
+
|
|
48
|
+
# The modification timestamp of the object context
|
|
49
|
+
property :object_timestamp, EpochTime
|
|
50
|
+
|
|
51
|
+
meta_def(:load_object) do |path,*args|
|
|
52
|
+
ObjectContext.load_object(context_name,path,*args)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
meta_def(:cache) do |path,*args|
|
|
56
|
+
load_object(path,*args).cache
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
meta_def(:mirror) do |path,*args|
|
|
60
|
+
path = File.expand_path(path)
|
|
61
|
+
existing_obj = first(:object_path => path)
|
|
62
|
+
|
|
63
|
+
if existing_obj
|
|
64
|
+
return existing_obj.mirror
|
|
65
|
+
else
|
|
66
|
+
return cache(path,*args)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
meta_def(:search) do |*attribs|
|
|
71
|
+
all(*attribs).map { |obj| obj.object }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
class_def(:object) do
|
|
75
|
+
self.class.load_object(self.object_path)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
class_def(:missing?) do
|
|
79
|
+
if self.object_path
|
|
80
|
+
return !(File.file?(self.object_path))
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
return false
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
class_def(:stale?) do
|
|
87
|
+
if self.object_timestamp
|
|
88
|
+
return File.mtime(self.object_path) > self.object_timestamp
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
return false
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
class_def(:cache) do
|
|
95
|
+
if self.object_path
|
|
96
|
+
self.object_timestamp = File.mtime(self.object_path)
|
|
97
|
+
return save
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
return false
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
class_def(:mirror) do
|
|
104
|
+
if self.object_path
|
|
105
|
+
unless File.file?(self.object_path)
|
|
106
|
+
return destroy
|
|
107
|
+
else
|
|
108
|
+
if (!(dirty?) && stale?)
|
|
109
|
+
destroy
|
|
110
|
+
return object.cache
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
return false
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# define Repo-level object loader method
|
|
119
|
+
Ronin.module_eval %{
|
|
120
|
+
def ronin_load_#{name}(path,*args,&block)
|
|
121
|
+
new_obj = #{self}.load_object(path,*args)
|
|
122
|
+
|
|
123
|
+
block.call(new_obj) if block
|
|
124
|
+
return new_obj
|
|
125
|
+
end
|
|
126
|
+
}
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
#
|
|
132
|
+
# Returns the Hash of all defined object-contexts.
|
|
133
|
+
#
|
|
134
|
+
def ObjectContext.object_contexts
|
|
135
|
+
@@ronin_object_contexts ||= {}
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
#
|
|
139
|
+
# Returns +true+ if there is an object-context defined with the
|
|
140
|
+
# specified _name_, returns +false+ otherwise.
|
|
141
|
+
#
|
|
142
|
+
def ObjectContext.is_object_context?(name)
|
|
143
|
+
ObjectContext.object_contexts.has_key?(name.to_sym)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
#
|
|
147
|
+
# Loads the object context of the specified _name_ and from the
|
|
148
|
+
# specified _path_ with the given _args_. If no object contexts were
|
|
149
|
+
# defined with the specified _name_, an UnknownObjectContext
|
|
150
|
+
# exception will be raised.
|
|
151
|
+
#
|
|
152
|
+
# ObjectContext.load_object(:note,'/path/to/my_notes.rb') # => Note
|
|
153
|
+
#
|
|
154
|
+
def ObjectContext.load_object(name,path,*args,&block)
|
|
155
|
+
name = name.to_sym
|
|
156
|
+
|
|
157
|
+
unless ObjectContext.is_object_context?(name)
|
|
158
|
+
raise(UnknownObjectContext,"unknown object context '#{name}'",caller)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
path = File.expand_path(path)
|
|
162
|
+
|
|
163
|
+
unless File.file?(path)
|
|
164
|
+
raise(ObjectContextNotFound,"object context #{path.dump} does not exist",caller)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
new_obj = Context.load_context(name,path,*args)
|
|
168
|
+
new_obj.object_path = path
|
|
169
|
+
|
|
170
|
+
block.call(new_obj) if block
|
|
171
|
+
return new_obj
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
#
|
|
175
|
+
# Loads all object contexts from the specified _path_ returning an
|
|
176
|
+
# +Array+ of loaded object contexts. If a _block_ is given, it will
|
|
177
|
+
# be passed each loaded object context.
|
|
178
|
+
#
|
|
179
|
+
# Context.load_contexts('/path/to/misc_contexts.rb') # => [...]
|
|
180
|
+
#
|
|
181
|
+
def ObjectContext.load_objects(path,&block)
|
|
182
|
+
path = File.expand_path(path)
|
|
183
|
+
|
|
184
|
+
unless File.file?(path)
|
|
185
|
+
raise(ObjectContextNotFound,"object context #{path.dump} does not exist",caller)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
return Context.load_contexts(path) do |new_obj|
|
|
189
|
+
new_obj.object_path = path
|
|
190
|
+
|
|
191
|
+
block.call(new_obj) if block
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
#
|
|
196
|
+
# Cache all objects loaded from the specified _path_.
|
|
197
|
+
#
|
|
198
|
+
def ObjectContext.cache_objects(path)
|
|
199
|
+
ObjectContext.load_objects(path).each do |obj|
|
|
200
|
+
obj.cache
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
#
|
|
205
|
+
# Cache all objects loaded from the paths within the specified
|
|
206
|
+
# _directory_.
|
|
207
|
+
#
|
|
208
|
+
def ObjectContext.cache_objects_in(directory)
|
|
209
|
+
directory = File.expand_path(directory)
|
|
210
|
+
paths = Dir[File.join(directory,'**','*.rb')]
|
|
211
|
+
|
|
212
|
+
paths.each do |path|
|
|
213
|
+
ObjectContext.load_objects(path).each do |obj|
|
|
214
|
+
obj.cache
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
return nil
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
#
|
|
222
|
+
# Mirror all objects that were previously cached from paths within
|
|
223
|
+
# the specified _directory_. Also cache objects which have yet to
|
|
224
|
+
# be cached.
|
|
225
|
+
#
|
|
226
|
+
def ObjectContext.mirror_objects_in(directory)
|
|
227
|
+
directory = File.expand_path(directory)
|
|
228
|
+
paths = Dir[File.join(directory,'**','*.rb')]
|
|
229
|
+
|
|
230
|
+
ObjectContext.object_contexts.each_value do |base|
|
|
231
|
+
objects = base.all(:object_path.like => "#{directory}%")
|
|
232
|
+
paths -= objects.map { |obj| obj.object_path }
|
|
233
|
+
|
|
234
|
+
objects.each { |obj| obj.mirror }
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
paths.each do |path|
|
|
238
|
+
ObjectContext.cache_objects(path)
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
return nil
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
#
|
|
245
|
+
# Deletes all cached objects that existed in the specified _directory_.
|
|
246
|
+
#
|
|
247
|
+
def ObjectContext.expunge_objects_from(directory)
|
|
248
|
+
directory = File.expand_path(directory)
|
|
249
|
+
|
|
250
|
+
ObjectContext.object_contexts.each_value do |base|
|
|
251
|
+
base.all(:object_path.like => "#{directory}%").destroy!
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
return nil
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
end
|