ronin-app 0.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +7 -0
  2. data/.dockerignore +3 -0
  3. data/.document +6 -0
  4. data/.env.dev +1 -0
  5. data/.github/workflows/ruby.yml +44 -0
  6. data/.gitignore +16 -0
  7. data/.rspec +1 -0
  8. data/.rubocop.yml +26 -0
  9. data/.ruby-version +1 -0
  10. data/.yardopts +1 -0
  11. data/CONTRIBUTING.md +34 -0
  12. data/COPYING.txt +661 -0
  13. data/ChangeLog.md +38 -0
  14. data/Dockerfile +27 -0
  15. data/Gemfile +61 -0
  16. data/Procfile +2 -0
  17. data/Procfile.dev +2 -0
  18. data/README.md +215 -0
  19. data/Rakefile +44 -0
  20. data/app/db.rb +680 -0
  21. data/app/scanning.rb +173 -0
  22. data/app.rb +372 -0
  23. data/bin/ronin-app +34 -0
  24. data/config/database.rb +17 -0
  25. data/config/puma.rb +24 -0
  26. data/config/redis.rb +4 -0
  27. data/config/sidekiq.rb +23 -0
  28. data/config/sidekiq.yml +12 -0
  29. data/config.ru +33 -0
  30. data/docker-compose.yml +45 -0
  31. data/etc/systemd/user/ronin-app-sidekiq.1.service +17 -0
  32. data/etc/systemd/user/ronin-app-web.1.service +18 -0
  33. data/etc/systemd/user/ronin-app.target +5 -0
  34. data/gemspec.yml +55 -0
  35. data/lib/middleware/sidekiq/active_record_connection_pool.rb +47 -0
  36. data/lib/ronin/app/cli.rb +197 -0
  37. data/lib/ronin/app/helpers/html.rb +71 -0
  38. data/lib/ronin/app/root.rb +28 -0
  39. data/lib/ronin/app/schemas/params_schema.rb +66 -0
  40. data/lib/ronin/app/schemas/payloads/build_schema.rb +56 -0
  41. data/lib/ronin/app/schemas/payloads/encoders/encode_schema.rb +60 -0
  42. data/lib/ronin/app/types/import.rb +35 -0
  43. data/lib/ronin/app/types/nmap.rb +81 -0
  44. data/lib/ronin/app/types/spider.rb +49 -0
  45. data/lib/ronin/app/types/vulns.rb +69 -0
  46. data/lib/ronin/app/types.rb +66 -0
  47. data/lib/ronin/app/validations/import_params.rb +71 -0
  48. data/lib/ronin/app/validations/install_repo_params.rb +78 -0
  49. data/lib/ronin/app/validations/masscan_params.rb +122 -0
  50. data/lib/ronin/app/validations/nmap_params.rb +183 -0
  51. data/lib/ronin/app/validations/recon_params.rb +86 -0
  52. data/lib/ronin/app/validations/spider_params.rb +103 -0
  53. data/lib/ronin/app/validations/vulns_params.rb +83 -0
  54. data/lib/ronin/app/version.rb +26 -0
  55. data/log/.gitkeep +0 -0
  56. data/man/ronin-app.1 +63 -0
  57. data/man/ronin-app.1.md +61 -0
  58. data/public/images/favicon.png +0 -0
  59. data/public/images/favicon.svg +78 -0
  60. data/public/images/logo.svg +78 -0
  61. data/public/images/sidekiq.svg +24 -0
  62. data/public/javascript/app.js +60 -0
  63. data/public/javascript/notes.js +28 -0
  64. data/public/javascript/tabs.js +40 -0
  65. data/public/stylesheets/app.css +216 -0
  66. data/public/stylesheets/bulma.min.css +1 -0
  67. data/ronin-app.gemspec +63 -0
  68. data/scripts/console +7 -0
  69. data/scripts/server +134 -0
  70. data/scripts/setup +447 -0
  71. data/scripts/update +55 -0
  72. data/tmp/.gitkeep +0 -0
  73. data/views/_authors.erb +62 -0
  74. data/views/_delete.erb +4 -0
  75. data/views/_delete_all.erb +4 -0
  76. data/views/_encoding_tabs.erb +25 -0
  77. data/views/_notes.erb +33 -0
  78. data/views/_pagination.erb +1 -0
  79. data/views/_param_fields.erb +66 -0
  80. data/views/_params.erb +35 -0
  81. data/views/about.erb +30 -0
  82. data/views/db/advisories/index.erb +30 -0
  83. data/views/db/advisories/show.erb +105 -0
  84. data/views/db/asns/index.erb +19 -0
  85. data/views/db/asns/show.erb +61 -0
  86. data/views/db/credentials/index.erb +30 -0
  87. data/views/db/credentials/show.erb +51 -0
  88. data/views/db/email_addresses/index.erb +30 -0
  89. data/views/db/email_addresses/show.erb +44 -0
  90. data/views/db/host_names/index.erb +30 -0
  91. data/views/db/host_names/show.erb +52 -0
  92. data/views/db/ip_addresses/index.erb +19 -0
  93. data/views/db/ip_addresses/show.erb +98 -0
  94. data/views/db/mac_addresses/index.erb +19 -0
  95. data/views/db/mac_addresses/show.erb +62 -0
  96. data/views/db/open_ports/index.erb +19 -0
  97. data/views/db/open_ports/show.erb +87 -0
  98. data/views/db/organizations/departments/show.erb +82 -0
  99. data/views/db/organizations/index.erb +28 -0
  100. data/views/db/organizations/members/show.erb +87 -0
  101. data/views/db/organizations/show.erb +111 -0
  102. data/views/db/oses/index.erb +19 -0
  103. data/views/db/oses/show.erb +46 -0
  104. data/views/db/passwords/index.erb +30 -0
  105. data/views/db/passwords/show.erb +52 -0
  106. data/views/db/people/index.erb +31 -0
  107. data/views/db/people/show.erb +120 -0
  108. data/views/db/phone_numbers/index.erb +30 -0
  109. data/views/db/phone_numbers/show.erb +63 -0
  110. data/views/db/ports/index.erb +30 -0
  111. data/views/db/ports/show.erb +70 -0
  112. data/views/db/services/index.erb +30 -0
  113. data/views/db/services/show.erb +65 -0
  114. data/views/db/software/index.erb +19 -0
  115. data/views/db/software/show.erb +52 -0
  116. data/views/db/software_vendors/index.erb +19 -0
  117. data/views/db/software_vendors/show.erb +36 -0
  118. data/views/db/street_addresses/index.erb +19 -0
  119. data/views/db/street_addresses/show.erb +63 -0
  120. data/views/db/url_query_param_names/index.erb +19 -0
  121. data/views/db/url_query_param_names/show.erb +50 -0
  122. data/views/db/url_schemes/index.erb +19 -0
  123. data/views/db/url_schemes/show.erb +36 -0
  124. data/views/db/urls/index.erb +30 -0
  125. data/views/db/urls/show.erb +103 -0
  126. data/views/db/user_names/index.erb +30 -0
  127. data/views/db/user_names/show.erb +48 -0
  128. data/views/db/vulns/index.erb +19 -0
  129. data/views/db/vulns/show.erb +104 -0
  130. data/views/db.erb +152 -0
  131. data/views/exploits/index.erb +9 -0
  132. data/views/exploits/show.erb +100 -0
  133. data/views/import.erb +30 -0
  134. data/views/index.erb +7 -0
  135. data/views/layout.erb +98 -0
  136. data/views/masscan.erb +459 -0
  137. data/views/nmap.erb +1009 -0
  138. data/views/payloads/build.erb +19 -0
  139. data/views/payloads/encoders/encode.erb +35 -0
  140. data/views/payloads/encoders/index.erb +9 -0
  141. data/views/payloads/encoders/show.erb +47 -0
  142. data/views/payloads/index.erb +9 -0
  143. data/views/payloads/show.erb +47 -0
  144. data/views/queue.erb +28 -0
  145. data/views/recon.erb +55 -0
  146. data/views/repos/index.erb +30 -0
  147. data/views/repos/install.erb +45 -0
  148. data/views/repos/show.erb +39 -0
  149. data/views/spider.erb +372 -0
  150. data/views/vulns.erb +214 -0
  151. data/workers/import.rb +96 -0
  152. data/workers/install_repo.rb +40 -0
  153. data/workers/masscan.rb +135 -0
  154. data/workers/nmap.rb +216 -0
  155. data/workers/purge_repos.rb +40 -0
  156. data/workers/recon.rb +95 -0
  157. data/workers/remove_repo.rb +40 -0
  158. data/workers/spider.rb +148 -0
  159. data/workers/update_repo.rb +42 -0
  160. data/workers/update_repos.rb +40 -0
  161. data/workers/vulns.rb +111 -0
  162. data/workers.rb +37 -0
  163. metadata +538 -0
data/app/db.rb ADDED
@@ -0,0 +1,680 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-app - a local web app for Ronin.
4
+ #
5
+ # Copyright (C) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
6
+ #
7
+ # ronin-app is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Affero General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-app 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 Affero General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Affero General Public License
18
+ # along with ronin-app. If not, see <http://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ #
22
+ # App class containing routes for database.
23
+ #
24
+ class App < Sinatra::Base
25
+
26
+ include Ronin::App
27
+ include Pagy::Backend
28
+
29
+ configure do
30
+ enable :sessions
31
+ register Sinatra::Flash
32
+ helpers Sinatra::ContentFor
33
+ helpers Helpers::HTML
34
+ end
35
+
36
+ configure :development do
37
+ register Sinatra::Reloader
38
+ end
39
+
40
+ helpers do
41
+ include Pagy::Frontend
42
+ end
43
+
44
+ get '/db' do
45
+ @host_name_count = Ronin::DB::HostName.count
46
+ @asn_count = Ronin::DB::ASN.count
47
+ @ip_address_count = Ronin::DB::IPAddress.count
48
+ @mac_address_count = Ronin::DB::MACAddress.count
49
+ @open_port_count = Ronin::DB::OpenPort.count
50
+ @port_count = Ronin::DB::Port.count
51
+ @service_count = Ronin::DB::Service.count
52
+ @url_count = Ronin::DB::URL.count
53
+ @url_scheme_count = Ronin::DB::URLScheme.count
54
+ @url_query_param_name_count = Ronin::DB::URLQueryParamName.count
55
+ @email_address_count = Ronin::DB::EmailAddress.count
56
+ @user_name_count = Ronin::DB::UserName.count
57
+ @password_count = Ronin::DB::Password.count
58
+ @credential_count = Ronin::DB::Credential.count
59
+ @advisory_count = Ronin::DB::Advisory.count
60
+ @software_count = Ronin::DB::Software.count
61
+ @software_vendor_count = Ronin::DB::SoftwareVendor.count
62
+ @oses_count = Ronin::DB::OS.count
63
+ @vulns_count = Ronin::DB::WebVuln.count
64
+ @phone_number_count = Ronin::DB::PhoneNumber.count
65
+ @street_address_count = Ronin::DB::StreetAddress.count
66
+ @organization_count = Ronin::DB::Organization.count
67
+ @people_count = Ronin::DB::Person.count
68
+
69
+ erb :db
70
+ end
71
+
72
+ get '/db/host_names' do
73
+ @pagy, @host_names = pagy(Ronin::DB::HostName)
74
+
75
+ erb :"db/host_names/index"
76
+ end
77
+
78
+ get '/db/host_names/:id' do
79
+ @host_name = Ronin::DB::HostName.find(params[:id])
80
+
81
+ if @host_name
82
+ erb :"db/host_names/show"
83
+ else
84
+ halt 404
85
+ end
86
+ end
87
+
88
+ post '/db/host_names/import' do
89
+ begin
90
+ host_name = Ronin::DB::HostName.find_or_import(params[:host_name])
91
+ rescue ArgumentError => error
92
+ flash[:danger] = error.message
93
+ redirect "db/host_names"
94
+ end
95
+
96
+ redirect "/db/host_names/#{host_name.id}"
97
+ end
98
+
99
+ {
100
+ mac_addresses: Ronin::DB::MACAddress,
101
+ ip_addresses: Ronin::DB::IPAddress,
102
+ host_names: Ronin::DB::HostName,
103
+ ports: Ronin::DB::Port,
104
+ services: Ronin::DB::Service,
105
+ open_ports: Ronin::DB::OpenPort,
106
+ credentials: Ronin::DB::Credential,
107
+ urls: Ronin::DB::URL,
108
+ user_names: Ronin::DB::UserName,
109
+ email_addresses: Ronin::DB::EmailAddress,
110
+ passwords: Ronin::DB::Password,
111
+ advisories: Ronin::DB::Advisory
112
+ }.each do |name, model|
113
+ post "/db/#{name}/:id/notes" do
114
+ @record = model.find(params[:id])
115
+
116
+ if @record
117
+ if @record.notes.create!(body: params[:body])
118
+ flash[:success] = "Note added successfully."
119
+ else
120
+ flash[:danger] = "Failed to create Note."
121
+ end
122
+
123
+ redirect "/db/#{name}/#{params[:id]}"
124
+ else
125
+ halt 404
126
+ end
127
+ end
128
+
129
+ delete "/db/#{name}/:id/notes/:note_id" do
130
+ @record = model.find(params[:id])
131
+
132
+ if @record && @record.notes.destroy(params[:note_id])
133
+ redirect "db/#{name}/#{params[:id]}"
134
+ else
135
+ halt 404
136
+ end
137
+ end
138
+ end
139
+
140
+ get '/db/asns' do
141
+ @pagy, @asns = pagy(Ronin::DB::ASN)
142
+
143
+ erb :"db/asns/index"
144
+ end
145
+
146
+ get '/db/asns/:id' do
147
+ @asn = Ronin::DB::ASN.find(params[:id])
148
+
149
+ if @asn
150
+ erb :"db/asns/show"
151
+ else
152
+ halt 404
153
+ end
154
+ end
155
+
156
+ get '/db/ip_addresses' do
157
+ @pagy, @ip_addresses = pagy(Ronin::DB::IPAddress)
158
+
159
+ erb :"db/ip_addresses/index"
160
+ end
161
+
162
+ get '/db/ip_addresses/:id' do
163
+ @ip_address = Ronin::DB::IPAddress.find(params[:id])
164
+
165
+ if @ip_address
166
+ erb :"db/ip_addresses/show"
167
+ else
168
+ halt 404
169
+ end
170
+ end
171
+
172
+ get '/db/mac_addresses' do
173
+ @pagy, @mac_addresses = pagy(Ronin::DB::MACAddress)
174
+
175
+ erb :"db/mac_addresses/index"
176
+ end
177
+
178
+ get '/db/mac_addresses/:id' do
179
+ @mac_address = Ronin::DB::MACAddress.find(params[:id])
180
+
181
+ if @mac_address
182
+ erb :"db/mac_addresses/show"
183
+ else
184
+ halt 404
185
+ end
186
+ end
187
+
188
+ get '/db/open_ports' do
189
+ @pagy, @open_ports = pagy(Ronin::DB::OpenPort)
190
+
191
+ erb :"db/open_ports/index"
192
+ end
193
+
194
+ get '/db/open_ports/:id' do
195
+ @open_port = Ronin::DB::OpenPort.find(params[:id])
196
+
197
+ if @open_port
198
+ erb :"db/open_ports/show"
199
+ else
200
+ halt 404
201
+ end
202
+ end
203
+
204
+ get '/db/ports' do
205
+ @pagy, @ports = pagy(Ronin::DB::Port)
206
+
207
+ erb :"db/ports/index"
208
+ end
209
+
210
+ get '/db/ports/:id' do
211
+ @port = Ronin::DB::Port.find(params[:id])
212
+
213
+ if @port
214
+ erb :"db/ports/show"
215
+ else
216
+ halt 404
217
+ end
218
+ end
219
+
220
+ post '/db/ports/import' do
221
+ begin
222
+ port = Ronin::DB::Port.find_or_import(params[:port])
223
+ rescue ArgumentError => error
224
+ flash[:danger] = error.message
225
+ redirect "db/ports"
226
+ end
227
+
228
+ redirect "/db/ports/#{port.id}"
229
+ end
230
+
231
+ get '/db/services' do
232
+ @pagy, @services = pagy(Ronin::DB::Service)
233
+
234
+ erb :"db/services/index"
235
+ end
236
+
237
+ get '/db/services/:id' do
238
+ @service = Ronin::DB::Service.find(params[:id])
239
+
240
+ if @service
241
+ erb :"db/services/show"
242
+ else
243
+ halt 404
244
+ end
245
+ end
246
+
247
+ post '/db/services/import' do
248
+ begin
249
+ service = Ronin::DB::Service.find_or_import(params[:service])
250
+ rescue ArgumentError => error
251
+ flash[:danger] = error.message
252
+ redirect "db/services"
253
+ end
254
+
255
+ redirect "/db/services/#{service.id}"
256
+ end
257
+
258
+ get '/db/urls' do
259
+ @pagy, @urls = pagy(Ronin::DB::URL)
260
+
261
+ erb :"db/urls/index"
262
+ end
263
+
264
+ get '/db/urls/:id' do
265
+ @url = Ronin::DB::URL.find(params[:id])
266
+
267
+ if @url
268
+ erb :"db/urls/show"
269
+ else
270
+ halt 404
271
+ end
272
+ end
273
+
274
+ post '/db/urls/import' do
275
+ begin
276
+ url = Ronin::DB::URL.find_or_import(params[:url])
277
+ rescue ArgumentError => error
278
+ flash[:danger] = error.message
279
+ redirect "db/urls"
280
+ end
281
+
282
+ redirect "/db/urls/#{url.id}"
283
+ end
284
+
285
+ get '/db/url_schemes' do
286
+ @pagy, @url_schemes = pagy(Ronin::DB::URLScheme)
287
+
288
+ erb :"db/url_schemes/index"
289
+ end
290
+
291
+ get '/db/url_schemes/:id' do
292
+ @url_scheme = Ronin::DB::URLScheme.find(params[:id])
293
+
294
+ if @url_scheme
295
+ erb :"db/url_schemes/show"
296
+ else
297
+ halt 404
298
+ end
299
+ end
300
+
301
+ get '/db/url_query_param_names' do
302
+ @pagy, @url_query_param_names = pagy(Ronin::DB::URLQueryParamName)
303
+
304
+ erb :"db/url_query_param_names/index"
305
+ end
306
+
307
+ get '/db/url_query_param_names/:id' do
308
+ @url_query_param_name = Ronin::DB::URLQueryParamName.find(params[:id])
309
+
310
+ if @url_query_param_name
311
+ erb :"db/url_query_param_names/show"
312
+ else
313
+ halt 404
314
+ end
315
+ end
316
+
317
+ get '/db/email_addresses' do
318
+ @pagy, @email_addresses = pagy(Ronin::DB::EmailAddress)
319
+
320
+ erb :"db/email_addresses/index"
321
+ end
322
+
323
+ get '/db/email_addresses/:id' do
324
+ @email_address = Ronin::DB::EmailAddress.find(params[:id])
325
+
326
+ if @email_address
327
+ erb :"db/email_addresses/show"
328
+ else
329
+ halt 404
330
+ end
331
+ end
332
+
333
+ post '/db/email_addresses/import' do
334
+ begin
335
+ email_address = Ronin::DB::EmailAddress.find_or_import(params[:email_address])
336
+ rescue ArgumentError => error
337
+ flash[:danger] = error.message
338
+ redirect "db/email_addresses"
339
+ end
340
+
341
+ redirect "/db/email_addresses/#{email_address.id}"
342
+ end
343
+
344
+ get '/db/user_names' do
345
+ @pagy, @user_names = pagy(Ronin::DB::UserName)
346
+
347
+ erb :"db/user_names/index"
348
+ end
349
+
350
+ get '/db/user_names/:id' do
351
+ @user_name = Ronin::DB::UserName.find(params[:id])
352
+
353
+ if @user_name
354
+ erb :"db/user_names/show"
355
+ else
356
+ halt 404
357
+ end
358
+ end
359
+
360
+ post '/db/user_names/import' do
361
+ begin
362
+ user_name = Ronin::DB::UserName.find_or_import(params[:user_name])
363
+ rescue ArgumentError => error
364
+ flash[:danger] = error.message
365
+ redirect "db/user_names"
366
+ end
367
+
368
+ redirect "/db/user_names/#{user_name.id}"
369
+ end
370
+
371
+ get '/db/passwords' do
372
+ @pagy, @passwords = pagy(Ronin::DB::Password)
373
+
374
+ erb :"db/passwords/index"
375
+ end
376
+
377
+ get '/db/passwords/:id' do
378
+ @password = Ronin::DB::Password.find(params[:id])
379
+
380
+ if @password
381
+ erb :"db/passwords/show"
382
+ else
383
+ halt 404
384
+ end
385
+ end
386
+
387
+ post '/db/passwords/import' do
388
+ begin
389
+ password = Ronin::DB::Password.find_or_import(params[:password])
390
+ rescue ArgumentError => error
391
+ flash[:danger] = error.message
392
+ redirect "db/passwords"
393
+ end
394
+
395
+ redirect "/db/passwords/#{password.id}"
396
+ end
397
+
398
+ get '/db/credentials' do
399
+ @pagy, @credentials = pagy(Ronin::DB::Credential)
400
+
401
+ erb :"db/credentials/index"
402
+ end
403
+
404
+ get '/db/credentials/:id' do
405
+ @credential = Ronin::DB::Credential.find(params[:id])
406
+
407
+ if @credential
408
+ erb :"db/credentials/show"
409
+ else
410
+ halt 404
411
+ end
412
+ end
413
+
414
+ post '/db/credentials/import' do
415
+ begin
416
+ credential = Ronin::DB::Credential.find_or_import(params[:cred])
417
+ rescue ArgumentError => error
418
+ flash[:danger] = error.message
419
+ redirect "db/credentials"
420
+ end
421
+
422
+ redirect "/db/credentials/#{credential.id}"
423
+ end
424
+
425
+ get '/db/advisories' do
426
+ @pagy, @advisories = pagy(Ronin::DB::Advisory)
427
+
428
+ erb :"db/advisories/index"
429
+ end
430
+
431
+ get '/db/advisories/:id' do
432
+ @advisory = Ronin::DB::Advisory.find(params[:id])
433
+
434
+ if @advisory
435
+ erb :"db/advisories/show"
436
+ else
437
+ halt 404
438
+ end
439
+ end
440
+
441
+ post '/db/advisories/import' do
442
+ begin
443
+ advisory = Ronin::DB::Advisory.find_or_import(params[:id])
444
+ rescue ArgumentError => error
445
+ flash[:danger] = error.message
446
+ redirect "db/advisories"
447
+ end
448
+
449
+ redirect "/db/advisories/#{advisory.id}"
450
+ end
451
+
452
+ get '/db/software' do
453
+ @pagy, @software = pagy(Ronin::DB::Software)
454
+
455
+ erb :"db/software/index"
456
+ end
457
+
458
+ get '/db/software/:id' do
459
+ @software = Ronin::DB::Software.find(params[:id])
460
+
461
+ if @software
462
+ erb :"db/software/show"
463
+ else
464
+ halt 404
465
+ end
466
+ end
467
+
468
+ get '/db/software_vendors' do
469
+ @pagy, @software_vendors = pagy(Ronin::DB::SoftwareVendor)
470
+
471
+ erb :"db/software_vendors/index"
472
+ end
473
+
474
+ get '/db/software_vendors/:id' do
475
+ @software_vendor = Ronin::DB::SoftwareVendor.find(params[:id])
476
+
477
+ erb :"db/software_vendors/show"
478
+ end
479
+
480
+ get '/db/oses' do
481
+ @pagy, @oses = pagy(Ronin::DB::OS)
482
+
483
+ erb :"db/oses/index"
484
+ end
485
+
486
+ get '/db/oses/:id' do
487
+ @os = Ronin::DB::OS.find(params[:id])
488
+
489
+ if @os
490
+ erb :"db/oses/show"
491
+ else
492
+ halt 404
493
+ end
494
+ end
495
+
496
+ get '/db/vulns' do
497
+ @pagy, @vulns = pagy(Ronin::DB::WebVuln)
498
+
499
+ erb :"db/vulns/index"
500
+ end
501
+
502
+ get '/db/vulns/:id' do
503
+ @vuln = Ronin::DB::WebVuln.find(params[:id])
504
+
505
+ if @vuln
506
+ erb :"db/vulns/show"
507
+ else
508
+ halt 404
509
+ end
510
+ end
511
+
512
+ get '/db/phone_numbers' do
513
+ @pagy, @phone_numbers = pagy(Ronin::DB::PhoneNumber)
514
+
515
+ erb :"db/phone_numbers/index"
516
+ end
517
+
518
+ get '/db/phone_numbers/:id' do
519
+ @phone_number = Ronin::DB::PhoneNumber.find(params[:id])
520
+
521
+ if @phone_number
522
+ erb :"db/phone_numbers/show"
523
+ else
524
+ halt 404
525
+ end
526
+ end
527
+
528
+ post '/db/phone_numbers/import' do
529
+ begin
530
+ phone_number = Ronin::DB::PhoneNumber.find_or_import(params[:phone_number])
531
+ rescue ArgumentError => error
532
+ flash[:danger] = error.message
533
+ redirect "db/phone_numbers"
534
+ end
535
+
536
+ redirect "/db/phone_numbers/#{phone_number.id}"
537
+ end
538
+
539
+ get '/db/street_addresses' do
540
+ @pagy, @street_addresses = pagy(Ronin::DB::StreetAddress)
541
+
542
+ erb :"db/street_addresses/index"
543
+ end
544
+
545
+ get '/db/street_addresses/:id' do
546
+ @street_address = Ronin::DB::StreetAddress.find(params[:id])
547
+
548
+ if @street_address
549
+ erb :"db/street_addresses/show"
550
+ else
551
+ halt 404
552
+ end
553
+ end
554
+
555
+ get '/db/organizations' do
556
+ @pagy, @organizations = pagy(Ronin::DB::Organization)
557
+
558
+ erb :"db/organizations/index"
559
+ end
560
+
561
+ get '/db/organizations/:id' do
562
+ @organization = Ronin::DB::Organization.find(params[:id])
563
+
564
+ if @organization
565
+ erb :"db/organizations/show"
566
+ else
567
+ halt 404
568
+ end
569
+ end
570
+
571
+ post '/db/organizations/import' do
572
+ begin
573
+ organization = Ronin::DB::Organization.find_or_import(params[:name])
574
+ rescue ArgumentError => error
575
+ flash[:danger] = error.message
576
+ redirect "db/organizations"
577
+ end
578
+
579
+ redirect "/db/organizations/#{organization.id}"
580
+ end
581
+
582
+ get '/db/organization_departments/:id' do
583
+ @organization_department = Ronin::DB::OrganizationDepartment.find(params[:id])
584
+
585
+ if @organization_department
586
+ erb :"db/organizations/departments/show"
587
+ else
588
+ halt 404
589
+ end
590
+ end
591
+
592
+ get '/db/organization_members/:id' do
593
+ @organization_member = Ronin::DB::OrganizationMember.find(params[:id])
594
+
595
+ if @organization_member
596
+ erb :"db/organizations/members/show"
597
+ else
598
+ halt 404
599
+ end
600
+ end
601
+
602
+ get '/db/people' do
603
+ @pagy, @people = pagy(Ronin::DB::Person)
604
+
605
+ erb :"db/people/index"
606
+ end
607
+
608
+ get '/db/people/:id' do
609
+ @person = Ronin::DB::Person.find(params[:id])
610
+
611
+ if @person
612
+ erb :"db/people/show"
613
+ else
614
+ halt 404
615
+ end
616
+ end
617
+
618
+ post '/db/people/import' do
619
+ begin
620
+ person = Ronin::DB::Person.find_or_import(params[:person])
621
+ rescue ArgumentError => error
622
+ flash[:danger] = error.message
623
+ redirect "db/people"
624
+ end
625
+
626
+ redirect "/db/people/#{person.id}"
627
+ end
628
+
629
+ {
630
+ host_names: Ronin::DB::HostName,
631
+ asns: Ronin::DB::ASN,
632
+ ip_addresses: Ronin::DB::IPAddress,
633
+ mac_addresses: Ronin::DB::MACAddress,
634
+ open_ports: Ronin::DB::OpenPort,
635
+ ports: Ronin::DB::Port,
636
+ services: Ronin::DB::Service,
637
+ urls: Ronin::DB::URL,
638
+ url_schemes: Ronin::DB::URLScheme,
639
+ url_query_param_names: Ronin::DB::URLQueryParamName,
640
+ email_addresses: Ronin::DB::EmailAddress,
641
+ user_names: Ronin::DB::UserName,
642
+ passwords: Ronin::DB::Password,
643
+ credentials: Ronin::DB::Credential,
644
+ advisories: Ronin::DB::Advisory,
645
+ software: Ronin::DB::Software,
646
+ software_vendors: Ronin::DB::SoftwareVendor,
647
+ oses: Ronin::DB::OS,
648
+ vulns: Ronin::DB::WebVuln,
649
+ phone_numbers: Ronin::DB::PhoneNumber,
650
+ street_addresses: Ronin::DB::StreetAddress,
651
+ organizations: Ronin::DB::Organization,
652
+ people: Ronin::DB::Person
653
+ }.each do |name, model|
654
+ delete "/db/#{name}" do
655
+ if model.destroy_all
656
+ flash[:success] = "Records deleted successfully."
657
+ else
658
+ flash[:danger] = "Failed to delete records."
659
+ end
660
+
661
+ redirect "/db/#{name}"
662
+ end
663
+
664
+ delete "/db/#{name}/:id" do
665
+ @record = model.find(params[:id])
666
+
667
+ if @record
668
+ if @record.destroy
669
+ flash[:success] = "Record deleted successfully."
670
+
671
+ redirect "/db/#{name}"
672
+ else
673
+ flash[:danger] = "Failed to delete record."
674
+ end
675
+ else
676
+ halt 404
677
+ end
678
+ end
679
+ end
680
+ end