ronin 1.0.0 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +0 -1
- data/ChangeLog.md +67 -3
- data/Gemfile +20 -12
- data/README.md +3 -5
- data/gemspec.yml +5 -5
- data/lib/ronin/address.rb +8 -3
- data/lib/ronin/arch.rb +39 -14
- data/lib/ronin/author.rb +2 -0
- data/lib/ronin/auto_load.rb +67 -0
- data/lib/ronin/campaign.rb +15 -2
- data/lib/ronin/class_methods.rb +7 -1
- data/lib/ronin/config.rb +5 -0
- data/lib/ronin/credential.rb +14 -3
- data/lib/ronin/database/database.rb +38 -12
- data/lib/ronin/database/migrations.rb +3 -1
- data/lib/ronin/database/migrations/add_created_at_column_to_targets_table.rb +48 -0
- data/lib/ronin/database/migrations/add_updated_at_column_to_campaigns_table.rb +47 -0
- data/lib/ronin/database/migrations/create_licenses_table.rb +1 -1
- data/lib/ronin/database/migrations/create_passwords_table.rb +1 -1
- data/lib/ronin/database/migrations/{create_cached_files_table.rb → create_script_paths_table.rb} +4 -4
- data/lib/ronin/database/migrations/migration.rb +3 -6
- data/lib/ronin/database/migrations/migrations.rb +3 -3
- data/lib/ronin/email_address.rb +20 -3
- data/lib/ronin/environment.rb +0 -3
- data/lib/ronin/host_name.rb +20 -6
- data/lib/ronin/host_name_ip_address.rb +2 -3
- data/lib/ronin/installation.rb +92 -23
- data/lib/ronin/ip_address.rb +31 -8
- data/lib/ronin/ip_address_mac_address.rb +2 -3
- data/lib/ronin/license.rb +1 -1
- data/lib/ronin/mac_address.rb +6 -4
- data/lib/ronin/model/class_methods.rb +4 -0
- data/lib/ronin/model/has_authors/class_methods.rb +4 -0
- data/lib/ronin/model/has_authors/has_authors.rb +4 -0
- data/lib/ronin/model/has_description/class_methods.rb +2 -0
- data/lib/ronin/model/has_description/has_description.rb +2 -0
- data/lib/ronin/model/has_license/class_methods.rb +2 -0
- data/lib/ronin/model/has_license/has_license.rb +4 -0
- data/lib/ronin/model/has_name/class_methods.rb +2 -0
- data/lib/ronin/model/has_name/has_name.rb +4 -0
- data/lib/ronin/model/has_title/class_methods.rb +2 -0
- data/lib/ronin/model/has_title/has_title.rb +2 -0
- data/lib/ronin/model/has_unique_name/class_methods.rb +2 -0
- data/lib/ronin/model/has_unique_name/has_unique_name.rb +7 -1
- data/lib/ronin/model/has_version/class_methods.rb +4 -0
- data/lib/ronin/model/has_version/has_version.rb +2 -0
- data/lib/ronin/model/model.rb +2 -0
- data/lib/ronin/model/types.rb +1 -7
- data/lib/ronin/model/types/description.rb +2 -0
- data/lib/ronin/network/mixins/esmtp.rb +40 -25
- data/lib/ronin/network/mixins/http.rb +336 -73
- data/lib/ronin/network/mixins/imap.rb +38 -25
- data/lib/ronin/network/mixins/pop3.rb +34 -21
- data/lib/ronin/network/mixins/smtp.rb +40 -25
- data/lib/ronin/network/mixins/tcp.rb +66 -41
- data/lib/ronin/network/mixins/telnet.rb +43 -30
- data/lib/ronin/network/mixins/udp.rb +59 -40
- data/lib/ronin/open_port.rb +12 -5
- data/lib/ronin/organization.rb +1 -2
- data/lib/ronin/os.rb +10 -3
- data/lib/ronin/os_guess.rb +2 -3
- data/lib/ronin/password.rb +11 -3
- data/lib/ronin/port.rb +7 -2
- data/lib/ronin/{engine/exceptions/deploy_failed.rb → repositories.rb} +4 -6
- data/lib/ronin/repository.rb +110 -37
- data/lib/ronin/ronin.rb +4 -3
- data/lib/ronin/{engine.rb → script.rb} +2 -1
- data/lib/ronin/{engine → script}/buildable.rb +43 -29
- data/lib/ronin/script/class_methods.rb +84 -0
- data/lib/ronin/{engine → script}/deployable.rb +61 -40
- data/lib/ronin/{engine → script}/exceptions.rb +4 -3
- data/lib/ronin/script/exceptions/deploy_failed.rb +27 -0
- data/lib/ronin/{engine/exceptions/not_built.rb → script/exceptions/exception.rb} +2 -2
- data/lib/ronin/{engine/exceptions/verification_failed.rb → script/exceptions/not_built.rb} +4 -2
- data/lib/ronin/script/exceptions/test_failed.rb +27 -0
- data/lib/ronin/script/instance_methods.rb +217 -0
- data/lib/ronin/script/path.rb +277 -0
- data/lib/ronin/{engine/engine.rb → script/script.rb} +52 -15
- data/lib/ronin/{engine/verifiable.rb → script/testable.rb} +97 -68
- data/lib/ronin/service.rb +1 -2
- data/lib/ronin/service_credential.rb +1 -2
- data/lib/ronin/software.rb +3 -2
- data/lib/ronin/spec/database.rb +0 -4
- data/lib/ronin/target.rb +11 -3
- data/lib/ronin/tcp_port.rb +3 -2
- data/lib/ronin/udp_port.rb +2 -0
- data/lib/ronin/ui/cli/cli.rb +6 -0
- data/lib/ronin/ui/cli/command.rb +48 -12
- data/lib/ronin/ui/cli/commands/campaigns.rb +3 -3
- data/lib/ronin/ui/cli/commands/console.rb +2 -1
- data/lib/ronin/ui/cli/commands/creds.rb +3 -3
- data/lib/ronin/ui/cli/commands/database.rb +1 -17
- data/lib/ronin/ui/cli/commands/emails.rb +3 -3
- data/lib/ronin/ui/cli/commands/hosts.rb +3 -7
- data/lib/ronin/ui/cli/commands/ips.rb +3 -7
- data/lib/ronin/ui/cli/commands/repos.rb +5 -17
- data/lib/ronin/ui/cli/commands/urls.rb +3 -3
- data/lib/ronin/ui/cli/model_command.rb +82 -97
- data/lib/ronin/ui/cli/resources_command.rb +89 -0
- data/lib/ronin/ui/cli/script_command.rb +115 -0
- data/lib/ronin/ui/console.rb +17 -3
- data/lib/ronin/ui/output/helpers.rb +18 -0
- data/lib/ronin/ui/output/output.rb +20 -1
- data/lib/ronin/ui/output/terminal/color.rb +10 -0
- data/lib/ronin/ui/output/terminal/raw.rb +10 -0
- data/lib/ronin/ui/shell.rb +2 -0
- data/lib/ronin/url.rb +47 -12
- data/lib/ronin/url_query_param.rb +4 -0
- data/lib/ronin/url_scheme.rb +3 -3
- data/lib/ronin/user_name.rb +2 -0
- data/lib/ronin/version.rb +1 -1
- data/lib/ronin/web_credential.rb +6 -3
- data/spec/arch_spec.rb +3 -3
- data/spec/classes/my_script.rb +21 -0
- data/spec/helpers/repos/{test1 → installed}/ronin.yml +1 -1
- data/spec/helpers/repos/{hello/cache → installed/scripts}/.keep +0 -0
- data/spec/helpers/repos/local/lib/init.rb +1 -0
- data/spec/helpers/repos/{hello → local}/lib/stuff/another_test.rb +0 -0
- data/spec/helpers/repos/{hello → local}/lib/stuff/test.rb +0 -0
- data/spec/helpers/repos/{random → local}/ronin.yml +1 -1
- data/spec/helpers/repos/{random/cache → local/scripts}/.keep +0 -0
- data/spec/helpers/repos/{hello → remote}/ronin.yml +1 -1
- data/spec/helpers/repos/remote/scripts/.keep +0 -0
- data/spec/helpers/repos/{test2 → scripts}/ronin.yml +0 -0
- data/spec/helpers/repos/scripts/scripts/cached/cached.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/cached/missing.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/cached/modified.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/cached/unmodified.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/failures/exceptions.rb +11 -0
- data/spec/helpers/repos/{test2/cache/cacheable_model → scripts/scripts/failures}/load_errors.rb +3 -1
- data/spec/helpers/repos/{test2/cache/cacheable_model → scripts/scripts/failures}/name_errors.rb +1 -0
- data/spec/helpers/repos/scripts/scripts/failures/no_method_errors.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/failures/syntax_errors.rb +11 -0
- data/spec/helpers/repos/scripts/scripts/failures/validation_errors.rb +11 -0
- data/spec/helpers/repos/scripts/scripts/my_scripts/test.rb +16 -0
- data/spec/model/spec_helper.rb +0 -2
- data/spec/repository_spec.rb +61 -81
- data/spec/ronin_spec.rb +2 -2
- data/spec/{engine → script}/buildable_spec.rb +9 -9
- data/spec/script/classes/buildable_class.rb +15 -0
- data/spec/script/classes/deployable_class.rb +13 -0
- data/spec/{engine/classes/engine_class.rb → script/classes/script_class.rb} +3 -3
- data/spec/{engine/classes/verifiable_class.rb → script/classes/testable_class.rb} +5 -5
- data/spec/{engine → script}/deployable_spec.rb +10 -10
- data/spec/{cached_file_spec.rb → script/path_spec.rb} +33 -72
- data/spec/script/script_spec.rb +130 -0
- data/spec/script/testable_spec.rb +117 -0
- data/spec/spec_helper.rb +15 -13
- metadata +114 -139
- data/lib/ronin/cached_file.rb +0 -247
- data/lib/ronin/engine/class_methods.rb +0 -135
- data/lib/ronin/engine/instance_methods.rb +0 -97
- data/lib/ronin/model/cacheable.rb +0 -21
- data/lib/ronin/model/cacheable/cacheable.rb +0 -273
- data/lib/ronin/model/cacheable/class_methods.rb +0 -60
- data/lib/ronin/ui/cli/engine_command.rb +0 -106
- data/spec/engine/classes/buildable_class.rb +0 -15
- data/spec/engine/classes/deployable_class.rb +0 -13
- data/spec/engine/engine_spec.rb +0 -55
- data/spec/engine/verifiable_spec.rb +0 -117
- data/spec/helpers/repos/hello/lib/init.rb +0 -1
- data/spec/helpers/repos/test1/cache/cacheable_model/one.rb +0 -15
- data/spec/helpers/repos/test2/cache/cacheable_model/exceptions.rb +0 -7
- data/spec/helpers/repos/test2/cache/cacheable_model/no_method_errors.rb +0 -9
- data/spec/helpers/repos/test2/cache/cacheable_model/syntax_errors.rb +0 -7
- data/spec/helpers/repos/test2/cache/cacheable_model/two.rb +0 -15
- data/spec/helpers/repos/test2/cache/cacheable_model/validation_errors.rb +0 -9
- data/spec/model/cacheable_spec.rb +0 -96
- data/spec/model/models/cacheable_model.rb +0 -13
@@ -18,6 +18,8 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/network/imap'
|
21
|
+
require 'ronin/ui/output/helpers'
|
22
|
+
require 'ronin/mixin'
|
21
23
|
|
22
24
|
require 'parameters'
|
23
25
|
|
@@ -27,39 +29,46 @@ module Ronin
|
|
27
29
|
#
|
28
30
|
# Adds IMAP convenience methods and connection parameters to a class.
|
29
31
|
#
|
32
|
+
# Defines the following parameters:
|
33
|
+
#
|
34
|
+
# * `host` (`String`) - IMAP host.
|
35
|
+
# * `port` (`Integer`) - IMAP port.
|
36
|
+
# * `imap_auth` (`String`) - IMAP authentication method.
|
37
|
+
# * `imap_user` (`String`) - IMAP user to login as.
|
38
|
+
# * `imap_password` (`String`) - IMAP password to login with.
|
39
|
+
#
|
30
40
|
module IMAP
|
31
|
-
include
|
41
|
+
include Mixin
|
42
|
+
|
43
|
+
mixin UI::Output::Helpers, Parameters
|
32
44
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
45
|
+
mixin do
|
46
|
+
# IMAP host
|
47
|
+
parameter :host, :type => String,
|
48
|
+
:description => 'IMAP host'
|
37
49
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
:description => 'IMAP port'
|
50
|
+
# IMAP port
|
51
|
+
parameter :port, :type => Integer,
|
52
|
+
:description => 'IMAP port'
|
42
53
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
:description => 'IMAP authentication method'
|
54
|
+
# IMAP auth
|
55
|
+
parameter :imap_auth, :type => String,
|
56
|
+
:description => 'IMAP authentication method'
|
47
57
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
:description => 'IMAP user to login as'
|
58
|
+
# IMAP user to login as
|
59
|
+
parameter :imap_user, :type => String,
|
60
|
+
:description => 'IMAP user to login as'
|
52
61
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
62
|
+
# IMAP password to login with
|
63
|
+
parameter :imap_password, :type => String,
|
64
|
+
:description => 'IMAP password to login with'
|
65
|
+
end
|
57
66
|
|
58
67
|
protected
|
59
68
|
|
60
69
|
#
|
61
|
-
# Creates a connection to the IMAP server. The
|
62
|
-
#
|
70
|
+
# Creates a connection to the IMAP server. The `host`, `port`,
|
71
|
+
# `imap_auth`, `imap_user` and `imap_password` parameters
|
63
72
|
# will also be used to make the connection.
|
64
73
|
#
|
65
74
|
# @param [Hash] options
|
@@ -86,6 +95,8 @@ module Ronin
|
|
86
95
|
# Indicates wether or not to use SSL when connecting to the
|
87
96
|
# server.
|
88
97
|
#
|
98
|
+
# @api public
|
99
|
+
#
|
89
100
|
def imap_connect(options={},&block)
|
90
101
|
options[:port] ||= self.port
|
91
102
|
options[:auth] ||= self.imap_auth
|
@@ -102,8 +113,8 @@ module Ronin
|
|
102
113
|
end
|
103
114
|
|
104
115
|
#
|
105
|
-
# Starts a session with the IMAP server. The
|
106
|
-
#
|
116
|
+
# Starts a session with the IMAP server. The `host`, `port`,
|
117
|
+
# `imap_auth`, `imap_user` and `imap_password` parameters
|
107
118
|
# will also be used to make the connection.
|
108
119
|
#
|
109
120
|
# @yield [session]
|
@@ -116,6 +127,8 @@ module Ronin
|
|
116
127
|
#
|
117
128
|
# @see imap_connect
|
118
129
|
#
|
130
|
+
# @api public
|
131
|
+
#
|
119
132
|
def imap_session(options={})
|
120
133
|
imap_connect(options) do |sess|
|
121
134
|
yield sess if block_given?
|
@@ -18,6 +18,8 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/network/pop3'
|
21
|
+
require 'ronin/ui/output/helpers'
|
22
|
+
require 'ronin/mixin'
|
21
23
|
|
22
24
|
require 'parameters'
|
23
25
|
|
@@ -27,34 +29,41 @@ module Ronin
|
|
27
29
|
#
|
28
30
|
# Adds POP3 convenience methods and connection parameters to a class.
|
29
31
|
#
|
32
|
+
# Defines the following parameters:
|
33
|
+
#
|
34
|
+
# * `host` (`String`) - POP3 host.
|
35
|
+
# * `port` (`Integer`) - POP3 port.
|
36
|
+
# * `pop3_user` (`String`) - POP3 user to login as.
|
37
|
+
# * `pop3_password` (`String`) - POP3 password to login with.
|
38
|
+
#
|
30
39
|
module POP3
|
31
|
-
include
|
40
|
+
include Mixin
|
41
|
+
|
42
|
+
mixin UI::Output::Helpers, Parameters
|
32
43
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
44
|
+
mixin do
|
45
|
+
# POP3 host
|
46
|
+
parameter :host, :type => String,
|
47
|
+
:description => 'POP3 host'
|
37
48
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
:description => 'POP3 port'
|
49
|
+
# POP3 port
|
50
|
+
parameter :port, :type => Integer,
|
51
|
+
:description => 'POP3 port'
|
42
52
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
:description => 'POP3 user to login as'
|
53
|
+
# POP3 user
|
54
|
+
parameter :pop3_user, :type => String,
|
55
|
+
:description => 'POP3 user to login as'
|
47
56
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
57
|
+
# POP3 password
|
58
|
+
parameter :pop3_password, :type => String,
|
59
|
+
:description => 'POP3 password to login with'
|
60
|
+
end
|
52
61
|
|
53
62
|
protected
|
54
63
|
|
55
64
|
#
|
56
|
-
# Creates a connection to the POP3 server. The
|
57
|
-
#
|
65
|
+
# Creates a connection to the POP3 server. The `host}, `port`,
|
66
|
+
# `pop3_user` and `pop3_password` parameters will also be used
|
58
67
|
# to connect to the server.
|
59
68
|
#
|
60
69
|
# @param [Hash] options
|
@@ -81,6 +90,8 @@ module Ronin
|
|
81
90
|
# @return [Net::POP3]
|
82
91
|
# The newly created POP3 session.
|
83
92
|
#
|
93
|
+
# @api public
|
94
|
+
#
|
84
95
|
def pop3_connect(options={},&block)
|
85
96
|
options[:port] ||= self.port
|
86
97
|
options[:user] ||= self.pop3_user
|
@@ -96,8 +107,8 @@ module Ronin
|
|
96
107
|
end
|
97
108
|
|
98
109
|
#
|
99
|
-
# Starts a session with the POP3 server. The
|
100
|
-
#
|
110
|
+
# Starts a session with the POP3 server. The `host`, `port`,
|
111
|
+
# `pop3_user` and `pop3_password` parameters will also be used
|
101
112
|
# to connect to the server.
|
102
113
|
#
|
103
114
|
# @yield [session]
|
@@ -110,6 +121,8 @@ module Ronin
|
|
110
121
|
#
|
111
122
|
# @see pop3_connect
|
112
123
|
#
|
124
|
+
# @api public
|
125
|
+
#
|
113
126
|
def pop3_session(options={})
|
114
127
|
pop3_connect(options) do |sess|
|
115
128
|
yield sess if block_given?
|
@@ -18,6 +18,8 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/network/smtp'
|
21
|
+
require 'ronin/ui/output/helpers'
|
22
|
+
require 'ronin/mixin'
|
21
23
|
|
22
24
|
require 'parameters'
|
23
25
|
|
@@ -27,46 +29,55 @@ module Ronin
|
|
27
29
|
#
|
28
30
|
# Adds SMTP convenience methods and connection parameters to a class.
|
29
31
|
#
|
32
|
+
# Defines the following parameters:
|
33
|
+
#
|
34
|
+
# * `host` (`String`) - SMTP host.
|
35
|
+
# * `port` (`Integer`) - SMTP port.
|
36
|
+
# * `smtp_login` (`String`) - SMTP authentication method.
|
37
|
+
# * `smtp_user` (`String`) - SMTP user to login as.
|
38
|
+
# * `smtp_password` (`String`) - SMTP password to login with.
|
39
|
+
#
|
30
40
|
module SMTP
|
31
|
-
include
|
41
|
+
include Mixin
|
32
42
|
|
33
|
-
|
34
|
-
parameter :host,
|
35
|
-
:type => String,
|
36
|
-
:description => 'SMTP host'
|
43
|
+
mixin UI::Output::Helpers, Parameters
|
37
44
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
45
|
+
mixin do
|
46
|
+
# SMTP host
|
47
|
+
parameter :host, :type => String,
|
48
|
+
:description => 'SMTP host'
|
42
49
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
:description => 'SMTP authentication method'
|
50
|
+
# SMTP port
|
51
|
+
parameter :port, :type => Integer,
|
52
|
+
:description => 'SMTP port'
|
47
53
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
:description => 'SMTP user to login as'
|
54
|
+
# SMTP authentication method
|
55
|
+
parameter :smtp_login, :type => String,
|
56
|
+
:description => 'SMTP authentication method'
|
52
57
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
58
|
+
# SMTP user to login as
|
59
|
+
parameter :smtp_user, :type => String,
|
60
|
+
:description => 'SMTP user to login as'
|
61
|
+
|
62
|
+
# SMTP user to login with
|
63
|
+
parameter :smtp_password, :type => String,
|
64
|
+
:description => 'SMTP password to login with'
|
65
|
+
end
|
57
66
|
|
58
67
|
protected
|
59
68
|
|
60
69
|
#
|
61
70
|
# @see Ronin::Network::SMTP.message
|
62
71
|
#
|
72
|
+
# @api public
|
73
|
+
#
|
63
74
|
def smtp_message(options={},&block)
|
64
75
|
Network::SMTP.message(options,&block)
|
65
76
|
end
|
66
77
|
|
67
78
|
#
|
68
|
-
# Creates a connection to the SMTP server. The
|
69
|
-
#
|
79
|
+
# Creates a connection to the SMTP server. The `host`, `port`,
|
80
|
+
# `smtp_login`, `smtp_user` and `smtp_password` parameters
|
70
81
|
# will also be used to connect to the server.
|
71
82
|
#
|
72
83
|
# @param [Hash] options
|
@@ -97,6 +108,8 @@ module Ronin
|
|
97
108
|
# @return [Net::SMTP]
|
98
109
|
# The SMTP session.
|
99
110
|
#
|
111
|
+
# @api public
|
112
|
+
#
|
100
113
|
def smtp_connect(options={},&block)
|
101
114
|
options[:port] ||= self.port
|
102
115
|
options[:login] ||= self.smtp_login
|
@@ -113,8 +126,8 @@ module Ronin
|
|
113
126
|
end
|
114
127
|
|
115
128
|
#
|
116
|
-
# Starts a session with the SMTP server. The
|
117
|
-
#
|
129
|
+
# Starts a session with the SMTP server. The `host`, `port`,
|
130
|
+
# `smtp_login`, `smtp_user` and `smtp_password` parameters
|
118
131
|
# will also be used to connect to the server.
|
119
132
|
#
|
120
133
|
# @yield [session]
|
@@ -126,6 +139,8 @@ module Ronin
|
|
126
139
|
#
|
127
140
|
# @see smtp_connect
|
128
141
|
#
|
142
|
+
# @api public
|
143
|
+
#
|
129
144
|
def smtp_session(options={},&block)
|
130
145
|
smtp_connect(options) do |sess|
|
131
146
|
yield sess if block_given?
|
@@ -18,6 +18,8 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/network/tcp'
|
21
|
+
require 'ronin/ui/output/helpers'
|
22
|
+
require 'ronin/mixin'
|
21
23
|
|
22
24
|
require 'parameters'
|
23
25
|
|
@@ -27,45 +29,52 @@ module Ronin
|
|
27
29
|
#
|
28
30
|
# Adds TCP convenience methods and connection parameters to a class.
|
29
31
|
#
|
32
|
+
# Defines the following parameters:
|
33
|
+
#
|
34
|
+
# * `host` (`String`) - TCP host.
|
35
|
+
# * `port` (`Integer`) - TCP port.
|
36
|
+
# * `local_host` (`String`) - TCP local host.
|
37
|
+
# * `local_port` (`Integer`) - TCP local port.
|
38
|
+
# * `server_host` (`String`) - TCP server host.
|
39
|
+
# * `server_port` (`Integer`) - TCP server port.
|
40
|
+
#
|
30
41
|
module TCP
|
31
|
-
include
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
:type => Integer,
|
61
|
-
:description => 'TCP server port'
|
42
|
+
include Mixin
|
43
|
+
|
44
|
+
mixin UI::Output::Helpers, Parameters
|
45
|
+
|
46
|
+
mixin do
|
47
|
+
# TCP host
|
48
|
+
parameter :host, :type => String,
|
49
|
+
:description => 'TCP host'
|
50
|
+
|
51
|
+
# TCP port
|
52
|
+
parameter :port, :type => Integer,
|
53
|
+
:description => 'TCP port'
|
54
|
+
|
55
|
+
# TCP local host
|
56
|
+
parameter :local_host, :type => String,
|
57
|
+
:description => 'TCP local host'
|
58
|
+
|
59
|
+
# TCP local port
|
60
|
+
parameter :local_port, :type => Integer,
|
61
|
+
:description => 'TCP local port'
|
62
|
+
|
63
|
+
# TCP server host
|
64
|
+
parameter :server_host, :type => String,
|
65
|
+
:description => 'TCP server host'
|
66
|
+
|
67
|
+
# TCP server port
|
68
|
+
parameter :server_port, :type => Integer,
|
69
|
+
:description => 'TCP server port'
|
70
|
+
end
|
62
71
|
|
63
72
|
protected
|
64
73
|
|
65
74
|
#
|
66
75
|
# Opens a TCP connection to the host and port specified by the
|
67
|
-
#
|
68
|
-
#
|
76
|
+
# `host` and `port` parameters. If the `local_host` and
|
77
|
+
# `local_port` parameters are set, they will be used for
|
69
78
|
# the local host and port of the TCP connection.
|
70
79
|
#
|
71
80
|
# @yield [socket]
|
@@ -87,6 +96,8 @@ module Ronin
|
|
87
96
|
# sock.close
|
88
97
|
# end
|
89
98
|
#
|
99
|
+
# @api public
|
100
|
+
#
|
90
101
|
def tcp_connect(&block)
|
91
102
|
print_info "Connecting to #{self.host}:#{self.port} ..."
|
92
103
|
|
@@ -94,7 +105,7 @@ module Ronin
|
|
94
105
|
end
|
95
106
|
|
96
107
|
#
|
97
|
-
# Connects to the host and port specified by the
|
108
|
+
# Connects to the host and port specified by the `host` and `port`
|
98
109
|
# parameters, then sends the given data.
|
99
110
|
#
|
100
111
|
# @param [String] data
|
@@ -109,6 +120,8 @@ module Ronin
|
|
109
120
|
# @return [TCPSocket]
|
110
121
|
# The newly created TCPSocket object.
|
111
122
|
#
|
123
|
+
# @api public
|
124
|
+
#
|
112
125
|
def tcp_connect_and_send(data,&block)
|
113
126
|
print_info "Connecting to #{self.host}:#{self.port} ..."
|
114
127
|
print_debug "Sending data: #{data.inspect}"
|
@@ -118,7 +131,7 @@ module Ronin
|
|
118
131
|
|
119
132
|
#
|
120
133
|
# Creates a TCP session to the host and port specified by the
|
121
|
-
#
|
134
|
+
# `host` and `port` parameters.
|
122
135
|
#
|
123
136
|
# @yield [socket]
|
124
137
|
# If a block is given, it will be passed the newly created socket.
|
@@ -129,6 +142,8 @@ module Ronin
|
|
129
142
|
#
|
130
143
|
# @return [nil]
|
131
144
|
#
|
145
|
+
# @api public
|
146
|
+
#
|
132
147
|
def tcp_session(&block)
|
133
148
|
print_info "Connecting to #{self.host}:#{self.port} ..."
|
134
149
|
|
@@ -139,7 +154,7 @@ module Ronin
|
|
139
154
|
end
|
140
155
|
|
141
156
|
#
|
142
|
-
# Connects to the host and port specified by the
|
157
|
+
# Connects to the host and port specified by the `host` and `port`
|
143
158
|
# parameters, reads the banner then closes the connection.
|
144
159
|
#
|
145
160
|
# @yield [banner]
|
@@ -155,6 +170,8 @@ module Ronin
|
|
155
170
|
# tcp_banner
|
156
171
|
# # => "220 mx.google.com ESMTP c20sm3096959rvf.1"
|
157
172
|
#
|
173
|
+
# @api public
|
174
|
+
#
|
158
175
|
def tcp_banner(&block)
|
159
176
|
print_debug "Grabbing banner from #{self.host}:#{self.port}"
|
160
177
|
|
@@ -162,7 +179,7 @@ module Ronin
|
|
162
179
|
end
|
163
180
|
|
164
181
|
#
|
165
|
-
# Connects to the host and port specified by the
|
182
|
+
# Connects to the host and port specified by the `host` and `port`
|
166
183
|
# parameters, sends the given data and then disconnects.
|
167
184
|
#
|
168
185
|
# @return [true]
|
@@ -173,6 +190,8 @@ module Ronin
|
|
173
190
|
# Net.tcp_send(buffer)
|
174
191
|
# # => true
|
175
192
|
#
|
193
|
+
# @api public
|
194
|
+
#
|
176
195
|
def tcp_send(data)
|
177
196
|
print_info "Connecting to #{self.host}:#{self.port} ..."
|
178
197
|
print_debug "Sending data: #{data.inspect}"
|
@@ -184,8 +203,8 @@ module Ronin
|
|
184
203
|
end
|
185
204
|
|
186
205
|
#
|
187
|
-
# Creates a new TCPServer object listening on the
|
188
|
-
# and
|
206
|
+
# Creates a new TCPServer object listening on the `server_host`
|
207
|
+
# and `server_port` parameters.
|
189
208
|
#
|
190
209
|
# @yield [server]
|
191
210
|
# The given block will be passed the newly created server.
|
@@ -199,6 +218,8 @@ module Ronin
|
|
199
218
|
# @example
|
200
219
|
# tcp_server
|
201
220
|
#
|
221
|
+
# @api public
|
222
|
+
#
|
202
223
|
def tcp_server(&block)
|
203
224
|
if self.server_host
|
204
225
|
print_info "Listening on #{self.server_host}:#{self.server_port} ..."
|
@@ -211,7 +232,7 @@ module Ronin
|
|
211
232
|
|
212
233
|
#
|
213
234
|
# Creates a new temporary TCPServer object listening on the
|
214
|
-
#
|
235
|
+
# `server_host` and `server_port` parameters.
|
215
236
|
#
|
216
237
|
# @yield [server]
|
217
238
|
# The given block will be passed the newly created server.
|
@@ -233,6 +254,8 @@ module Ronin
|
|
233
254
|
# client2.close
|
234
255
|
# end
|
235
256
|
#
|
257
|
+
# @api public
|
258
|
+
#
|
236
259
|
def tcp_server_session(&block)
|
237
260
|
if self.server_host
|
238
261
|
print_info "Listening on #{self.server_host}:#{self.server_port} ..."
|
@@ -253,7 +276,7 @@ module Ronin
|
|
253
276
|
|
254
277
|
#
|
255
278
|
# Creates a new temporary TCPServer object listening on
|
256
|
-
#
|
279
|
+
# `server_host` and `server_port` parameters.
|
257
280
|
# The TCPServer will accepting one client, pass the newly connected
|
258
281
|
# client to a given block, disconnects the client and stops
|
259
282
|
# listening.
|
@@ -273,6 +296,8 @@ module Ronin
|
|
273
296
|
# client.puts 'lol'
|
274
297
|
# end
|
275
298
|
#
|
299
|
+
# @api public
|
300
|
+
#
|
276
301
|
def tcp_single_server(&block)
|
277
302
|
if self.server_host
|
278
303
|
print_info "Listening on #{self.server_host}:#{self.server_port} ..."
|