active_attack 0.1.14

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.
Files changed (93) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +50 -0
  4. data/Rakefile +32 -0
  5. data/app/assets/config/active_attack_manifest.js +2 -0
  6. data/app/assets/images/active_attack/logo.png +0 -0
  7. data/app/assets/javascripts/active_attack/application.js +8 -0
  8. data/app/assets/javascripts/active_attack/controllers/campaign_controller.es6 +23 -0
  9. data/app/assets/javascripts/active_attack/controllers/matrix_controller.es6 +23 -0
  10. data/app/assets/javascripts/active_attack/controllers/playbooks_controller.es6 +28 -0
  11. data/app/assets/javascripts/active_attack/initializers/stimulus.coffee +2 -0
  12. data/app/assets/stylesheets/active_attack/application.css +15 -0
  13. data/app/assets/stylesheets/active_attack/data_sources.css +4 -0
  14. data/app/assets/stylesheets/active_attack/detections.css +4 -0
  15. data/app/assets/stylesheets/active_attack/difficulty_for_adversaries.css +4 -0
  16. data/app/assets/stylesheets/active_attack/matrices.css +4 -0
  17. data/app/assets/stylesheets/active_attack/permissions_requireds.css +4 -0
  18. data/app/assets/stylesheets/active_attack/platforms.css +4 -0
  19. data/app/assets/stylesheets/active_attack/playbooks.css +400 -0
  20. data/app/assets/stylesheets/active_attack/tactics.css +4 -0
  21. data/app/assets/stylesheets/active_attack/versions.css +4 -0
  22. data/app/controllers/active_attack/application_controller.rb +5 -0
  23. data/app/controllers/active_attack/matrices_controller.rb +82 -0
  24. data/app/controllers/active_attack/playbooks_controller.rb +89 -0
  25. data/app/controllers/active_attack/tactics_controller.rb +62 -0
  26. data/app/helpers/active_attack/application_helper.rb +4 -0
  27. data/app/helpers/active_attack/playbooks_helper.rb +21 -0
  28. data/app/helpers/active_attack/tactics_helper.rb +4 -0
  29. data/app/jobs/active_attack/application_job.rb +4 -0
  30. data/app/mailers/active_attack/application_mailer.rb +6 -0
  31. data/app/models/active_attack/active_attack.rb +7 -0
  32. data/app/models/active_attack/application_record.rb +5 -0
  33. data/app/models/active_attack/build.rb +6 -0
  34. data/app/models/active_attack/data_source.rb +15 -0
  35. data/app/models/active_attack/detection.rb +14 -0
  36. data/app/models/active_attack/difficulty_for_adversary.rb +10 -0
  37. data/app/models/active_attack/matrix.rb +82 -0
  38. data/app/models/active_attack/permissions_required.rb +14 -0
  39. data/app/models/active_attack/platform.rb +16 -0
  40. data/app/models/active_attack/playbook.rb +177 -0
  41. data/app/models/active_attack/tactic.rb +61 -0
  42. data/app/models/active_attack/version.rb +14 -0
  43. data/app/overrides/models/active_stix/active_stix_override.rb +7 -0
  44. data/app/overrides/models/active_stix/attack_pattern_override.rb +75 -0
  45. data/app/overrides/models/active_stix/bundle_override.rb +18 -0
  46. data/app/overrides/models/active_stix/malware_override.rb +40 -0
  47. data/app/overrides/models/active_stix/report_override.rb +18 -0
  48. data/app/overrides/models/active_stix/tool_override.rb +36 -0
  49. data/app/views/active_attack/matrices/_form.html.erb +27 -0
  50. data/app/views/active_attack/matrices/_stix_attack_matrix.json.jbuilder +2 -0
  51. data/app/views/active_attack/matrices/edit.html.erb +6 -0
  52. data/app/views/active_attack/matrices/index.html.erb +16 -0
  53. data/app/views/active_attack/matrices/index.json.jbuilder +1 -0
  54. data/app/views/active_attack/matrices/new.html.erb +5 -0
  55. data/app/views/active_attack/matrices/show.html.erb +33 -0
  56. data/app/views/active_attack/matrices/show.json.jbuilder +1 -0
  57. data/app/views/active_attack/playbooks/_attack_playbook.json.jbuilder +2 -0
  58. data/app/views/active_attack/playbooks/_form.html.erb +32 -0
  59. data/app/views/active_attack/playbooks/edit.html.erb +6 -0
  60. data/app/views/active_attack/playbooks/index.html.erb +38 -0
  61. data/app/views/active_attack/playbooks/index.json.jbuilder +1 -0
  62. data/app/views/active_attack/playbooks/new.html.erb +5 -0
  63. data/app/views/active_attack/playbooks/show.html.erb +70 -0
  64. data/app/views/active_attack/playbooks/show.json.jbuilder +1 -0
  65. data/app/views/active_attack/tactics/_form.html.erb +42 -0
  66. data/app/views/active_attack/tactics/edit.html.erb +6 -0
  67. data/app/views/active_attack/tactics/index.html.erb +35 -0
  68. data/app/views/active_attack/tactics/new.html.erb +5 -0
  69. data/app/views/active_attack/tactics/show.html.erb +29 -0
  70. data/app/views/layouts/active_attack/application.html.erb +15 -0
  71. data/config/routes.rb +11 -0
  72. data/db/migrate/20191211202017_create_active_attack_data_sources.rb +10 -0
  73. data/db/migrate/20191211202101_create_active_attack_detections.rb +10 -0
  74. data/db/migrate/20191211202127_create_active_attack_difficulty_for_adversaries.rb +10 -0
  75. data/db/migrate/20191211202210_create_active_attack_matrices.rb +10 -0
  76. data/db/migrate/20191211202241_create_active_attack_permissions_requireds.rb +9 -0
  77. data/db/migrate/20191211202303_create_active_attack_platforms.rb +10 -0
  78. data/db/migrate/20191211202358_create_active_attack_playbooks.rb +11 -0
  79. data/db/migrate/20191211202448_create_active_attack_versions.rb +10 -0
  80. data/db/migrate/20191212205423_create_active_attack_tactics.rb +14 -0
  81. data/db/migrate/20200405004308_create_active_attack_builds.rb +10 -0
  82. data/db/migrate/20200405005101_add_buildable_type_to_builds.rb +5 -0
  83. data/db/migrate/20200405040306_add_stix_id_to_active_attack_matrices.rb +5 -0
  84. data/db/migrate/20200405040455_add_attributes_to_active_attack_matrices.rb +6 -0
  85. data/db/migrate/20200405041534_add_matrix_ref_to_active_attack_tactics.rb +5 -0
  86. data/db/migrate/20200405041824_add_created_by_ref_to_active_attack_matrices.rb +5 -0
  87. data/db/migrate/20200410170440_add_threat_actor_to_active_attack_playbooks.rb +5 -0
  88. data/lib/active_attack.rb +6 -0
  89. data/lib/active_attack/engine.rb +25 -0
  90. data/lib/active_attack/version.rb +3 -0
  91. data/lib/enterprise-attack.json +145354 -0
  92. data/lib/tasks/active_attack_tasks.rake +4 -0
  93. metadata +238 -0
@@ -0,0 +1,36 @@
1
+ ActiveStix::Tool.class_eval do
2
+ has_many :builds, class_name: "ActiveAttack::Build", as: :buildable
3
+ has_many :platforms, through: :builds, class_name: "ActiveAttack::Platform"
4
+
5
+ def self.expected_keys
6
+ [
7
+ 'description',
8
+ 'external_references',
9
+ 'object_marking_refs',
10
+ 'x_mitre_aliases',
11
+ 'x_mitre_platforms',
12
+ 'labels',
13
+ 'x_mitre_version'
14
+ ]
15
+ end
16
+
17
+
18
+ def self.x_mitre_aliases(tool, obj)
19
+ tool.aliases = obj['x_mitre_aliases']
20
+ end
21
+
22
+ def self.x_mitre_platforms(tool, obj)
23
+ obj['x_mitre_platforms'].each do |plat|
24
+ platform = ActiveAttack::Platform.create_platform(plat)
25
+ # todo make sure these are stix_ids
26
+ tool.platforms << platform unless ActiveAttack::Build.find_by(platform_id: platform.id, buildable_id: tool.id)
27
+ end
28
+ end
29
+
30
+ def self.x_mitre_version(tool, obj)
31
+ # todo
32
+ # version = ActiveAttack::Version.create_version(obj['x_mitre_version'])
33
+ # tool.versions << version unless ActiveAttack::ToolVersion.find_by(version_id: version.id, tool_id: tool.id)
34
+ end
35
+
36
+ end
@@ -0,0 +1,27 @@
1
+ <%= form_with(model: attack_matrix, local: true) do |form| %>
2
+ <% if attack_matrix.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(attack_matrix.errors.count, "error") %> prohibited this attack_matrix from being saved:</h2>
5
+
6
+ <ul>
7
+ <% attack_matrix.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= form.label :uploaded_file, 'Upload your file.' %><br/>
16
+ <%= form.file_field :uploaded_file %>
17
+ </div>
18
+
19
+ <div class="field">
20
+ <%= form.label :name %>
21
+ <%= form.text_field :name %>
22
+ </div>
23
+
24
+ <div class="actions">
25
+ <%= form.submit %>
26
+ </div>
27
+ <% end %>
@@ -0,0 +1,2 @@
1
+ json.extract! stix_attack_matrix, :id, :stix_bundle_id, :created_at, :updated_at
2
+ json.url stix_attack_matrix_url(stix_attack_matrix, format: :json)
@@ -0,0 +1,6 @@
1
+ <h1>Editing Stix Attack Matrix</h1>
2
+
3
+ <%= render 'form', stix_attack_matrix: @attack_attack_matrix %>
4
+
5
+ <%= link_to 'Show', @attack_attack_matrix %> |
6
+ <%= link_to 'Back', attack_attack_matrices_path %>
@@ -0,0 +1,16 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+
4
+ <h1>Att&ck Matrix</h1>
5
+
6
+
7
+ <table>
8
+ <% @attack_matrices.each do |matrix| %>
9
+ <tr>
10
+ <td>
11
+ <%= link_to matrix.name, matrix %>
12
+ </td>
13
+ </tr>
14
+ <% end %>
15
+ </table>
16
+ <%= link_to 'New', new_attack_matrix_path %>
@@ -0,0 +1 @@
1
+ json.array! @attack_attack_matrices, partial: "attack_attack_matrices/attack_attack_matrix", as: :attack_attack_matrix
@@ -0,0 +1,5 @@
1
+ <h1>New Attack Matrix</h1>
2
+
3
+ <%= render 'form', attack_matrix: @attack_matrix %>
4
+
5
+ <%= link_to 'Back', attack_matrices_path %>
@@ -0,0 +1,33 @@
1
+ <p id="notice"><%= notice %></p>
2
+ <h1> <%= @attack_matrix.name %> </h1>
3
+
4
+ <% bundle_phases = [] %>
5
+ <% @attack_matrix.stix_bundle.bundled_objects.where("stix_object_type = 'ActiveStix::AttackPattern'").each do | ap_ref | %>
6
+ <% bundle_phases << ActiveStix::AttackPattern.where(stix_id: ap_ref.stix_object_ref).first.phases.first %>
7
+ <% end %>
8
+ <% bundle_phases = bundle_phases.uniq.sort_by(&:rank) %>
9
+ <table style="width:100%;text-align:center;border:1px solid black">
10
+ <tr>
11
+ <% bundle_phases.each do | phase | %>
12
+ <th style="text-align:center;width:5%;border:1px solid black"><%= phase.name %></th>
13
+ <% end %>
14
+ </tr>
15
+
16
+ <tr>
17
+ <% bundle_phases.each do | phase | %>
18
+ <td valign="top">
19
+ <table style="width:100%">
20
+ <% phase.attack_patterns.uniq.each do | attack | %>
21
+ <tr>
22
+ <td style="width:5%;border:1px solid black;font-size:75%"> <%= link_to attack.name, attack %> </td>
23
+ </tr>
24
+ <% end %>
25
+ </table>
26
+ </td>
27
+ <% end %>
28
+ </tr>
29
+ </table>
30
+
31
+ <br>
32
+
33
+ <%= link_to 'New Stix Attack Matrix', new_attack_matrix_path %>
@@ -0,0 +1 @@
1
+ json.partial! "attack_attack_matrices/attack_attack_matrix", attack_attack_matrix: @attack_attack_matrix
@@ -0,0 +1,2 @@
1
+ json.extract! attack_playbook, :id, :name, :stix_bundle_id, :created_at, :updated_at
2
+ json.url attack_playbook_url(attack_playbook, format: :json)
@@ -0,0 +1,32 @@
1
+ <%= form_with(model: attack_playbook, local: true) do |form| %>
2
+ <% if attack_playbook.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(attack_playbook.errors.count, "error") %> prohibited this attack_playbook from being saved:</h2>
5
+
6
+ <ul>
7
+ <% attack_playbook.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= form.label :name %>
16
+ <%= form.text_field :name %>
17
+ </div>
18
+
19
+ <!-- <div class="field">-->
20
+ <%#= form.label :stix_bundle_id %>
21
+ <%#= form.text_field :stix_bundle_id %>
22
+ <!-- </div>-->
23
+
24
+ <div class="field">
25
+ <%= form.label :uploaded_file, 'Upload your file.' %><br/>
26
+ <%= form.file_field :uploaded_file %>
27
+ </div>
28
+
29
+ <div class="actions">
30
+ <%= form.submit %>
31
+ </div>
32
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing Attack Playbook</h1>
2
+
3
+ <%= render 'form', attack_playbook: @attack_playbook %>
4
+
5
+ <%= link_to 'Show', @attack_playbook %> |
6
+ <%= link_to 'Back', attack_playbooks_path %>
@@ -0,0 +1,38 @@
1
+ <div class="container-fluid">
2
+ <div class="wrapper" data-controller="playbooks">
3
+ <div class="box header">
4
+ <span>PLAYBOOK VIEWER</span></div>
5
+ <div class="box sidebar">
6
+ <a href="https://unit42.paloaltonetworks.com/" target="_blank"></a>
7
+ <!--<span>PLAYBOOKS</span><br>-->
8
+ <% @playbooks.each do |playbook| %>
9
+ <div class="btn playbook"><%= link_to playbook.threat_actor.name, playbook %></div>
10
+ <% end %>
11
+
12
+
13
+
14
+ <!--<div class="btn playbook" id="playbook_name" pb_file="name.json" onclick="">NAME</div>-->
15
+
16
+ </div>
17
+ <div class="box inside" data-controller="campaign">
18
+ </div>
19
+ <div class="info">
20
+
21
+
22
+ </div>
23
+ <div class="container-fluid" data-controller="matrix">
24
+ </div>
25
+
26
+ <div class="phasescontainer">
27
+
28
+ </div>
29
+ <div class="box footer">
30
+ Inspired by Palo Alto Networks - Unit 42
31
+ <br><a style="color:#95989a" href="https://attack.mitre.org/wiki/Main_Page">Mitre ATT&CK™</a>
32
+ | <a style="color:#95989a" href="https://oasis-open.github.io/cti-documentation/stix/intro">STIX 2.0</a>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ <% content_for :header do %>
37
+ <%= stylesheet_link_tag "active_attack/playbooks", media: "all" %>
38
+ <% end %>
@@ -0,0 +1 @@
1
+ json.array! @attack_playbooks, partial: "attack_playbooks/attack_playbook", as: :attack_playbook
@@ -0,0 +1,5 @@
1
+ <h1>New Attack Playbook</h1>
2
+
3
+ <%= render 'form', attack_playbook: @attack_playbook %>
4
+
5
+ <%= link_to 'Back', attack_playbooks_path %>
@@ -0,0 +1,70 @@
1
+ <div class="container-fluid">
2
+ <div class="wrapper" data-controller="playbooks">
3
+ <div class="box header">
4
+ <span>PLAYBOOK VIEWER</span></div>
5
+ <div class="box sidebar">
6
+ <a href="https://unit42.paloaltonetworks.com/" target="_blank"></a>
7
+ <!--<span>PLAYBOOKS</span><br>-->
8
+ <% @playbooks.each do |playbook| %>
9
+ <div class="btn playbook"><%= link_to playbook.threat_actor.name, playbook %></div>
10
+ <% end %>
11
+
12
+
13
+
14
+ <!--<div class="btn playbook" id="playbook_name" pb_file="name.json" onclick="">NAME</div>-->
15
+
16
+ </div>
17
+ <div class="box inside" data-controller="campaign">
18
+ <div class="box description">
19
+ <% @playbook.campaigns.each_with_index do |campaign, i| %>
20
+ <span data-target="campaign.description" id="campaign-<%= i %>" class="filter--notUsed"><%= campaign.description %></span>
21
+ <% end %>
22
+ </div>
23
+ <div class="box timeline">
24
+ <% @playbook.campaigns.each_with_index do |campaign,i| %>
25
+ <div class="timeline_btn btn btn-report" data-action="click->campaign#view click->playbooks#updateMatrix" data-target="campaign" index="<%= i %>" id="<%= campaign.stix_id%>" campaign_id="<%= campaign.stix_id%>" >
26
+ <%= campaign.name %>
27
+ </div>
28
+ <% end %>
29
+ </div>
30
+ </div>
31
+ <div class="info">
32
+
33
+
34
+ </div>
35
+ <div class="container-fluid" data-controller="matrix">
36
+ <button data-action="click->matrix#playbook">
37
+ Filter
38
+ </button>
39
+ <div class="row">
40
+ <% @playbook.kill_chain.phases.each do |phase| %>
41
+ <div class="col header kill-chain-phase-header rounded border"><%= phase.name %></div>
42
+ <% end %>
43
+ </div>
44
+ <% 0.upto(@playbook.number_of_rows - 1).each do |row| %>
45
+ <div data-target="matrix.row playbooks.row" class="row">
46
+ <% @playbook.kill_chain.phases.each do |phase| %>
47
+ <div class="col rounded border">
48
+ <span data-target="matrix.attackPattern playbooks.attackPattern" class="attack-pattern <%= campaign_list(phase.name, row) %>"><%= @playbook.attack_pattern_matrix(phase.name, row) %></span>
49
+ </div>
50
+ <% end %>
51
+ </div>
52
+ <% end %>
53
+ </div>
54
+
55
+ <div class="phasescontainer">
56
+
57
+ </div>
58
+ <div class="box footer">
59
+ Inspired by Palo Alto Networks - Unit 42
60
+ <br><a style="color:#95989a" href="https://attack.mitre.org/wiki/Main_Page">Mitre ATT&CK™</a>
61
+ | <a style="color:#95989a" href="https://oasis-open.github.io/cti-documentation/stix/intro">STIX 2.0</a>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ <% content_for :header do %>
66
+ <script src="https://unpkg.com/stimulus/dist/stimulus.umd.js"></script>
67
+ <%= stylesheet_link_tag "active_attack/playbooks", media: "all" %>
68
+ <% end %>
69
+ <%= javascript_include_tag "active_attack/application", media: "all" %>
70
+
@@ -0,0 +1 @@
1
+ json.partial! "attack_playbooks/attack_playbook", attack_playbook: @attack_playbook
@@ -0,0 +1,42 @@
1
+ <%= form_with(model: tactic, local: true) do |form| %>
2
+ <% if tactic.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(tactic.errors.count, "error") %> prohibited this tactic from being saved:</h2>
5
+
6
+ <ul>
7
+ <% tactic.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= form.label :stix_id %>
16
+ <%= form.text_field :stix_id %>
17
+ </div>
18
+
19
+ <div class="field">
20
+ <%= form.label :name %>
21
+ <%= form.text_field :name %>
22
+ </div>
23
+
24
+ <div class="field">
25
+ <%= form.label :description %>
26
+ <%= form.text_area :description %>
27
+ </div>
28
+
29
+ <div class="field">
30
+ <%= form.label :shortname %>
31
+ <%= form.text_field :shortname %>
32
+ </div>
33
+
34
+ <div class="field">
35
+ <%= form.label :created_by_ref %>
36
+ <%= form.text_field :created_by_ref %>
37
+ </div>
38
+
39
+ <div class="actions">
40
+ <%= form.submit %>
41
+ </div>
42
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing Tactic</h1>
2
+
3
+ <%= render 'form', tactic: @tactic %>
4
+
5
+ <%= link_to 'Show', @tactic %> |
6
+ <%= link_to 'Back', tactics_path %>
@@ -0,0 +1,35 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h1>Tactics</h1>
4
+
5
+ <table>
6
+ <thead>
7
+ <tr>
8
+ <th>Stix</th>
9
+ <th>Name</th>
10
+ <th>Description</th>
11
+ <th>Shortname</th>
12
+ <th>Created by ref</th>
13
+ <th colspan="3"></th>
14
+ </tr>
15
+ </thead>
16
+
17
+ <tbody>
18
+ <% @tactics.each do |tactic| %>
19
+ <tr>
20
+ <td><%= tactic.stix_id %></td>
21
+ <td><%= tactic.name %></td>
22
+ <td><%= tactic.description %></td>
23
+ <td><%= tactic.shortname %></td>
24
+ <td><%= tactic.created_by_ref %></td>
25
+ <td><%= link_to 'Show', tactic %></td>
26
+ <td><%= link_to 'Edit', edit_tactic_path(tactic) %></td>
27
+ <td><%= link_to 'Destroy', tactic, method: :delete, data: { confirm: 'Are you sure?' } %></td>
28
+ </tr>
29
+ <% end %>
30
+ </tbody>
31
+ </table>
32
+
33
+ <br>
34
+
35
+ <%= link_to 'New Tactic', new_tactic_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New Tactic</h1>
2
+
3
+ <%= render 'form', tactic: @tactic %>
4
+
5
+ <%= link_to 'Back', tactics_path %>
@@ -0,0 +1,29 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>Stix:</strong>
5
+ <%= @tactic.stix_id %>
6
+ </p>
7
+
8
+ <p>
9
+ <strong>Name:</strong>
10
+ <%= @tactic.name %>
11
+ </p>
12
+
13
+ <p>
14
+ <strong>Description:</strong>
15
+ <%= @tactic.description %>
16
+ </p>
17
+
18
+ <p>
19
+ <strong>Shortname:</strong>
20
+ <%= @tactic.shortname %>
21
+ </p>
22
+
23
+ <p>
24
+ <strong>Created by ref:</strong>
25
+ <%= @tactic.created_by_ref %>
26
+ </p>
27
+
28
+ <%= link_to 'Edit', edit_tactic_path(@tactic) %> |
29
+ <%= link_to 'Back', tactics_path %>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Active attack</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "active_attack/application", media: "all" %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>