ronin-db 0.1.2-java → 0.2.0.rc1-java
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 +4 -4
- data/.github/workflows/ruby.yml +3 -2
- data/.gitignore +1 -0
- data/ChangeLog.md +33 -0
- data/Gemfile +6 -4
- data/README.md +17 -5
- data/Rakefile +13 -35
- data/data/completions/ronin-db +271 -0
- data/gemspec.yml +17 -2
- data/lib/ronin/db/cli/command.rb +1 -1
- data/lib/ronin/db/cli/commands/add.rb +1 -1
- data/lib/ronin/db/cli/commands/asn.rb +12 -2
- data/lib/ronin/db/cli/commands/certs.rb +322 -0
- data/lib/ronin/db/cli/commands/completion.rb +63 -0
- data/lib/ronin/db/cli/commands/creds.rb +2 -1
- data/lib/ronin/db/cli/commands/edit.rb +1 -1
- data/lib/ronin/db/cli/commands/emails.rb +22 -1
- data/lib/ronin/db/cli/commands/hosts.rb +2 -1
- data/lib/ronin/db/cli/commands/ips.rb +2 -1
- data/lib/ronin/db/cli/commands/irb.rb +8 -4
- data/lib/ronin/db/cli/commands/list.rb +1 -1
- data/lib/ronin/db/cli/commands/migrate.rb +12 -8
- data/lib/ronin/db/cli/commands/open_ports.rb +102 -0
- data/lib/ronin/db/cli/commands/oses.rb +95 -0
- data/lib/ronin/db/cli/commands/passwords.rb +83 -0
- data/lib/ronin/db/cli/commands/people.rb +185 -0
- data/lib/ronin/db/cli/commands/phone_numbers.rb +136 -0
- data/lib/ronin/db/cli/commands/ports.rb +103 -0
- data/lib/ronin/db/cli/commands/remove.rb +1 -1
- data/lib/ronin/db/cli/commands/services.rb +102 -0
- data/lib/ronin/db/cli/commands/software.rb +95 -0
- data/lib/ronin/db/cli/commands/street_addresses.rb +129 -0
- data/lib/ronin/db/cli/commands/urls.rb +2 -1
- data/lib/ronin/db/cli/commands/web_vulns.rb +235 -0
- data/lib/ronin/db/cli/database_options.rb +87 -0
- data/lib/ronin/db/cli/deletable.rb +85 -0
- data/lib/ronin/db/cli/importable.rb +108 -0
- data/lib/ronin/db/cli/model_command.rb +8 -6
- data/lib/ronin/db/cli/modifiable.rb +12 -104
- data/lib/ronin/db/cli/printing.rb +58 -0
- data/lib/ronin/db/cli/ruby_shell.rb +1 -1
- data/lib/ronin/db/cli/uri_methods.rb +1 -1
- data/lib/ronin/db/cli.rb +3 -1
- data/lib/ronin/db/config_file.rb +13 -8
- data/lib/ronin/db/exceptions.rb +10 -1
- data/lib/ronin/db/home.rb +1 -1
- data/lib/ronin/db/root.rb +1 -1
- data/lib/ronin/db/tasks.rb +87 -0
- data/lib/ronin/db/version.rb +2 -2
- data/lib/ronin/db.rb +24 -7
- data/man/ronin-db-add.1 +48 -70
- data/man/ronin-db-add.1.md +26 -22
- data/man/ronin-db-asn.1 +37 -55
- data/man/ronin-db-asn.1.md +29 -19
- data/man/ronin-db-certs.1 +108 -0
- data/man/ronin-db-certs.1.md +106 -0
- data/man/ronin-db-completion.1 +76 -0
- data/man/ronin-db-completion.1.md +78 -0
- data/man/ronin-db-creds.1 +29 -47
- data/man/ronin-db-creds.1.md +23 -16
- data/man/ronin-db-edit.1 +16 -27
- data/man/ronin-db-edit.1.md +11 -7
- data/man/ronin-db-emails.1 +37 -50
- data/man/ronin-db-emails.1.md +30 -17
- data/man/ronin-db-hosts.1 +32 -52
- data/man/ronin-db-hosts.1.md +25 -18
- data/man/ronin-db-ips.1 +32 -53
- data/man/ronin-db-ips.1.md +26 -19
- data/man/ronin-db-irb.1 +23 -36
- data/man/ronin-db-irb.1.md +17 -10
- data/man/ronin-db-list.1 +17 -31
- data/man/ronin-db-list.1.md +13 -9
- data/man/ronin-db-migrate.1 +23 -36
- data/man/ronin-db-migrate.1.md +17 -10
- data/man/ronin-db-open-ports.1 +72 -0
- data/man/ronin-db-open-ports.1.md +70 -0
- data/man/ronin-db-oses.1 +72 -0
- data/man/ronin-db-oses.1.md +70 -0
- data/man/ronin-db-passwords.1 +75 -0
- data/man/ronin-db-passwords.1.md +73 -0
- data/man/ronin-db-people.1 +96 -0
- data/man/ronin-db-people.1.md +94 -0
- data/man/ronin-db-phone-numbers.1 +93 -0
- data/man/ronin-db-phone-numbers.1.md +91 -0
- data/man/ronin-db-ports.1 +87 -0
- data/man/ronin-db-ports.1.md +85 -0
- data/man/ronin-db-remove.1 +16 -29
- data/man/ronin-db-remove.1.md +12 -8
- data/man/ronin-db-services.1 +84 -0
- data/man/ronin-db-services.1.md +82 -0
- data/man/ronin-db-software.1 +72 -0
- data/man/ronin-db-software.1.md +70 -0
- data/man/ronin-db-street-addresses.1 +81 -0
- data/man/ronin-db-street-addresses.1.md +79 -0
- data/man/ronin-db-urls.1 +38 -61
- data/man/ronin-db-urls.1.md +28 -21
- data/man/ronin-db-web-vulns.1 +87 -0
- data/man/ronin-db-web-vulns.1.md +85 -0
- data/man/ronin-db.1 +118 -0
- data/man/ronin-db.1.md +99 -0
- data/scripts/setup +58 -0
- metadata +70 -13
- data/lib/ronin/db/cli/database_command.rb +0 -71
- data/lib/ronin/db/cli/resources_command.rb +0 -118
@@ -0,0 +1,322 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-db - A common database library for managing and querying security data.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-db is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-db is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU Lesser General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
18
|
+
# along with ronin-db. If not, see <https://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ronin/db/cli/model_command'
|
22
|
+
|
23
|
+
require 'command_kit/printing/indent'
|
24
|
+
require 'command_kit/printing/fields'
|
25
|
+
require 'command_kit/printing/lists'
|
26
|
+
|
27
|
+
module Ronin
|
28
|
+
module DB
|
29
|
+
class CLI
|
30
|
+
module Commands
|
31
|
+
#
|
32
|
+
# Queries or imports SSL/TLS certificates.
|
33
|
+
#
|
34
|
+
# ## Usage
|
35
|
+
#
|
36
|
+
# ronin-db asn [options]
|
37
|
+
#
|
38
|
+
# ## Options
|
39
|
+
#
|
40
|
+
# --db NAME The database to connect to (Default: default)
|
41
|
+
# --db-uri URI The database URI to connect to
|
42
|
+
# --db-file PATH The sqlite3 database file to use
|
43
|
+
# -v, --verbose Enables verbose output
|
44
|
+
# -A, --active Searches for all Certs that are active
|
45
|
+
# -E, --expired Searches for all Certs that are expired
|
46
|
+
# --issuer-common-name NAME Searches for all Certs with the Issuer Common Name (CN)
|
47
|
+
# --issuer-organization NAME Searches for all Certs with the Issuer Organization (O)
|
48
|
+
# --issuer-organizational-unit NAME
|
49
|
+
# Searches for all Certs with the Issuer Organizational Unit (OU)
|
50
|
+
# --issuer-locality LOCALITY Searches for all Certs with the Issuer Locality (L)
|
51
|
+
# --issuer-state STATE Searches for all Certs with the Issuer State (ST)
|
52
|
+
# --issuer-country COUNTRY Searches for all Certs with the Issuer Country (C)
|
53
|
+
# --common-name HOST Searches for all Certs with the Subject Common Name (CN)
|
54
|
+
# --subject-alt-name HOST Searches for all Certs with the Subject Alternative Name (SAN)
|
55
|
+
# --organization NAME Searches for all Certs with the Subject Organization (O)
|
56
|
+
# --organizational-unit NAME Searches for all Certs with the Subject Organizational Unit (OU)
|
57
|
+
# --locality LOCALITY Searches for all Certs with the Subject Locality (L)
|
58
|
+
# --state STATE Searches for all Certs with the Subject State (ST)
|
59
|
+
# --country COUNTRY Searches for all Certs with the Subject Country (C)
|
60
|
+
# --import FILE Imports a Cert from a file
|
61
|
+
# -h, --help Print help information
|
62
|
+
#
|
63
|
+
# @since 0.2.0
|
64
|
+
#
|
65
|
+
class Certs < ModelCommand
|
66
|
+
|
67
|
+
include CommandKit::Printing::Indent
|
68
|
+
include CommandKit::Printing::Fields
|
69
|
+
include CommandKit::Printing::Lists
|
70
|
+
|
71
|
+
model_file 'ronin/db/cert'
|
72
|
+
model_name 'Cert'
|
73
|
+
|
74
|
+
option :active, short: '-A',
|
75
|
+
desc: 'Searches for all Certs that are active' do
|
76
|
+
@query_method_calls << [:active]
|
77
|
+
end
|
78
|
+
|
79
|
+
option :expired, short: '-E',
|
80
|
+
desc: 'Searches for all Certs that are expired' do
|
81
|
+
@query_method_calls << [:expired]
|
82
|
+
end
|
83
|
+
|
84
|
+
option :issuer_common_name, value: {
|
85
|
+
type: String,
|
86
|
+
usage: 'NAME'
|
87
|
+
},
|
88
|
+
desc: 'Searches for all Certs with the Issuer Common Name (CN)' do |name|
|
89
|
+
@query_method_calls << [:with_issuer_common_name, [name]]
|
90
|
+
end
|
91
|
+
|
92
|
+
option :issuer_organization, value: {
|
93
|
+
type: String,
|
94
|
+
usage: 'NAME'
|
95
|
+
},
|
96
|
+
desc: 'Searches for all Certs with the Issuer Organization (O)' do |name|
|
97
|
+
@query_method_calls << [:with_issuer_organization, [name]]
|
98
|
+
end
|
99
|
+
|
100
|
+
option :issuer_organizational_unit, value: {
|
101
|
+
type: String,
|
102
|
+
usage: 'NAME'
|
103
|
+
},
|
104
|
+
desc: 'Searches for all Certs with the Issuer Organizational Unit (OU)' do |name|
|
105
|
+
@query_method_calls << [:with_issuer_organizational_unit, [name]]
|
106
|
+
end
|
107
|
+
|
108
|
+
option :issuer_locality, value: {
|
109
|
+
type: String,
|
110
|
+
usage: 'LOCALITY'
|
111
|
+
},
|
112
|
+
desc: 'Searches for all Certs with the Issuer Locality (L)' do |locality|
|
113
|
+
@query_method_calls << [:with_issuer_locality, [locality]]
|
114
|
+
end
|
115
|
+
|
116
|
+
option :issuer_state, value: {
|
117
|
+
type: String,
|
118
|
+
usage: 'STATE'
|
119
|
+
},
|
120
|
+
desc: 'Searches for all Certs with the Issuer State (ST)' do |state|
|
121
|
+
@query_method_calls << [:with_issuer_state, [state]]
|
122
|
+
end
|
123
|
+
|
124
|
+
option :issuer_country, value: {
|
125
|
+
type: String,
|
126
|
+
usage: 'COUNTRY'
|
127
|
+
},
|
128
|
+
desc: 'Searches for all Certs with the Issuer Country (C)' do |country|
|
129
|
+
@query_method_calls << [:with_issuer_country, [country]]
|
130
|
+
end
|
131
|
+
|
132
|
+
option :common_name, value: {
|
133
|
+
type: String,
|
134
|
+
usage: 'HOST'
|
135
|
+
},
|
136
|
+
desc: 'Searches for all Certs with the Subject Common Name (CN)' do |host|
|
137
|
+
@query_method_calls << [:with_common_name, [host]]
|
138
|
+
end
|
139
|
+
|
140
|
+
option :subject_alt_name, value: {
|
141
|
+
type: String,
|
142
|
+
usage: 'HOST'
|
143
|
+
},
|
144
|
+
desc: 'Searches for all Certs with the Subject Alternative Name (SAN)' do |host|
|
145
|
+
@query_method_calls << [:with_subject_alt_name, [host]]
|
146
|
+
end
|
147
|
+
|
148
|
+
option :organization, value: {
|
149
|
+
type: String,
|
150
|
+
usage: 'NAME'
|
151
|
+
},
|
152
|
+
desc: 'Searches for all Certs with the Subject Organization (O)' do |name|
|
153
|
+
@query_method_calls << [:with_organization, [name]]
|
154
|
+
end
|
155
|
+
|
156
|
+
option :organizational_unit, value: {
|
157
|
+
type: String,
|
158
|
+
usage: 'NAME'
|
159
|
+
},
|
160
|
+
desc: 'Searches for all Certs with the Subject Organizational Unit (OU)' do |name|
|
161
|
+
@query_method_calls << [:with_organizational_unit, [name]]
|
162
|
+
end
|
163
|
+
|
164
|
+
option :locality, value: {
|
165
|
+
type: String,
|
166
|
+
usage: 'LOCALITY'
|
167
|
+
},
|
168
|
+
desc: 'Searches for all Certs with the Subject Locality (L)' do |locality|
|
169
|
+
@query_method_calls << [:with_locality, [locality]]
|
170
|
+
end
|
171
|
+
|
172
|
+
option :state, value: {
|
173
|
+
type: String,
|
174
|
+
usage: 'STATE'
|
175
|
+
},
|
176
|
+
desc: 'Searches for all Certs with the Subject State (ST)' do |state|
|
177
|
+
@query_method_calls << [:with_state, [state]]
|
178
|
+
end
|
179
|
+
|
180
|
+
option :country, value: {
|
181
|
+
type: String,
|
182
|
+
usage: 'COUNTRY'
|
183
|
+
},
|
184
|
+
desc: 'Searches for all Certs with the Subject Country (C)' do |country|
|
185
|
+
@query_method_calls << [:with_country, [country]]
|
186
|
+
end
|
187
|
+
|
188
|
+
option :import, value: {
|
189
|
+
type: String,
|
190
|
+
usage: 'FILE'
|
191
|
+
},
|
192
|
+
desc: 'Imports a Cert from a file'
|
193
|
+
|
194
|
+
description 'Queries or imports SSL/TLS certificates'
|
195
|
+
|
196
|
+
man_page 'ronin-db-certs.1'
|
197
|
+
|
198
|
+
#
|
199
|
+
# Runs the `ronin-db certs` command.
|
200
|
+
#
|
201
|
+
def run
|
202
|
+
db_connect
|
203
|
+
|
204
|
+
if options[:import]
|
205
|
+
import_cert(options[:import])
|
206
|
+
else
|
207
|
+
list
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
#
|
212
|
+
# Imports a certificate from a file.
|
213
|
+
#
|
214
|
+
# @param [String] path
|
215
|
+
# The path to the certificate file.
|
216
|
+
#
|
217
|
+
def import_cert(path)
|
218
|
+
unless File.file?(path)
|
219
|
+
print_error "no such file or directory: #{path}"
|
220
|
+
exit(-1)
|
221
|
+
end
|
222
|
+
|
223
|
+
cert = begin
|
224
|
+
Ronin::Support::Crypto::Cert.load_file(path)
|
225
|
+
rescue OpenSSL::X509::CertificateError
|
226
|
+
print_error "cannot parse the certificate file: #{path}"
|
227
|
+
exit(-1)
|
228
|
+
end
|
229
|
+
|
230
|
+
model.find_or_import(cert)
|
231
|
+
end
|
232
|
+
|
233
|
+
#
|
234
|
+
# Prints a certificate record.
|
235
|
+
#
|
236
|
+
# @param [Ronin::DB::Cert] cert
|
237
|
+
# The certificate record to print.
|
238
|
+
#
|
239
|
+
def print_record(cert)
|
240
|
+
puts "[ #{cert.subject.common_name} ]"
|
241
|
+
puts
|
242
|
+
|
243
|
+
indent do
|
244
|
+
print_fields(
|
245
|
+
"Serial" => cert.serial,
|
246
|
+
"Not Before" => cert.not_before,
|
247
|
+
"Not After" => cert.not_after
|
248
|
+
)
|
249
|
+
puts
|
250
|
+
|
251
|
+
puts "Subject:"
|
252
|
+
indent { print_cert_org(cert.subject) }
|
253
|
+
puts
|
254
|
+
|
255
|
+
unless cert.subject_alt_names.empty?
|
256
|
+
puts "Subject Alt Names:"
|
257
|
+
indent { print_list(cert.subject_alt_names) }
|
258
|
+
puts
|
259
|
+
end
|
260
|
+
|
261
|
+
if cert.issuer
|
262
|
+
puts "Issuer:"
|
263
|
+
indent { print_cert_org(cert.issuer) }
|
264
|
+
puts
|
265
|
+
end
|
266
|
+
|
267
|
+
print_fields(
|
268
|
+
'Public Key Algorithm' => cert.public_key_algorithm.upcase,
|
269
|
+
'Public Key Size' => cert.public_key_size,
|
270
|
+
'Signing Algorithm' => cert.signing_algorithm,
|
271
|
+
'SHA1 Fingerprint' => cert.sha1_fingerprint,
|
272
|
+
'SHA256 Fingerprint' => cert.sha256_fingerprint
|
273
|
+
)
|
274
|
+
end
|
275
|
+
puts
|
276
|
+
end
|
277
|
+
|
278
|
+
#
|
279
|
+
# Prints a certificate Subject or Issuer.
|
280
|
+
#
|
281
|
+
# @param [Ronin::DB::CertSubject, Ronin::DB::CertIssuer] cert_org
|
282
|
+
# The Subject or Issuer to print.
|
283
|
+
#
|
284
|
+
def print_cert_org(cert_org)
|
285
|
+
fields = {}
|
286
|
+
|
287
|
+
if cert_org.common_name
|
288
|
+
fields['Common Name (CN)'] = cert_org.common_name
|
289
|
+
end
|
290
|
+
|
291
|
+
if cert_org.email_address
|
292
|
+
fields['Email address'] = cert_org.email_address
|
293
|
+
end
|
294
|
+
|
295
|
+
if cert_org.organization
|
296
|
+
fields['Organization (O)'] = cert_org.organization
|
297
|
+
end
|
298
|
+
|
299
|
+
if cert_org.organizational_unit
|
300
|
+
fields['Organization Unit (OU)'] = cert_org.organizational_unit
|
301
|
+
end
|
302
|
+
|
303
|
+
if cert_org.locality
|
304
|
+
fields['Locality (L)'] = cert_org.locality
|
305
|
+
end
|
306
|
+
|
307
|
+
if cert_org.state
|
308
|
+
fields['State (ST)'] = cert_org.state
|
309
|
+
end
|
310
|
+
|
311
|
+
if cert_org.country
|
312
|
+
fields['Country (C)'] = cert_org.country
|
313
|
+
end
|
314
|
+
|
315
|
+
print_fields(fields)
|
316
|
+
end
|
317
|
+
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-db - A common database library for managing and querying security data.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-db is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-db is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU Lesser General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
18
|
+
# along with ronin-db. If not, see <https://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ronin/db/root'
|
22
|
+
require 'ronin/core/cli/completion_command'
|
23
|
+
|
24
|
+
module Ronin
|
25
|
+
module DB
|
26
|
+
class CLI
|
27
|
+
module Commands
|
28
|
+
#
|
29
|
+
# Manages the shell completion rules for `ronin-db`.
|
30
|
+
#
|
31
|
+
# ## Usage
|
32
|
+
#
|
33
|
+
# ronin-db completion [options]
|
34
|
+
#
|
35
|
+
# ## Options
|
36
|
+
#
|
37
|
+
# --print Prints the shell completion file
|
38
|
+
# --install Installs the shell completion file
|
39
|
+
# --uninstall Uninstalls the shell completion file
|
40
|
+
# -h, --help Print help information
|
41
|
+
#
|
42
|
+
# ## Examples
|
43
|
+
#
|
44
|
+
# ronin-db completion --print
|
45
|
+
# ronin-db completion --install
|
46
|
+
# ronin-db completion --uninstall
|
47
|
+
#
|
48
|
+
# @since 0.2.0
|
49
|
+
#
|
50
|
+
class Completion < Core::CLI::CompletionCommand
|
51
|
+
|
52
|
+
completion_file File.join(ROOT,'data','completions','ronin-db')
|
53
|
+
|
54
|
+
man_dir File.join(ROOT,'man')
|
55
|
+
man_page 'ronin-db-completion.1'
|
56
|
+
|
57
|
+
description 'Manages the shell completion rules for ronin-db'
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db - A common database library for managing and querying security data.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2006-
|
5
|
+
# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -36,6 +36,7 @@ module Ronin
|
|
36
36
|
#
|
37
37
|
# --db NAME The database to connect to (Default: default)
|
38
38
|
# --db-uri URI The database URI to connect to
|
39
|
+
# --db-file PATH The sqlite3 database file to use
|
39
40
|
# -v, --verbose Enables verbose output
|
40
41
|
# --add VALUE Adds a value to the database
|
41
42
|
# --import FILE Imports the values from the FILE into the database
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db - A common database library for managing and querying security data.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2006-
|
5
|
+
# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db - A common database library for managing and querying security data.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2006-
|
5
|
+
# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -36,6 +36,7 @@ module Ronin
|
|
36
36
|
#
|
37
37
|
# --db NAME The database to connect to (Default: default)
|
38
38
|
# --db-uri URI The database URI to connect to
|
39
|
+
# --db-file PATH The sqlite3 database file to use
|
39
40
|
# -v, --verbose Enables verbose output
|
40
41
|
# --add VALUE Adds a value to the database
|
41
42
|
# --import FILE Imports the values from the FILE into the database
|
@@ -44,6 +45,8 @@ module Ronin
|
|
44
45
|
# -H, --with-host [HOST [...]]
|
45
46
|
# -I, --with-ip [IP [...]]
|
46
47
|
# -u, --with-user [NAME [...]]
|
48
|
+
# -P, --for-person FULL_NAME Searches for the associated person
|
49
|
+
# -O, --for-organization NAME Searches for the associated organization
|
47
50
|
#
|
48
51
|
class Emails < ModelCommand
|
49
52
|
|
@@ -79,6 +82,24 @@ module Ronin
|
|
79
82
|
@query_method_calls << [:with_user_name, [user]]
|
80
83
|
end
|
81
84
|
|
85
|
+
option :for_person, short: '-P',
|
86
|
+
value: {
|
87
|
+
type: String,
|
88
|
+
usage: 'FULL_NAME'
|
89
|
+
},
|
90
|
+
desc: 'Searches for the associated person' do |full_name|
|
91
|
+
@query_method_calls << [:for_person, [full_name]]
|
92
|
+
end
|
93
|
+
|
94
|
+
option :for_organization, short: '-O',
|
95
|
+
value: {
|
96
|
+
type: String,
|
97
|
+
usage: 'NAME'
|
98
|
+
},
|
99
|
+
desc: 'Searches for the associated organization' do |name|
|
100
|
+
@query_method_calls << [:for_organization, [name]]
|
101
|
+
end
|
102
|
+
|
82
103
|
description 'Manages all email addresses in the database'
|
83
104
|
|
84
105
|
man_page 'ronin-db-emails.1'
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db - A common database library for managing and querying security data.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2006-
|
5
|
+
# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -36,6 +36,7 @@ module Ronin
|
|
36
36
|
#
|
37
37
|
# --db NAME The database to connect to (Default: default)
|
38
38
|
# --db-uri URI The database URI to connect to
|
39
|
+
# --db-file PATH The sqlite3 database file to use
|
39
40
|
# -v, --verbose Enables verbose output
|
40
41
|
# --add VALUE Adds a value to the database
|
41
42
|
# --import FILE Imports the values from the FILE into the database
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db - A common database library for managing and querying security data.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2006-
|
5
|
+
# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -36,6 +36,7 @@ module Ronin
|
|
36
36
|
#
|
37
37
|
# --db NAME The database to connect to (Default: default)
|
38
38
|
# --db-uri URI The database URI to connect to
|
39
|
+
# --db-file PATH The sqlite3 database file to use
|
39
40
|
# -v, --verbose Enables verbose output
|
40
41
|
# --add VALUE Adds a value to the database
|
41
42
|
# --import FILE Imports the values from the FILE into the database
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db - A common database library for managing and querying security data.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2006-
|
5
|
+
# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -18,7 +18,8 @@
|
|
18
18
|
# along with ronin-db. If not, see <https://www.gnu.org/licenses/>.
|
19
19
|
#
|
20
20
|
|
21
|
-
require 'ronin/db/cli/
|
21
|
+
require 'ronin/db/cli/command'
|
22
|
+
require 'ronin/db/cli/database_options'
|
22
23
|
require 'ronin/db/cli/ruby_shell'
|
23
24
|
|
24
25
|
module Ronin
|
@@ -36,10 +37,13 @@ module Ronin
|
|
36
37
|
#
|
37
38
|
# --db NAME The database to connect to (Default: default)
|
38
39
|
# --db-uri URI The database URI to connect to
|
40
|
+
# --db-file PATH The sqlite3 database file to use
|
39
41
|
# --no-connect Do not connect to a database on startup
|
40
42
|
# -h, --help Print help information
|
41
43
|
#
|
42
|
-
class Irb <
|
44
|
+
class Irb < Command
|
45
|
+
|
46
|
+
include DatabaseOptions
|
43
47
|
|
44
48
|
option :no_connect, desc: 'Do not connect to a database on startup'
|
45
49
|
|
@@ -52,7 +56,7 @@ module Ronin
|
|
52
56
|
#
|
53
57
|
def run
|
54
58
|
unless options[:no_connect]
|
55
|
-
|
59
|
+
db_connect
|
56
60
|
load_models
|
57
61
|
end
|
58
62
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db - A common database library for managing and querying security data.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2006-
|
5
|
+
# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db - A common database library for managing and querying security data.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2006-
|
5
|
+
# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -18,7 +18,8 @@
|
|
18
18
|
# along with ronin-db. If not, see <https://www.gnu.org/licenses/>.
|
19
19
|
#
|
20
20
|
|
21
|
-
require 'ronin/db/cli/
|
21
|
+
require 'ronin/db/cli/command'
|
22
|
+
require 'ronin/db/cli/database_options'
|
22
23
|
require 'ronin/db'
|
23
24
|
|
24
25
|
module Ronin
|
@@ -36,9 +37,12 @@ module Ronin
|
|
36
37
|
#
|
37
38
|
# --db NAME The database to connect to (Default: default)
|
38
39
|
# --db-uri URI The database URI to connect to
|
40
|
+
# --db-file PATH The sqlite3 database file to use
|
39
41
|
# -h, --help Print help information
|
40
42
|
#
|
41
|
-
class Migrate <
|
43
|
+
class Migrate < Command
|
44
|
+
|
45
|
+
include DatabaseOptions
|
42
46
|
|
43
47
|
usage '[options]'
|
44
48
|
|
@@ -50,21 +54,21 @@ module Ronin
|
|
50
54
|
# Runs the `ronin-db migrate` command.
|
51
55
|
#
|
52
56
|
def run
|
53
|
-
|
54
|
-
|
57
|
+
db_connect
|
58
|
+
db_migrate
|
55
59
|
end
|
56
60
|
|
57
61
|
#
|
58
62
|
# Connects to the database.
|
59
63
|
#
|
60
|
-
def
|
61
|
-
DB.connect(
|
64
|
+
def db_connect
|
65
|
+
DB.connect(db_config, load_models: false)
|
62
66
|
end
|
63
67
|
|
64
68
|
#
|
65
69
|
# Runs migrations.
|
66
70
|
#
|
67
|
-
def
|
71
|
+
def db_migrate
|
68
72
|
DB.migrate!
|
69
73
|
end
|
70
74
|
|