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/spider.rb ADDED
@@ -0,0 +1,148 @@
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/spider'
24
+
25
+ require 'ronin/web/spider'
26
+
27
+ module Workers
28
+ #
29
+ # Web spider worker.
30
+ #
31
+ class Spider
32
+
33
+ include Ronin::App
34
+ include Sidekiq::Worker
35
+ sidekiq_options queue: :spider, retry: false, backtrace: true
36
+
37
+ Params = Dry::Schema::JSON() do
38
+ required(:type).filled(Types::Spider::TargetType)
39
+ required(:target).filled(:string)
40
+
41
+ optional(:host_header).maybe(:string)
42
+ # optional(:host_headers)
43
+ # optional(:default_headers)
44
+ optional(:user_agent).maybe(:string)
45
+ optional(:referer).maybe(:string)
46
+ optional(:open_timeout).maybe(:integer)
47
+ optional(:read_timeout).maybe(:integer)
48
+ optional(:ssl_timeout).maybe(:integer)
49
+ optional(:continue_timeout).maybe(:integer)
50
+ optional(:keep_alive_timeout).maybe(:integer)
51
+ optional(:proxy).maybe(:string)
52
+ optional(:delay).maybe(:integer)
53
+ optional(:limit).maybe(:integer)
54
+ optional(:max_depth).maybe(:integer)
55
+ optional(:strip_fragments).maybe(:bool)
56
+ optional(:strip_query).maybe(:bool)
57
+ optional(:hosts).maybe(:array)
58
+ optional(:ignore_hosts).maybe(:array)
59
+ optional(:ports).maybe(:array)
60
+ optional(:ignore_ports).maybe(:array)
61
+ optional(:urls).maybe(:array)
62
+ optional(:ignore_urls).maybe(:array)
63
+ optional(:exts).maybe(:array)
64
+ optional(:ignore_exts).maybe(:array)
65
+ optional(:robots).maybe(:bool)
66
+ end
67
+
68
+ #
69
+ # Processes a web spider job.
70
+ #
71
+ # @param [Hash{String => Object}] params
72
+ # The JSON deserialized params for the job.
73
+ #
74
+ # @raise [ArgumentError]
75
+ # The params could not be validated or coerced.
76
+ #
77
+ def perform(params)
78
+ params = validate(params)
79
+ type = params.delete(:type)
80
+ target = params.delete(:target)
81
+
82
+ spider(type,target,**params) do |agent|
83
+ agent.every_page do |page|
84
+ puts page.url
85
+ import_url(page.url)
86
+ end
87
+ end
88
+ end
89
+
90
+ #
91
+ # Validates the given job params.
92
+ #
93
+ # @param [Hash{String => Object}] params
94
+ # The JSON deserialized params for the job.
95
+ #
96
+ # @return [Hash{Symbol => Object}]
97
+ # The validated and coerced params as a Symbol Hash.
98
+ #
99
+ # @raise [ArgumentError]
100
+ # The params could not be validated or coerced.
101
+ #
102
+ def validate(params)
103
+ result = Params.call(params)
104
+
105
+ if result.failure?
106
+ raise(ArgumentError,"invalid spider params (#{params.inspect}): #{result.errors.inspect}")
107
+ end
108
+
109
+ return result.to_h
110
+ end
111
+
112
+ #
113
+ # Spiders a host, domain, or site.
114
+ #
115
+ # @param ["host", "domain", "site"] type
116
+ # Indicates whether to spider a host, domain, or site.
117
+ #
118
+ # @param [String] target
119
+ # The host name, domain name, or website base URL to spider.
120
+ #
121
+ # @yield [agent]
122
+ # The given block will be yielded the new web spider agent to configure.
123
+ #
124
+ # @yieldparam [Ronin::Web::Spider::Agent] agent
125
+ # The new web spider agent.
126
+ #
127
+ def spider(type,target,**kwargs,&block)
128
+ case type
129
+ when 'host' then Ronin::Web::Spider.host(target,**kwargs,&block)
130
+ when 'domain' then Ronin::Web::Spider.domain(target,**kwargs,&block)
131
+ when 'site' then Ronin::Web::Spider.site(target,**kwargs,&block)
132
+ end
133
+ end
134
+
135
+ #
136
+ # Imports a URL.
137
+ #
138
+ # @param [String, URI::HTTP] url
139
+ # The URL or URI to import.
140
+ #
141
+ def import_url(url)
142
+ Ronin::DB::URL.transaction do
143
+ Ronin::DB::URL.import(url)
144
+ end
145
+ end
146
+
147
+ end
148
+ end
@@ -0,0 +1,42 @@
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 updates a single [ronin repo][ronin-repos].
27
+ #
28
+ # [ronin-repos]: https://github.com/ronin-rb/ronin-repos#readme
29
+ #
30
+ class UpdateRepo
31
+
32
+ include Sidekiq::Worker
33
+ sidekiq_options queue: :repos, retry: false, backtrace: true
34
+
35
+ def perform(name)
36
+ repo = Ronin::Repos.cache_dir[name]
37
+
38
+ repo.update
39
+ end
40
+
41
+ end
42
+ 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 updates all [ronin repos][ronin-repos].
27
+ #
28
+ # [ronin-repos]: https://github.com/ronin-rb/ronin-repos#readme
29
+ #
30
+ class UpdateRepos
31
+
32
+ include Sidekiq::Worker
33
+ sidekiq_options queue: :repos, retry: false, backtrace: true
34
+
35
+ def perform
36
+ Ronin::Repos.cache_dir.update
37
+ end
38
+
39
+ end
40
+ end
data/workers/vulns.rb ADDED
@@ -0,0 +1,111 @@
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/vulns/url_scanner'
25
+ require 'ronin/vulns/importer'
26
+ require 'ronin/app/types/vulns'
27
+
28
+ module Workers
29
+ #
30
+ # Vulnerabilities scanner worker.
31
+ #
32
+ class Vulns
33
+
34
+ include Ronin::App
35
+ include Sidekiq::Worker
36
+ sidekiq_options queue: :vulns, retry: false, backtrace: true
37
+
38
+ Params = Dry::Schema::JSON() do
39
+ required(:url).filled(:string)
40
+
41
+ optional(:lfi).hash do
42
+ optional(:os).maybe(Types::Vulns::LFI::OSType)
43
+ optional(:depth).maybe(:integer)
44
+ optional(:filter_bypass).maybe(Types::Vulns::LFI::FilterBypassType)
45
+ end
46
+
47
+ optional(:rfi).hash do
48
+ optional(:filter_bypass).maybe(Types::Vulns::RFI::FilterBypassType)
49
+ optional(:test_script_url).maybe(:string)
50
+ end
51
+
52
+ optional(:sqli).hash do
53
+ optional(:escape_quote).maybe(:bool)
54
+ optional(:escape_parens).maybe(:bool)
55
+ optional(:terminate).maybe(:bool)
56
+ end
57
+
58
+ optional(:ssti).hash do
59
+ optional(:escape).maybe(Types::Vulns::SSTI::EscapeType)
60
+ end
61
+
62
+ optional(:command_injection).hash do
63
+ optional(:escape_quote).maybe(:string)
64
+ optional(:escape_operator).maybe(:string)
65
+ optional(:terminate).maybe(:string)
66
+ end
67
+
68
+ optional(:open_redirect).hash do
69
+ optional(:test_url).maybe(:string)
70
+ end
71
+
72
+ before(:value_coercer) do |result|
73
+ result.to_h.map do |_, value|
74
+ value.is_a?(Hash) ? value.compact! : value
75
+ end
76
+ end
77
+ end
78
+
79
+ def perform(params)
80
+ kwargs = validate(params)
81
+ url = kwargs.delete(:url)
82
+
83
+ Ronin::Vulns::URLScanner.scan(url, **kwargs) do |vuln|
84
+ Ronin::Vulns::Importer.import(vuln)
85
+ end
86
+ end
87
+
88
+ #
89
+ # Validates the given job params.
90
+ #
91
+ # @param [Hash{String => Object}] params
92
+ # The JSON deserialized params for the job.
93
+ #
94
+ # @return [Hash{Symbol => Object}]
95
+ # The validated and coerced params as a Symbol Hash.
96
+ #
97
+ # @raise [ArgumentError]
98
+ # The params could not be validated or coerced.
99
+ #
100
+ def validate(params)
101
+ result = Params.call(params)
102
+
103
+ if result.failure?
104
+ raise(ArgumentError,"invalid nmap params (#{params.inspect}): #{result.errors.inspect}")
105
+ end
106
+
107
+ return result.to_h
108
+ end
109
+
110
+ end
111
+ end
data/workers.rb ADDED
@@ -0,0 +1,37 @@
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
+ $LOAD_PATH.unshift(File.join(__dir__,'lib'))
22
+
23
+ require './config/sidekiq'
24
+ require './config/database'
25
+
26
+ require './workers/install_repo'
27
+ require './workers/update_repo'
28
+ require './workers/update_repos'
29
+ require './workers/remove_repo'
30
+ require './workers/purge_repos'
31
+
32
+ require './workers/nmap'
33
+ require './workers/masscan'
34
+ require './workers/import'
35
+ require './workers/spider'
36
+ require './workers/recon'
37
+ require './workers/vulns'