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/workers/import.rb ADDED
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-app - a local web app for Ronin.
4
+ #
5
+ # Copyright (C) 2023 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
+ require 'sidekiq'
22
+ require 'dry-schema'
23
+ require 'ronin/app/types'
24
+ require 'ronin/app/types/import'
25
+
26
+ require 'ronin/nmap/importer'
27
+ require 'ronin/masscan/importer'
28
+
29
+ module Workers
30
+ #
31
+ # Worker which imports `nmap` or `masscan` scan files.
32
+ #
33
+ class Import
34
+
35
+ include Ronin::App
36
+ include Sidekiq::Worker
37
+ sidekiq_options queue: :import, retry: false, backtrace: true
38
+
39
+ # The accepted JSON params which will be passed to {Import#perform}.
40
+ Params = Dry::Schema::JSON() do
41
+ required(:type).filled(Types::Import::TypeType)
42
+ required(:path).filled(:string)
43
+ end
44
+
45
+ # Mapping of importer `type`s and the importer modules.
46
+ IMPORT_TYPES = {
47
+ 'nmap' => Ronin::Nmap::Importer,
48
+ 'masscan' => Ronin::Masscan::Importer
49
+ }
50
+
51
+ #
52
+ # Processes an `import` job.
53
+ #
54
+ # @param [Hash{String => Object}] params
55
+ # The JSON deserialized params for the job.
56
+ #
57
+ # @raise [ArgumentError]
58
+ # The params could not be validated or coerced.
59
+ #
60
+ def perform(params)
61
+ kwargs = validate(params)
62
+
63
+ type = kwargs[:type]
64
+ path = kwargs[:path]
65
+
66
+ importer = IMPORT_TYPES.fetch(type) do
67
+ raise(NotImplementedError,"unsupported import type: #{type.inspect}")
68
+ end
69
+
70
+ importer.import_file(path)
71
+ end
72
+
73
+ #
74
+ # Validates the given job params.
75
+ #
76
+ # @param [Hash{String => Object}] params
77
+ # The JSON deserialized params for the job.
78
+ #
79
+ # @return [Hash{Symbol => Object}]
80
+ # The validated and coerced params as a Symbol Hash.
81
+ #
82
+ # @raise [ArgumentError]
83
+ # The params could not be validated or coerced.
84
+ #
85
+ def validate(params)
86
+ result = Params.call(params)
87
+
88
+ if result.failure?
89
+ raise(ArgumentError,"invalid import params (#{params.inspect}): #{result.errors.inspect}")
90
+ end
91
+
92
+ return result.to_h
93
+ end
94
+
95
+ end
96
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-app - a local web app for Ronin.
4
+ #
5
+ # Copyright (C) 2023 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
+ require 'sidekiq'
22
+ require 'ronin/repos'
23
+
24
+ module Workers
25
+ #
26
+ # A worker that installs a new [ronin repo][ronin-repos].
27
+ #
28
+ # [ronin-repos]: https://github.com/ronin-rb/ronin-repos#readme
29
+ #
30
+ class InstallRepo
31
+
32
+ include Sidekiq::Worker
33
+ sidekiq_options queue: :repos, retry: false, backtrace: true
34
+
35
+ def perform(uri,name=nil)
36
+ Ronin::Repos.cache_dir.install(uri,name)
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,135 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-app - a local web app for Ronin.
4
+ #
5
+ # Copyright (C) 2023 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
+ require 'sidekiq'
22
+ require 'dry-schema'
23
+ require 'ronin/app/types'
24
+
25
+ require 'tempfile'
26
+ require 'masscan/command'
27
+ require 'ronin/masscan/importer'
28
+
29
+ module Workers
30
+ #
31
+ # `masscan` scanner worker.
32
+ #
33
+ class Masscan
34
+
35
+ include Ronin::App
36
+ include Sidekiq::Worker
37
+ sidekiq_options queue: :scan, retry: false, backtrace: true
38
+
39
+ # The accepted JSON params which will be passed to {Masscan#perform}.
40
+ Params = Dry::Schema::JSON() do
41
+ required(:ips).array(:string).each(:string)
42
+ required(:ports).filled(:string)
43
+
44
+ optional(:banners).maybe(:bool)
45
+ optional(:rate).maybe(:integer)
46
+ optional(:config_file).maybe(:string)
47
+ optional(:adapter).maybe(:string)
48
+ optional(:adapter_ip).maybe(:string)
49
+ optional(:adapter_port).maybe(:string)
50
+ optional(:adapter_mac).maybe(:string)
51
+ optional(:adapter_vlan).maybe(:string)
52
+ optional(:router_mac).maybe(:string)
53
+ optional(:ping).maybe(:bool)
54
+ optional(:exclude).maybe(:string)
55
+ optional(:exclude_file).maybe(:string)
56
+ optional(:include_file).maybe(:string)
57
+ optional(:pcap_payloads).maybe(:string)
58
+ optional(:nmap_payloads).maybe(:string)
59
+ optional(:http_method).maybe(Types::HTTPMethod)
60
+ optional(:http_url).maybe(:string)
61
+ optional(:http_version).maybe(:string)
62
+ optional(:http_host).maybe(:string)
63
+ optional(:http_user_agent).maybe(:string)
64
+ optional(:http_field).maybe(:string)
65
+ optional(:http_cookie).maybe(:string)
66
+ optional(:http_payload).maybe(:string)
67
+ optional(:open_only).maybe(:bool)
68
+ optional(:pcap).maybe(:string)
69
+ optional(:packet_trace).maybe(:bool)
70
+ optional(:pfring).maybe(:bool)
71
+ optional(:shards).maybe(:string)
72
+ optional(:seed).maybe(:integer)
73
+ optional(:ttl).maybe(:integer)
74
+ optional(:wait).maybe(:integer)
75
+ optional(:retries).maybe(:integer)
76
+ end
77
+
78
+ #
79
+ # Processes an `masscan` job.
80
+ #
81
+ # @param [Hash{String => Object}] params
82
+ # The JSON deserialized params for the job.
83
+ #
84
+ # @raise [ArgumentError]
85
+ # The params could not be validated or coerced.
86
+ #
87
+ # @raise [RuntimeError]
88
+ # The `masscan` command failed or is not installed.
89
+ #
90
+ def perform(params)
91
+ kwargs = validate(params)
92
+
93
+ Tempfile.open(['masscan-', '.bin']) do |tempfile|
94
+ status = ::Masscan::Command.run(
95
+ **kwargs,
96
+ interactive: true,
97
+ output_format: :binary,
98
+ output_file: tempfile.path
99
+ )
100
+
101
+ case status
102
+ when true
103
+ Ronin::Masscan::Importer.import_file(tempfile.path)
104
+ when false
105
+ raise("masscan command failed")
106
+ when nil
107
+ raise("masscan command not installed")
108
+ end
109
+ end
110
+ end
111
+
112
+ #
113
+ # Validates the given job params.
114
+ #
115
+ # @param [Hash{String => Object}] params
116
+ # The JSON deserialized params for the job.
117
+ #
118
+ # @return [Hash{Symbol => Object}]
119
+ # The validated and coerced params as a Symbol Hash.
120
+ #
121
+ # @raise [ArgumentError]
122
+ # The params could not be validated or coerced.
123
+ #
124
+ def validate(params)
125
+ result = Params.call(params)
126
+
127
+ if result.failure?
128
+ raise(ArgumentError,"invalid masscan params (#{params.inspect}): #{result.errors.inspect}")
129
+ end
130
+
131
+ return result.to_h
132
+ end
133
+
134
+ end
135
+ end
data/workers/nmap.rb ADDED
@@ -0,0 +1,216 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-app - a local web app for Ronin.
4
+ #
5
+ # Copyright (C) 2023 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
+ require 'sidekiq'
22
+ require 'dry-schema'
23
+ require 'ronin/app/types/nmap'
24
+
25
+ require 'tempfile'
26
+ require 'nmap/command'
27
+ require 'ronin/nmap/importer'
28
+
29
+ module Workers
30
+ #
31
+ # `nmap` scanner worker.
32
+ #
33
+ class Nmap
34
+
35
+ include Ronin::App
36
+ include Sidekiq::Worker
37
+ sidekiq_options queue: :scan, retry: false, backtrace: true
38
+
39
+ # The accepted JSON params which will be passed to {Nmap#perform}.
40
+ Params = Dry::Schema::JSON() do
41
+ required(:targets).array(:string).each(:string)
42
+
43
+ # TARGET SPECIFICATIONS:
44
+ optional(:target_file).maybe(:string)
45
+ optional(:random_targets).maybe(:integer)
46
+ optional(:exclude).maybe(:array)
47
+ optional(:exclude_file).maybe(:string)
48
+
49
+ # HOST DISCOVERY:
50
+ optional(:ping).maybe(:bool)
51
+ optional(:skip_discovery).maybe(:bool)
52
+ optional(:syn_discovery).maybe(Types::Bool | Types::Nmap::PortRangeList)
53
+ optional(:ack_discovery).maybe(Types::Bool | Types::Nmap::PortRangeList)
54
+ optional(:udp_discovery).maybe(Types::Bool | Types::Nmap::PortRangeList)
55
+ optional(:sctp_init_ping).maybe(Types::Bool | Types::Nmap::PortRangeList)
56
+ optional(:icmp_echo_discovery).maybe(:bool)
57
+ optional(:icmp_timestamp_discovery).maybe(:bool)
58
+ optional(:icmp_netmask_discovery).maybe(:bool)
59
+ optional(:ip_ping).maybe(Types::Bool | Types::Nmap::ProtocolList)
60
+ optional(:arp_ping).maybe(:bool)
61
+ optional(:traceroute).maybe(:bool)
62
+ optional(:disable_dns).maybe(:bool)
63
+ optional(:enable_dns).maybe(:bool)
64
+ optional(:resolve_all).maybe(:bool)
65
+ optional(:unique).maybe(:bool)
66
+ optional(:dns_servers).maybe(:array)
67
+ optional(:system_dns).maybe(:bool)
68
+
69
+ # PORT SCANNING TECHNIQUES:
70
+ optional(:syn_scan).maybe(:bool)
71
+ optional(:connect_scan).maybe(:bool)
72
+ optional(:udp_scan).maybe(:bool)
73
+ optional(:sctp_init_scan).maybe(:bool)
74
+ optional(:null_scan).maybe(:bool)
75
+ optional(:fin_scan).maybe(:bool)
76
+ optional(:xmas_scan).maybe(:bool)
77
+ optional(:ack_scan).maybe(:bool)
78
+ optional(:window_scan).maybe(:bool)
79
+ optional(:maimon_scan).maybe(:bool)
80
+ optional(:scan_flags).maybe(Types::Nmap::ScanFlags)
81
+ optional(:sctp_cookie_echo_scan).maybe(:bool)
82
+ optional(:idle_scan).maybe(:string)
83
+ optional(:ip_scan).maybe(:bool)
84
+ optional(:ftp_bounce_scan).maybe(:string)
85
+
86
+ # PORT SPECIFICATION AND SCAN ORDER:
87
+ optional(:ports).maybe(Types::Nmap::PortRangeList)
88
+ optional(:exclude_ports).maybe(Types::Nmap::PortRangeList)
89
+ optional(:fast).maybe(:bool)
90
+ optional(:consecutively).maybe(:bool)
91
+ optional(:top_ports).maybe(:integer)
92
+ optional(:port_ratio).maybe(:float)
93
+
94
+ # SERVICE/VERSION DETECTION:
95
+ optional(:service_scan).maybe(:bool)
96
+ optional(:all_ports).maybe(:bool)
97
+ optional(:version_intensity).maybe(:integer)
98
+ optional(:version_light).maybe(:bool)
99
+ optional(:version_all).maybe(:bool)
100
+ optional(:version_trace).maybe(:bool)
101
+
102
+ # OS DETECTION:
103
+ optional(:os_fingerprint).maybe(:bool)
104
+ optional(:limit_os_scan).maybe(:bool)
105
+ optional(:max_os_scan).maybe(:bool)
106
+ optional(:max_os_tries).maybe(:bool)
107
+
108
+ # TIMING AND PERFORMANCE:
109
+ optional(:min_host_group).maybe(:integer)
110
+ optional(:max_host_group).maybe(:integer)
111
+ optional(:min_parallelism).maybe(:integer)
112
+ optional(:max_parallelism).maybe(:integer)
113
+ optional(:min_rtt_timeout).maybe(Types::Nmap::Time)
114
+ optional(:max_rtt_timeout).maybe(Types::Nmap::Time)
115
+ optional(:initial_rtt_timeout).maybe(Types::Nmap::Time)
116
+ optional(:max_retries).maybe(:integer)
117
+ optional(:host_timeout).maybe(Types::Nmap::Time)
118
+ optional(:script_timeout).maybe(Types::Nmap::Time)
119
+ optional(:scan_delay).maybe(Types::Nmap::Time)
120
+ optional(:max_scan_delay).maybe(Types::Nmap::Time)
121
+ optional(:min_rate).maybe(:integer)
122
+ optional(:max_rate).maybe(:integer)
123
+ optional(:defeat_rst_ratelimit).maybe(:bool)
124
+ optional(:defeat_icmp_ratelimit).maybe(:bool)
125
+ optional(:nsock_engine).maybe(Types::Nmap::NsockEngine)
126
+ optional(:timing_template).maybe(Types::Nmap::TimingTemplate)
127
+
128
+ # FIREWALL/IDS EVASION AND SPOOFING:
129
+ optional(:packet_fragments).maybe(:bool)
130
+ optional(:mtu).maybe(Types::Bool | Types::Integer)
131
+ optional(:decoys).maybe(:array)
132
+ optional(:spoof).maybe(:string)
133
+ optional(:interface).maybe(:string)
134
+ optional(:source_port).maybe(Types::Nmap::Port)
135
+ optional(:proxies).maybe(:array)
136
+ optional(:data).maybe(Types::Nmap::HexString)
137
+ optional(:data_string).maybe(:string)
138
+ optional(:data_length).maybe(:integer)
139
+ optional(:ip_options).maybe(:string)
140
+ optional(:ttl).maybe(:integer)
141
+ optional(:randomize_hosts).maybe(:bool)
142
+ optional(:spoof_mac).maybe(:string)
143
+ optional(:bad_checksum).maybe(:bool)
144
+ optional(:sctp_adler32).maybe(:bool)
145
+
146
+ # MISC:
147
+ optional(:ipv6).maybe(:bool)
148
+ optional(:all).maybe(:bool)
149
+ optional(:nmap_datadir).maybe(:string)
150
+ optional(:servicedb).maybe(:string)
151
+ optional(:versiondb).maybe(:string)
152
+ optional(:send_eth).maybe(:bool)
153
+ optional(:send_ip).maybe(:bool)
154
+ optional(:privileged).maybe(:bool)
155
+ optional(:unprivileged).maybe(:bool)
156
+ optional(:release_memory).maybe(:bool)
157
+ end
158
+
159
+ #
160
+ # Processes an `nmap` job.
161
+ #
162
+ # @param [Hash{String => Object}] params
163
+ # The JSON deserialized params for the job.
164
+ #
165
+ # @raise [ArgumentError]
166
+ # The params could not be validated or coerced.
167
+ #
168
+ # @raise [RuntimeError]
169
+ # The `nmap` command failed or is not installed.
170
+ #
171
+ def perform(params)
172
+ kwargs = validate(params)
173
+
174
+ Tempfile.open(['nmap-', '.xml']) do |tempfile|
175
+ status = ::Nmap::Command.run(
176
+ **kwargs,
177
+ verbose: true,
178
+ privileged: true,
179
+ output_xml: tempfile.path
180
+ )
181
+
182
+ case status
183
+ when true
184
+ Ronin::Nmap::Importer.import_file(tempfile.path)
185
+ when false
186
+ raise("nmap command failed")
187
+ when nil
188
+ raise("nmap command not installed")
189
+ end
190
+ end
191
+ end
192
+
193
+ #
194
+ # Validates the given job params.
195
+ #
196
+ # @param [Hash{String => Object}] params
197
+ # The JSON deserialized params for the job.
198
+ #
199
+ # @return [Hash{Symbol => Object}]
200
+ # The validated and coerced params as a Symbol Hash.
201
+ #
202
+ # @raise [ArgumentError]
203
+ # The params could not be validated or coerced.
204
+ #
205
+ def validate(params)
206
+ result = Params.call(params)
207
+
208
+ if result.failure?
209
+ raise(ArgumentError,"invalid nmap params (#{params.inspect}): #{result.errors.inspect}")
210
+ end
211
+
212
+ return result.to_h
213
+ end
214
+
215
+ end
216
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-app - a local web app for Ronin.
4
+ #
5
+ # Copyright (C) 2023 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
+ require 'sidekiq'
22
+ require 'ronin/repos'
23
+
24
+ module Workers
25
+ #
26
+ # A worker that deletes all installed [ronin repos][ronin-repos].
27
+ #
28
+ # [ronin-repos]: https://github.com/ronin-rb/ronin-repos#readme
29
+ #
30
+ class PurgeRepos
31
+
32
+ include Sidekiq::Worker
33
+ sidekiq_options queue: :repos, retry: false, backtrace: true
34
+
35
+ def perform
36
+ Ronin::Repos.cache_dir.purge
37
+ end
38
+
39
+ end
40
+ end
data/workers/recon.rb ADDED
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-app - a local web app for Ronin.
4
+ #
5
+ # Copyright (C) 2023 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
+ require 'sidekiq'
22
+ require 'dry-schema'
23
+
24
+ require 'ronin/recon/value/parser'
25
+ require 'ronin/recon/engine'
26
+ require 'ronin/recon/importer'
27
+
28
+ module Workers
29
+ #
30
+ # `ronin-recon run` worker.
31
+ #
32
+ class Recon
33
+
34
+ include Sidekiq::Worker
35
+ sidekiq_options queue: :recon, retry: false, backtrace: true
36
+
37
+ # The accepted JSON params which will be passed to {Recon#perform}.
38
+ Params = Dry::Schema::JSON() do
39
+ required(:scope).array(:string).each(:filled?)
40
+
41
+ optional(:ignore).maybe(:array)
42
+ optional(:max_depth).maybe(:integer)
43
+ end
44
+
45
+ #
46
+ # Processes a `recon` job.
47
+ #
48
+ # @param [Hash{String => Object}] params
49
+ # The JSON deserialized params for the job.
50
+ #
51
+ # @raise [ArgumentError]
52
+ # The params could not be validated or coerced.
53
+ #
54
+ def perform(params)
55
+ kwargs = validate(params)
56
+ values = kwargs[:scope].map(&Ronin::Recon::Value.method(:parse))
57
+
58
+ ignore = if (ignore_kwargs = kwargs[:ignore])
59
+ ignore_kwargs.map(&Ronin::Recon::Value.method(:parse))
60
+ else
61
+ []
62
+ end
63
+
64
+ Ronin::Recon::Engine.run(values, ignore: ignore,
65
+ max_depth: kwargs[:max_depth]) do |engine|
66
+ engine.on(:value) do |value,parent|
67
+ Ronin::Recon::Importer.import_value(value)
68
+ end
69
+ end
70
+ end
71
+
72
+ #
73
+ # Validates the given job params.
74
+ #
75
+ # @param [Hash{String => Object}] params
76
+ # The JSON deserialized params for the job.
77
+ #
78
+ # @return [Hash{Symbol => Object}]
79
+ # The validated and coerced params as a Symbol Hash.
80
+ #
81
+ # @raise [ArgumentError]
82
+ # The params could not be validated or coerced.
83
+ #
84
+ def validate(params)
85
+ result = Params.call(params)
86
+
87
+ if result.failure?
88
+ raise(ArgumentError,"invalid recon params (#{params.inspect}): #{result.errors.inspect}")
89
+ end
90
+
91
+ return result.to_h
92
+ end
93
+
94
+ end
95
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-app - a local web app for Ronin.
4
+ #
5
+ # Copyright (C) 2023 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
+ require 'sidekiq'
22
+ require 'ronin/repos'
23
+
24
+ module Workers
25
+ #
26
+ # A worker that removes an installed [ronin repo][ronin-repos].
27
+ #
28
+ # [ronin-repos]: https://github.com/ronin-rb/ronin-repos#readme
29
+ #
30
+ class RemoveRepo
31
+
32
+ include Sidekiq::Worker
33
+ sidekiq_options queue: :repos, retry: false, backtrace: true
34
+
35
+ def perform(name)
36
+ Ronin::Repos.cache_dir.remove(name)
37
+ end
38
+
39
+ end
40
+ end