From 055ef5b77b66f62a9d5132f9bc746c353b90ca29 Mon Sep 17 00:00:00 2001
From: ts
Date: Thu, 24 Jan 2019 12:25:34 +0000
Subject: [PATCH 01/47] explicitly set file permissions for flags leaked by
::secgen_functions::leak_file
---
.../unix/ctf/misc/hidden_file/manifests/install.pp | 1 +
.../unix/ctf/reverse/java/java_decompile/manifests/install.pp | 1 +
.../vulnerabilities/unix/local/chkrootkit/manifests/install.pp | 1 +
modules/vulnerabilities/unix/local/setuid_nmap/manifests/init.pp | 1 +
4 files changed, 4 insertions(+)
diff --git a/modules/vulnerabilities/unix/ctf/misc/hidden_file/manifests/install.pp b/modules/vulnerabilities/unix/ctf/misc/hidden_file/manifests/install.pp
index f6939b0a8..e982a60f6 100644
--- a/modules/vulnerabilities/unix/ctf/misc/hidden_file/manifests/install.pp
+++ b/modules/vulnerabilities/unix/ctf/misc/hidden_file/manifests/install.pp
@@ -30,6 +30,7 @@ class hidden_file::install {
storage_directory => $challenge_directory,
strings_to_leak => $strings_to_leak,
leaked_from => "$challenge_directory-hidden_file",
+ mode => '0644'
}
}
diff --git a/modules/vulnerabilities/unix/ctf/reverse/java/java_decompile/manifests/install.pp b/modules/vulnerabilities/unix/ctf/reverse/java/java_decompile/manifests/install.pp
index d33eae229..63fdba171 100644
--- a/modules/vulnerabilities/unix/ctf/reverse/java/java_decompile/manifests/install.pp
+++ b/modules/vulnerabilities/unix/ctf/reverse/java/java_decompile/manifests/install.pp
@@ -36,6 +36,7 @@ class java_decompile::install {
leaked_filenames => $leaked_filenames,
strings_to_leak => $strings_to_leak,
leaked_from => "java_decompile_instructions",
+ mode => '0644'
}
# Run the template to generate a .java file
diff --git a/modules/vulnerabilities/unix/local/chkrootkit/manifests/install.pp b/modules/vulnerabilities/unix/local/chkrootkit/manifests/install.pp
index 3cf0df123..0ceda4ac2 100644
--- a/modules/vulnerabilities/unix/local/chkrootkit/manifests/install.pp
+++ b/modules/vulnerabilities/unix/local/chkrootkit/manifests/install.pp
@@ -40,5 +40,6 @@ class chkrootkit::install {
leaked_filenames => $leaked_filenames,
strings_to_leak => $strings_to_leak,
leaked_from => "chkrootkit_vuln",
+ mode => '0600'
}
}
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/local/setuid_nmap/manifests/init.pp b/modules/vulnerabilities/unix/local/setuid_nmap/manifests/init.pp
index 54f0aca52..56c685a09 100644
--- a/modules/vulnerabilities/unix/local/setuid_nmap/manifests/init.pp
+++ b/modules/vulnerabilities/unix/local/setuid_nmap/manifests/init.pp
@@ -14,5 +14,6 @@ class setuid_nmap::init {
leaked_filenames => $leaked_filenames,
strings_to_leak => $strings_to_leak,
leaked_from => "setuid_nmap",
+ mode => '0600'
}
}
\ No newline at end of file
From 372e1361a050e80bb66019c6dce98a80aa2e20aa Mon Sep 17 00:00:00 2001
From: ts
Date: Thu, 24 Jan 2019 12:47:43 +0000
Subject: [PATCH 02/47] basic_narrative.xml: removed sqlmap from the
onlinestore vm as we've got an attacker vm within the scenario
---
scenarios/ctf/basic_narrative.xml | 2 --
1 file changed, 2 deletions(-)
diff --git a/scenarios/ctf/basic_narrative.xml b/scenarios/ctf/basic_narrative.xml
index 5cefcf581..c081e4b5c 100644
--- a/scenarios/ctf/basic_narrative.xml
+++ b/scenarios/ctf/basic_narrative.xml
@@ -437,8 +437,6 @@
-
-
IP_addresses
From 115002fe0866ed9234660aa5f9e0f42b019b77d0 Mon Sep 17 00:00:00 2001
From: ts
Date: Fri, 1 Feb 2019 22:18:43 +0000
Subject: [PATCH 03/47] gitignore update
---
.gitignore | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 48fc02156..9a4aeb302 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,4 +12,6 @@ modules/generators/challenges/exif/secgen_local/tmp.jpg
modules/generators/challenges/compression/zip/tmp
modules/generators/challenges/image/random_jpg/secgen_local/tmp.jpg
secgen.conf
-modules/encoders/compression/huffman/tmp
\ No newline at end of file
+modules/encoders/compression/huffman/tmp
+.rakeTasks
+modules/**/Gemfile.lock
From 1c4a9aebf10a442f34b49a8893ec0361f7e4d0b9 Mon Sep 17 00:00:00 2001
From: ts
Date: Sat, 2 Feb 2019 00:17:06 +0000
Subject: [PATCH 04/47] randomly generated json_inputs filenames now include
module_name
---
lib/templates/Vagrantfile.erb | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/templates/Vagrantfile.erb b/lib/templates/Vagrantfile.erb
index 1babe9dfd..93d706ea2 100644
--- a/lib/templates/Vagrantfile.erb
+++ b/lib/templates/Vagrantfile.erb
@@ -161,14 +161,14 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
b64_json_inputs = Base64.strict_encode64(json_inputs)
# save the inputs in a randomly named file in the
# project out directory of the secgen_functions module
- rand = SecureRandom.hex().to_s
+ json_inputs_filename = "#{module_name}_#{SecureRandom.hex(15).to_s}"
dir = "#{@out_dir}/puppet/#{system.name}/modules/secgen_functions/files/json_inputs"
FileUtils.mkdir_p(dir) unless File.exists?(dir)
- Print.verbose "Writing #{selected_module.module_path_name} input to: #{dir}/#{rand}"
- File.write("#{dir}/#{rand}", b64_json_inputs)
+ Print.verbose "Writing #{selected_module.module_path_name} input to: #{dir}/#{json_inputs_filename}"
+ File.write("#{dir}/#{json_inputs_filename}", b64_json_inputs)
-%>
<%= module_name%>.facter = {
- "base64_inputs_file" => '<%= rand %>',
+ "base64_inputs_file" => '<%= json_inputs_filename %>',
}
<% end -%>
<%=module_name%>.module_path = "<%="puppet/#{system.name}/modules"%>"
From 1fffa4b05c8bdc092300f71438d79130f87a704b Mon Sep 17 00:00:00 2001
From: ts
Date: Sat, 2 Feb 2019 01:27:50 +0000
Subject: [PATCH 05/47] (WiP) Created proftpd_133c_backdoor testing script -
Needs testing!
---
lib/objects/post_provision_test.rb | 91 +++++++++++++++++++
lib/output/project_files_creator.rb | 4 +
lib/templates/Vagrantfile.erb | 2 +-
.../secgen_test/proftpd_133c_backdoor.rb | 30 ++++++
scenarios/tests/test_scenario.xml | 6 +-
secgen.rb | 28 ++++++
6 files changed, 158 insertions(+), 3 deletions(-)
create mode 100644 lib/objects/post_provision_test.rb
create mode 100644 modules/vulnerabilities/unix/ftp/proftpd_133c_backdoor/secgen_test/proftpd_133c_backdoor.rb
diff --git a/lib/objects/post_provision_test.rb b/lib/objects/post_provision_test.rb
new file mode 100644
index 000000000..b7bf537f7
--- /dev/null
+++ b/lib/objects/post_provision_test.rb
@@ -0,0 +1,91 @@
+# Post Provision Testing
+#
+# This file will be copied into each project folder at creation time.
+# It will be required from each of the modules/secgen_tests/module_name.rb test scripts
+#
+# Test classes must: require_relative '../../../../../lib/post_provision_test'
+
+require_relative "../../../lib/helpers/print.rb"
+require 'json'
+require 'base64'
+
+require 'socket'
+require 'timeout'
+
+class PostProvisionTest
+ attr_accessor :project_path
+ attr_accessor :system_ip
+ attr_accessor :module_name
+ attr_accessor :module_path
+ attr_accessor :json_inputs
+
+ def initialize
+ # self.project_path =
+ end
+
+ def run
+ Print.info "Running tests for #{self.module_name}"
+ test_module
+ end
+
+ def test_module
+ # Override me with testing details
+ end
+
+ def get_system_ip(module_file_path)
+ # Get Vagrantfile
+
+ end
+
+ def get_json_inputs
+ json_inputs_path = "#{File.expand_path('../', self.module_path)}/secgen_functions/files/json_inputs/*"
+ Print.info "json_inputs_path: #{json_inputs_path}"
+ json_inputs_files = Dir.glob(json_inputs_path)
+ Print.info "json_input_files (pre delete): #{json_inputs_files}"
+ json_inputs_files.delete_if { |path| !path.include?(self.module_name) }
+ Print.info "json_input_files (post delete): #{json_inputs_files}"
+ JSON.parse(Base64.strict_decode64(File.read(json_inputs_files.first)))
+ end
+
+ # Pass __FILE__ in from subclasses
+ def get_module_path(file_path)
+ "#{File.expand_path('..', File.dirname(file_path))}"
+ end
+
+ # Note: returns proftpd_testing
+ def get_system_name
+ get_system_path.match(/.*?([^\/]*)$/i).captures[0]
+ end
+
+ # Note: returns /home/thomashaw/git/SecGen/projects/SecGen20190202_010552/puppet/proftpd_testing
+ def get_system_path
+ "#{File.expand_path('../../', self.module_path)}"
+ end
+
+ # Note: returns /home/thomashaw/git/SecGen/projects/SecGen20190202_010552/
+ def get_project_path
+ "#{File.expand_path('../../../../', self.module_path)}"
+ end
+
+ ##############################
+ ## Useful testing functions ##
+ ##############################
+
+ def is_port_open?(ip, port)
+ begin
+ Timeout::timeout(1) do
+ begin
+ s = TCPSocket.new(ip, port)
+ s.close
+ return true
+ rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
+ return false
+ end
+ end
+ rescue Timeout::Error
+ # ignored
+ end
+ false
+ end
+
+end
\ No newline at end of file
diff --git a/lib/output/project_files_creator.rb b/lib/output/project_files_creator.rb
index 6f2e0a4b7..475e06abb 100644
--- a/lib/output/project_files_creator.rb
+++ b/lib/output/project_files_creator.rb
@@ -172,6 +172,10 @@ class ProjectFilesCreator
abort
end
+ # Copy the test superclass into the project/lib directory
+ Print.std "Copying post-provision testing class"
+ FileUtils.mkdir("#{@out_dir}/lib")
+ FileUtils.cp("#{ROOT_DIR}/lib/objects/post_provision_test.rb", "#{@out_dir}/lib/post_provision_test.rb")
Print.std "VM(s) can be built using 'vagrant up' in #{@out_dir}"
diff --git a/lib/templates/Vagrantfile.erb b/lib/templates/Vagrantfile.erb
index 93d706ea2..ede0f1522 100644
--- a/lib/templates/Vagrantfile.erb
+++ b/lib/templates/Vagrantfile.erb
@@ -161,7 +161,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
b64_json_inputs = Base64.strict_encode64(json_inputs)
# save the inputs in a randomly named file in the
# project out directory of the secgen_functions module
- json_inputs_filename = "#{module_name}_#{SecureRandom.hex(15).to_s}"
+ json_inputs_filename = "#{selected_module.module_path_end}_#{SecureRandom.hex(15).to_s}"
dir = "#{@out_dir}/puppet/#{system.name}/modules/secgen_functions/files/json_inputs"
FileUtils.mkdir_p(dir) unless File.exists?(dir)
Print.verbose "Writing #{selected_module.module_path_name} input to: #{dir}/#{json_inputs_filename}"
diff --git a/modules/vulnerabilities/unix/ftp/proftpd_133c_backdoor/secgen_test/proftpd_133c_backdoor.rb b/modules/vulnerabilities/unix/ftp/proftpd_133c_backdoor/secgen_test/proftpd_133c_backdoor.rb
new file mode 100644
index 000000000..92bd87158
--- /dev/null
+++ b/modules/vulnerabilities/unix/ftp/proftpd_133c_backdoor/secgen_test/proftpd_133c_backdoor.rb
@@ -0,0 +1,30 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class Proftpd133cBackdoorTest < PostProvisionTest
+
+ attr_accessor :ftp_port
+ def initialize
+ super
+ self.module_name = 'proftpd_133c_backdoor'
+ self.module_path = get_module_path(__FILE__)
+ self.json_inputs = get_json_inputs
+ self.ftp_port = get_json_inputs['port'].to_i
+ # Print.info self.json_inputs
+ # Print.info "get_system_name: #{get_system_name}"
+ # Print.info "get_system_path: #{get_system_path}"
+ # Print.info "get_project_path: #{get_project_path}"
+ end
+
+ def test_module
+ # TODO: Need to determine how to handle the output... see other Open3.capture3 module and stdout print pass/fail perhaps?
+ # TODO: Raise an exception? Return false? Print the PASSED / FAILED only?
+
+ if is_port_open? "172.16.0.5", "21"
+ Print.info "PASSED: Port #{ftp_port} is open on #{get_system_name}!"
+ else
+ Print.err "FAILED: Port #{ftp_port} is closed on #{get_system_name}!"
+ end
+ end
+end
+
+Proftpd133cBackdoorTest.new.run
\ No newline at end of file
diff --git a/scenarios/tests/test_scenario.xml b/scenarios/tests/test_scenario.xml
index 3c84e680c..e3ef57c74 100644
--- a/scenarios/tests/test_scenario.xml
+++ b/scenarios/tests/test_scenario.xml
@@ -4,8 +4,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.github/cliffe/SecGen/scenario">
- empty_stretch
-
+ proftpd_testing
+
+
+ 172.16.0.5
diff --git a/secgen.rb b/secgen.rb
index 817dfac89..fb67ac42a 100644
--- a/secgen.rb
+++ b/secgen.rb
@@ -118,6 +118,8 @@ def build_vms(scenario, project_dir, options)
while retry_count and !successful_creation
vagrant_output = GemExec.exe('vagrant', project_dir, "#{command} #{system}")
if vagrant_output[:status] == 0
+ shutdown_cycle(project_dir)
+ post_provision_tests(project_dir)
Print.info 'VMs created.'
successful_creation = true
if options[:shutdown] or OVirtFunctions::provider_ovirt?(options)
@@ -329,6 +331,32 @@ def get_vm_names(scenario)
vm_names
end
+def shutdown_cycle(project_dir)
+ Print.info 'Shutting down VMs.'
+ sleep(30)
+ GemExec.exe('vagrant', project_dir, 'halt')
+ sleep 5
+ GemExec.exe('vagrant',project_dir,'up')
+ sleep 30
+end
+
+def post_provision_tests(project_dir)
+ # Get project files
+ Print.err "project_dir: #{project_dir}"
+
+ # Get system names
+ test_script_paths = Dir.glob("#{project_dir}/puppet/*/modules/*/secgen_test/*.rb")
+
+ test_script_paths.each {|test_file_path|
+ output = `bundle exec ruby #{test_file_path}`
+ Print.info output
+ if output.include? "FAILED"
+ raise "Post provision failure!"
+ end
+ }
+ Print.info 'Running post-provision tests...'
+end
+
# end of method declarations
# start of program execution
From 3279c506374fc75a59d3530f5d1d364c5354bd46 Mon Sep 17 00:00:00 2001
From: ts
Date: Sat, 2 Feb 2019 02:31:20 +0000
Subject: [PATCH 06/47] Tests now working! Added for all ftp services and
vulnerabilities.
---
lib/objects/post_provision_test.rb | 22 ++++++-------
lib/templates/Vagrantfile.erb | 2 ++
.../unix/ftp/proftpd/secgen_test/proftpd.rb | 24 ++++++++++++++
.../unix/ftp/vsftpd/secgen_test/vsftpd.rb | 24 ++++++++++++++
.../secgen_test/proftpd_133c_backdoor.rb | 12 ++-----
.../secgen_test/vsftpd_234_backdoor.rb | 24 ++++++++++++++
secgen.rb | 31 ++++++++++---------
7 files changed, 104 insertions(+), 35 deletions(-)
create mode 100644 modules/services/unix/ftp/proftpd/secgen_test/proftpd.rb
create mode 100644 modules/services/unix/ftp/vsftpd/secgen_test/vsftpd.rb
create mode 100644 modules/vulnerabilities/unix/ftp/vsftpd_234_backdoor/secgen_test/vsftpd_234_backdoor.rb
diff --git a/lib/objects/post_provision_test.rb b/lib/objects/post_provision_test.rb
index b7bf537f7..b8c1252f2 100644
--- a/lib/objects/post_provision_test.rb
+++ b/lib/objects/post_provision_test.rb
@@ -5,7 +5,7 @@
#
# Test classes must: require_relative '../../../../../lib/post_provision_test'
-require_relative "../../../lib/helpers/print.rb"
+require_relative '../../../lib/helpers/print.rb'
require 'json'
require 'base64'
@@ -19,10 +19,6 @@ class PostProvisionTest
attr_accessor :module_path
attr_accessor :json_inputs
- def initialize
- # self.project_path =
- end
-
def run
Print.info "Running tests for #{self.module_name}"
test_module
@@ -32,18 +28,22 @@ class PostProvisionTest
# Override me with testing details
end
- def get_system_ip(module_file_path)
- # Get Vagrantfile
-
+ def get_system_ip
+ vagrant_file_path = "#{get_project_path}/Vagrantfile"
+ vagrantfile = File.read(vagrant_file_path)
+ ip_line = vagrantfile.split("\n").delete_if { |line| !line.include? "# ip_address_for_#{get_system_name}"}[0]
+ ip_address = ip_line.split('=')[-1]
+ if ip_address == "DHCP"
+ "FAILED: Cannot test against dynamic IPs" # TODO: fix this so that we grab dynamic IP address (maybe from vagrant?)
+ else
+ ip_address
+ end
end
def get_json_inputs
json_inputs_path = "#{File.expand_path('../', self.module_path)}/secgen_functions/files/json_inputs/*"
- Print.info "json_inputs_path: #{json_inputs_path}"
json_inputs_files = Dir.glob(json_inputs_path)
- Print.info "json_input_files (pre delete): #{json_inputs_files}"
json_inputs_files.delete_if { |path| !path.include?(self.module_name) }
- Print.info "json_input_files (post delete): #{json_inputs_files}"
JSON.parse(Base64.strict_decode64(File.read(json_inputs_files.first)))
end
diff --git a/lib/templates/Vagrantfile.erb b/lib/templates/Vagrantfile.erb
index ede0f1522..6b3d4cb6f 100644
--- a/lib/templates/Vagrantfile.erb
+++ b/lib/templates/Vagrantfile.erb
@@ -136,6 +136,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
<% else %>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, type: "dhcp", auto_config: false
<% end %>
+ # ip_address_for_<%= system.name %>=DHCP
<% # Static networking -%>
<% else -%>
<% # Static oVirt networking -%>
@@ -150,6 +151,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
<% # Static Virtualbox networking -%>
<% else -%>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, ip: "<%= resolve_network(selected_module)%>"
+ # ip_address_for_<%= system.name %>=<%= resolve_network(selected_module)%>
<% end -%>
<% end -%>
<% when 'vulnerability', 'service', 'utility', 'build' -%>
diff --git a/modules/services/unix/ftp/proftpd/secgen_test/proftpd.rb b/modules/services/unix/ftp/proftpd/secgen_test/proftpd.rb
new file mode 100644
index 000000000..169af55e4
--- /dev/null
+++ b/modules/services/unix/ftp/proftpd/secgen_test/proftpd.rb
@@ -0,0 +1,24 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class ProftpdTest < PostProvisionTest
+
+ attr_accessor :ftp_port
+ def initialize
+ super
+ self.module_name = 'proftpd'
+ self.module_path = get_module_path(__FILE__)
+ self.json_inputs = get_json_inputs
+ self.ftp_port = get_json_inputs['port'][0].to_i
+ self.system_ip = get_system_ip
+ end
+
+ def test_module
+ if is_port_open? system_ip, ftp_port
+ Print.info "PASSED: Port #{ftp_port} is open on #{get_system_name}!"
+ else
+ Print.err "FAILED: Port #{ftp_port} is closed on #{get_system_name}!"
+ end
+ end
+end
+
+ProftpdTest.new.run
\ No newline at end of file
diff --git a/modules/services/unix/ftp/vsftpd/secgen_test/vsftpd.rb b/modules/services/unix/ftp/vsftpd/secgen_test/vsftpd.rb
new file mode 100644
index 000000000..34a602bcc
--- /dev/null
+++ b/modules/services/unix/ftp/vsftpd/secgen_test/vsftpd.rb
@@ -0,0 +1,24 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class VsftpdTest < PostProvisionTest
+
+ attr_accessor :ftp_port
+ def initialize
+ super
+ self.module_name = 'vsftpd'
+ self.module_path = get_module_path(__FILE__)
+ self.json_inputs = get_json_inputs
+ self.ftp_port = get_json_inputs['port'][0].to_i
+ self.system_ip = get_system_ip
+ end
+
+ def test_module
+ if is_port_open? system_ip, ftp_port
+ Print.info "PASSED: Port #{ftp_port} is open on #{get_system_name}!"
+ else
+ Print.err "FAILED: Port #{ftp_port} is closed on #{get_system_name}!"
+ end
+ end
+end
+
+VsftpdTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/ftp/proftpd_133c_backdoor/secgen_test/proftpd_133c_backdoor.rb b/modules/vulnerabilities/unix/ftp/proftpd_133c_backdoor/secgen_test/proftpd_133c_backdoor.rb
index 92bd87158..cc656ce45 100644
--- a/modules/vulnerabilities/unix/ftp/proftpd_133c_backdoor/secgen_test/proftpd_133c_backdoor.rb
+++ b/modules/vulnerabilities/unix/ftp/proftpd_133c_backdoor/secgen_test/proftpd_133c_backdoor.rb
@@ -8,18 +8,12 @@ class Proftpd133cBackdoorTest < PostProvisionTest
self.module_name = 'proftpd_133c_backdoor'
self.module_path = get_module_path(__FILE__)
self.json_inputs = get_json_inputs
- self.ftp_port = get_json_inputs['port'].to_i
- # Print.info self.json_inputs
- # Print.info "get_system_name: #{get_system_name}"
- # Print.info "get_system_path: #{get_system_path}"
- # Print.info "get_project_path: #{get_project_path}"
+ self.ftp_port = get_json_inputs['port'][0].to_i
+ self.system_ip = get_system_ip
end
def test_module
- # TODO: Need to determine how to handle the output... see other Open3.capture3 module and stdout print pass/fail perhaps?
- # TODO: Raise an exception? Return false? Print the PASSED / FAILED only?
-
- if is_port_open? "172.16.0.5", "21"
+ if is_port_open? system_ip, ftp_port
Print.info "PASSED: Port #{ftp_port} is open on #{get_system_name}!"
else
Print.err "FAILED: Port #{ftp_port} is closed on #{get_system_name}!"
diff --git a/modules/vulnerabilities/unix/ftp/vsftpd_234_backdoor/secgen_test/vsftpd_234_backdoor.rb b/modules/vulnerabilities/unix/ftp/vsftpd_234_backdoor/secgen_test/vsftpd_234_backdoor.rb
new file mode 100644
index 000000000..55e3a6a23
--- /dev/null
+++ b/modules/vulnerabilities/unix/ftp/vsftpd_234_backdoor/secgen_test/vsftpd_234_backdoor.rb
@@ -0,0 +1,24 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class Vsftpd234BackdoorTest < PostProvisionTest
+
+ attr_accessor :ftp_port
+ def initialize
+ super
+ self.module_name = 'vsftpd_234_backdoor'
+ self.module_path = get_module_path(__FILE__)
+ self.json_inputs = get_json_inputs
+ self.ftp_port = get_json_inputs['port'][0].to_i
+ self.system_ip = get_system_ip
+ end
+
+ def test_module
+ if is_port_open? system_ip, ftp_port
+ Print.info "PASSED: Port #{ftp_port} is open on #{get_system_name}!"
+ else
+ Print.err "FAILED: Port #{ftp_port} is closed on #{get_system_name}!"
+ end
+ end
+end
+
+Vsftpd234BackdoorTest.new.run
\ No newline at end of file
diff --git a/secgen.rb b/secgen.rb
index fb67ac42a..cedc3120d 100644
--- a/secgen.rb
+++ b/secgen.rb
@@ -119,13 +119,16 @@ def build_vms(scenario, project_dir, options)
vagrant_output = GemExec.exe('vagrant', project_dir, "#{command} #{system}")
if vagrant_output[:status] == 0
shutdown_cycle(project_dir)
- post_provision_tests(project_dir)
- Print.info 'VMs created.'
- successful_creation = true
- if options[:shutdown] or OVirtFunctions::provider_ovirt?(options)
- Print.info 'Shutting down VMs.'
- sleep(30)
- GemExec.exe('vagrant', project_dir, 'halt')
+ if post_provision_tests(project_dir)
+ Print.info 'VMs created.'
+ successful_creation = true
+ if options[:shutdown] or OVirtFunctions::provider_ovirt?(options)
+ Print.info 'Shutting down VMs.'
+ sleep(30)
+ GemExec.exe('vagrant', project_dir, 'halt')
+ end
+ else
+ Print.err 'Tests failed!'
end
else
if retry_count > 0
@@ -341,20 +344,18 @@ def shutdown_cycle(project_dir)
end
def post_provision_tests(project_dir)
- # Get project files
- Print.err "project_dir: #{project_dir}"
+ Print.info 'Running post-provision tests...'
- # Get system names
test_script_paths = Dir.glob("#{project_dir}/puppet/*/modules/*/secgen_test/*.rb")
-
- test_script_paths.each {|test_file_path|
+ test_script_paths.each do |test_file_path|
output = `bundle exec ruby #{test_file_path}`
Print.info output
if output.include? "FAILED"
- raise "Post provision failure!"
+ Print.err "ERROR: Post provision failure!"
+ return false
end
- }
- Print.info 'Running post-provision tests...'
+ end
+ true
end
# end of method declarations
From 17ed03a3274ebce23828e4223eef4bc11511d2b4 Mon Sep 17 00:00:00 2001
From: ts
Date: Sat, 2 Feb 2019 17:22:50 +0000
Subject: [PATCH 07/47] Testing most service modules for open port [todo.. NTP
and popa3d]
---
lib/objects/post_provision_test.rb | 51 ++-
lib/templates/Vagrantfile.erb | 4 +-
.../unix/ftp/proftpd/secgen_test/proftpd.rb | 14 +-
.../unix/ftp/vsftpd/secgen_test/vsftpd.rb | 14 +-
.../secgen_test/parameterised_website.rb | 47 +++
.../unix/irc/unrealirc/secgen_metadata.xml | 4 -
.../irc/unrealirc/secgen_test/unrealirc.rb | 16 +
.../nfs/nfs_share/secgen_test/nfs_share.rb | 17 +
.../unix/smb/samba/secgen_test/samba.rb | 17 +
.../secgen_test/proftpd_133c_backdoor.rb | 14 +-
.../secgen_test/vsftpd_234_backdoor.rb | 13 +-
.../secgen_metadata.xml | 6 +-
.../secgen_test/unrealirc_3281_backdoor.rb | 16 +
.../nc_backdoor/secgen_test/nc_backdoor.rb | 16 +
.../web_training/dvwa/secgen_test/dvwa.rb | 16 +
.../gitlist_040/secgen_test/gitlist_040.rb | 16 +
.../moinmoin_195/secgen_test/moinmoin_195.rb | 16 +
.../onlinestore/secgen_test/onlinestore.rb | 16 +
.../wordpress_1x/secgen_test/wordpress_1x.rb | 16 +
.../wordpress_2x/secgen_test/wordpress_2x.rb | 16 +
.../wordpress_3x/secgen_test/wordpress_3x.rb | 16 +
.../wordpress_4x/secgen_test/wordpress_4x.rb | 16 +
scenarios/tests/test_scenario.xml | 6 +-
secgen.rb | 322 +++++++++---------
24 files changed, 486 insertions(+), 219 deletions(-)
create mode 100644 modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
create mode 100644 modules/services/unix/irc/unrealirc/secgen_test/unrealirc.rb
create mode 100644 modules/services/unix/nfs/nfs_share/secgen_test/nfs_share.rb
create mode 100644 modules/services/unix/smb/samba/secgen_test/samba.rb
create mode 100644 modules/vulnerabilities/unix/irc/unrealirc_3281_backdoor/secgen_test/unrealirc_3281_backdoor.rb
create mode 100644 modules/vulnerabilities/unix/misc/nc_backdoor/secgen_test/nc_backdoor.rb
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/secgen_test/dvwa.rb
create mode 100644 modules/vulnerabilities/unix/webapp/gitlist_040/secgen_test/gitlist_040.rb
create mode 100644 modules/vulnerabilities/unix/webapp/moinmoin_195/secgen_test/moinmoin_195.rb
create mode 100644 modules/vulnerabilities/unix/webapp/onlinestore/secgen_test/onlinestore.rb
create mode 100644 modules/vulnerabilities/unix/webapp/wordpress_1x/secgen_test/wordpress_1x.rb
create mode 100644 modules/vulnerabilities/unix/webapp/wordpress_2x/secgen_test/wordpress_2x.rb
create mode 100644 modules/vulnerabilities/unix/webapp/wordpress_3x/secgen_test/wordpress_3x.rb
create mode 100644 modules/vulnerabilities/unix/webapp/wordpress_4x/secgen_test/wordpress_4x.rb
diff --git a/lib/objects/post_provision_test.rb b/lib/objects/post_provision_test.rb
index b8c1252f2..47edaa25f 100644
--- a/lib/objects/post_provision_test.rb
+++ b/lib/objects/post_provision_test.rb
@@ -5,7 +5,6 @@
#
# Test classes must: require_relative '../../../../../lib/post_provision_test'
-require_relative '../../../lib/helpers/print.rb'
require 'json'
require 'base64'
@@ -18,23 +17,50 @@ class PostProvisionTest
attr_accessor :module_name
attr_accessor :module_path
attr_accessor :json_inputs
+ attr_accessor :port
+ attr_accessor :outputs
+
+ def initialize
+ self.system_ip = get_system_ip
+ self.json_inputs = get_json_inputs
+ self.port = get_port
+ self.outputs = []
+ end
def run
- Print.info "Running tests for #{self.module_name}"
test_module
+ puts self.outputs
end
def test_module
- # Override me with testing details
+ # Call super first in overriden methods
+ self.outputs << "Running tests for #{self.module_name}"
end
+ #####################
+ # Testing Functions #
+ #####################
+
+ def test_service_up
+ if is_port_open? system_ip, self.port
+ self.outputs << "PASSED: Port #{self.port} is open at #{get_system_ip} (#{get_system_name})!"
+ else
+ self.outputs << "FAILED: Port #{self.port} is closed at #{get_system_ip} (#{get_system_name})!"
+ end
+ end
+
+ ##################
+ # Misc Functions #
+ ##################
+
def get_system_ip
vagrant_file_path = "#{get_project_path}/Vagrantfile"
vagrantfile = File.read(vagrant_file_path)
ip_line = vagrantfile.split("\n").delete_if { |line| !line.include? "# ip_address_for_#{get_system_name}"}[0]
ip_address = ip_line.split('=')[-1]
if ip_address == "DHCP"
- "FAILED: Cannot test against dynamic IPs" # TODO: fix this so that we grab dynamic IP address (maybe from vagrant?)
+ self.outputs << "FAILED: Cannot test against dynamic IPs" # TODO: fix this so that we grab dynamic IP address (maybe from vagrant?)
+ exit(1)
else
ip_address
end
@@ -44,7 +70,18 @@ class PostProvisionTest
json_inputs_path = "#{File.expand_path('../', self.module_path)}/secgen_functions/files/json_inputs/*"
json_inputs_files = Dir.glob(json_inputs_path)
json_inputs_files.delete_if { |path| !path.include?(self.module_name) }
- JSON.parse(Base64.strict_decode64(File.read(json_inputs_files.first)))
+ if json_inputs_files.size > 0
+ return JSON.parse(Base64.strict_decode64(File.read(json_inputs_files.first)))
+ end
+ {}
+ end
+
+ def get_port
+ if get_json_inputs != {}
+ get_json_inputs['port'][0].to_i
+ else
+ -1
+ end
end
# Pass __FILE__ in from subclasses
@@ -67,10 +104,6 @@ class PostProvisionTest
"#{File.expand_path('../../../../', self.module_path)}"
end
- ##############################
- ## Useful testing functions ##
- ##############################
-
def is_port_open?(ip, port)
begin
Timeout::timeout(1) do
diff --git a/lib/templates/Vagrantfile.erb b/lib/templates/Vagrantfile.erb
index 6b3d4cb6f..1001829a0 100644
--- a/lib/templates/Vagrantfile.erb
+++ b/lib/templates/Vagrantfile.erb
@@ -136,7 +136,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
<% else %>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, type: "dhcp", auto_config: false
<% end %>
- # ip_address_for_<%= system.name %>=DHCP
+ # ip_address_for_<%= system.name %>=DHCP
<% # Static networking -%>
<% else -%>
<% # Static oVirt networking -%>
@@ -151,7 +151,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
<% # Static Virtualbox networking -%>
<% else -%>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, ip: "<%= resolve_network(selected_module)%>"
- # ip_address_for_<%= system.name %>=<%= resolve_network(selected_module)%>
+ # ip_address_for_<%= system.name %>=<%= resolve_network(selected_module)%>
<% end -%>
<% end -%>
<% when 'vulnerability', 'service', 'utility', 'build' -%>
diff --git a/modules/services/unix/ftp/proftpd/secgen_test/proftpd.rb b/modules/services/unix/ftp/proftpd/secgen_test/proftpd.rb
index 169af55e4..01ad6df76 100644
--- a/modules/services/unix/ftp/proftpd/secgen_test/proftpd.rb
+++ b/modules/services/unix/ftp/proftpd/secgen_test/proftpd.rb
@@ -1,23 +1,15 @@
require_relative '../../../../../lib/post_provision_test'
class ProftpdTest < PostProvisionTest
-
- attr_accessor :ftp_port
def initialize
- super
self.module_name = 'proftpd'
self.module_path = get_module_path(__FILE__)
- self.json_inputs = get_json_inputs
- self.ftp_port = get_json_inputs['port'][0].to_i
- self.system_ip = get_system_ip
+ super
end
def test_module
- if is_port_open? system_ip, ftp_port
- Print.info "PASSED: Port #{ftp_port} is open on #{get_system_name}!"
- else
- Print.err "FAILED: Port #{ftp_port} is closed on #{get_system_name}!"
- end
+ super
+ test_service_up
end
end
diff --git a/modules/services/unix/ftp/vsftpd/secgen_test/vsftpd.rb b/modules/services/unix/ftp/vsftpd/secgen_test/vsftpd.rb
index 34a602bcc..13115198a 100644
--- a/modules/services/unix/ftp/vsftpd/secgen_test/vsftpd.rb
+++ b/modules/services/unix/ftp/vsftpd/secgen_test/vsftpd.rb
@@ -1,23 +1,15 @@
require_relative '../../../../../lib/post_provision_test'
class VsftpdTest < PostProvisionTest
-
- attr_accessor :ftp_port
def initialize
- super
self.module_name = 'vsftpd'
self.module_path = get_module_path(__FILE__)
- self.json_inputs = get_json_inputs
- self.ftp_port = get_json_inputs['port'][0].to_i
- self.system_ip = get_system_ip
+ super
end
def test_module
- if is_port_open? system_ip, ftp_port
- Print.info "PASSED: Port #{ftp_port} is open on #{get_system_name}!"
- else
- Print.err "FAILED: Port #{ftp_port} is closed on #{get_system_name}!"
- end
+ super
+ test_service_up
end
end
diff --git a/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb b/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
new file mode 100644
index 000000000..f4512644d
--- /dev/null
+++ b/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
@@ -0,0 +1,47 @@
+require_relative '../../../../../lib/post_provision_test'
+require 'json'
+require 'net/http'
+
+class ParamWebsiteTest < PostProvisionTest
+ def initialize
+ self.module_name = 'parameterised_website'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ json_inputs = get_json_inputs
+ css_theme = json_inputs['theme'][0]
+
+ if json_inputs['organisation']
+ organisation = JSON.parse(json_inputs['organisation'][0])
+ employee_1 = organisation['employees'][0]
+
+ test_html_returned_content('/index.html', organisation['business_name'])
+ test_html_returned_content('/contact.html', organisation['business_moto'])
+ test_html_returned_content('/contact.html', employee_1['name'])
+ end
+
+ test_html_returned_content("/css/#{css_theme}", 'Bootswatch v4.0.0')
+
+ test_service_up
+ end
+
+ def test_html_returned_content(page, match_string)
+
+ begin
+ source = Net::HTTP.get(get_system_ip, page, self.port)
+ rescue SocketError
+ # do nothing
+ end
+
+ if source.include? match_string
+ self.outputs << "PASSED: Content #{match_string} is contained within #{page} at #{get_system_ip}:#{self.port} (#{get_system_name})!"
+ else
+ self.outputs << "FAILED: Content #{match_string} is contained within #{page} at #{get_system_ip}:#{self.port} (#{get_system_name})!"
+ end
+ end
+end
+
+ParamWebsiteTest.new.run
\ No newline at end of file
diff --git a/modules/services/unix/irc/unrealirc/secgen_metadata.xml b/modules/services/unix/irc/unrealirc/secgen_metadata.xml
index 0e30d7480..77bf56ce5 100644
--- a/modules/services/unix/irc/unrealirc/secgen_metadata.xml
+++ b/modules/services/unix/irc/unrealirc/secgen_metadata.xml
@@ -32,10 +32,6 @@
Kali.*
-
- .*Stretch.*
-
-
update
diff --git a/modules/services/unix/irc/unrealirc/secgen_test/unrealirc.rb b/modules/services/unix/irc/unrealirc/secgen_test/unrealirc.rb
new file mode 100644
index 000000000..511d0860d
--- /dev/null
+++ b/modules/services/unix/irc/unrealirc/secgen_test/unrealirc.rb
@@ -0,0 +1,16 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class UnrealircTest < PostProvisionTest
+ def initialize
+ self.module_name = 'unrealirc'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+UnrealircTest.new.run
\ No newline at end of file
diff --git a/modules/services/unix/nfs/nfs_share/secgen_test/nfs_share.rb b/modules/services/unix/nfs/nfs_share/secgen_test/nfs_share.rb
new file mode 100644
index 000000000..a08e90b04
--- /dev/null
+++ b/modules/services/unix/nfs/nfs_share/secgen_test/nfs_share.rb
@@ -0,0 +1,17 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class NFSShareTest < PostProvisionTest
+ def initialize
+ self.module_name = 'ntp'
+ self.module_path = get_module_path(__FILE__)
+ super
+ self.port = 2049
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+NFSShareTest.new.run
\ No newline at end of file
diff --git a/modules/services/unix/smb/samba/secgen_test/samba.rb b/modules/services/unix/smb/samba/secgen_test/samba.rb
new file mode 100644
index 000000000..f406ebc26
--- /dev/null
+++ b/modules/services/unix/smb/samba/secgen_test/samba.rb
@@ -0,0 +1,17 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class SambaTest < PostProvisionTest
+ def initialize
+ self.module_name = 'samba'
+ self.module_path = get_module_path(__FILE__)
+ super
+ self.port = 139
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+SambaTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/ftp/proftpd_133c_backdoor/secgen_test/proftpd_133c_backdoor.rb b/modules/vulnerabilities/unix/ftp/proftpd_133c_backdoor/secgen_test/proftpd_133c_backdoor.rb
index cc656ce45..2d22e586d 100644
--- a/modules/vulnerabilities/unix/ftp/proftpd_133c_backdoor/secgen_test/proftpd_133c_backdoor.rb
+++ b/modules/vulnerabilities/unix/ftp/proftpd_133c_backdoor/secgen_test/proftpd_133c_backdoor.rb
@@ -1,23 +1,15 @@
require_relative '../../../../../lib/post_provision_test'
class Proftpd133cBackdoorTest < PostProvisionTest
-
- attr_accessor :ftp_port
def initialize
- super
self.module_name = 'proftpd_133c_backdoor'
self.module_path = get_module_path(__FILE__)
- self.json_inputs = get_json_inputs
- self.ftp_port = get_json_inputs['port'][0].to_i
- self.system_ip = get_system_ip
+ super
end
def test_module
- if is_port_open? system_ip, ftp_port
- Print.info "PASSED: Port #{ftp_port} is open on #{get_system_name}!"
- else
- Print.err "FAILED: Port #{ftp_port} is closed on #{get_system_name}!"
- end
+ super
+ test_service_up
end
end
diff --git a/modules/vulnerabilities/unix/ftp/vsftpd_234_backdoor/secgen_test/vsftpd_234_backdoor.rb b/modules/vulnerabilities/unix/ftp/vsftpd_234_backdoor/secgen_test/vsftpd_234_backdoor.rb
index 55e3a6a23..d5d7e85d4 100644
--- a/modules/vulnerabilities/unix/ftp/vsftpd_234_backdoor/secgen_test/vsftpd_234_backdoor.rb
+++ b/modules/vulnerabilities/unix/ftp/vsftpd_234_backdoor/secgen_test/vsftpd_234_backdoor.rb
@@ -1,23 +1,16 @@
require_relative '../../../../../lib/post_provision_test'
class Vsftpd234BackdoorTest < PostProvisionTest
-
- attr_accessor :ftp_port
def initialize
super
self.module_name = 'vsftpd_234_backdoor'
self.module_path = get_module_path(__FILE__)
- self.json_inputs = get_json_inputs
- self.ftp_port = get_json_inputs['port'][0].to_i
- self.system_ip = get_system_ip
+ super
end
def test_module
- if is_port_open? system_ip, ftp_port
- Print.info "PASSED: Port #{ftp_port} is open on #{get_system_name}!"
- else
- Print.err "FAILED: Port #{ftp_port} is closed on #{get_system_name}!"
- end
+ super
+ test_service_up
end
end
diff --git a/modules/vulnerabilities/unix/irc/unrealirc_3281_backdoor/secgen_metadata.xml b/modules/vulnerabilities/unix/irc/unrealirc_3281_backdoor/secgen_metadata.xml
index c5ddf6fa2..fe04f8218 100644
--- a/modules/vulnerabilities/unix/irc/unrealirc_3281_backdoor/secgen_metadata.xml
+++ b/modules/vulnerabilities/unix/irc/unrealirc_3281_backdoor/secgen_metadata.xml
@@ -84,9 +84,9 @@
unrealircdMIT
-
- .*Stretch.*
-
+
+
+
.*Kali.*
diff --git a/modules/vulnerabilities/unix/irc/unrealirc_3281_backdoor/secgen_test/unrealirc_3281_backdoor.rb b/modules/vulnerabilities/unix/irc/unrealirc_3281_backdoor/secgen_test/unrealirc_3281_backdoor.rb
new file mode 100644
index 000000000..f58b4c22e
--- /dev/null
+++ b/modules/vulnerabilities/unix/irc/unrealirc_3281_backdoor/secgen_test/unrealirc_3281_backdoor.rb
@@ -0,0 +1,16 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class Unrealirc3281BackdoorTest < PostProvisionTest
+ def initialize
+ self.module_name = 'unrealirc_3281_backdoor'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+Unrealirc3281BackdoorTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/misc/nc_backdoor/secgen_test/nc_backdoor.rb b/modules/vulnerabilities/unix/misc/nc_backdoor/secgen_test/nc_backdoor.rb
new file mode 100644
index 000000000..ad8664095
--- /dev/null
+++ b/modules/vulnerabilities/unix/misc/nc_backdoor/secgen_test/nc_backdoor.rb
@@ -0,0 +1,16 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class NcBackdoorTest < PostProvisionTest
+ def initialize
+ self.module_name = 'nc_backdoor'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+NcBackdoorTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/web_training/dvwa/secgen_test/dvwa.rb b/modules/vulnerabilities/unix/web_training/dvwa/secgen_test/dvwa.rb
new file mode 100644
index 000000000..04cc12715
--- /dev/null
+++ b/modules/vulnerabilities/unix/web_training/dvwa/secgen_test/dvwa.rb
@@ -0,0 +1,16 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class DVWATest < PostProvisionTest
+ def initialize
+ self.module_name = 'dvwa'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+DVWATest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/webapp/gitlist_040/secgen_test/gitlist_040.rb b/modules/vulnerabilities/unix/webapp/gitlist_040/secgen_test/gitlist_040.rb
new file mode 100644
index 000000000..b80f1599a
--- /dev/null
+++ b/modules/vulnerabilities/unix/webapp/gitlist_040/secgen_test/gitlist_040.rb
@@ -0,0 +1,16 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class Gitlist040Test < PostProvisionTest
+ def initialize
+ self.module_name = 'gitlist_040'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+Gitlist040Test.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/webapp/moinmoin_195/secgen_test/moinmoin_195.rb b/modules/vulnerabilities/unix/webapp/moinmoin_195/secgen_test/moinmoin_195.rb
new file mode 100644
index 000000000..4c6fcc9f7
--- /dev/null
+++ b/modules/vulnerabilities/unix/webapp/moinmoin_195/secgen_test/moinmoin_195.rb
@@ -0,0 +1,16 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class MoinMoin195Test < PostProvisionTest
+ def initialize
+ self.module_name = 'moinmoin_195'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+MoinMoin195Test.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/webapp/onlinestore/secgen_test/onlinestore.rb b/modules/vulnerabilities/unix/webapp/onlinestore/secgen_test/onlinestore.rb
new file mode 100644
index 000000000..b242f6028
--- /dev/null
+++ b/modules/vulnerabilities/unix/webapp/onlinestore/secgen_test/onlinestore.rb
@@ -0,0 +1,16 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class OnlineStoreTest < PostProvisionTest
+ def initialize
+ self.module_name = 'onlinestore'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+OnlineStoreTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/webapp/wordpress_1x/secgen_test/wordpress_1x.rb b/modules/vulnerabilities/unix/webapp/wordpress_1x/secgen_test/wordpress_1x.rb
new file mode 100644
index 000000000..c7d022bcd
--- /dev/null
+++ b/modules/vulnerabilities/unix/webapp/wordpress_1x/secgen_test/wordpress_1x.rb
@@ -0,0 +1,16 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class Wordpress1xTest < PostProvisionTest
+ def initialize
+ self.module_name = 'wordpress_1x'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+Wordpress1xTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/webapp/wordpress_2x/secgen_test/wordpress_2x.rb b/modules/vulnerabilities/unix/webapp/wordpress_2x/secgen_test/wordpress_2x.rb
new file mode 100644
index 000000000..15ec4cbba
--- /dev/null
+++ b/modules/vulnerabilities/unix/webapp/wordpress_2x/secgen_test/wordpress_2x.rb
@@ -0,0 +1,16 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class Wordpress2xTest < PostProvisionTest
+ def initialize
+ self.module_name = 'wordpress_2x'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+Wordpress2xTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/webapp/wordpress_3x/secgen_test/wordpress_3x.rb b/modules/vulnerabilities/unix/webapp/wordpress_3x/secgen_test/wordpress_3x.rb
new file mode 100644
index 000000000..fdc3ec350
--- /dev/null
+++ b/modules/vulnerabilities/unix/webapp/wordpress_3x/secgen_test/wordpress_3x.rb
@@ -0,0 +1,16 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class Wordpress3xTest < PostProvisionTest
+ def initialize
+ self.module_name = 'wordpress_3x'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+Wordpress3xTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/webapp/wordpress_4x/secgen_test/wordpress_4x.rb b/modules/vulnerabilities/unix/webapp/wordpress_4x/secgen_test/wordpress_4x.rb
new file mode 100644
index 000000000..39fda4055
--- /dev/null
+++ b/modules/vulnerabilities/unix/webapp/wordpress_4x/secgen_test/wordpress_4x.rb
@@ -0,0 +1,16 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class Wordpress4xTest < PostProvisionTest
+ def initialize
+ self.module_name = 'wordpress_4x'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+Wordpress4xTest.new.run
\ No newline at end of file
diff --git a/scenarios/tests/test_scenario.xml b/scenarios/tests/test_scenario.xml
index e3ef57c74..1f0c3a9bf 100644
--- a/scenarios/tests/test_scenario.xml
+++ b/scenarios/tests/test_scenario.xml
@@ -7,10 +7,12 @@
proftpd_testing
-
+
+
+
- 172.16.0.5
+ 172.16.0.17
diff --git a/secgen.rb b/secgen.rb
index cedc3120d..9963ff87f 100644
--- a/secgen.rb
+++ b/secgen.rb
@@ -77,7 +77,7 @@ def build_config(scenario, out_dir, options)
Print.info 'Resolving systems: randomising scenario...'
# update systems with module selections
- systems.map! { |system|
+ systems.map! {|system|
system.module_selections = system.resolve_module_selection(all_available_modules, options)
system
}
@@ -115,10 +115,11 @@ def build_vms(scenario, project_dir, options)
retry_count = OVirtFunctions::provider_ovirt?(options) ? 2 : 0
successful_creation = false
- while retry_count and !successful_creation
+ while retry_count >= 0 and !successful_creation
vagrant_output = GemExec.exe('vagrant', project_dir, "#{command} #{system}")
if vagrant_output[:status] == 0
- shutdown_cycle(project_dir)
+ # if true
+ reboot_cycle(project_dir)
if post_provision_tests(project_dir)
Print.info 'VMs created.'
successful_creation = true
@@ -127,8 +128,6 @@ def build_vms(scenario, project_dir, options)
sleep(30)
GemExec.exe('vagrant', project_dir, 'halt')
end
- else
- Print.err 'Tests failed!'
end
else
if retry_count > 0
@@ -146,7 +145,7 @@ def build_vms(scenario, project_dir, options)
elsif match = line.match(/^([-a-zA-Z_0-9]+):[^:]+VM is not created/i)
vm_not_to_destroy = match.captures[0]
Print.err "Not going to destroy #{vm_not_to_destroy}, since it does not exist"
- failures_to_destroy.delete_if {|x| x == vm_not_to_destroy }
+ failures_to_destroy.delete_if {|x| x == vm_not_to_destroy}
# TODO: not sure if there is a need to remove_uncreated_vms() here too? (I don't think so?)
end
end
@@ -173,7 +172,7 @@ def build_vms(scenario, project_dir, options)
end
sleep(10)
end
- else # TODO: elsif vagrant_output[:exception].type == ProcessHelper::TimeoutError >destroy individually broken vms as above?
+ else # TODO: elsif vagrant_output[:exception].type == ProcessHelper::TimeoutError >destroy individually broken vms as above?
Print.err 'Vagrant up timeout, destroying VMs and retrying...'
GemExec.exe('vagrant', project_dir, 'destroy -f')
end
@@ -263,14 +262,14 @@ def make_forensic_image(project_dir, image_output_location, image_type)
system "cd '#{project_dir}' && vagrant halt"
case image_type.downcase
- when 'raw', 'dd'
- create_dd_image(drive_path, image_output_location)
+ when 'raw', 'dd'
+ create_dd_image(drive_path, image_output_location)
- when 'ewf', 'e01'
- create_ewf_image(drive_path, image_output_location)
+ when 'ewf', 'e01'
+ create_ewf_image(drive_path, image_output_location)
- else
- Print.info "The image type [#{image_type}] is not recognised."
+ else
+ Print.info "The image type [#{image_type}] is not recognised."
end
end
@@ -292,14 +291,14 @@ end
def list_scenarios
Print.std "Full paths to scenario files are displayed below"
- Dir["#{ROOT_DIR}/scenarios/**/*"].select { |file| !File.directory? file }.each_with_index do |scenario_name, scenario_number|
+ Dir["#{ROOT_DIR}/scenarios/**/*"].select {|file| !File.directory? file}.each_with_index do |scenario_name, scenario_number|
Print.std "#{scenario_number}) #{scenario_name}"
end
end
def list_projects
Print.std "Full paths to project directories are displayed below"
- Dir["#{PROJECTS_DIR}/*"].select { |file| !File.file? file }.each_with_index do |scenario_name, scenario_number|
+ Dir["#{PROJECTS_DIR}/*"].select {|file| !File.file? file}.each_with_index do |scenario_name, scenario_number|
Print.std "#{scenario_number}) #{scenario_name}"
end
end
@@ -334,37 +333,48 @@ def get_vm_names(scenario)
vm_names
end
-def shutdown_cycle(project_dir)
+def reboot_cycle(project_dir)
Print.info 'Shutting down VMs.'
sleep(30)
GemExec.exe('vagrant', project_dir, 'halt')
sleep 5
- GemExec.exe('vagrant',project_dir,'up')
+ GemExec.exe('vagrant', project_dir, 'up --no-provision')
sleep 30
end
def post_provision_tests(project_dir)
Print.info 'Running post-provision tests...'
+ tests_passed = true
+ test_module_outputs = []
test_script_paths = Dir.glob("#{project_dir}/puppet/*/modules/*/secgen_test/*.rb")
test_script_paths.each do |test_file_path|
- output = `bundle exec ruby #{test_file_path}`
- Print.info output
- if output.include? "FAILED"
- Print.err "ERROR: Post provision failure!"
- return false
+ test_script_output = `bundle exec ruby #{test_file_path}`
+ test_module_outputs << test_script_output.split("\n")
+ end
+ test_module_outputs.each do |output_lines|
+ output_lines.each do |line|
+ if line.include? "FAILED:"
+ tests_passed = false
+ Print.err line
+ Print.err "Post provision tests contained failures!"
+ elsif line.include? "PASSED:"
+ Print.info line
+ else
+ Print.std line
+ end
end
end
- true
+ tests_passed
end
# end of method declarations
# start of program execution
-Print.std '~'*47
+Print.std '~' * 47
Print.std 'SecGen - Creates virtualised security scenarios'
Print.std ' Licensed GPLv3 2014-18'
-Print.std '~'*47
+Print.std '~' * 47
# Add read-options from config file (needs handling before options parsed by GetoptLong)
if ARGV.include? '--read-options'
@@ -416,94 +426,94 @@ options = {}
opts.each do |opt, arg|
case opt
# Main options
- when '--help'
- usage
- when '--scenario'
- scenario = arg;
- when '--project'
- project_dir = arg;
- when '--prefix'
- options[:prefix] = arg
- project_dir = project_dir(arg)
+ when '--help'
+ usage
+ when '--scenario'
+ scenario = arg;
+ when '--project'
+ project_dir = arg;
+ when '--prefix'
+ options[:prefix] = arg
+ project_dir = project_dir(arg)
# Additional options
- when '--system'
- Print.info "VM control (Vagrant) commands will only apply to system #{arg} (must match a system defined in the scenario)"
- options[:system] = arg
- when '--reload'
- Print.info "Will reload and re-provision the VMs"
- options[:reload] = true
- when '--gui-output'
- Print.info "Gui output set (virtual machines will be spawned)"
- options[:gui_output] = true
- when '--nopae'
- Print.info "no pae"
- options[:nopae] = true
- when '--hwvirtex'
- Print.info "with HW virtualisation"
- options[:hwvirtex] = true
- when '--vtxvpid'
- Print.info "with VT support"
- options[:vtxvpid] = true
- when '--memory-per-vm'
- if options.has_key? :total_memory
- Print.info 'Total memory option specified before memory per vm option, defaulting to total memory value'
- else
- Print.info "Memory per vm set to #{arg}"
- options[:memory_per_vm] = arg
- end
- when '--total-memory'
- if options.has_key? :memory_per_vm
- Print.info 'Memory per vm option specified before total memory option, defaulting to memory per vm value'
- else
- Print.info "Total memory to be used set to #{arg}"
- options[:total_memory] = arg
- end
- when '--cpu-cores'
- Print.info "Number of cpus to be used set to #{arg}"
- options[:cpu_cores] = arg
- when '--max-cpu-usage'
- Print.info "Max CPU usage set to #{arg}"
- options[:max_cpu_usage] = arg
- when '--shutdown'
- Print.info 'Shutdown VMs after provisioning'
- options[:shutdown] = true
- when '--network-ranges'
- Print.info 'Overriding Network Ranges'
- options[:ip_ranges] = arg.split(',')
- when '--forensic-image-type'
- Print.info "Image output type set to #{arg}"
- options[:forensic_image_type] = arg
-
- when '--ovirtuser'
- Print.info "Ovirt Username : #{arg}"
- options[:ovirtuser] = arg
- when '--ovirtpass'
- Print.info "Ovirt Password : ********"
- options[:ovirtpass] = arg
- when '--ovirt-url'
- Print.info "Ovirt API url : #{arg}"
- options[:ovirturl] = arg
- when '--ovirtauthz'
- Print.info "Ovirt Authz: #{arg}"
- options[:ovirtauthz] = arg
- when '--ovirt-cluster'
- Print.info "Ovirt Cluster : #{arg}"
- options[:ovirtcluster] = arg
- when '--ovirt-network'
- Print.info "Ovirt Network Name : #{arg}"
- options[:ovirtnetwork] = arg
- when '--ovirt-affinity-group'
- Print.info "Ovirt Affinity Group : #{arg}"
- options[:ovirtaffinitygroup] = arg
- when '--snapshot'
- Print.info "Taking snapshots when VMs are created"
- options[:snapshot] = true
-
+ when '--system'
+ Print.info "VM control (Vagrant) commands will only apply to system #{arg} (must match a system defined in the scenario)"
+ options[:system] = arg
+ when '--reload'
+ Print.info "Will reload and re-provision the VMs"
+ options[:reload] = true
+ when '--gui-output'
+ Print.info "Gui output set (virtual machines will be spawned)"
+ options[:gui_output] = true
+ when '--nopae'
+ Print.info "no pae"
+ options[:nopae] = true
+ when '--hwvirtex'
+ Print.info "with HW virtualisation"
+ options[:hwvirtex] = true
+ when '--vtxvpid'
+ Print.info "with VT support"
+ options[:vtxvpid] = true
+ when '--memory-per-vm'
+ if options.has_key? :total_memory
+ Print.info 'Total memory option specified before memory per vm option, defaulting to total memory value'
else
- Print.err "Argument not valid: #{arg}"
- usage
- exit 1
+ Print.info "Memory per vm set to #{arg}"
+ options[:memory_per_vm] = arg
+ end
+ when '--total-memory'
+ if options.has_key? :memory_per_vm
+ Print.info 'Memory per vm option specified before total memory option, defaulting to memory per vm value'
+ else
+ Print.info "Total memory to be used set to #{arg}"
+ options[:total_memory] = arg
+ end
+ when '--cpu-cores'
+ Print.info "Number of cpus to be used set to #{arg}"
+ options[:cpu_cores] = arg
+ when '--max-cpu-usage'
+ Print.info "Max CPU usage set to #{arg}"
+ options[:max_cpu_usage] = arg
+ when '--shutdown'
+ Print.info 'Shutdown VMs after provisioning'
+ options[:shutdown] = true
+ when '--network-ranges'
+ Print.info 'Overriding Network Ranges'
+ options[:ip_ranges] = arg.split(',')
+ when '--forensic-image-type'
+ Print.info "Image output type set to #{arg}"
+ options[:forensic_image_type] = arg
+
+ when '--ovirtuser'
+ Print.info "Ovirt Username : #{arg}"
+ options[:ovirtuser] = arg
+ when '--ovirtpass'
+ Print.info "Ovirt Password : ********"
+ options[:ovirtpass] = arg
+ when '--ovirt-url'
+ Print.info "Ovirt API url : #{arg}"
+ options[:ovirturl] = arg
+ when '--ovirtauthz'
+ Print.info "Ovirt Authz: #{arg}"
+ options[:ovirtauthz] = arg
+ when '--ovirt-cluster'
+ Print.info "Ovirt Cluster : #{arg}"
+ options[:ovirtcluster] = arg
+ when '--ovirt-network'
+ Print.info "Ovirt Network Name : #{arg}"
+ options[:ovirtnetwork] = arg
+ when '--ovirt-affinity-group'
+ Print.info "Ovirt Affinity Group : #{arg}"
+ options[:ovirtaffinitygroup] = arg
+ when '--snapshot'
+ Print.info "Taking snapshots when VMs are created"
+ options[:snapshot] = true
+
+ else
+ Print.err "Argument not valid: #{arg}"
+ usage
+ exit 1
end
end
@@ -516,53 +526,53 @@ end
# process command
case ARGV[0]
- when 'run', 'r'
- project_dir = default_project_dir unless project_dir
- run(scenario, project_dir, options)
- when 'build-project', 'p'
- project_dir = default_project_dir unless project_dir
- build_config(scenario, project_dir, options)
- when 'build-vms', 'v'
- if project_dir
- build_vms(scenario, project_dir, options)
- else
- Print.err 'Please specify project directory to read'
- usage
- exit 1
- end
-
- when 'create-forensic-image'
- image_type = options.has_key?(:forensic_image_type) ? options[:forensic_image_type] : 'raw';
-
- if project_dir
- build_vms(scenario, project_dir, options)
- make_forensic_image(project_dir, nil, image_type)
- else
- project_dir = default_project_dir unless project_dir
- build_config(scenario, project_dir, options)
- build_vms(scenario, project_dir, options)
- make_forensic_image(project_dir, nil, image_type)
- end
-
- when 'ovirt-post-build'
- ovirt_post_build(options, scenario, project_dir)
- exit 0
-
- when 'list-scenarios'
- list_scenarios
- exit 0
-
- when 'list-projects'
- list_projects
- exit 0
-
- when 'delete-all-projects'
- delete_all_projects
- Print.std 'All projects deleted'
- exit 0
-
+when 'run', 'r'
+ project_dir = default_project_dir unless project_dir
+ run(scenario, project_dir, options)
+when 'build-project', 'p'
+ project_dir = default_project_dir unless project_dir
+ build_config(scenario, project_dir, options)
+when 'build-vms', 'v'
+ if project_dir
+ build_vms(scenario, project_dir, options)
else
- Print.err "Command not valid: #{ARGV[0]}"
+ Print.err 'Please specify project directory to read'
usage
exit 1
+ end
+
+when 'create-forensic-image'
+ image_type = options.has_key?(:forensic_image_type) ? options[:forensic_image_type] : 'raw';
+
+ if project_dir
+ build_vms(scenario, project_dir, options)
+ make_forensic_image(project_dir, nil, image_type)
+ else
+ project_dir = default_project_dir unless project_dir
+ build_config(scenario, project_dir, options)
+ build_vms(scenario, project_dir, options)
+ make_forensic_image(project_dir, nil, image_type)
+ end
+
+when 'ovirt-post-build'
+ ovirt_post_build(options, scenario, project_dir)
+ exit 0
+
+when 'list-scenarios'
+ list_scenarios
+ exit 0
+
+when 'list-projects'
+ list_projects
+ exit 0
+
+when 'delete-all-projects'
+ delete_all_projects
+ Print.std 'All projects deleted'
+ exit 0
+
+else
+ Print.err "Command not valid: #{ARGV[0]}"
+ usage
+ exit 1
end
From 606f267b2cec9b7d4f1a82e149ecd716bc03dec7 Mon Sep 17 00:00:00 2001
From: ts
Date: Sat, 2 Feb 2019 17:23:42 +0000
Subject: [PATCH 08/47] more port check tests...
---
.../secgen_test/mysql_stretch_compatible.rb | 17 +++++++++++++++++
.../secgen_test/mysql_wheezy_compatible.rb | 17 +++++++++++++++++
.../http/apache_bash_cgi/secgen_metadata.xml | 4 ++++
.../secgen_test/apache_bash_cgi.rb | 17 +++++++++++++++++
.../services/unix/irc/irc2/secgen_test/irc2.rb | 17 +++++++++++++++++
.../misc/distcc_exec/secgen_test/distcc_exec.rb | 17 +++++++++++++++++
6 files changed, 89 insertions(+)
create mode 100644 modules/services/unix/database/mysql_stretch_compatible/mysql/secgen_test/mysql_stretch_compatible.rb
create mode 100644 modules/services/unix/database/mysql_wheezy_compatible/mysql/secgen_test/mysql_wheezy_compatible.rb
create mode 100644 modules/services/unix/http/apache_bash_cgi/secgen_test/apache_bash_cgi.rb
create mode 100644 modules/services/unix/irc/irc2/secgen_test/irc2.rb
create mode 100644 modules/vulnerabilities/unix/misc/distcc_exec/secgen_test/distcc_exec.rb
diff --git a/modules/services/unix/database/mysql_stretch_compatible/mysql/secgen_test/mysql_stretch_compatible.rb b/modules/services/unix/database/mysql_stretch_compatible/mysql/secgen_test/mysql_stretch_compatible.rb
new file mode 100644
index 000000000..d95a30073
--- /dev/null
+++ b/modules/services/unix/database/mysql_stretch_compatible/mysql/secgen_test/mysql_stretch_compatible.rb
@@ -0,0 +1,17 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class MySQLStretchTest < PostProvisionTest
+ def initialize
+ self.module_name = 'mysql_stretch_compatible'
+ self.module_path = get_module_path(__FILE__)
+ super
+ self.port = 3306
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+MySQLStretchTest.new.run
\ No newline at end of file
diff --git a/modules/services/unix/database/mysql_wheezy_compatible/mysql/secgen_test/mysql_wheezy_compatible.rb b/modules/services/unix/database/mysql_wheezy_compatible/mysql/secgen_test/mysql_wheezy_compatible.rb
new file mode 100644
index 000000000..7a53abfd7
--- /dev/null
+++ b/modules/services/unix/database/mysql_wheezy_compatible/mysql/secgen_test/mysql_wheezy_compatible.rb
@@ -0,0 +1,17 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class MySQLWheezyTest < PostProvisionTest
+ def initialize
+ self.module_name = 'mysql_wheezy_compatible'
+ self.module_path = get_module_path(__FILE__)
+ super
+ self.port = 3306
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+MySQLWheezyTest.new.run
\ No newline at end of file
diff --git a/modules/services/unix/http/apache_bash_cgi/secgen_metadata.xml b/modules/services/unix/http/apache_bash_cgi/secgen_metadata.xml
index cbc588364..b1f2a0eaa 100644
--- a/modules/services/unix/http/apache_bash_cgi/secgen_metadata.xml
+++ b/modules/services/unix/http/apache_bash_cgi/secgen_metadata.xml
@@ -14,6 +14,10 @@
https://httpd.apache.org/Apache v2
+
+ webapp
+
+
.*apachehttpd
diff --git a/modules/services/unix/http/apache_bash_cgi/secgen_test/apache_bash_cgi.rb b/modules/services/unix/http/apache_bash_cgi/secgen_test/apache_bash_cgi.rb
new file mode 100644
index 000000000..9343efa95
--- /dev/null
+++ b/modules/services/unix/http/apache_bash_cgi/secgen_test/apache_bash_cgi.rb
@@ -0,0 +1,17 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class ApacheBashCGITest < PostProvisionTest
+ def initialize
+ self.module_name = 'apache_bash_cgi'
+ self.module_path = get_module_path(__FILE__)
+ super
+ self.port = 80
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+ApacheBashCGITest.new.run
\ No newline at end of file
diff --git a/modules/services/unix/irc/irc2/secgen_test/irc2.rb b/modules/services/unix/irc/irc2/secgen_test/irc2.rb
new file mode 100644
index 000000000..7761fac90
--- /dev/null
+++ b/modules/services/unix/irc/irc2/secgen_test/irc2.rb
@@ -0,0 +1,17 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class IRC2Test < PostProvisionTest
+ def initialize
+ self.module_name = 'irc2'
+ self.module_path = get_module_path(__FILE__)
+ super
+ self.port = 6667
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+IRC2Test.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/misc/distcc_exec/secgen_test/distcc_exec.rb b/modules/vulnerabilities/unix/misc/distcc_exec/secgen_test/distcc_exec.rb
new file mode 100644
index 000000000..e3e3245e5
--- /dev/null
+++ b/modules/vulnerabilities/unix/misc/distcc_exec/secgen_test/distcc_exec.rb
@@ -0,0 +1,17 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class DistCCExecTest < PostProvisionTest
+ def initialize
+ self.module_name = 'distcc_exec'
+ self.module_path = get_module_path(__FILE__)
+ super
+ self.port = 3632
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+DistCCExecTest.new.run
\ No newline at end of file
From db7a9daa8af7d542f40f366d48301f99996fb395 Mon Sep 17 00:00:00 2001
From: ts
Date: Sat, 2 Feb 2019 17:50:23 +0000
Subject: [PATCH 09/47] popa3d and port check
---
lib/objects/post_provision_test.rb | 2 +-
.../unix/email/popa3d/secgen_test/popa3d.rb | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
create mode 100644 modules/services/unix/email/popa3d/secgen_test/popa3d.rb
diff --git a/lib/objects/post_provision_test.rb b/lib/objects/post_provision_test.rb
index 47edaa25f..ebcc7f63d 100644
--- a/lib/objects/post_provision_test.rb
+++ b/lib/objects/post_provision_test.rb
@@ -77,7 +77,7 @@ class PostProvisionTest
end
def get_port
- if get_json_inputs != {}
+ if get_json_inputs != {} and get_json_inputs['port'] != nil
get_json_inputs['port'][0].to_i
else
-1
diff --git a/modules/services/unix/email/popa3d/secgen_test/popa3d.rb b/modules/services/unix/email/popa3d/secgen_test/popa3d.rb
new file mode 100644
index 000000000..b32aeec5a
--- /dev/null
+++ b/modules/services/unix/email/popa3d/secgen_test/popa3d.rb
@@ -0,0 +1,17 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class Popa3dTest < PostProvisionTest
+ def initialize
+ self.module_name = 'popa3d'
+ self.module_path = get_module_path(__FILE__)
+ super
+ self.port = 110
+ end
+
+ def test_module
+ super
+ test_service_up
+ end
+end
+
+Popa3dTest.new.run
\ No newline at end of file
From fcb2dc0e9ba2562b3dd88bde8095f27e6d973ee2 Mon Sep 17 00:00:00 2001
From: ts
Date: Mon, 4 Feb 2019 16:52:31 +0000
Subject: [PATCH 10/47] Added NTP test. Refactored html match from
parameterised_website into the superclass
---
Gemfile | 1 +
Gemfile.lock | 4 ++-
lib/objects/post_provision_test.rb | 21 +++++++++++++--
.../secgen_test/parameterised_website.rb | 14 ----------
.../services/unix/ntp/ntp/secgen_test/ntp.rb | 27 +++++++++++++++++++
scenarios/tests/test_scenario.xml | 11 ++++----
secgen.rb | 2 +-
7 files changed, 56 insertions(+), 24 deletions(-)
create mode 100644 modules/services/unix/ntp/ntp/secgen_test/ntp.rb
diff --git a/Gemfile b/Gemfile
index bc9ba0183..455954052 100644
--- a/Gemfile
+++ b/Gemfile
@@ -33,6 +33,7 @@ gem 'ruby-graphviz'
gem 'rsa'
gem 'gpgmeh'
gem 'digest-sha3', :git => "http://github.com/izetex/digest-sha3-ruby"
+gem 'net-ntp'
#development only gems go here
group :test, :development do
diff --git a/Gemfile.lock b/Gemfile.lock
index 214c26f37..265befd94 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -85,6 +85,7 @@ GEM
minitest (5.11.3)
multi_json (1.13.1)
multipart-post (2.0.0)
+ net-ntp (2.1.3)
nio4r (2.3.1)
nokogiri (1.8.4)
mini_portile2 (~> 2.3.0)
@@ -159,6 +160,7 @@ DEPENDENCIES
librarian-puppet
mini_exiftool_vendored
minitest
+ net-ntp
nokogiri
nori
ovirt-engine-sdk
@@ -182,4 +184,4 @@ DEPENDENCIES
zipruby
BUNDLED WITH
- 1.16.1
+ 2.0.0.pre.2
diff --git a/lib/objects/post_provision_test.rb b/lib/objects/post_provision_test.rb
index ebcc7f63d..dea4e49d0 100644
--- a/lib/objects/post_provision_test.rb
+++ b/lib/objects/post_provision_test.rb
@@ -41,6 +41,7 @@ class PostProvisionTest
# Testing Functions #
#####################
+ # Test service is up (tcp)
def test_service_up
if is_port_open? system_ip, self.port
self.outputs << "PASSED: Port #{self.port} is open at #{get_system_ip} (#{get_system_name})!"
@@ -49,6 +50,22 @@ class PostProvisionTest
end
end
+ # example usage for page: /index.html
+ def test_html_returned_content(page, match_string)
+
+ begin
+ source = Net::HTTP.get(get_system_ip, page, self.port)
+ rescue SocketError
+ # do nothing
+ end
+
+ if source.include? match_string
+ self.outputs << "PASSED: Content #{match_string} is contained within #{page} at #{get_system_ip}:#{self.port} (#{get_system_name})!"
+ else
+ self.outputs << "FAILED: Content #{match_string} is contained within #{page} at #{get_system_ip}:#{self.port} (#{get_system_name})!"
+ end
+ end
+
##################
# Misc Functions #
##################
@@ -56,7 +73,7 @@ class PostProvisionTest
def get_system_ip
vagrant_file_path = "#{get_project_path}/Vagrantfile"
vagrantfile = File.read(vagrant_file_path)
- ip_line = vagrantfile.split("\n").delete_if { |line| !line.include? "# ip_address_for_#{get_system_name}"}[0]
+ ip_line = vagrantfile.split("\n").delete_if {|line| !line.include? "# ip_address_for_#{get_system_name}"}[0]
ip_address = ip_line.split('=')[-1]
if ip_address == "DHCP"
self.outputs << "FAILED: Cannot test against dynamic IPs" # TODO: fix this so that we grab dynamic IP address (maybe from vagrant?)
@@ -69,7 +86,7 @@ class PostProvisionTest
def get_json_inputs
json_inputs_path = "#{File.expand_path('../', self.module_path)}/secgen_functions/files/json_inputs/*"
json_inputs_files = Dir.glob(json_inputs_path)
- json_inputs_files.delete_if { |path| !path.include?(self.module_name) }
+ json_inputs_files.delete_if {|path| !path.include?(self.module_name)}
if json_inputs_files.size > 0
return JSON.parse(Base64.strict_decode64(File.read(json_inputs_files.first)))
end
diff --git a/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb b/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
index f4512644d..79b0f68b4 100644
--- a/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
+++ b/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
@@ -28,20 +28,6 @@ class ParamWebsiteTest < PostProvisionTest
test_service_up
end
- def test_html_returned_content(page, match_string)
-
- begin
- source = Net::HTTP.get(get_system_ip, page, self.port)
- rescue SocketError
- # do nothing
- end
-
- if source.include? match_string
- self.outputs << "PASSED: Content #{match_string} is contained within #{page} at #{get_system_ip}:#{self.port} (#{get_system_name})!"
- else
- self.outputs << "FAILED: Content #{match_string} is contained within #{page} at #{get_system_ip}:#{self.port} (#{get_system_name})!"
- end
- end
end
ParamWebsiteTest.new.run
\ No newline at end of file
diff --git a/modules/services/unix/ntp/ntp/secgen_test/ntp.rb b/modules/services/unix/ntp/ntp/secgen_test/ntp.rb
new file mode 100644
index 000000000..75a2a8c74
--- /dev/null
+++ b/modules/services/unix/ntp/ntp/secgen_test/ntp.rb
@@ -0,0 +1,27 @@
+require_relative '../../../../../lib/post_provision_test'
+require 'net/ntp'
+
+class NTPTest < PostProvisionTest
+ def initialize
+ self.module_name = 'ntp'
+ self.module_path = get_module_path(__FILE__)
+ super
+ self.port = 123
+ end
+
+ def test_module
+ super
+ test_ntp_query #TODO
+ end
+
+ def test_ntp_query
+ begin
+ time_response = Net::NTP.get(system_ip, port).time
+ self.outputs << "PASSED: NTP responded on UDP port #{port} with #{time_response}"
+ rescue Errno::ECONNREFUSED
+ self.outputs << "FAILED: unable to connect to #{module_name} on UDP port #{port} "
+ end
+ end
+end
+
+NTPTest.new.run
\ No newline at end of file
diff --git a/scenarios/tests/test_scenario.xml b/scenarios/tests/test_scenario.xml
index 1f0c3a9bf..5d39e3819 100644
--- a/scenarios/tests/test_scenario.xml
+++ b/scenarios/tests/test_scenario.xml
@@ -4,15 +4,14 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.github/cliffe/SecGen/scenario">
- proftpd_testing
-
+ testing
+
-
-
-
+
+
- 172.16.0.17
+ 172.16.0.13
diff --git a/secgen.rb b/secgen.rb
index 9963ff87f..65f329939 100644
--- a/secgen.rb
+++ b/secgen.rb
@@ -354,7 +354,7 @@ def post_provision_tests(project_dir)
end
test_module_outputs.each do |output_lines|
output_lines.each do |line|
- if line.include? "FAILED:"
+ if line.include? "FAILED:" # todo: read exit code instead
tests_passed = false
Print.err line
Print.err "Post provision tests contained failures!"
From 714b2c7b66107d4fffed06cd02be23fec25c45e7 Mon Sep 17 00:00:00 2001
From: ts
Date: Mon, 4 Feb 2019 17:29:38 +0000
Subject: [PATCH 11/47] Test faiures read exit code instead of "FAILED" or
"PASSED" strings
---
lib/objects/post_provision_test.rb | 2 ++
.../services/unix/ntp/ntp/secgen_test/ntp.rb | 3 +-
secgen.rb | 32 +++++++++----------
3 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/lib/objects/post_provision_test.rb b/lib/objects/post_provision_test.rb
index dea4e49d0..b45ff20b0 100644
--- a/lib/objects/post_provision_test.rb
+++ b/lib/objects/post_provision_test.rb
@@ -47,6 +47,7 @@ class PostProvisionTest
self.outputs << "PASSED: Port #{self.port} is open at #{get_system_ip} (#{get_system_name})!"
else
self.outputs << "FAILED: Port #{self.port} is closed at #{get_system_ip} (#{get_system_name})!"
+ exit(1)
end
end
@@ -63,6 +64,7 @@ class PostProvisionTest
self.outputs << "PASSED: Content #{match_string} is contained within #{page} at #{get_system_ip}:#{self.port} (#{get_system_name})!"
else
self.outputs << "FAILED: Content #{match_string} is contained within #{page} at #{get_system_ip}:#{self.port} (#{get_system_name})!"
+ exit(1)
end
end
diff --git a/modules/services/unix/ntp/ntp/secgen_test/ntp.rb b/modules/services/unix/ntp/ntp/secgen_test/ntp.rb
index 75a2a8c74..b48d8a80b 100644
--- a/modules/services/unix/ntp/ntp/secgen_test/ntp.rb
+++ b/modules/services/unix/ntp/ntp/secgen_test/ntp.rb
@@ -6,7 +6,7 @@ class NTPTest < PostProvisionTest
self.module_name = 'ntp'
self.module_path = get_module_path(__FILE__)
super
- self.port = 123
+ self.port = 12
end
def test_module
@@ -20,6 +20,7 @@ class NTPTest < PostProvisionTest
self.outputs << "PASSED: NTP responded on UDP port #{port} with #{time_response}"
rescue Errno::ECONNREFUSED
self.outputs << "FAILED: unable to connect to #{module_name} on UDP port #{port} "
+ exit(1)
end
end
end
diff --git a/secgen.rb b/secgen.rb
index 65f329939..984213201 100644
--- a/secgen.rb
+++ b/secgen.rb
@@ -1,6 +1,7 @@
require 'getoptlong'
require 'fileutils'
require 'nori'
+require 'open3'
require_relative 'lib/helpers/constants.rb'
require_relative 'lib/helpers/print.rb'
@@ -116,10 +117,10 @@ def build_vms(scenario, project_dir, options)
successful_creation = false
while retry_count >= 0 and !successful_creation
- vagrant_output = GemExec.exe('vagrant', project_dir, "#{command} #{system}")
- if vagrant_output[:status] == 0
- # if true
- reboot_cycle(project_dir)
+ # vagrant_output = GemExec.exe('vagrant', project_dir, "#{command} #{system}")
+ # if vagrant_output[:status] == 0
+ if true
+ # reboot_cycle(project_dir)
if post_provision_tests(project_dir)
Print.info 'VMs created.'
successful_creation = true
@@ -349,20 +350,17 @@ def post_provision_tests(project_dir)
test_module_outputs = []
test_script_paths = Dir.glob("#{project_dir}/puppet/*/modules/*/secgen_test/*.rb")
test_script_paths.each do |test_file_path|
- test_script_output = `bundle exec ruby #{test_file_path}`
- test_module_outputs << test_script_output.split("\n")
+ test_stdout, test_stderr, test_status = Open3.capture3("bundle exec ruby #{test_file_path}")
+ test_module_outputs << {:stdout => test_stdout.split("\n"), :stderr => test_stderr, :exit_status => test_status}
end
- test_module_outputs.each do |output_lines|
- output_lines.each do |line|
- if line.include? "FAILED:" # todo: read exit code instead
- tests_passed = false
- Print.err line
- Print.err "Post provision tests contained failures!"
- elsif line.include? "PASSED:"
- Print.info line
- else
- Print.std line
- end
+ test_module_outputs.each do |test_output|
+ if test_output[:exit_status].exitstatus != 0
+ tests_passed = false
+ Print.err test_output[:stdout].join("\n")
+ Print.err "Post provision tests contained failures!"
+ Print.err test_output[:stderr].join("\n")
+ else
+ Print.info test_output[:stdout].join("\n")
end
end
tests_passed
From 4c6718146601ac022b194e283c35ebcabed2b31f Mon Sep 17 00:00:00 2001
From: ts
Date: Mon, 4 Feb 2019 17:38:00 +0000
Subject: [PATCH 12/47] Test faiures read exit code instead of "FAILED" or
"PASSED" strings
---
lib/objects/post_provision_test.rb | 5 ++++-
modules/services/unix/ntp/ntp/secgen_test/ntp.rb | 8 ++++----
secgen.rb | 2 +-
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/lib/objects/post_provision_test.rb b/lib/objects/post_provision_test.rb
index b45ff20b0..e4659a2f6 100644
--- a/lib/objects/post_provision_test.rb
+++ b/lib/objects/post_provision_test.rb
@@ -19,17 +19,20 @@ class PostProvisionTest
attr_accessor :json_inputs
attr_accessor :port
attr_accessor :outputs
+ attr_accessor :all_tests_passed
def initialize
self.system_ip = get_system_ip
self.json_inputs = get_json_inputs
self.port = get_port
self.outputs = []
+ self.all_tests_passed = true
end
def run
test_module
puts self.outputs
+ exit(1) unless all_tests_passed
end
def test_module
@@ -47,7 +50,7 @@ class PostProvisionTest
self.outputs << "PASSED: Port #{self.port} is open at #{get_system_ip} (#{get_system_name})!"
else
self.outputs << "FAILED: Port #{self.port} is closed at #{get_system_ip} (#{get_system_name})!"
- exit(1)
+ self.all_tests_passed = false
end
end
diff --git a/modules/services/unix/ntp/ntp/secgen_test/ntp.rb b/modules/services/unix/ntp/ntp/secgen_test/ntp.rb
index b48d8a80b..2f8bcf569 100644
--- a/modules/services/unix/ntp/ntp/secgen_test/ntp.rb
+++ b/modules/services/unix/ntp/ntp/secgen_test/ntp.rb
@@ -6,12 +6,12 @@ class NTPTest < PostProvisionTest
self.module_name = 'ntp'
self.module_path = get_module_path(__FILE__)
super
- self.port = 12
+ self.port = 123
end
def test_module
super
- test_ntp_query #TODO
+ test_ntp_query
end
def test_ntp_query
@@ -19,8 +19,8 @@ class NTPTest < PostProvisionTest
time_response = Net::NTP.get(system_ip, port).time
self.outputs << "PASSED: NTP responded on UDP port #{port} with #{time_response}"
rescue Errno::ECONNREFUSED
- self.outputs << "FAILED: unable to connect to #{module_name} on UDP port #{port} "
- exit(1)
+ self.outputs << "FAILED: unable to connect to #{module_name} on UDP port #{port}"
+ self.all_tests_passed = false
end
end
end
diff --git a/secgen.rb b/secgen.rb
index 984213201..085c156fa 100644
--- a/secgen.rb
+++ b/secgen.rb
@@ -358,7 +358,7 @@ def post_provision_tests(project_dir)
tests_passed = false
Print.err test_output[:stdout].join("\n")
Print.err "Post provision tests contained failures!"
- Print.err test_output[:stderr].join("\n")
+ Print.err test_output[:stderr].join("\n") if test_output[:stderr].length > 0
else
Print.info test_output[:stdout].join("\n")
end
From 9574ba5601402cdecd6775cd2b1a92a6ba35a4e6 Mon Sep 17 00:00:00 2001
From: ts
Date: Tue, 5 Feb 2019 11:46:14 +0000
Subject: [PATCH 13/47] Tests: local software modules (chkrootkit / nmap)
---
lib/objects/post_provision_test.rb | 21 ++++++++++++++++++-
lib/templates/Vagrantfile.erb | 6 ++++--
.../chkrootkit/secgen_test/chkrootkit.rb | 17 +++++++++++++++
.../setuid_nmap/secgen_test/setuid_nmap.rb | 19 +++++++++++++++++
scenarios/tests/test_scenario.xml | 5 ++---
secgen.rb | 9 ++++----
6 files changed, 66 insertions(+), 11 deletions(-)
create mode 100644 modules/vulnerabilities/unix/local/chkrootkit/secgen_test/chkrootkit.rb
create mode 100644 modules/vulnerabilities/unix/local/setuid_nmap/secgen_test/setuid_nmap.rb
diff --git a/lib/objects/post_provision_test.rb b/lib/objects/post_provision_test.rb
index e4659a2f6..533f9b08b 100644
--- a/lib/objects/post_provision_test.rb
+++ b/lib/objects/post_provision_test.rb
@@ -7,10 +7,11 @@
require 'json'
require 'base64'
-
require 'socket'
require 'timeout'
+require_relative '../../../lib/helpers/gem_exec'
+
class PostProvisionTest
attr_accessor :project_path
attr_accessor :system_ip
@@ -71,10 +72,28 @@ class PostProvisionTest
end
end
+ def test_local_command(test_output, local_command, match_string)
+ Dir.chdir(get_project_path) do
+ output = run_vagrant_ssh(local_command)
+ if output[:stdout].include? match_string or output[:stderr].include? match_string
+ self.outputs << "PASSED: #{test_output} local command (#{local_command}) matches with output (#{match_string}) on #{get_system_name}!"
+ else
+ self.outputs << "FAILED: #{test_output} local command (#{local_command}) matches with output (#{match_string}) on #{get_system_name}!"
+ self.outputs << output[:stderr]
+ self.all_tests_passed = false
+ end
+ end
+ end
+
##################
# Misc Functions #
##################
+ def run_vagrant_ssh(args)
+ stdout, stderr, status = Open3.capture3("/usr/bin/vagrant ssh -c '#{args}'")
+ {:stdout => stdout, :stderr => stderr, :exit_status => status}
+ end
+
def get_system_ip
vagrant_file_path = "#{get_project_path}/Vagrantfile"
vagrantfile = File.read(vagrant_file_path)
diff --git a/lib/templates/Vagrantfile.erb b/lib/templates/Vagrantfile.erb
index 1001829a0..fe2d02346 100644
--- a/lib/templates/Vagrantfile.erb
+++ b/lib/templates/Vagrantfile.erb
@@ -136,7 +136,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
<% else %>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, type: "dhcp", auto_config: false
<% end %>
- # ip_address_for_<%= system.name %>=DHCP
+ <% # Below string is used within testing, do not delete. -%>
+ # ip_address_for_<%= system.name %>=DHCP
<% # Static networking -%>
<% else -%>
<% # Static oVirt networking -%>
@@ -151,7 +152,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
<% # Static Virtualbox networking -%>
<% else -%>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, ip: "<%= resolve_network(selected_module)%>"
- # ip_address_for_<%= system.name %>=<%= resolve_network(selected_module)%>
+ <% # Below string is used within testing, do not delete. -%>
+ # ip_address_for_<%= system.name %>=<%= resolve_network(selected_module)%>
<% end -%>
<% end -%>
<% when 'vulnerability', 'service', 'utility', 'build' -%>
diff --git a/modules/vulnerabilities/unix/local/chkrootkit/secgen_test/chkrootkit.rb b/modules/vulnerabilities/unix/local/chkrootkit/secgen_test/chkrootkit.rb
new file mode 100644
index 000000000..452d4aa6b
--- /dev/null
+++ b/modules/vulnerabilities/unix/local/chkrootkit/secgen_test/chkrootkit.rb
@@ -0,0 +1,17 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class ChkrootkitVulnTest < PostProvisionTest
+ def initialize
+ self.module_name = 'chkrootkit'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_local_command('Chkrootkit binary exists?', 'sudo ls -la /usr/sbin/chkrootkit', 'chkrootkit-0.49')
+ test_local_command('Chkrootkit runs?', 'sudo /usr/sbin/chkrootkit -V', 'chkrootkit version 0.49')
+ end
+
+end
+ChkrootkitVulnTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/local/setuid_nmap/secgen_test/setuid_nmap.rb b/modules/vulnerabilities/unix/local/setuid_nmap/secgen_test/setuid_nmap.rb
new file mode 100644
index 000000000..78e9506f0
--- /dev/null
+++ b/modules/vulnerabilities/unix/local/setuid_nmap/secgen_test/setuid_nmap.rb
@@ -0,0 +1,19 @@
+require_relative '../../../../../lib/post_provision_test'
+
+
+class SetUIDNmapTest < PostProvisionTest
+ def initialize
+ self.module_name = 'setuid_nmap'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_local_command('nmap has setuid flag?', 'sudo ls -la /usr/bin/nmap', '-rwsr-xr-x')
+ test_local_command('nmap runs?', 'sudo /usr/bin/nmap --version', 'Nmap version')
+ end
+
+end
+
+SetUIDNmapTest.new.run
\ No newline at end of file
diff --git a/scenarios/tests/test_scenario.xml b/scenarios/tests/test_scenario.xml
index 5d39e3819..0368e177e 100644
--- a/scenarios/tests/test_scenario.xml
+++ b/scenarios/tests/test_scenario.xml
@@ -7,11 +7,10 @@
testing
-
-
+
- 172.16.0.13
+ 172.16.0.12
diff --git a/secgen.rb b/secgen.rb
index 085c156fa..9a4d97575 100644
--- a/secgen.rb
+++ b/secgen.rb
@@ -117,10 +117,9 @@ def build_vms(scenario, project_dir, options)
successful_creation = false
while retry_count >= 0 and !successful_creation
- # vagrant_output = GemExec.exe('vagrant', project_dir, "#{command} #{system}")
- # if vagrant_output[:status] == 0
- if true
- # reboot_cycle(project_dir)
+ vagrant_output = GemExec.exe('vagrant', project_dir, "#{command} #{system}")
+ if vagrant_output[:status] == 0
+ reboot_cycle(project_dir)
if post_provision_tests(project_dir)
Print.info 'VMs created.'
successful_creation = true
@@ -358,7 +357,7 @@ def post_provision_tests(project_dir)
tests_passed = false
Print.err test_output[:stdout].join("\n")
Print.err "Post provision tests contained failures!"
- Print.err test_output[:stderr].join("\n") if test_output[:stderr].length > 0
+ Print.err test_output[:stderr]
else
Print.info test_output[:stdout].join("\n")
end
From a8afae3569f225818668086bfb4ffc2978e69a7a Mon Sep 17 00:00:00 2001
From: ts
Date: Tue, 5 Feb 2019 12:15:26 +0000
Subject: [PATCH 14/47] suid root bash tests + name update
---
.../manifests/config.pp | 2 +-
.../secgen_metadata.xml | 0
.../secgen_test/suid_root_bash.rb | 19 +++++++++++++++++++
.../suid_root_bash/suid_root_bash.pp | 1 +
.../uid_bash_root/uid_bash_root.pp | 1 -
.../uid_bash_root.xml | 4 ++--
6 files changed, 23 insertions(+), 4 deletions(-)
rename modules/vulnerabilities/unix/access_control_misconfigurations/{uid_bash_root => suid_root_bash}/manifests/config.pp (69%)
rename modules/vulnerabilities/unix/access_control_misconfigurations/{uid_bash_root => suid_root_bash}/secgen_metadata.xml (100%)
create mode 100644 modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/secgen_test/suid_root_bash.rb
create mode 100644 modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/suid_root_bash.pp
delete mode 100644 modules/vulnerabilities/unix/access_control_misconfigurations/uid_bash_root/uid_bash_root.pp
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_bash_root/manifests/config.pp b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/manifests/config.pp
similarity index 69%
rename from modules/vulnerabilities/unix/access_control_misconfigurations/uid_bash_root/manifests/config.pp
rename to modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/manifests/config.pp
index 1931fcfab..87063f48a 100644
--- a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_bash_root/manifests/config.pp
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/manifests/config.pp
@@ -1,4 +1,4 @@
-class uid_bash_root::config {
+class suid_root_bash::config {
file { '/bin/bash':
ensure => present,
mode => '4777',
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_bash_root/secgen_metadata.xml b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/secgen_metadata.xml
similarity index 100%
rename from modules/vulnerabilities/unix/access_control_misconfigurations/uid_bash_root/secgen_metadata.xml
rename to modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/secgen_metadata.xml
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/secgen_test/suid_root_bash.rb b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/secgen_test/suid_root_bash.rb
new file mode 100644
index 000000000..e8f8c1589
--- /dev/null
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/secgen_test/suid_root_bash.rb
@@ -0,0 +1,19 @@
+require_relative '../../../../../lib/post_provision_test'
+
+
+class SUIDNanoTest < PostProvisionTest
+ def initialize
+ self.module_name = 'suid_root_nano'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_local_command('nano suid bit set?','sudo ls -la /bin/nano', '-rwsrwxrwx')
+ test_local_command('nano runs?','/bin/nano --version', 'GNU nano')
+ end
+
+end
+
+SUIDNanoTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/suid_root_bash.pp b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/suid_root_bash.pp
new file mode 100644
index 000000000..d16274345
--- /dev/null
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/suid_root_bash.pp
@@ -0,0 +1 @@
+include suid_root_bash::config
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_bash_root/uid_bash_root.pp b/modules/vulnerabilities/unix/access_control_misconfigurations/uid_bash_root/uid_bash_root.pp
deleted file mode 100644
index 5169dbf9b..000000000
--- a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_bash_root/uid_bash_root.pp
+++ /dev/null
@@ -1 +0,0 @@
-include uid_bash_root::config
\ No newline at end of file
diff --git a/scenarios/examples/vulnerability_examples/access_control_misconfiguration_examples/uid_bash_root.xml b/scenarios/examples/vulnerability_examples/access_control_misconfiguration_examples/uid_bash_root.xml
index 64357f8b5..03642ae78 100644
--- a/scenarios/examples/vulnerability_examples/access_control_misconfiguration_examples/uid_bash_root.xml
+++ b/scenarios/examples/vulnerability_examples/access_control_misconfiguration_examples/uid_bash_root.xml
@@ -6,10 +6,10 @@
- access_control_misconfigurations_uid_bash_root
+ access_control_misconfigurations_suid_root_bash
-
+
From d27a0f8262427b4375f44f75b14969d46ef9b94c Mon Sep 17 00:00:00 2001
From: ts
Date: Tue, 5 Feb 2019 12:16:11 +0000
Subject: [PATCH 15/47] readable shadow
---
.../readable_shadow/manifests/config.pp | 2 +-
.../readable_shadow/secgen_metadata.xml | 2 +-
.../secgen_test/readable_shadow.rb | 18 ++++++++++++++++++
3 files changed, 20 insertions(+), 2 deletions(-)
create mode 100644 modules/vulnerabilities/unix/access_control_misconfigurations/readable_shadow/secgen_test/readable_shadow.rb
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/readable_shadow/manifests/config.pp b/modules/vulnerabilities/unix/access_control_misconfigurations/readable_shadow/manifests/config.pp
index 0639445c9..58fe907a0 100644
--- a/modules/vulnerabilities/unix/access_control_misconfigurations/readable_shadow/manifests/config.pp
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/readable_shadow/manifests/config.pp
@@ -1,6 +1,6 @@
class readable_shadow::config {
file { '/etc/shadow':
ensure => present,
- mode => '0622',
+ mode => '0644',
}
}
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/readable_shadow/secgen_metadata.xml b/modules/vulnerabilities/unix/access_control_misconfigurations/readable_shadow/secgen_metadata.xml
index 48ed6a44e..8f3cbeece 100644
--- a/modules/vulnerabilities/unix/access_control_misconfigurations/readable_shadow/secgen_metadata.xml
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/readable_shadow/secgen_metadata.xml
@@ -6,7 +6,7 @@
Readable Shadow FileThomas ShawMIT
- Changes permissions on shadow file to 0622, reveals password hashes to local users.
+ Changes permissions on shadow file to 0611, reveals password hashes to local users.
This is not a common misconfiguration, and not particularly subtle.access_control_misconfiguration
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/readable_shadow/secgen_test/readable_shadow.rb b/modules/vulnerabilities/unix/access_control_misconfigurations/readable_shadow/secgen_test/readable_shadow.rb
new file mode 100644
index 000000000..1bb66fc01
--- /dev/null
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/readable_shadow/secgen_test/readable_shadow.rb
@@ -0,0 +1,18 @@
+require_relative '../../../../../lib/post_provision_test'
+
+
+class ReadableShadowTest < PostProvisionTest
+ def initialize
+ self.module_name = 'readable_shadow'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_local_command('Shadow readable?','sudo ls -la /etc/shadow', '-rw-r--r--')
+ end
+
+end
+
+ReadableShadowTest.new.run
\ No newline at end of file
From 91f7d6398ed08f66a4a4194f867e84ad9724bb9f Mon Sep 17 00:00:00 2001
From: ts
Date: Tue, 5 Feb 2019 12:17:44 +0000
Subject: [PATCH 16/47] suid_root_nano tests
---
.../secgen_test/suid_root_nano.rb | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_nano/secgen_test/suid_root_nano.rb
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_nano/secgen_test/suid_root_nano.rb b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_nano/secgen_test/suid_root_nano.rb
new file mode 100644
index 000000000..e8f8c1589
--- /dev/null
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_nano/secgen_test/suid_root_nano.rb
@@ -0,0 +1,19 @@
+require_relative '../../../../../lib/post_provision_test'
+
+
+class SUIDNanoTest < PostProvisionTest
+ def initialize
+ self.module_name = 'suid_root_nano'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_local_command('nano suid bit set?','sudo ls -la /bin/nano', '-rwsrwxrwx')
+ test_local_command('nano runs?','/bin/nano --version', 'GNU nano')
+ end
+
+end
+
+SUIDNanoTest.new.run
\ No newline at end of file
From c9fc118a69a5aa7cd7a9d011b574de9557258735 Mon Sep 17 00:00:00 2001
From: ts
Date: Tue, 5 Feb 2019 13:27:46 +0000
Subject: [PATCH 17/47] access_control_misconfigurations: added tests + updated
module names + scenarios that referred to old names
---
.../manifests/change_uid_permissions.pp | 2 +-
.../secgen_metadata.xml | 0
.../secgen_test/suid_root_less.rb | 19 +++++++++++++++++++
.../suid_root_less.pp} | 2 +-
.../manifests/change_uid_permissions.pp | 2 +-
.../secgen_metadata.xml | 0
.../suid_root_vi/secgen_test/suid_root_vi.rb | 18 ++++++++++++++++++
.../suid_root_vi.pp} | 3 ++-
.../secgen_test/writable_groups.rb | 18 ++++++++++++++++++
.../secgen_test/writable_passwd.rb | 18 ++++++++++++++++++
.../secgen_test/writable_shadow.rb | 18 ++++++++++++++++++
.../uid_less_root.xml | 2 +-
.../uid_vi_root.xml | 2 +-
..._control_misconfigurations_uid_vi_root.xml | 2 +-
14 files changed, 99 insertions(+), 7 deletions(-)
rename modules/vulnerabilities/unix/access_control_misconfigurations/{uid_less_root => suid_root_less}/manifests/change_uid_permissions.pp (69%)
rename modules/vulnerabilities/unix/access_control_misconfigurations/{uid_less_root => suid_root_less}/secgen_metadata.xml (100%)
create mode 100644 modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_less/secgen_test/suid_root_less.rb
rename modules/vulnerabilities/unix/access_control_misconfigurations/{uid_less_root/uid_less_root.pp => suid_root_less/suid_root_less.pp} (67%)
rename modules/vulnerabilities/unix/access_control_misconfigurations/{uid_vi_root => suid_root_vi}/manifests/change_uid_permissions.pp (71%)
rename modules/vulnerabilities/unix/access_control_misconfigurations/{uid_vi_root => suid_root_vi}/secgen_metadata.xml (100%)
create mode 100644 modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_vi/secgen_test/suid_root_vi.rb
rename modules/vulnerabilities/unix/access_control_misconfigurations/{uid_vi_root/uid_vi_root.pp => suid_root_vi/suid_root_vi.pp} (59%)
create mode 100644 modules/vulnerabilities/unix/access_control_misconfigurations/writable_groups/secgen_test/writable_groups.rb
create mode 100644 modules/vulnerabilities/unix/access_control_misconfigurations/writable_passwd/secgen_test/writable_passwd.rb
create mode 100644 modules/vulnerabilities/unix/access_control_misconfigurations/writable_shadow/secgen_test/writable_shadow.rb
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_less_root/manifests/change_uid_permissions.pp b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_less/manifests/change_uid_permissions.pp
similarity index 69%
rename from modules/vulnerabilities/unix/access_control_misconfigurations/uid_less_root/manifests/change_uid_permissions.pp
rename to modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_less/manifests/change_uid_permissions.pp
index 91e2c793d..ee920c929 100644
--- a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_less_root/manifests/change_uid_permissions.pp
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_less/manifests/change_uid_permissions.pp
@@ -1,4 +1,4 @@
-class uid_less_root::change_uid_permissions ($file_input = [], $user = 'root') {
+class suid_root_less::change_uid_permissions ($file_input = [], $user = 'root') {
$file_input.each |$file, $permission_code| {
file { $file:
mode => $permission_code,
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_less_root/secgen_metadata.xml b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_less/secgen_metadata.xml
similarity index 100%
rename from modules/vulnerabilities/unix/access_control_misconfigurations/uid_less_root/secgen_metadata.xml
rename to modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_less/secgen_metadata.xml
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_less/secgen_test/suid_root_less.rb b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_less/secgen_test/suid_root_less.rb
new file mode 100644
index 000000000..66c962058
--- /dev/null
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_less/secgen_test/suid_root_less.rb
@@ -0,0 +1,19 @@
+require_relative '../../../../../lib/post_provision_test'
+
+
+class SUIDLessTest < PostProvisionTest
+ def initialize
+ self.module_name = 'suid_root_less'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_local_command('less suid bit set?','sudo ls -la /bin/less', '-rwsrwxrwx')
+ test_local_command('less runs?','/bin/less --help', 'Commands marked with * may be preceded by a number')
+ end
+
+end
+
+SUIDLessTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_less_root/uid_less_root.pp b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_less/suid_root_less.pp
similarity index 67%
rename from modules/vulnerabilities/unix/access_control_misconfigurations/uid_less_root/uid_less_root.pp
rename to modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_less/suid_root_less.pp
index 6ab2160da..5365f21a6 100644
--- a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_less_root/uid_less_root.pp
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_less/suid_root_less.pp
@@ -1,4 +1,4 @@
-class {'uid_less_root::change_uid_permissions':
+class {'suid_root_less::change_uid_permissions':
user => 'root',
file_input => {
'/bin/less' => '4777',
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_vi_root/manifests/change_uid_permissions.pp b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_vi/manifests/change_uid_permissions.pp
similarity index 71%
rename from modules/vulnerabilities/unix/access_control_misconfigurations/uid_vi_root/manifests/change_uid_permissions.pp
rename to modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_vi/manifests/change_uid_permissions.pp
index bd2ecc8a8..e41feba25 100644
--- a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_vi_root/manifests/change_uid_permissions.pp
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_vi/manifests/change_uid_permissions.pp
@@ -1,4 +1,4 @@
-class uid_vi_root::change_uid_permissions ($file_input = [],$user = 'root') {
+class suid_root_vi::change_uid_permissions ($file_input = [],$user = 'root') {
$file_input.each |String $file, String $permission_code| {
file { $file:
mode => $permission_code,
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_vi_root/secgen_metadata.xml b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_vi/secgen_metadata.xml
similarity index 100%
rename from modules/vulnerabilities/unix/access_control_misconfigurations/uid_vi_root/secgen_metadata.xml
rename to modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_vi/secgen_metadata.xml
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_vi/secgen_test/suid_root_vi.rb b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_vi/secgen_test/suid_root_vi.rb
new file mode 100644
index 000000000..31277d102
--- /dev/null
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_vi/secgen_test/suid_root_vi.rb
@@ -0,0 +1,18 @@
+require_relative '../../../../../lib/post_provision_test'
+
+
+class SUIDviTest < PostProvisionTest
+ def initialize
+ self.module_name = 'suid_root_vi'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_local_command('vi suid bit set?','sudo ls -la $(readlink -f `whereis vim`)', 'rwsrwxrwx')
+ end
+
+end
+
+SUIDviTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_vi_root/uid_vi_root.pp b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_vi/suid_root_vi.pp
similarity index 59%
rename from modules/vulnerabilities/unix/access_control_misconfigurations/uid_vi_root/uid_vi_root.pp
rename to modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_vi/suid_root_vi.pp
index 3fade5615..ca86b21fb 100644
--- a/modules/vulnerabilities/unix/access_control_misconfigurations/uid_vi_root/uid_vi_root.pp
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_vi/suid_root_vi.pp
@@ -1,7 +1,8 @@
-class {'uid_vi_root::change_uid_permissions':
+class {'suid_root_vi::change_uid_permissions':
file_input => {
'/usr/bin/vi' => '4777',
'/etc/alternatives/vi' => '4777',
'/usr/bin/vim.tiny' => '4777',
+ '/usr/bin/vim.basic' => '4777',
}
}
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/writable_groups/secgen_test/writable_groups.rb b/modules/vulnerabilities/unix/access_control_misconfigurations/writable_groups/secgen_test/writable_groups.rb
new file mode 100644
index 000000000..92f7b6f92
--- /dev/null
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/writable_groups/secgen_test/writable_groups.rb
@@ -0,0 +1,18 @@
+require_relative '../../../../../lib/post_provision_test'
+
+
+class WritableGroupsTest < PostProvisionTest
+ def initialize
+ self.module_name = 'writable_groups'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_local_command('writable groups?','sudo ls -la /etc/group', 'rwxrwxrwx')
+ end
+
+end
+
+WritableGroupsTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/writable_passwd/secgen_test/writable_passwd.rb b/modules/vulnerabilities/unix/access_control_misconfigurations/writable_passwd/secgen_test/writable_passwd.rb
new file mode 100644
index 000000000..0b2d12630
--- /dev/null
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/writable_passwd/secgen_test/writable_passwd.rb
@@ -0,0 +1,18 @@
+require_relative '../../../../../lib/post_provision_test'
+
+
+class WritablePasswdTest < PostProvisionTest
+ def initialize
+ self.module_name = 'writable_passwd'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_local_command('writable /etc/passwd?','sudo ls -la /etc/passwd', 'rwxrwxrwx')
+ end
+
+end
+
+WritablePasswdTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/writable_shadow/secgen_test/writable_shadow.rb b/modules/vulnerabilities/unix/access_control_misconfigurations/writable_shadow/secgen_test/writable_shadow.rb
new file mode 100644
index 000000000..d1d41d3f0
--- /dev/null
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/writable_shadow/secgen_test/writable_shadow.rb
@@ -0,0 +1,18 @@
+require_relative '../../../../../lib/post_provision_test'
+
+
+class WritableShadowTest < PostProvisionTest
+ def initialize
+ self.module_name = 'writable_shadow'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_local_command('writable /etc/shadow?','sudo ls -la /etc/shadow', 'rwxrwxrwx')
+ end
+
+end
+
+WritableShadowTest.new.run
\ No newline at end of file
diff --git a/scenarios/examples/vulnerability_examples/access_control_misconfiguration_examples/uid_less_root.xml b/scenarios/examples/vulnerability_examples/access_control_misconfiguration_examples/uid_less_root.xml
index d9e6035d2..fecb5378c 100644
--- a/scenarios/examples/vulnerability_examples/access_control_misconfiguration_examples/uid_less_root.xml
+++ b/scenarios/examples/vulnerability_examples/access_control_misconfiguration_examples/uid_less_root.xml
@@ -9,7 +9,7 @@
access_control_misconfigurations_uid_less_root
-
+
diff --git a/scenarios/examples/vulnerability_examples/access_control_misconfiguration_examples/uid_vi_root.xml b/scenarios/examples/vulnerability_examples/access_control_misconfiguration_examples/uid_vi_root.xml
index e0b8030d0..672491336 100644
--- a/scenarios/examples/vulnerability_examples/access_control_misconfiguration_examples/uid_vi_root.xml
+++ b/scenarios/examples/vulnerability_examples/access_control_misconfiguration_examples/uid_vi_root.xml
@@ -9,7 +9,7 @@
access_control_misconfigurations_vi_root
-
+
diff --git a/scenarios/examples/vulnerability_examples/access_control_misconfigurations_uid_vi_root.xml b/scenarios/examples/vulnerability_examples/access_control_misconfigurations_uid_vi_root.xml
index 19bb7eadb..d0056cffa 100644
--- a/scenarios/examples/vulnerability_examples/access_control_misconfigurations_uid_vi_root.xml
+++ b/scenarios/examples/vulnerability_examples/access_control_misconfigurations_uid_vi_root.xml
@@ -9,7 +9,7 @@
access_control_misconfigurations_vi_root
-
+
From b0881938f0ecf782ac6edbcc3c33c3e1308579d5 Mon Sep 17 00:00:00 2001
From: ts
Date: Tue, 5 Feb 2019 16:28:51 +0000
Subject: [PATCH 18/47] fixed mysql tests + update parameterised_website tests
---
lib/objects/post_provision_test.rb | 5 ++--
.../secgen_test/mysql_stretch_compatible.rb | 3 +-
.../secgen_test/mysql_wheezy_compatible.rb | 2 +-
.../secgen_test/parameterised_website.rb | 29 ++++++++++++++++---
4 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/lib/objects/post_provision_test.rb b/lib/objects/post_provision_test.rb
index 533f9b08b..e1d167a4f 100644
--- a/lib/objects/post_provision_test.rb
+++ b/lib/objects/post_provision_test.rb
@@ -56,7 +56,7 @@ class PostProvisionTest
end
# example usage for page: /index.html
- def test_html_returned_content(page, match_string)
+ def test_html_returned_content(page, match_string, hide_content=false)
begin
source = Net::HTTP.get(get_system_ip, page, self.port)
@@ -65,6 +65,7 @@ class PostProvisionTest
end
if source.include? match_string
+ match_string = '' if hide_content
self.outputs << "PASSED: Content #{match_string} is contained within #{page} at #{get_system_ip}:#{self.port} (#{get_system_name})!"
else
self.outputs << "FAILED: Content #{match_string} is contained within #{page} at #{get_system_ip}:#{self.port} (#{get_system_name})!"
@@ -90,7 +91,7 @@ class PostProvisionTest
##################
def run_vagrant_ssh(args)
- stdout, stderr, status = Open3.capture3("/usr/bin/vagrant ssh -c '#{args}'")
+ stdout, stderr, status = Open3.capture3("/usr/bin/vagrant ssh #{get_system_name} -c '#{args}'")
{:stdout => stdout, :stderr => stderr, :exit_status => status}
end
diff --git a/modules/services/unix/database/mysql_stretch_compatible/mysql/secgen_test/mysql_stretch_compatible.rb b/modules/services/unix/database/mysql_stretch_compatible/mysql/secgen_test/mysql_stretch_compatible.rb
index d95a30073..8b821b377 100644
--- a/modules/services/unix/database/mysql_stretch_compatible/mysql/secgen_test/mysql_stretch_compatible.rb
+++ b/modules/services/unix/database/mysql_stretch_compatible/mysql/secgen_test/mysql_stretch_compatible.rb
@@ -5,12 +5,11 @@ class MySQLStretchTest < PostProvisionTest
self.module_name = 'mysql_stretch_compatible'
self.module_path = get_module_path(__FILE__)
super
- self.port = 3306
end
def test_module
super
- test_service_up
+ test_local_command('mysqld process running?', 'ps -ef | grep mysqld', '/usr/sbin/mysqld')
end
end
diff --git a/modules/services/unix/database/mysql_wheezy_compatible/mysql/secgen_test/mysql_wheezy_compatible.rb b/modules/services/unix/database/mysql_wheezy_compatible/mysql/secgen_test/mysql_wheezy_compatible.rb
index 7a53abfd7..4e07fd320 100644
--- a/modules/services/unix/database/mysql_wheezy_compatible/mysql/secgen_test/mysql_wheezy_compatible.rb
+++ b/modules/services/unix/database/mysql_wheezy_compatible/mysql/secgen_test/mysql_wheezy_compatible.rb
@@ -10,7 +10,7 @@ class MySQLWheezyTest < PostProvisionTest
def test_module
super
- test_service_up
+ test_local_command('mysqld process running?', 'ps -ef | grep mysqld', '/usr/bin/mysqld')
end
end
diff --git a/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb b/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
index 79b0f68b4..18b97ac40 100644
--- a/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
+++ b/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
@@ -12,9 +12,19 @@ class ParamWebsiteTest < PostProvisionTest
def test_module
super
json_inputs = get_json_inputs
- css_theme = json_inputs['theme'][0]
- if json_inputs['organisation']
+ test_organisation_functionality(json_inputs)
+ test_additional_page(json_inputs)
+ test_html_returned_content("/css/#{json_inputs['theme'][0]}", 'Bootswatch v4.0.0')
+
+ test_service_up
+ end
+
+ def test_organisation_functionality(json_inputs)
+ if json_inputs['organisation'] and
+ json_inputs['organisation'][0] and
+ json_inputs['organisation'][0] != ''
+
organisation = JSON.parse(json_inputs['organisation'][0])
employee_1 = organisation['employees'][0]
@@ -22,10 +32,21 @@ class ParamWebsiteTest < PostProvisionTest
test_html_returned_content('/contact.html', organisation['business_moto'])
test_html_returned_content('/contact.html', employee_1['name'])
end
+ end
- test_html_returned_content("/css/#{css_theme}", 'Bootswatch v4.0.0')
- test_service_up
+ def test_additional_page(json_inputs)
+ if json_inputs['additional_page_filenames'] and
+ json_inputs['additional_page_filenames'][0] and
+ json_inputs['additional_page_filenames'][0].include? 'html' and
+ json_inputs['additional_pages'] and
+ json_inputs['additional_pages'][0]
+
+ page_name = json_inputs['additional_page_filenames'][0]
+ page_name = "/#{page_name}" if page_name.split[0] != '/'
+
+ test_html_returned_content(page_name, json_inputs['additional_pages'][0], true)
+ end
end
end
From 4dfd3e03eb52796754f73eb1597c2321a0a8fc47 Mon Sep 17 00:00:00 2001
From: ts
Date: Tue, 5 Feb 2019 16:29:39 +0000
Subject: [PATCH 19/47] parameterised_website/secgen_tests: more sensible test
order
---
.../secgen_test/parameterised_website.rb | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb b/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
index 18b97ac40..2dfba2a0f 100644
--- a/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
+++ b/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
@@ -12,12 +12,10 @@ class ParamWebsiteTest < PostProvisionTest
def test_module
super
json_inputs = get_json_inputs
-
+ test_service_up
test_organisation_functionality(json_inputs)
test_additional_page(json_inputs)
test_html_returned_content("/css/#{json_inputs['theme'][0]}", 'Bootswatch v4.0.0')
-
- test_service_up
end
def test_organisation_functionality(json_inputs)
From 8704db35e981ac3646bb5cb5102209ccadf02557 Mon Sep 17 00:00:00 2001
From: ts
Date: Tue, 5 Feb 2019 17:26:40 +0000
Subject: [PATCH 20/47] basic_narrative.xml: added _server to prevent console
access
---
scenarios/ctf/basic_narrative.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scenarios/ctf/basic_narrative.xml b/scenarios/ctf/basic_narrative.xml
index c081e4b5c..e6a086379 100644
--- a/scenarios/ctf/basic_narrative.xml
+++ b/scenarios/ctf/basic_narrative.xml
@@ -15,7 +15,7 @@
intermediate
- target
+ target_server
From 1a61db5b1fb500b7e04d73c1322483c9125e3ca6 Mon Sep 17 00:00:00 2001
From: ts
Date: Tue, 5 Feb 2019 17:27:39 +0000
Subject: [PATCH 21/47] tests: net/http moved to superclass, updated website
tests
---
lib/objects/post_provision_test.rb | 5 +++--
.../secgen_test/parameterised_website.rb | 5 ++---
.../unix/webapp/onlinestore/secgen_test/onlinestore.rb | 1 +
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/objects/post_provision_test.rb b/lib/objects/post_provision_test.rb
index e1d167a4f..6d3f55ae1 100644
--- a/lib/objects/post_provision_test.rb
+++ b/lib/objects/post_provision_test.rb
@@ -9,6 +9,7 @@ require 'json'
require 'base64'
require 'socket'
require 'timeout'
+require 'net/http'
require_relative '../../../lib/helpers/gem_exec'
@@ -68,8 +69,8 @@ class PostProvisionTest
match_string = '' if hide_content
self.outputs << "PASSED: Content #{match_string} is contained within #{page} at #{get_system_ip}:#{self.port} (#{get_system_name})!"
else
- self.outputs << "FAILED: Content #{match_string} is contained within #{page} at #{get_system_ip}:#{self.port} (#{get_system_name})!"
- exit(1)
+ self.outputs << "FAILED: Content #{match_string} is not contained within #{page} at #{get_system_ip}:#{self.port} (#{get_system_name})!"
+ self.all_tests_passed = false
end
end
diff --git a/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb b/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
index 2dfba2a0f..53de3efc7 100644
--- a/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
+++ b/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
@@ -1,6 +1,5 @@
require_relative '../../../../../lib/post_provision_test'
require 'json'
-require 'net/http'
class ParamWebsiteTest < PostProvisionTest
def initialize
@@ -13,12 +12,12 @@ class ParamWebsiteTest < PostProvisionTest
super
json_inputs = get_json_inputs
test_service_up
- test_organisation_functionality(json_inputs)
+ test_org_functionality(json_inputs)
test_additional_page(json_inputs)
test_html_returned_content("/css/#{json_inputs['theme'][0]}", 'Bootswatch v4.0.0')
end
- def test_organisation_functionality(json_inputs)
+ def test_org_functionality(json_inputs)
if json_inputs['organisation'] and
json_inputs['organisation'][0] and
json_inputs['organisation'][0] != ''
diff --git a/modules/vulnerabilities/unix/webapp/onlinestore/secgen_test/onlinestore.rb b/modules/vulnerabilities/unix/webapp/onlinestore/secgen_test/onlinestore.rb
index b242f6028..d20a08982 100644
--- a/modules/vulnerabilities/unix/webapp/onlinestore/secgen_test/onlinestore.rb
+++ b/modules/vulnerabilities/unix/webapp/onlinestore/secgen_test/onlinestore.rb
@@ -10,6 +10,7 @@ class OnlineStoreTest < PostProvisionTest
def test_module
super
test_service_up
+ test_html_returned_content('/index.php', 'Welcome to furniture!')
end
end
From 341cd0bdf6df9da71bf882fd6625cec7010f69a5 Mon Sep 17 00:00:00 2001
From: ts
Date: Tue, 5 Feb 2019 17:28:15 +0000
Subject: [PATCH 22/47] vulnerabilities/unix/local/dirtycow
---
.../debian_puppet_32/secgen_metadata.xml | 5 +++
.../secgen_metadata.xml | 4 +++
.../unix/update/apt_upgrade/manifests/apt.pp | 35 ++++++++++++-------
.../unix/local/dirtycow/dirtycow.pp | 1 +
.../unix/local/dirtycow/manifests/config.pp | 3 ++
.../unix/local/dirtycow/secgen_metadata.xml | 33 +++++++++++++++++
.../local/dirtycow/secgen_test/dirtycow.rb | 17 +++++++++
7 files changed, 86 insertions(+), 12 deletions(-)
create mode 100644 modules/vulnerabilities/unix/local/dirtycow/dirtycow.pp
create mode 100644 modules/vulnerabilities/unix/local/dirtycow/manifests/config.pp
create mode 100644 modules/vulnerabilities/unix/local/dirtycow/secgen_metadata.xml
create mode 100644 modules/vulnerabilities/unix/local/dirtycow/secgen_test/dirtycow.rb
diff --git a/modules/bases/debian_puppet_32/secgen_metadata.xml b/modules/bases/debian_puppet_32/secgen_metadata.xml
index 171d99ba9..fdda2be95 100644
--- a/modules/bases/debian_puppet_32/secgen_metadata.xml
+++ b/modules/bases/debian_puppet_32/secgen_metadata.xml
@@ -20,4 +20,9 @@
https://atlas.hashicorp.com/puppetlabsvarious
+
+
+ upgrade
+
+
diff --git a/modules/bases/debian_wheezy_desktop_kde/secgen_metadata.xml b/modules/bases/debian_wheezy_desktop_kde/secgen_metadata.xml
index a73992247..ec9597f9f 100644
--- a/modules/bases/debian_wheezy_desktop_kde/secgen_metadata.xml
+++ b/modules/bases/debian_wheezy_desktop_kde/secgen_metadata.xml
@@ -21,4 +21,8 @@
https://atlas.hashicorp.com/puppetlabsvarious
+
+ upgrade
+
+
diff --git a/modules/utilities/unix/update/apt_upgrade/manifests/apt.pp b/modules/utilities/unix/update/apt_upgrade/manifests/apt.pp
index 654d0c6f0..281d9a353 100644
--- a/modules/utilities/unix/update/apt_upgrade/manifests/apt.pp
+++ b/modules/utilities/unix/update/apt_upgrade/manifests/apt.pp
@@ -1,17 +1,28 @@
class apt_upgrade::apt {
- case $operatingsystem {
- 'Debian': {
- exec { 'update':
- command => "/usr/bin/apt-get upgrade",
- tries => 5,
- try_sleep => 30,
+
+ notice("Running apt-upgrade module...")
+
+ if defined('dirtycow::config') {
+ notice("vulnerabilities/unix/local/dirtycow included - skipping apt-get upgrade...")
+ } else {
+ case $operatingsystem {
+ 'Debian': {
+ exec { 'update':
+ command => "/usr/bin/apt-get -y upgrade",
+ tries => 5,
+ try_sleep => 30,
+ timeout => 0,
+ logoutput => true,
+ }
}
- }
- 'Ubuntu': {
- exec { 'update':
- command => "/usr/bin/apt-get upgrade",
- tries => 5,
- try_sleep => 30,
+ 'Ubuntu': {
+ exec { 'update':
+ command => "/usr/bin/apt-get -y upgrade",
+ tries => 5,
+ try_sleep => 30,
+ timeout => 0,
+ logoutput => true,
+ }
}
}
}
diff --git a/modules/vulnerabilities/unix/local/dirtycow/dirtycow.pp b/modules/vulnerabilities/unix/local/dirtycow/dirtycow.pp
new file mode 100644
index 000000000..f86b5785e
--- /dev/null
+++ b/modules/vulnerabilities/unix/local/dirtycow/dirtycow.pp
@@ -0,0 +1 @@
+include dirtycow::config
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/local/dirtycow/manifests/config.pp b/modules/vulnerabilities/unix/local/dirtycow/manifests/config.pp
new file mode 100644
index 000000000..5a22e775d
--- /dev/null
+++ b/modules/vulnerabilities/unix/local/dirtycow/manifests/config.pp
@@ -0,0 +1,3 @@
+class dirtycow::config {
+ notice("dirtycow::config: Do nothing, the apt upgrade just checks if we're defined and blocks apt-get upgrade if so.")
+}
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/local/dirtycow/secgen_metadata.xml b/modules/vulnerabilities/unix/local/dirtycow/secgen_metadata.xml
new file mode 100644
index 000000000..90d6aaac1
--- /dev/null
+++ b/modules/vulnerabilities/unix/local/dirtycow/secgen_metadata.xml
@@ -0,0 +1,33 @@
+
+
+
+ DirtyCow privilege escalation
+ Thomas Shaw
+ MIT
+ DirtyCow local privilege escalation. Including this module prevents the default apt-get upgrade from
+ running which leaves the wheezy bases vulnerable.
+
+
+ unpatched_kernel
+ race_condition
+ root_rwx
+ local
+ linux
+ medium
+
+
+ .*Stretch.*
+
+
+ .*Kali.*
+
+
+ .*Windows.*
+
+
+ .*Ubuntu.*
+
+
+
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/local/dirtycow/secgen_test/dirtycow.rb b/modules/vulnerabilities/unix/local/dirtycow/secgen_test/dirtycow.rb
new file mode 100644
index 000000000..1433b43a4
--- /dev/null
+++ b/modules/vulnerabilities/unix/local/dirtycow/secgen_test/dirtycow.rb
@@ -0,0 +1,17 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class DirtyCOWTest < PostProvisionTest
+ def initialize
+ self.module_name = 'dirtycow'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_local_command('apt-get upgrade not performed?', 'sudo apt-get -u upgrade --assume-no','linux-image-3.')
+ end
+
+end
+
+DirtyCOWTest.new.run
\ No newline at end of file
From b60f421d47a36d56b0f569802a8359685ba04456 Mon Sep 17 00:00:00 2001
From: ts
Date: Tue, 5 Feb 2019 17:30:40 +0000
Subject: [PATCH 23/47] scenarios/examples/vulnerability_examples/dirtycow.xml
---
.../vulnerability_examples/dirtycow.xml | 24 +++++++++++++++++++
scenarios/tests/test_scenario.xml | 4 ++--
secgen.rb | 2 +-
3 files changed, 27 insertions(+), 3 deletions(-)
create mode 100644 scenarios/examples/vulnerability_examples/dirtycow.xml
diff --git a/scenarios/examples/vulnerability_examples/dirtycow.xml b/scenarios/examples/vulnerability_examples/dirtycow.xml
new file mode 100644
index 000000000..aba9df04f
--- /dev/null
+++ b/scenarios/examples/vulnerability_examples/dirtycow.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+ dirtycow
+
+
+
+
+
+
+ 172.16.0.12
+
+
+
+
+ IP_addresses
+
+
+
+
diff --git a/scenarios/tests/test_scenario.xml b/scenarios/tests/test_scenario.xml
index 0368e177e..7d5e7cc5d 100644
--- a/scenarios/tests/test_scenario.xml
+++ b/scenarios/tests/test_scenario.xml
@@ -5,9 +5,9 @@
xsi:schemaLocation="http://www.github/cliffe/SecGen/scenario">
testing
-
+
-
+ 172.16.0.12
diff --git a/secgen.rb b/secgen.rb
index 9a4d97575..36bf0a8e7 100644
--- a/secgen.rb
+++ b/secgen.rb
@@ -147,7 +147,7 @@ def build_vms(scenario, project_dir, options)
Print.err "Not going to destroy #{vm_not_to_destroy}, since it does not exist"
failures_to_destroy.delete_if {|x| x == vm_not_to_destroy}
# TODO: not sure if there is a need to remove_uncreated_vms() here too? (I don't think so?)
- end
+ end # TODO: Add another elsif here to check if any tests have failed, edit the output of the tests so that it has a unique string that captures the vm name
end
failures_to_destroy = failures_to_destroy.uniq
From 18948474997a401a6bc101f7627dc0c04f6a068b Mon Sep 17 00:00:00 2001
From: ts
Date: Tue, 5 Feb 2019 18:15:59 +0000
Subject: [PATCH 24/47] post_provision_test, replaced gem_exec with open3
---
lib/objects/post_provision_test.rb | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/objects/post_provision_test.rb b/lib/objects/post_provision_test.rb
index 6d3f55ae1..d42787ef6 100644
--- a/lib/objects/post_provision_test.rb
+++ b/lib/objects/post_provision_test.rb
@@ -10,8 +10,7 @@ require 'base64'
require 'socket'
require 'timeout'
require 'net/http'
-
-require_relative '../../../lib/helpers/gem_exec'
+require 'open3'
class PostProvisionTest
attr_accessor :project_path
From 1c6deeff94be7598801907c25ef9a9973658494c Mon Sep 17 00:00:00 2001
From: ts
Date: Tue, 5 Feb 2019 18:16:25 +0000
Subject: [PATCH 25/47] gitlist_040: added content test
---
.../unix/webapp/gitlist_040/secgen_test/gitlist_040.rb | 1 +
1 file changed, 1 insertion(+)
diff --git a/modules/vulnerabilities/unix/webapp/gitlist_040/secgen_test/gitlist_040.rb b/modules/vulnerabilities/unix/webapp/gitlist_040/secgen_test/gitlist_040.rb
index b80f1599a..5dceede60 100644
--- a/modules/vulnerabilities/unix/webapp/gitlist_040/secgen_test/gitlist_040.rb
+++ b/modules/vulnerabilities/unix/webapp/gitlist_040/secgen_test/gitlist_040.rb
@@ -10,6 +10,7 @@ class Gitlist040Test < PostProvisionTest
def test_module
super
test_service_up
+ test_html_returned_content('/', 'GitList')
end
end
From d5adcf4ccac35d81e5c26a7dc8395ba5a5242fa1 Mon Sep 17 00:00:00 2001
From: ts
Date: Tue, 5 Feb 2019 18:53:10 +0000
Subject: [PATCH 26/47] added retry loop for test_service_up? and increased
sleep time as some web applications were failing.
---
lib/objects/post_provision_test.rb | 30 +++++++++++++++++-------------
secgen.rb | 2 +-
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/lib/objects/post_provision_test.rb b/lib/objects/post_provision_test.rb
index d42787ef6..f02030dae 100644
--- a/lib/objects/post_provision_test.rb
+++ b/lib/objects/post_provision_test.rb
@@ -56,15 +56,15 @@ class PostProvisionTest
end
# example usage for page: /index.html
- def test_html_returned_content(page, match_string, hide_content=false)
+ def test_html_returned_content(page, match_string, hide_content = false)
begin
source = Net::HTTP.get(get_system_ip, page, self.port)
- rescue SocketError
+ rescue SocketError, Errno::ECONNREFUSED
# do nothing
end
- if source.include? match_string
+ if source and source.include? match_string
match_string = '' if hide_content
self.outputs << "PASSED: Content #{match_string} is contained within #{page} at #{get_system_ip}:#{self.port} (#{get_system_name})!"
else
@@ -147,18 +147,22 @@ class PostProvisionTest
end
def is_port_open?(ip, port)
- begin
- Timeout::timeout(1) do
- begin
- s = TCPSocket.new(ip, port)
- s.close
- return true
- rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
- return false
+ retries = 5
+ while retries > 0
+ begin
+ Timeout::timeout(2) do
+ begin
+ s = TCPSocket.new(ip, port)
+ s.close
+ return true
+ rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
+ # do nothing
+ end
end
+ rescue Timeout::Error
+ # ignored
end
- rescue Timeout::Error
- # ignored
+ retries -= 1
end
false
end
diff --git a/secgen.rb b/secgen.rb
index 36bf0a8e7..68e94e413 100644
--- a/secgen.rb
+++ b/secgen.rb
@@ -339,7 +339,7 @@ def reboot_cycle(project_dir)
GemExec.exe('vagrant', project_dir, 'halt')
sleep 5
GemExec.exe('vagrant', project_dir, 'up --no-provision')
- sleep 30
+ sleep 45
end
def post_provision_tests(project_dir)
From 0f8b41c3d0698a3ac653a687145441b516d6653c Mon Sep 17 00:00:00 2001
From: ts
Date: Wed, 6 Feb 2019 17:45:11 +0000
Subject: [PATCH 27/47] delete bases/ubuntu_xenial_64
---
.../ubuntu_xenial_64/secgen_metadata.xml | 22 -------------------
1 file changed, 22 deletions(-)
delete mode 100644 modules/bases/ubuntu_xenial_64/secgen_metadata.xml
diff --git a/modules/bases/ubuntu_xenial_64/secgen_metadata.xml b/modules/bases/ubuntu_xenial_64/secgen_metadata.xml
deleted file mode 100644
index f013c4cfb..000000000
--- a/modules/bases/ubuntu_xenial_64/secgen_metadata.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
- Ubuntu Xenial 16.04 LTS 64-bit Server by puppetlabs
- Thomas Shaw
- GPLv3
- TODO
- 64-bit
- server
- cli
-
- linux
- unix
- Ubuntu Xenial 16.04 LTS
- https://app.vagrantup.com/puppetlabs/boxes/ubuntu-16.04-64-puppet/versions/1.0.0/providers/virtualbox.box
- debian_server
-
- https://atlas.hashicorp.com/puppetlabs
- various
-
From d655b3d226ef276da6c01831d5ff3a01c23331cf Mon Sep 17 00:00:00 2001
From: ts
Date: Thu, 7 Feb 2019 11:11:50 +0000
Subject: [PATCH 28/47] updated tests + team project
---
.../secgen_test/parameterised_website.rb | 42 +++++++++++++++----
.../services/unix/ntp/ntp/secgen_test/ntp.rb | 17 ++++++--
.../secgen_test/parameterised_accounts.rb | 24 +++++++++++
.../suid_root_bash/secgen_metadata.xml | 4 ++
.../secgen_test/suid_root_bash.rb | 10 ++---
.../bash/shellshock/secgen_test/shellshock.rb | 18 ++++++++
.../secgen_test/vsftpd_234_backdoor.rb | 1 -
.../moinmoin_195/secgen_test/moinmoin_195.rb | 1 +
scenarios/security_audit/team_project.xml | 2 +-
scenarios/tests/test_scenario.xml | 2 +-
10 files changed, 101 insertions(+), 20 deletions(-)
create mode 100644 modules/utilities/unix/system/parameterised_accounts/secgen_test/parameterised_accounts.rb
create mode 100644 modules/vulnerabilities/unix/bash/shellshock/secgen_test/shellshock.rb
diff --git a/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb b/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
index 53de3efc7..032c30b34 100644
--- a/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
+++ b/modules/services/unix/http/parameterised_website/secgen_test/parameterised_website.rb
@@ -2,6 +2,8 @@ require_relative '../../../../../lib/post_provision_test'
require 'json'
class ParamWebsiteTest < PostProvisionTest
+ attr_accessor :organisation
+
def initialize
self.module_name = 'parameterised_website'
self.module_path = get_module_path(__FILE__)
@@ -12,32 +14,54 @@ class ParamWebsiteTest < PostProvisionTest
super
json_inputs = get_json_inputs
test_service_up
+ test_html_returned_content("/css/#{json_inputs['theme'][0]}", 'Bootswatch v4.0.0')
test_org_functionality(json_inputs)
test_additional_page(json_inputs)
- test_html_returned_content("/css/#{json_inputs['theme'][0]}", 'Bootswatch v4.0.0')
+ test_security_audit_remit(json_inputs)
+ test_acceptable_use_policy(json_inputs)
+ end
+
+ def get_organisation(json_inputs)
+ JSON.parse(json_inputs['organisation'][0])
end
def test_org_functionality(json_inputs)
if json_inputs['organisation'] and
- json_inputs['organisation'][0] and
- json_inputs['organisation'][0] != ''
+ json_inputs['organisation'][0] and
+ json_inputs['organisation'][0] != ''
- organisation = JSON.parse(json_inputs['organisation'][0])
+ organisation = get_organisation(json_inputs)
employee_1 = organisation['employees'][0]
test_html_returned_content('/index.html', organisation['business_name'])
- test_html_returned_content('/contact.html', organisation['business_moto'])
+ test_html_returned_content('/contact.html', organisation['business_motto'])
test_html_returned_content('/contact.html', employee_1['name'])
end
end
+ def test_security_audit_remit(json_inputs)
+ if json_inputs['security_audit'] and
+ json_inputs['security_audit'][0] and
+ json_inputs['security_audit'][0] != ''
+ test_html_returned_content('/security_audit_remit.html', "Security Audit Remit of #{get_organisation(json_inputs)['business_name']}")
+ end
+ end
+
+ def test_acceptable_use_policy(json_inputs)
+ if json_inputs['host_acceptable_use_policy'] and
+ json_inputs['host_acceptable_use_policy'][0] and
+ json_inputs['host_acceptable_use_policy'][0] == 'true'
+ test_html_returned_content('/acceptable_use_policy.html', "Acceptable Use Policy")
+ test_html_returned_content('/acceptable_use_policy.html', get_organisation(json_inputs)['business_name'])
+ end
+ end
def test_additional_page(json_inputs)
if json_inputs['additional_page_filenames'] and
- json_inputs['additional_page_filenames'][0] and
- json_inputs['additional_page_filenames'][0].include? 'html' and
- json_inputs['additional_pages'] and
- json_inputs['additional_pages'][0]
+ json_inputs['additional_page_filenames'][0] and
+ json_inputs['additional_page_filenames'][0].include? 'html' and
+ json_inputs['additional_pages'] and
+ json_inputs['additional_pages'][0]
page_name = json_inputs['additional_page_filenames'][0]
page_name = "/#{page_name}" if page_name.split[0] != '/'
diff --git a/modules/services/unix/ntp/ntp/secgen_test/ntp.rb b/modules/services/unix/ntp/ntp/secgen_test/ntp.rb
index 2f8bcf569..8a72f2117 100644
--- a/modules/services/unix/ntp/ntp/secgen_test/ntp.rb
+++ b/modules/services/unix/ntp/ntp/secgen_test/ntp.rb
@@ -15,10 +15,21 @@ class NTPTest < PostProvisionTest
end
def test_ntp_query
- begin
- time_response = Net::NTP.get(system_ip, port).time
+ time_response = ''
+ retries = 5
+ while retries > 0
+ begin
+ time_response = Net::NTP.get(system_ip, port).time
+ break
+ rescue Errno::ECONNREFUSED, Timeout::Error
+ # do nothing
+ end
+ sleep 2
+ retries = -1
+ end
+ if time_response != ''
self.outputs << "PASSED: NTP responded on UDP port #{port} with #{time_response}"
- rescue Errno::ECONNREFUSED
+ else
self.outputs << "FAILED: unable to connect to #{module_name} on UDP port #{port}"
self.all_tests_passed = false
end
diff --git a/modules/utilities/unix/system/parameterised_accounts/secgen_test/parameterised_accounts.rb b/modules/utilities/unix/system/parameterised_accounts/secgen_test/parameterised_accounts.rb
new file mode 100644
index 000000000..b869febd9
--- /dev/null
+++ b/modules/utilities/unix/system/parameterised_accounts/secgen_test/parameterised_accounts.rb
@@ -0,0 +1,24 @@
+require_relative '../../../../../lib/post_provision_test'
+
+class ParameterisedAccountsTest < PostProvisionTest
+ def initialize
+ self.module_name = 'parameterised_accounts'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_accounts_exist
+ end
+
+ def test_accounts_exist
+ get_json_inputs['accounts'].each do |account|
+ account = JSON.parse(account)
+ username = account['username']
+ test_local_command("#{username} account exists?", 'cat /etc/passwd', username)
+ end
+ end
+end
+
+ParameterisedAccountsTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/secgen_metadata.xml b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/secgen_metadata.xml
index 8e4f18057..718b2a5a6 100644
--- a/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/secgen_metadata.xml
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/secgen_metadata.xml
@@ -15,4 +15,8 @@
Shell permission misconfigurationBash shell running with root permissions due to suid bit set (try /bin/bash -cp "some_command")
+
+
+ .*shellshock.*
+
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/secgen_test/suid_root_bash.rb b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/secgen_test/suid_root_bash.rb
index e8f8c1589..df9d697cc 100644
--- a/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/secgen_test/suid_root_bash.rb
+++ b/modules/vulnerabilities/unix/access_control_misconfigurations/suid_root_bash/secgen_test/suid_root_bash.rb
@@ -1,19 +1,19 @@
require_relative '../../../../../lib/post_provision_test'
-class SUIDNanoTest < PostProvisionTest
+class SUIDBashTest < PostProvisionTest
def initialize
- self.module_name = 'suid_root_nano'
+ self.module_name = 'suid_root_bash'
self.module_path = get_module_path(__FILE__)
super
end
def test_module
super
- test_local_command('nano suid bit set?','sudo ls -la /bin/nano', '-rwsrwxrwx')
- test_local_command('nano runs?','/bin/nano --version', 'GNU nano')
+ test_local_command('bash suid bit set?','sudo ls -la /bin/bash', '-rwsrwxrwx')
+ test_local_command('bash runs?','/bin/bash --version', 'GNU bash')
end
end
-SUIDNanoTest.new.run
\ No newline at end of file
+SUIDBashTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/bash/shellshock/secgen_test/shellshock.rb b/modules/vulnerabilities/unix/bash/shellshock/secgen_test/shellshock.rb
new file mode 100644
index 000000000..7f506e288
--- /dev/null
+++ b/modules/vulnerabilities/unix/bash/shellshock/secgen_test/shellshock.rb
@@ -0,0 +1,18 @@
+require_relative '../../../../../lib/post_provision_test'
+
+
+class ShellshockTest < PostProvisionTest
+ def initialize
+ self.module_name = 'shellshock'
+ self.module_path = get_module_path(__FILE__)
+ super
+ end
+
+ def test_module
+ super
+ test_local_command('correct /bin/bash version?','/bin/bash --version', 'version 4.1')
+ end
+
+end
+
+ShellshockTest.new.run
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/ftp/vsftpd_234_backdoor/secgen_test/vsftpd_234_backdoor.rb b/modules/vulnerabilities/unix/ftp/vsftpd_234_backdoor/secgen_test/vsftpd_234_backdoor.rb
index d5d7e85d4..176bcfb8b 100644
--- a/modules/vulnerabilities/unix/ftp/vsftpd_234_backdoor/secgen_test/vsftpd_234_backdoor.rb
+++ b/modules/vulnerabilities/unix/ftp/vsftpd_234_backdoor/secgen_test/vsftpd_234_backdoor.rb
@@ -2,7 +2,6 @@ require_relative '../../../../../lib/post_provision_test'
class Vsftpd234BackdoorTest < PostProvisionTest
def initialize
- super
self.module_name = 'vsftpd_234_backdoor'
self.module_path = get_module_path(__FILE__)
super
diff --git a/modules/vulnerabilities/unix/webapp/moinmoin_195/secgen_test/moinmoin_195.rb b/modules/vulnerabilities/unix/webapp/moinmoin_195/secgen_test/moinmoin_195.rb
index 4c6fcc9f7..bd0de9206 100644
--- a/modules/vulnerabilities/unix/webapp/moinmoin_195/secgen_test/moinmoin_195.rb
+++ b/modules/vulnerabilities/unix/webapp/moinmoin_195/secgen_test/moinmoin_195.rb
@@ -10,6 +10,7 @@ class MoinMoin195Test < PostProvisionTest
def test_module
super
test_service_up
+ test_html_returned_content('/index.html','')
end
end
diff --git a/scenarios/security_audit/team_project.xml b/scenarios/security_audit/team_project.xml
index b80365b6a..1cd951b2b 100644
--- a/scenarios/security_audit/team_project.xml
+++ b/scenarios/security_audit/team_project.xml
@@ -19,7 +19,7 @@
web
-
+ 172.10.0.2
diff --git a/scenarios/tests/test_scenario.xml b/scenarios/tests/test_scenario.xml
index 7d5e7cc5d..4b5bd5335 100644
--- a/scenarios/tests/test_scenario.xml
+++ b/scenarios/tests/test_scenario.xml
@@ -10,7 +10,7 @@
- 172.16.0.12
+ 172.16.0.14
From 3e4123642c0fb0dc2acd65fe98b216ac9a5562b1 Mon Sep 17 00:00:00 2001
From: thomashaw
Date: Thu, 7 Feb 2019 12:57:18 +0000
Subject: [PATCH 29/47] reverting dirtycow for now, need to exclude the puppet
package from apt-get upgrade before inclusion
---
Gemfile.lock | 41 ++++++++++---------
.../unix/local/dirtycow/dirtycow.pp | 1 -
.../unix/local/dirtycow/manifests/config.pp | 3 --
.../unix/local/dirtycow/secgen_metadata.xml | 33 ---------------
.../local/dirtycow/secgen_test/dirtycow.rb | 17 --------
scenarios/security_audit/team_project.xml | 25 +----------
6 files changed, 23 insertions(+), 97 deletions(-)
delete mode 100644 modules/vulnerabilities/unix/local/dirtycow/dirtycow.pp
delete mode 100644 modules/vulnerabilities/unix/local/dirtycow/manifests/config.pp
delete mode 100644 modules/vulnerabilities/unix/local/dirtycow/secgen_metadata.xml
delete mode 100644 modules/vulnerabilities/unix/local/dirtycow/secgen_test/dirtycow.rb
diff --git a/Gemfile.lock b/Gemfile.lock
index 265befd94..e9a7c27b4 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -19,17 +19,18 @@ GIT
GEM
remote: https://rubygems.org/
specs:
+ CFPropertyList (2.3.6)
PriorityQueue (0.1.2)
- activesupport (5.2.1)
+ activesupport (5.2.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
bases (1.0.2)
bcrypt (3.1.12)
- chunky_png (1.3.10)
+ chunky_png (1.3.11)
cinch (2.3.4)
- concurrent-ruby (1.0.5)
+ concurrent-ruby (1.1.4)
credy (0.2.1)
thor (~> 0.19.1)
digest-simple (1.1.0)
@@ -38,6 +39,7 @@ GEM
digest-whirlpool (1.0.3)
duplicate (1.1.1)
facter (2.5.1)
+ CFPropertyList (~> 2.2)
faker (1.9.1)
i18n (>= 0.7)
faraday (0.13.1)
@@ -45,7 +47,7 @@ GEM
faraday_middleware (0.12.2)
faraday (>= 0.7.4, < 1.0)
fast_gettext (1.1.2)
- ffi (1.9.25)
+ ffi (1.10.0)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
@@ -60,14 +62,14 @@ GEM
gpgmeh (0.1.6)
activesupport (>= 2.3)
nio4r (~> 2.2)
- hiera (3.4.5)
+ hiera (3.5.0)
hocon (1.2.5)
httpclient (2.8.3)
huffman (0.0.1)
PriorityQueue
activesupport
ruby-graphviz
- i18n (1.1.0)
+ i18n (1.5.3)
concurrent-ruby (~> 1.0)
json (2.1.0)
librarian-puppet (3.0.0)
@@ -80,21 +82,22 @@ GEM
mini_exiftool (2.9.0)
mini_exiftool_vendored (9.2.7.v1)
mini_exiftool (>= 1.6.0)
- mini_portile2 (2.3.0)
- minitar (0.6.1)
+ mini_portile2 (2.4.0)
+ minitar (0.8)
minitest (5.11.3)
multi_json (1.13.1)
multipart-post (2.0.0)
net-ntp (2.1.3)
nio4r (2.3.1)
- nokogiri (1.8.4)
- mini_portile2 (~> 2.3.0)
+ nokogiri (1.10.1)
+ mini_portile2 (~> 2.4.0)
nori (2.6.0)
- ovirt-engine-sdk (4.2.4)
+ ovirt-engine-sdk (4.3.0)
json (>= 1, < 3)
- pg (1.1.3)
+ pg (1.1.4)
process_helper (0.1.2)
- puppet (6.0.0)
+ puppet (6.2.0)
+ CFPropertyList (~> 2.2)
facter (> 2.0.1, < 4)
fast_gettext (~> 1.1.2)
hiera (>= 3.2.1, < 4)
@@ -103,7 +106,7 @@ GEM
multi_json (~> 1.10)
puppet-resource_api (~> 1.5)
semantic_puppet (~> 1.0)
- puppet-resource_api (1.5.0)
+ puppet-resource_api (1.6.2)
hocon (>= 1.0)
puppet_forge (2.2.9)
faraday (>= 0.9.0, < 0.14.0)
@@ -111,15 +114,15 @@ GEM
gettext-setup (~> 0.11)
minitar
semantic_puppet (~> 1.0)
- rake (12.3.1)
- rdoc (6.0.4)
+ rake (12.3.2)
+ rdoc (6.1.1)
redcarpet (3.4.0)
rmagick (2.16.0)
rqrcode (0.10.1)
chunky_png (~> 1.0)
rsa (0.1.4)
rsync (1.0.9)
- ruby-graphviz (1.2.3)
+ ruby-graphviz (1.2.4)
rubyzip (1.2.2)
scrypt (3.0.6)
ffi-compiler (>= 1.0, < 2.0)
@@ -135,7 +138,7 @@ GEM
thread_safe (~> 0.1)
wordlist (0.1.1)
spidr (~> 0.2)
- yard (0.9.16)
+ yard (0.9.18)
zip-zip (0.3)
rubyzip (>= 1.0.0)
zipruby (0.3.6)
@@ -184,4 +187,4 @@ DEPENDENCIES
zipruby
BUNDLED WITH
- 2.0.0.pre.2
+ 1.11.2
diff --git a/modules/vulnerabilities/unix/local/dirtycow/dirtycow.pp b/modules/vulnerabilities/unix/local/dirtycow/dirtycow.pp
deleted file mode 100644
index f86b5785e..000000000
--- a/modules/vulnerabilities/unix/local/dirtycow/dirtycow.pp
+++ /dev/null
@@ -1 +0,0 @@
-include dirtycow::config
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/local/dirtycow/manifests/config.pp b/modules/vulnerabilities/unix/local/dirtycow/manifests/config.pp
deleted file mode 100644
index 5a22e775d..000000000
--- a/modules/vulnerabilities/unix/local/dirtycow/manifests/config.pp
+++ /dev/null
@@ -1,3 +0,0 @@
-class dirtycow::config {
- notice("dirtycow::config: Do nothing, the apt upgrade just checks if we're defined and blocks apt-get upgrade if so.")
-}
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/local/dirtycow/secgen_metadata.xml b/modules/vulnerabilities/unix/local/dirtycow/secgen_metadata.xml
deleted file mode 100644
index 90d6aaac1..000000000
--- a/modules/vulnerabilities/unix/local/dirtycow/secgen_metadata.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
- DirtyCow privilege escalation
- Thomas Shaw
- MIT
- DirtyCow local privilege escalation. Including this module prevents the default apt-get upgrade from
- running which leaves the wheezy bases vulnerable.
-
-
- unpatched_kernel
- race_condition
- root_rwx
- local
- linux
- medium
-
-
- .*Stretch.*
-
-
- .*Kali.*
-
-
- .*Windows.*
-
-
- .*Ubuntu.*
-
-
-
\ No newline at end of file
diff --git a/modules/vulnerabilities/unix/local/dirtycow/secgen_test/dirtycow.rb b/modules/vulnerabilities/unix/local/dirtycow/secgen_test/dirtycow.rb
deleted file mode 100644
index 1433b43a4..000000000
--- a/modules/vulnerabilities/unix/local/dirtycow/secgen_test/dirtycow.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-require_relative '../../../../../lib/post_provision_test'
-
-class DirtyCOWTest < PostProvisionTest
- def initialize
- self.module_name = 'dirtycow'
- self.module_path = get_module_path(__FILE__)
- super
- end
-
- def test_module
- super
- test_local_command('apt-get upgrade not performed?', 'sudo apt-get -u upgrade --assume-no','linux-image-3.')
- end
-
-end
-
-DirtyCOWTest.new.run
\ No newline at end of file
diff --git a/scenarios/security_audit/team_project.xml b/scenarios/security_audit/team_project.xml
index 1cd951b2b..0f45423a3 100644
--- a/scenarios/security_audit/team_project.xml
+++ b/scenarios/security_audit/team_project.xml
@@ -19,7 +19,7 @@
web
-
+ 172.10.0.2
@@ -194,27 +194,4 @@
-
-
- attack_vm_1
-
-
-
- IP_addresses
-
-
-
-
-
-
- attack_vm_2
-
-
-
- IP_addresses
-
-
-
-
-
From a0ced2520113cf72418403605c1b499ebaa6425f Mon Sep 17 00:00:00 2001
From: thomashaw
Date: Thu, 7 Feb 2019 13:02:00 +0000
Subject: [PATCH 30/47] reverting upgrade on wheezy bases for now
---
modules/bases/debian_puppet_32/secgen_metadata.xml | 4 ----
modules/bases/debian_wheezy_desktop_kde/secgen_metadata.xml | 4 ----
2 files changed, 8 deletions(-)
diff --git a/modules/bases/debian_puppet_32/secgen_metadata.xml b/modules/bases/debian_puppet_32/secgen_metadata.xml
index fdda2be95..b8bf6196e 100644
--- a/modules/bases/debian_puppet_32/secgen_metadata.xml
+++ b/modules/bases/debian_puppet_32/secgen_metadata.xml
@@ -21,8 +21,4 @@
https://atlas.hashicorp.com/puppetlabsvarious
-
- upgrade
-
-
diff --git a/modules/bases/debian_wheezy_desktop_kde/secgen_metadata.xml b/modules/bases/debian_wheezy_desktop_kde/secgen_metadata.xml
index ec9597f9f..a73992247 100644
--- a/modules/bases/debian_wheezy_desktop_kde/secgen_metadata.xml
+++ b/modules/bases/debian_wheezy_desktop_kde/secgen_metadata.xml
@@ -21,8 +21,4 @@
https://atlas.hashicorp.com/puppetlabsvarious
-
- upgrade
-
-
From 345e902ccacce26f6bbf498aad6c0d2d9b1fb6bc Mon Sep 17 00:00:00 2001
From: ts
Date: Thu, 7 Feb 2019 14:25:54 +0000
Subject: [PATCH 31/47] removed example ctf challenge stuff..
---
.../dc16_amadhj/manifests/install.pp | 39 -----------
.../manifests/install.pp | 45 -------------
.../python2_challenge_example.pp | 1 -
.../secgen_metadata.xml | 63 -----------------
.../manifests/install.pp | 17 -----
.../ruby_challenge_example.pp | 1 -
.../secgen_metadata.xml | 67 -------------------
7 files changed, 233 deletions(-)
delete mode 100644 modules/vulnerabilities/unix/ctf/defcon_quals_2016/dc16_amadhj/manifests/install.pp
delete mode 100644 modules/vulnerabilities/unix/ctf/example/python2_challenge_example/manifests/install.pp
delete mode 100644 modules/vulnerabilities/unix/ctf/example/python2_challenge_example/python2_challenge_example.pp
delete mode 100644 modules/vulnerabilities/unix/ctf/example/python2_challenge_example/secgen_metadata.xml
delete mode 100644 modules/vulnerabilities/unix/ctf/example/ruby_challenge_example/manifests/install.pp
delete mode 100644 modules/vulnerabilities/unix/ctf/example/ruby_challenge_example/ruby_challenge_example.pp
delete mode 100644 modules/vulnerabilities/unix/ctf/example/ruby_challenge_example/secgen_metadata.xml
diff --git a/modules/vulnerabilities/unix/ctf/defcon_quals_2016/dc16_amadhj/manifests/install.pp b/modules/vulnerabilities/unix/ctf/defcon_quals_2016/dc16_amadhj/manifests/install.pp
deleted file mode 100644
index 5fb68ebc5..000000000
--- a/modules/vulnerabilities/unix/ctf/defcon_quals_2016/dc16_amadhj/manifests/install.pp
+++ /dev/null
@@ -1,39 +0,0 @@
-class dc16_amadhj::install {
- $secgen_params = secgen_functions::get_parameters($::base64_inputs_file)
- $group = $secgen_params['group']
-
- if $secgen_params['account'][0] and $secgen_params['account'][0] != '' {
- $account = parsejson($secgen_params['account'][0])
- } else {
- $account = undef
- }
-
- if $secgen_params['storage_directory'] and $secgen_params['storage_directory'][0] {
- $storage_dir = $secgen_params['storage_directory'][0]
- } else {
- $storage_dir = undef
- }
-
- if $group {
- ::secgen_functions::install_setgid_binary { 'defcon16_amadhj_group':
- source_module_name => $module_name,
- challenge_name => $secgen_params['challenge_name'][0],
- group => $group[0],
- account => $account,
- flag => $secgen_params['flag'][0],
- flag_name => 'flag',
- storage_dir => $storage_dir,
- strings_to_leak => $secgen_params['strings_to_leak'],
- }
- } else {
- ::secgen_functions::install_setuid_root_binary { 'defcon16_amadhj':
- source_module_name => $module_name,
- challenge_name => $secgen_params['challenge_name'][0],
- account => $account,
- flag => $secgen_params['flag'][0],
- flag_name => 'flag',
- storage_dir => $storage_dir,
- strings_to_leak => $secgen_params['strings_to_leak'],
- }
- }
-}
diff --git a/modules/vulnerabilities/unix/ctf/example/python2_challenge_example/manifests/install.pp b/modules/vulnerabilities/unix/ctf/example/python2_challenge_example/manifests/install.pp
deleted file mode 100644
index 747a9f5a8..000000000
--- a/modules/vulnerabilities/unix/ctf/example/python2_challenge_example/manifests/install.pp
+++ /dev/null
@@ -1,45 +0,0 @@
-class python2_challenge_example::install {
- $secgen_params = secgen_functions::get_parameters($::base64_inputs_file)
- $group = $secgen_params['group']
- $script_data = $secgen_params['script_data']
-
- if $secgen_params['account'][0] and $secgen_params['account'][0] != '' {
- $account = parsejson($secgen_params['account'][0])
- } else {
- $account = undef
- }
-
- if $secgen_params['storage_directory'] and $secgen_params['storage_directory'][0] {
- $storage_dir = $secgen_params['storage_directory'][0]
- } else {
- $storage_dir = undef
- }
-
- if $group {
- ::secgen_functions::install_setgid_script { 'python2_challenge_example':
- source_module_name => $module_name,
- challenge_name => $secgen_params['challenge_name'][0],
- script_name => 'test.py',
- script_data => $script_data[0],
- group => $group[0],
- account => $account,
- flag => $secgen_params['flag'][0],
- flag_name => 'flag',
- storage_dir => $storage_dir,
- strings_to_leak => $secgen_params['strings_to_leak'],
- }
- } else {
- ::secgen_functions::install_setuid_root_script { 'python2_challenge_example':
- source_module_name => $module_name,
- challenge_name => $secgen_params['challenge_name'][0],
- script_name => 'test.py',
- script_data => $script_data[0],
- account => $account,
- flag => $secgen_params['flag'][0],
- flag_name => 'flag',
- storage_dir => $storage_dir,
- strings_to_leak => $secgen_params['strings_to_leak'],
- }
- }
-
-}
diff --git a/modules/vulnerabilities/unix/ctf/example/python2_challenge_example/python2_challenge_example.pp b/modules/vulnerabilities/unix/ctf/example/python2_challenge_example/python2_challenge_example.pp
deleted file mode 100644
index 99d16c5df..000000000
--- a/modules/vulnerabilities/unix/ctf/example/python2_challenge_example/python2_challenge_example.pp
+++ /dev/null
@@ -1 +0,0 @@
-include python2_challenge_example::install
diff --git a/modules/vulnerabilities/unix/ctf/example/python2_challenge_example/secgen_metadata.xml b/modules/vulnerabilities/unix/ctf/example/python2_challenge_example/secgen_metadata.xml
deleted file mode 100644
index 7f102f83e..000000000
--- a/modules/vulnerabilities/unix/ctf/example/python2_challenge_example/secgen_metadata.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
- python2 Challenge Example
- Thomas Shaw
- MIT
- python2 challenge example
-
- script_challenge
- none
- local
- linux
-
- misc
- example
-
-
- challenge_name
- script_data
- account
- flag
-
- storage_directory
-
- group
-
- python2_script_example
-
-
-
-
-
-
-
- challenges
-
-
- password
-
-
-
-
-
-
-
- python2_script_example
-
-
-
- utilities/unix/system/accounts
-
-
-
- utilities/unix/system/binary_script_container
-
-
-
- utilities/unix/languages/python2/python
-
-
-
diff --git a/modules/vulnerabilities/unix/ctf/example/ruby_challenge_example/manifests/install.pp b/modules/vulnerabilities/unix/ctf/example/ruby_challenge_example/manifests/install.pp
deleted file mode 100644
index f1bb96019..000000000
--- a/modules/vulnerabilities/unix/ctf/example/ruby_challenge_example/manifests/install.pp
+++ /dev/null
@@ -1,17 +0,0 @@
-class ruby_challenge_example::install {
- $secgen_params = secgen_functions::get_parameters($::base64_inputs_file)
- $challenge_name = $secgen_params['challenge_name'][0]
-
- ::secgen_functions::install_setgid_script { $challenge_name:
- source_module_name => $module_name,
- challenge_name => $challenge_name,
- script_name => 'test.rb',
- script_data => $secgen_params['script_data'][0],
- group => $secgen_params['group'],
- account => $secgen_params['account'],
- flag => $secgen_params['flag'],
- port => $secgen_params['port'],
- storage_directory => $secgen_params['storage_directory'],
- strings_to_leak => $secgen_params['strings_to_leak'],
- }
-}
diff --git a/modules/vulnerabilities/unix/ctf/example/ruby_challenge_example/ruby_challenge_example.pp b/modules/vulnerabilities/unix/ctf/example/ruby_challenge_example/ruby_challenge_example.pp
deleted file mode 100644
index 7bf010122..000000000
--- a/modules/vulnerabilities/unix/ctf/example/ruby_challenge_example/ruby_challenge_example.pp
+++ /dev/null
@@ -1 +0,0 @@
-include ruby_challenge_example::install
diff --git a/modules/vulnerabilities/unix/ctf/example/ruby_challenge_example/secgen_metadata.xml b/modules/vulnerabilities/unix/ctf/example/ruby_challenge_example/secgen_metadata.xml
deleted file mode 100644
index f64b75118..000000000
--- a/modules/vulnerabilities/unix/ctf/example/ruby_challenge_example/secgen_metadata.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
- Ruby Challenge Example
- Thomas Shaw
- MIT
- Ruby challenge example
-
- ctf_challenge
- none
- local
- linux
-
- misc
- example
-
-
- challenge_name
- script_data
- account
- flag
-
- group
-
- storage_directory
-
- port
-
-
- ruby_challenge_example
-
-
-
-
-
-
-
- challenges
-
-
- password
-
-
-
-
-
-
-
-
- utilities/unix/system/accounts
-
-
-
- utilities/unix/system/binary_script_container
-
-
-
- utilities/unix/languages/ruby
-
-
-
- utilities/unix/system/xinetd
-
-
-
From 44fec02a322c2992127f1ae774cf0f923f48d550 Mon Sep 17 00:00:00 2001
From: "Z. Cliffe Schreuders"
Date: Wed, 6 Feb 2019 16:40:45 +0000
Subject: [PATCH 32/47] narrative update
---
scenarios/ctf/basic_narrative.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/scenarios/ctf/basic_narrative.xml b/scenarios/ctf/basic_narrative.xml
index e6a086379..2582204ec 100644
--- a/scenarios/ctf/basic_narrative.xml
+++ b/scenarios/ctf/basic_narrative.xml
@@ -453,6 +453,7 @@
attack_vm
+ IP_addresses
From b5ae825f4d387aec99268ac9aee82cada44df0ae Mon Sep 17 00:00:00 2001
From: ts
Date: Thu, 14 Feb 2019 14:56:39 +0000
Subject: [PATCH 33/47] Added firefox auto-open to basic narrative
---
scenarios/ctf/basic_narrative.xml | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/scenarios/ctf/basic_narrative.xml b/scenarios/ctf/basic_narrative.xml
index 2582204ec..5d44ed5e6 100644
--- a/scenarios/ctf/basic_narrative.xml
+++ b/scenarios/ctf/basic_narrative.xml
@@ -439,7 +439,7 @@
- IP_addresses
+ IP_addresses
@@ -454,9 +454,22 @@
attack_vm
+
+
+
+ {"username":"root","password":"toor","super_user":"","strings_to_leak":[],"leaked_filenames":[]}
+
+
+ true
+
+
+ IP_addresses
+
+
+
- IP_addresses
+ IP_addresses
From 4ee93f7e497e179ce137ad81481bfe54be3007ea Mon Sep 17 00:00:00 2001
From: ts
Date: Thu, 14 Feb 2019 14:58:33 +0000
Subject: [PATCH 34/47] added test string for Vagrantfile
---
lib/templates/Vagrantfile.erb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/templates/Vagrantfile.erb b/lib/templates/Vagrantfile.erb
index fe2d02346..05aea1512 100644
--- a/lib/templates/Vagrantfile.erb
+++ b/lib/templates/Vagrantfile.erb
@@ -149,7 +149,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# use some shell scripting to identify the name of the network interface (eth0/ens3/...), and set the IP address statically
<%= system.name %>.vm.provision 'shell', inline: "echo -e \"auto lo\niface lo inet loopback\n\nauto <%= interface %>\niface <%= interface %> inet static\n\taddress <%= resolve_network(selected_module)%>\" > /etc/network/interfaces"
<%= system.name %>.vm.provision 'shell', inline: "echo '' > /etc/environment"
-<% # Static Virtualbox networking -%>
+ <% # Below string is used within testing, do not delete. -%>
+ # ip_address_for_<%= system.name %>=<%= resolve_network(selected_module)%>
+ <% # Static Virtualbox networking -%>
<% else -%>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, ip: "<%= resolve_network(selected_module)%>"
<% # Below string is used within testing, do not delete. -%>
From 53bba1113365a4451a0af007176285fd49e14070 Mon Sep 17 00:00:00 2001
From: "Z. Cliffe Schreuders"
Date: Sat, 26 Jan 2019 20:11:17 +0000
Subject: [PATCH 35/47] lab updates (and related modules)
(cherry picked from commit 665b0589c88feedbf6553322b1c485d32212b899)
---
lib/objects/system.rb | 65 ++-
.../hbauthentication/hbauthentication.pp | 0
.../hbauthentication/manifests/.no_puppet | 0
.../hbauthentication/secgen_local/local.rb | 35 ++
.../hbauthentication/secgen_metadata.xml | 39 ++
.../hbauthentication/shared/labsheet.html.erb | 29 +
.../hbauthentication/shared/license.md.erb | 4 +
.../hbauthentication/templates/intro.md.erb | 299 ++++++++++
.../hbauthentication/templates/lab.xml.erb | 161 ++++++
.../templates/labsheet.html.erb | 114 ++++
.../hbauthentication/templates/license.md.erb | 6 +
.../templates/resources.md.erb | 0
.../integrity_protection/secgen_metadata.xml | 7 +-
.../kali_forensic/kali_forensic.pp | 1 +
.../kali_forensic/manifests/install.pp | 5 +
.../kali_forensic/secgen_metadata.xml | 25 +
.../kali_metapackages/kali_full/kali_full.pp | 1 +
.../kali_full/manifests/install.pp | 5 +
.../kali_full/secgen_metadata.xml | 25 +
.../kali_pwtools/kali_pwtools.pp | 1 +
.../kali_pwtools/manifests/install.pp | 5 +
.../kali_pwtools/secgen_metadata.xml | 25 +
.../kali_top10/kali_top10.pp | 1 +
.../kali_top10/manifests/install.pp | 5 +
.../kali_top10/secgen_metadata.xml | 25 +
.../kali_metapackages/kali_web/kali_web.pp | 1 +
.../kali_web/manifests/install.pp | 5 +
.../kali_web/secgen_metadata.xml | 25 +
.../setup_scripts/install-docker-debian.sh | 90 +++
.../unix/labtainers/manifests/config.pp | 12 +
.../unix/labtainers/manifests/install.pp | 27 +
.../dvwa/files/DVWA-master/.gitignore | 5 +-
.../dvwa/files/DVWA-master/README.md | 60 +-
.../DVWA-master/config/config.inc.php.dist | 2 +-
.../DVWA-master/dvwa/includes/DBMS/MySQL.php | 15 +-
.../dvwa/includes/dvwaPage.inc.php | 9 +-
.../dvwa/js/add_event_listeners.js | 24 +
.../files/DVWA-master/dvwa/js/dvwaPage.js | 3 +-
.../external/recaptcha/recaptchalib.php | 290 +---------
.../vulnerabilities/brute/help/help.php | 2 +-
.../brute/source/impossible.php | 2 +-
.../vulnerabilities/captcha/help/help.php | 4 +-
.../vulnerabilities/captcha/index.php | 2 +-
.../vulnerabilities/captcha/source/high.php | 35 +-
.../captcha/source/impossible.php | 10 +-
.../vulnerabilities/captcha/source/low.php | 10 +-
.../vulnerabilities/captcha/source/medium.php | 10 +-
.../vulnerabilities/csp/help/help.php | 52 ++
.../DVWA-master/vulnerabilities/csp/index.php | 57 ++
.../vulnerabilities/csp/source/high.js | 19 +
.../vulnerabilities/csp/source/high.php | 22 +
.../vulnerabilities/csp/source/impossible.js | 19 +
.../vulnerabilities/csp/source/impossible.php | 23 +
.../vulnerabilities/csp/source/jsonp.php | 13 +
.../csp/source/jsonp_impossible.php | 7 +
.../vulnerabilities/csp/source/low.php | 22 +
.../vulnerabilities/csp/source/medium.php | 25 +
.../vulnerabilities/javascript/help/help.php | 52 ++
.../vulnerabilities/javascript/index.php | 123 ++++
.../vulnerabilities/javascript/source/high.js | 1 +
.../javascript/source/high.php | 5 +
.../javascript/source/high_unobfuscated.js | 540 ++++++++++++++++++
.../javascript/source/impossible.php | 0
.../vulnerabilities/javascript/source/low.php | 24 +
.../javascript/source/medium.js | 1 +
.../javascript/source/medium.php | 5 +
.../vulnerabilities/upload/help/help.php | 2 +-
.../vulnerabilities/view_source.php | 20 +
.../vulnerabilities/view_source_all.php | 3 +
.../web_training/dvwa/manifests/apache.pp | 39 +-
.../web_training/dvwa/secgen_metadata.xml | 14 +-
.../examples/vulnerability_examples/dvwa.xml | 21 +-
scenarios/labs/ads_1_authentication.xml | 350 ++++++++++++
scenarios/labs/websec_lab_env.xml | 53 ++
74 files changed, 2647 insertions(+), 391 deletions(-)
create mode 100644 modules/generators/structured_content/hackerbot_config/hbauthentication/hbauthentication.pp
create mode 100644 modules/generators/structured_content/hackerbot_config/hbauthentication/manifests/.no_puppet
create mode 100644 modules/generators/structured_content/hackerbot_config/hbauthentication/secgen_local/local.rb
create mode 100644 modules/generators/structured_content/hackerbot_config/hbauthentication/secgen_metadata.xml
create mode 100644 modules/generators/structured_content/hackerbot_config/hbauthentication/shared/labsheet.html.erb
create mode 100644 modules/generators/structured_content/hackerbot_config/hbauthentication/shared/license.md.erb
create mode 100644 modules/generators/structured_content/hackerbot_config/hbauthentication/templates/intro.md.erb
create mode 100644 modules/generators/structured_content/hackerbot_config/hbauthentication/templates/lab.xml.erb
create mode 100644 modules/generators/structured_content/hackerbot_config/hbauthentication/templates/labsheet.html.erb
create mode 100644 modules/generators/structured_content/hackerbot_config/hbauthentication/templates/license.md.erb
create mode 100644 modules/generators/structured_content/hackerbot_config/hbauthentication/templates/resources.md.erb
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_forensic/kali_forensic.pp
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_forensic/manifests/install.pp
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_forensic/secgen_metadata.xml
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_full/kali_full.pp
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_full/manifests/install.pp
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_full/secgen_metadata.xml
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_pwtools/kali_pwtools.pp
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_pwtools/manifests/install.pp
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_pwtools/secgen_metadata.xml
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_top10/kali_top10.pp
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_top10/manifests/install.pp
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_top10/secgen_metadata.xml
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_web/kali_web.pp
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_web/manifests/install.pp
create mode 100644 modules/utilities/unix/attack_tools/kali_metapackages/kali_web/secgen_metadata.xml
create mode 100755 modules/utilities/unix/labtainers/files/labtainer.files/trunk/setup_scripts/install-docker-debian.sh
create mode 100644 modules/utilities/unix/labtainers/manifests/config.pp
create mode 100644 modules/utilities/unix/labtainers/manifests/install.pp
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/dvwa/js/add_event_listeners.js
mode change 100755 => 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/external/recaptcha/recaptchalib.php
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/csp/help/help.php
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/csp/index.php
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/csp/source/high.js
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/csp/source/high.php
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/csp/source/impossible.js
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/csp/source/impossible.php
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/csp/source/jsonp.php
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/csp/source/jsonp_impossible.php
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/csp/source/low.php
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/csp/source/medium.php
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/javascript/help/help.php
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/javascript/index.php
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/javascript/source/high.js
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/javascript/source/high.php
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/javascript/source/high_unobfuscated.js
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/javascript/source/impossible.php
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/javascript/source/low.php
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/javascript/source/medium.js
create mode 100644 modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/javascript/source/medium.php
create mode 100644 scenarios/labs/ads_1_authentication.xml
create mode 100644 scenarios/labs/websec_lab_env.xml
diff --git a/lib/objects/system.rb b/lib/objects/system.rb
index 30dbd4b2f..1012fe9eb 100644
--- a/lib/objects/system.rb
+++ b/lib/objects/system.rb
@@ -208,37 +208,42 @@ class System
datastore_access = datastore_variablename_and_access_type['access']
datastore_variablename = datastore_variablename_and_access_type['variablename']
datastore_retrieved = []
- if datastore_access == 'first'
- datastore_retrieved = [$datastore[datastore_variablename].first]
- elsif datastore_access == 'next'
- last_accessed = $datastore_iterators[datastore_variablename]
- # first use? start at beginning
- if last_accessed == nil
- index_to_access = 0
+ begin
+ if datastore_access == 'first'
+ datastore_retrieved = [$datastore[datastore_variablename].first]
+ elsif datastore_access == 'next'
+ last_accessed = $datastore_iterators[datastore_variablename]
+ # first use? start at beginning
+ if last_accessed == nil
+ index_to_access = 0
+ else
+ index_to_access = last_accessed + 1
+ end
+ $datastore_iterators[datastore_variablename] = index_to_access
+ datastore_retrieved = [$datastore[datastore_variablename][index_to_access]]
+ elsif datastore_access == 'previous'
+ last_accessed = $datastore_iterators[datastore_variablename]
+ # first use? start at end
+ if last_accessed == nil
+ index_to_access = $datastore[datastore_variablename].size - 1
+ else
+ index_to_access = last_accessed - 1
+ end
+ $datastore_iterators[datastore_variablename] = index_to_access
+ datastore_retrieved = [$datastore[datastore_variablename][index_to_access]]
+ elsif datastore_access.to_s == datastore_access.to_i.to_s
+ # Test for a valid element key (integer)
+ index_to_access = datastore_access.to_i
+ $datastore_iterators[datastore_variablename] = index_to_access
+ datastore_retrieved = [$datastore[datastore_variablename][index_to_access]]
+ elsif datastore_access == "all"
+ datastore_retrieved = $datastore[datastore_variablename]
else
- index_to_access = last_accessed + 1
+ Print.err "Error: invalid access value (#{datastore_access})"
+ raise 'failed'
end
- $datastore_iterators[datastore_variablename] = index_to_access
- datastore_retrieved = [$datastore[datastore_variablename][index_to_access]]
- elsif datastore_access == 'previous'
- last_accessed = $datastore_iterators[datastore_variablename]
- # first use? start at end
- if last_accessed == nil
- index_to_access = $datastore[datastore_variablename].size - 1
- else
- index_to_access = last_accessed - 1
- end
- $datastore_iterators[datastore_variablename] = index_to_access
- datastore_retrieved = [$datastore[datastore_variablename][index_to_access]]
- elsif datastore_access.to_s == datastore_access.to_i.to_s
- # Test for a valid element key (integer)
- index_to_access = datastore_access.to_i
- $datastore_iterators[datastore_variablename] = index_to_access
- datastore_retrieved = [$datastore[datastore_variablename][index_to_access]]
- elsif datastore_access == "all"
- datastore_retrieved = $datastore[datastore_variablename]
- else
- Print.err "Error: invalid access value (#{datastore_access})"
+ rescue NoMethodError, SyntaxError => err
+ Print.err "Error accessing element (#{datastore_access}) from datastore (#{datastore_variablename}): #{err}"
raise 'failed'
end
if datastore_retrieved && datastore_retrieved != [nil]
@@ -457,4 +462,4 @@ class System
modules_to_add
end
-end
\ No newline at end of file
+end
diff --git a/modules/generators/structured_content/hackerbot_config/hbauthentication/hbauthentication.pp b/modules/generators/structured_content/hackerbot_config/hbauthentication/hbauthentication.pp
new file mode 100644
index 000000000..e69de29bb
diff --git a/modules/generators/structured_content/hackerbot_config/hbauthentication/manifests/.no_puppet b/modules/generators/structured_content/hackerbot_config/hbauthentication/manifests/.no_puppet
new file mode 100644
index 000000000..e69de29bb
diff --git a/modules/generators/structured_content/hackerbot_config/hbauthentication/secgen_local/local.rb b/modules/generators/structured_content/hackerbot_config/hbauthentication/secgen_local/local.rb
new file mode 100644
index 000000000..91be58494
--- /dev/null
+++ b/modules/generators/structured_content/hackerbot_config/hbauthentication/secgen_local/local.rb
@@ -0,0 +1,35 @@
+#!/usr/bin/ruby
+require_relative '../../../../../../lib/objects/local_hackerbot_config_generator.rb'
+
+class HB < HackerbotConfigGenerator
+
+ attr_accessor :server_ip
+
+ def initialize
+ super
+ self.module_name = 'Hackerbot Config Generator Authentication'
+ self.title = 'Authentication'
+
+ self.local_dir = File.expand_path('../../',__FILE__)
+ self.templates_path = "#{self.local_dir}/templates/"
+ self.config_template_path = "#{self.local_dir}/templates/lab.xml.erb"
+ self.html_template_path = "#{self.local_dir}/templates/labsheet.html.erb"
+
+ self.server_ip = []
+ end
+
+ def get_options_array
+ super + [['--server_ip', GetoptLong::REQUIRED_ARGUMENT]]
+ end
+
+ def process_options(opt, arg)
+ super
+ case opt
+ when '--server_ip'
+ self.server_ip << arg;
+ end
+ end
+
+end
+
+HB.new.run
diff --git a/modules/generators/structured_content/hackerbot_config/hbauthentication/secgen_metadata.xml b/modules/generators/structured_content/hackerbot_config/hbauthentication/secgen_metadata.xml
new file mode 100644
index 000000000..59d09fa03
--- /dev/null
+++ b/modules/generators/structured_content/hackerbot_config/hbauthentication/secgen_metadata.xml
@@ -0,0 +1,39 @@
+
+
+
+ Hackerbot config for a authentication lab
+ Z. Cliffe Schreuders
+ GPLv3
+ Generates a config file for a hackerbot for an integrity lab.
+ Topics covered: .
+
+ hackerbot_config
+ linux
+
+ accounts
+ flags
+ root_password
+
+
+
+
+
+
+ vagrant
+
+
+
+
+
+
+
+
+
+ puppet
+
+
+ hackerbot
+
+
diff --git a/modules/generators/structured_content/hackerbot_config/hbauthentication/shared/labsheet.html.erb b/modules/generators/structured_content/hackerbot_config/hbauthentication/shared/labsheet.html.erb
new file mode 100644
index 000000000..72dab611a
--- /dev/null
+++ b/modules/generators/structured_content/hackerbot_config/hbauthentication/shared/labsheet.html.erb
@@ -0,0 +1,29 @@
+
+
+ <%= self.title %>
+
+
+
+
+
+
+
+ <%= self.html_rendered %>
+
+
+
+
+
diff --git a/modules/generators/structured_content/hackerbot_config/hbauthentication/shared/license.md.erb b/modules/generators/structured_content/hackerbot_config/hbauthentication/shared/license.md.erb
new file mode 100644
index 000000000..8e89ace31
--- /dev/null
+++ b/modules/generators/structured_content/hackerbot_config/hbauthentication/shared/license.md.erb
@@ -0,0 +1,4 @@
+## License
+This lab by [*Z. Cliffe Schreuders*](http://z.cliffe.schreuders.org) at Leeds Beckett University is licensed under a [*Creative Commons Attribution-ShareAlike 3.0 Unported License*](http://creativecommons.org/licenses/by-sa/3.0/deed.en_GB).
+
+Included software source code is also licensed under the GNU General Public License, either version 3 of the License, or (at your option) any later version.
diff --git a/modules/generators/structured_content/hackerbot_config/hbauthentication/templates/intro.md.erb b/modules/generators/structured_content/hackerbot_config/hbauthentication/templates/intro.md.erb
new file mode 100644
index 000000000..4fb95fc32
--- /dev/null
+++ b/modules/generators/structured_content/hackerbot_config/hbauthentication/templates/intro.md.erb
@@ -0,0 +1,299 @@
+# Authentication
+
+## Getting started
+### VMs in this lab
+
+==Start these VMs== (if you haven't already):
+- hackerbot_server (leave it running, you don't log into this)
+- desktop (you can sudo to get superuser access)
+- server (<%= $server_ip %>, you can ssh to this machine, but you don't have superuser access)
+- kali_cracker (you will use this to crack the hashes you find)
+
+### Your login details for the "desktop" and "server" VMs
+User: <%= $main_user %>
+Password: tiaspbiqe2r (**t**his **i**s **a** **s**ecure **p**assword **b**ut **i**s **q**uite **e**asy **2** **r**emember)
+
+You won't login to the hackerbot_server, but the VM needs to be running to complete the lab.
+
+### For marks in the module
+1. **You need to submit flags**. Note that the flags and the challenges in your VMs are different to other's in the class. Flags will be revealed to you as you complete challenges throughout the module. Flags look like this: ==flag{*somethingrandom*}==. Follow the link on the module page to submit your flags.
+2. **You need to document the work and your solutions in a Log Book**. This needs to include screenshots (including the flags) of how you solved each Hackerbot challenge and a writeup describing your solution to each challenge, and answering any "Log Book Questions". The Log Book will be submitted later in the semester.
+
+## Meet Hackerbot!
+
+
+This exercise involves interacting with Hackerbot, a chatbot who will attack your system. If you satisfy Hackerbot by completing the challenges she will reveal flags to you.
+
+**On the desktop VM:**
+
+==Open Pidgin and send some messages to Hackerbot:==
+
+- Try asking Hackerbot some questions
+- Send "help"
+- Send "list"
+- Send "hello"
+
+> If Hackerbot seems to be waiting or halted, simply say 'hi'
+
+Work through the below exercises, completing the Hackerbot challenges as noted.
+
+---
+
+## Introduction to authentication
+
+Authentication plays the important role of verifying an identity. For example, when someone gets into an airplane, sits down at a computer, picks up a mobile device, or uses a website, authentication is what is used to confirm that the person is who they claim to be. Authentication is an important first step *before* deciding how the system should act and what to allow.
+
+## Identity: users and groups
+
+Most computer systems have the concept of a user account. Although some devices such as mobile phones typically only have one user account, most modern computers can support having multiple users, each with their own identity. For example, a computer can have a separate account for each person that uses it, and if configured to do so may enable each user to have their own account preferences, and access to different resources.
+
+On Unix/Linux systems every user account is identified by a user ID number (UID), which is a 32-bit integer (whole number), and can have one or more user names, which are human readable strings of text.
+
+**On the desktop VM:**
+
+Open a terminal console.
+
+Assuming you have already logged in, you have already authenticated yourself on this system.
+
+==Log Book Question: When and how did you authenticate yourself?==
+
+Use these commands to find out about your current identity (or more accurately the identity of the software you are interacting with):
+
+```bash
+whoami
+
+groups
+
+id
+```
+
+==Make a note of your UID and username.==
+
+Note that your account is also a member of one or more groups. A primary group, and a list of other groups. Some Linux systems, such as Debian, create a new seperate primary group for each user, others such as openSUSE have a shared group (named "users") that all normal users are a member of. Similar to the relationship between user names and UIDs, each group has a group name, and a group ID (GID).
+
+Information about user accounts is stored in the /etc/passwd file, which typically all users can read.
+
+==View the /etc/passwd file:==
+
+```bash
+less /etc/passwd
+```
+
+==Find the line that describes your user account.==
+
+This line defines the username, password (well, it used to be stored here... we will come back to this), UID, primary group GID, full name, home directory, and shell for your account.
+
+Confirm this matches the information you recorded earlier.
+
+==Find the line that describes the root user account.==
+
+==Where is the root user's home directory?==
+
+> Press 'q' to quit less.
+
+==View the /etc/group file:==
+
+```bash
+less /etc/group
+```
+
+Groups are defined in this file, along with which users are members.
+
+==Which users are members of the audio group?==
+
+Remember, primary groups do not appear in this file; for example, on openSUSE the "users" group, which all normal users are a member of, may not appear in the /etc/group file.
+
+The "su" program can be used to run a program (usually a shell; that is, a command prompt) as another user, effectively enabling users to switch between user accounts at the command prompt.
+
+==Change your identity to root==. Run:
+
+```bash
+su -
+```
+
+Enter the root password.
+
+Use these commands to ==find out about your new identity:==
+
+```bash
+whoami
+
+groups
+
+id
+```
+
+==What is the UID of root? What does this mean about this user?==
+
+==Lab Book Question: What gives this user special privileges: the name of the account, or the UID?==
+
+==Use the useradd command to create a new user account "fred"==
+
+> Hint: refer to the man page for useradd, by running "man useradd".
+
+==Set a password for the user fred.==
+
+> Hint: `sudo passwd fred`
+
+==Change identity to fred.==
+
+> Hint: `su - fred`
+
+==Run:(after su)==
+
+```bash
+id
+```
+
+==Compare the result to the previous output.==
+
+==How does this compare to your other normal user account? What is different, and what about it is the same?==
+
+Run the single command "id" as root:
+
+```bash
+sudo id
+```
+
+==Log Book Question: What is the difference between sudo and su? Which is most likely protect against accidental damage and also log the commands used?==
+
+## Users and SSH
+
+==Log in to the server via ssh:==
+
+```bash
+ssh <%= $main_user %>@<%= $server_ip %>
+```
+
+==Display details of all users logged on to the system:==
+
+```bash
+who
+```
+
+==List all the processes run by all users:==
+
+```bash
+ps -eo user,comm
+```
+
+==List all the processes running as root:==
+
+```bash
+ps -o user,comm -u root
+```
+
+==Run a command to list all the processes running as *your* normal user.==
+
+==Lab Book Question: How is this server authenticating users? What user accounts exist?==
+
+## Passwords, hashes and salt
+
+Given that important security decisions are made based on the user accounts, it is important to authenticate users, to ensure that the subjects are associated with the correct identity.
+
+==What are the kinds of factors that can be used to verify a user's identity? Hint: for example, "something they have".==
+
+==Which category of authentication factors is a password considered to be?==
+
+Originally passwords were stored "in the clear" (not enciphered). For example, Multics stored passwords in a file, and once at MIT a software bug caused the password file to be copied to the motd file (message of the day), which was printed every time anyone logged into the system. A solution is not to store the password in the clear. Instead a hash can be computed, using a one way hash function, and stored. When the user enters a password, a new hash is computed and compared to the original.
+
+On Linux, the command "shasum" can be used to check the integrity of files (hash functions have many uses), and works on the same principle. We can use it to generate a hash for any given string, for example a password:
+
+```bash
+shasum
+```
+
+> Type "hello" without the quotes. Press Ctrl-D (which indicates "EOF"; that is, end of input).
+
+Repeat the above, with the same password ("hello"), and with a slight difference ("hello.").
+
+Are the outputs the same?
+
+Are the different hashes similar?
+
+Is this good? Why?
+
+Which one-way hash function does the shasum program use? Would this be a good option for hashing passwords?
+
+For password authentication, the hash still needs to be stored. On Unix, password hashes were once stored in the world-readable file /etc/passwd, now they are typically stored in /etc/shadow, which only root (the superuser) can access.
+
+==View the shadow file:==
+
+```bash
+sudo less /etc/shadow
+```
+
+The format of the shadow file is:
+
+> username:**password**:last-changed(since 1-1-1970):days-until-may-change:days-until-must-change:days-warning-notice:days-since-expired-account-disabled:date-disable:reserved-field
+
+==Find the hash of your user account's password.==
+
+> Exit less ("q").
+
+Use the passwd command to ==change your password:==
+
+```bash
+passwd
+```
+
+> When prompted, enter a new password of your choosing.
+
+View the shadow file, and confirm that the stored password has changed.
+
+With reference to the shadow file, and the man page for crypt (Hint: "man crypt"), ==answer these Log Book questions==:
+
+- On Linux, the password hash stored in /etc/shadow has a prefix that specifies the hash function used.\
+ > ==What hash function is used for your password?==
+ > Hint: the `hash-identifier` command line tool may also help.
+
+- ==When was the root password last changed?==
+
+- ==Do any accounts have a setting that will force a password change at a specific date?==
+
+A salt is a random string, used as further input into a one-way hash function (concatenated to the password). The salt is typically stored along with the hash. As a result the same password will have different hashes, so long as the salt is different.
+
+Why is that a good thing?
+
+What kind of attack does a salt defend against?
+
+What is the current salt for your account? Hint: it is stored after the second "\$".
+
+## Password weaknesses
+
+The strength of a password depends on its entropy: its degree of randomness. If a user chooses a word from a dictionary, it would not take long to attempt every dictionary word until finding one that results in the same hash.
+
+Try your hand at cracking passwords using the Kali virtual machine.
+
+**On your desktop VM:**
+Add some new users with these passwords:
+> Hello
+>
+> hellothere
+>
+> password1
+
+**On your Kali VM:**
+==Use John the Ripper (or Johnny a GUI for the John the Ripper) to crack the passwords.==
+> Hint: `man john`, on the Kali Linux system.
+> You will need to combine the passwd and shadow files (manually or with the kali `unshadow` command.)
+
+==Log Book Questions:==
+- Which passwords are cracked the fastest?
+
+- How long did they take?
+
+
+## Conclusion
+
+At this point you have:
+
+- Applied authentication concepts to Unix/Linux
+
+- Experimented with user accounts and identity
+
+- Experimented with one-way hash functions, salts, and password storage
+
+- Cracked passwords with low entropy using dictionary attacks
+
+Well done!
diff --git a/modules/generators/structured_content/hackerbot_config/hbauthentication/templates/lab.xml.erb b/modules/generators/structured_content/hackerbot_config/hbauthentication/templates/lab.xml.erb
new file mode 100644
index 000000000..20053effd
--- /dev/null
+++ b/modules/generators/structured_content/hackerbot_config/hbauthentication/templates/lab.xml.erb
@@ -0,0 +1,161 @@
+<%
+ require 'json'
+ require 'securerandom'
+ require 'digest/sha1'
+ require 'fileutils'
+ require 'erb'
+
+ if self.accounts.empty?
+ abort('Sorry, you need to provide an account')
+ end
+
+ $first_account = JSON.parse(self.accounts.first)
+
+ $main_user = $first_account['username'].to_s
+ $main_user_pass = $first_account['password'].to_s
+
+ $server_ip = self.server_ip.first
+ $root_password = self.root_password
+ $flags = self.flags
+
+ REQUIRED_FLAGS = 1
+ while $flags.length < REQUIRED_FLAGS
+ $flags << "flag{#{SecureRandom.hex}}"
+ Print.err "Warning: Not enough flags provided to hackerbot_config generator, some flags won't be tracked/marked!"
+ end
+
+ def get_binding
+ binding
+ end
+%>
+
+
+
+
+
+ Hackerbot
+
+ config/AIML
+
+
+ sshpass -p <%= $root_password %> ssh -oStrictHostKeyChecking=no root@{{chat_ip_address}} /bin/bash
+
+
+
+
+ Hi there. Today I'm your boss of sorts. I need you to test the security of our server. Help out and I'll give you some flags.
+
+
+ When you are ready, simply say 'ready'.
+ 'Ready'?
+ Ok, I'll do what I can to move things along...
+ Moving things along to the next one...
+ Ok, I'll do what I can to back things up...
+ Ok, backing up.
+ Ok, skipping it along.
+ Let me see what I can do to goto that attack.
+ That was the last one for now. You can rest easy, until next time... (End.)
+ That was the last one. Game over?
+ You are back to the beginning!
+ This is where it all began.
+ Doing my thing...
+ Here we go...
+ ...
+ ....
+ Let me know when you are 'ready', if you want to move on say 'next', or 'previous' and I'll move things along.
+ Say 'ready', 'next', or 'previous'.
+
+
+ I am waiting for you to say 'ready', 'next', 'previous', 'list', 'goto *X*', or 'answer *X*'
+ Say "The answer is *X*".
+ There is no question to answer
+ Correct
+ Incorrect
+ That's not possible.
+ Wouldn't you like to know.
+
+
+ Oh no. Failed to get shell... You need to let us in.
+
+
+
+ Authentication
+ <%= ERB.new(File.read self.templates_path + 'intro.md.erb').result(self.get_binding) %>
+
+
+ true
+
+
+
+
+
+ <% $newuser = "user#{SecureRandom.hex(2)}" -%>
+
+ Add a user to the system, named "<%= $newuser %>".
+ grep <%= $newuser %> /etc/shadow; echo $?
+
+
+ 0
+ :) Well done! <%= $flags.pop %>
+
+
+
+ 1
+ :( It looks like you forgot to create the user?
+
+
+ :( User not found
+
+
+
+
+
+
+ Add the new <%= $newuser %> user to the 'users' group.
+ id <%= $newuser %> | grep users; echo $?
+
+
+ 0
+ :) Well done! <%= $flags.pop %>
+
+
+
+ 1
+ :( It looks like you forgot to add the user to the group?
+
+
+ :( Group not found
+
+
+
+
+
+
+ Crack the passwords of the users on the desktop VM, and use those credentials to SSH to the server, where you will find flags (ssh username@<%= $server_ip %> for each username you crack the password for.) This is the end.
+
+
+ .*
+ :)
+
+
+
+ .*
+ :)
+
+
+
+ :)
+
+
+
+
+
+
diff --git a/modules/generators/structured_content/hackerbot_config/hbauthentication/templates/labsheet.html.erb b/modules/generators/structured_content/hackerbot_config/hbauthentication/templates/labsheet.html.erb
new file mode 100644
index 000000000..0bb7cc90a
--- /dev/null
+++ b/modules/generators/structured_content/hackerbot_config/hbauthentication/templates/labsheet.html.erb
@@ -0,0 +1,114 @@
+
+
+ <%= self.title %>
+
+
+
+
+
+
+ <%= self.html_TOC_rendered %>
+
+
+
+ <%= self.html_rendered %>
+
+
+
+
diff --git a/modules/generators/structured_content/hackerbot_config/hbauthentication/templates/license.md.erb b/modules/generators/structured_content/hackerbot_config/hbauthentication/templates/license.md.erb
new file mode 100644
index 000000000..c11478e8e
--- /dev/null
+++ b/modules/generators/structured_content/hackerbot_config/hbauthentication/templates/license.md.erb
@@ -0,0 +1,6 @@
+## License
+This lab by [*Z. Cliffe Schreuders*](http://z.cliffe.schreuders.org) at Leeds Beckett University is licensed under a [*Creative Commons Attribution-ShareAlike 3.0 Unported License*](http://creativecommons.org/licenses/by-sa/3.0/deed.en_GB).
+
+Included software source code is also licensed under the GNU General Public License, either version 3 of the License, or (at your option) any later version.
+
+
diff --git a/modules/generators/structured_content/hackerbot_config/hbauthentication/templates/resources.md.erb b/modules/generators/structured_content/hackerbot_config/hbauthentication/templates/resources.md.erb
new file mode 100644
index 000000000..e69de29bb
diff --git a/modules/generators/structured_content/hackerbot_config/integrity_protection/secgen_metadata.xml b/modules/generators/structured_content/hackerbot_config/integrity_protection/secgen_metadata.xml
index a748298ff..bb040ff7e 100644
--- a/modules/generators/structured_content/hackerbot_config/integrity_protection/secgen_metadata.xml
+++ b/modules/generators/structured_content/hackerbot_config/integrity_protection/secgen_metadata.xml
@@ -29,10 +29,7 @@
-
-
-
-
+
@@ -41,4 +38,4 @@
hackerbot
-
\ No newline at end of file
+
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_forensic/kali_forensic.pp b/modules/utilities/unix/attack_tools/kali_metapackages/kali_forensic/kali_forensic.pp
new file mode 100644
index 000000000..b84aee99a
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_forensic/kali_forensic.pp
@@ -0,0 +1 @@
+include kali_forensic::install
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_forensic/manifests/install.pp b/modules/utilities/unix/attack_tools/kali_metapackages/kali_forensic/manifests/install.pp
new file mode 100644
index 000000000..d7f7ed569
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_forensic/manifests/install.pp
@@ -0,0 +1,5 @@
+class kali_forensic::install{
+ package { ['kali-linux-forensic']:
+ ensure => 'installed',
+ }
+}
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_forensic/secgen_metadata.xml b/modules/utilities/unix/attack_tools/kali_metapackages/kali_forensic/secgen_metadata.xml
new file mode 100644
index 000000000..c3ec2b3ff
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_forensic/secgen_metadata.xml
@@ -0,0 +1,25 @@
+
+
+
+ Kali Linux Metapackage: kali-linux-forensic
+ Z. Cliffe Schreuders
+ GPLv3
+ Installs a collection of software onto Kali.
+ kali-linux-forensic
+ If you are doing forensics work, you don’t want your analysis system to contain a bunch of unnecessary tools. To the rescue comes the kali-linux-forensic metapackage, which only contains the forensics tools in Kali.
+ Installation Size: 3.1 GB
+
+ attack_tools
+ linux
+
+
+ Kali Light.*
+ attack
+ desktop
+
+
+ update
+
+
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_full/kali_full.pp b/modules/utilities/unix/attack_tools/kali_metapackages/kali_full/kali_full.pp
new file mode 100644
index 000000000..f21676bc1
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_full/kali_full.pp
@@ -0,0 +1 @@
+include kali_full::install
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_full/manifests/install.pp b/modules/utilities/unix/attack_tools/kali_metapackages/kali_full/manifests/install.pp
new file mode 100644
index 000000000..dfb110de6
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_full/manifests/install.pp
@@ -0,0 +1,5 @@
+class kali_full::install{
+ package { ['kali-linux-full']:
+ ensure => 'installed',
+ }
+}
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_full/secgen_metadata.xml b/modules/utilities/unix/attack_tools/kali_metapackages/kali_full/secgen_metadata.xml
new file mode 100644
index 000000000..aad49a1ea
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_full/secgen_metadata.xml
@@ -0,0 +1,25 @@
+
+
+
+ Kali Linux Metapackage: kali-linux-full
+ Z. Cliffe Schreuders
+ GPLv3
+ Installs a collection of software onto Kali.
+ kali-linux-full
+ When you download a Kali Linux ISO, you are essentially downloading an installation that has the kali-linux-full metapackage installed. This package includes all of the tools you are familiar with in Kali.
+ Installation Size: 9.0 GB
+
+ attack_tools
+ linux
+
+
+ Kali Light.*
+ attack
+ desktop
+
+
+ update
+
+
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_pwtools/kali_pwtools.pp b/modules/utilities/unix/attack_tools/kali_metapackages/kali_pwtools/kali_pwtools.pp
new file mode 100644
index 000000000..9c6c591e5
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_pwtools/kali_pwtools.pp
@@ -0,0 +1 @@
+include kali_pwtools::install
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_pwtools/manifests/install.pp b/modules/utilities/unix/attack_tools/kali_metapackages/kali_pwtools/manifests/install.pp
new file mode 100644
index 000000000..cfdc535fa
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_pwtools/manifests/install.pp
@@ -0,0 +1,5 @@
+class kali_pwtools::install{
+ package { ['kali-linux-pwtools']:
+ ensure => 'installed',
+ }
+}
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_pwtools/secgen_metadata.xml b/modules/utilities/unix/attack_tools/kali_metapackages/kali_pwtools/secgen_metadata.xml
new file mode 100644
index 000000000..204aab2b0
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_pwtools/secgen_metadata.xml
@@ -0,0 +1,25 @@
+
+
+
+ Kali Linux Metapackage: kali-linux-pwtools
+ Z. Cliffe Schreuders
+ GPLv3
+ Installs a collection of software onto Kali.
+ kali-linux-pwtools
+ The kali-linux-pwtools metapackage contains over 40 different password cracking utilities as well as the GPU tools contained in kali-linux-gpu.
+ Installation Size: 6.0 GB
+
+ attack_tools
+ linux
+
+
+ Kali Light.*
+ attack
+ desktop
+
+
+ update
+
+
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_top10/kali_top10.pp b/modules/utilities/unix/attack_tools/kali_metapackages/kali_top10/kali_top10.pp
new file mode 100644
index 000000000..2bf2404df
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_top10/kali_top10.pp
@@ -0,0 +1 @@
+include kali_top10::install
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_top10/manifests/install.pp b/modules/utilities/unix/attack_tools/kali_metapackages/kali_top10/manifests/install.pp
new file mode 100644
index 000000000..b45b4a3d4
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_top10/manifests/install.pp
@@ -0,0 +1,5 @@
+class kali_top10::install{
+ package { ['kali-linux-top10']:
+ ensure => 'installed',
+ }
+}
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_top10/secgen_metadata.xml b/modules/utilities/unix/attack_tools/kali_metapackages/kali_top10/secgen_metadata.xml
new file mode 100644
index 000000000..bac3c97b4
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_top10/secgen_metadata.xml
@@ -0,0 +1,25 @@
+
+
+
+ Kali Linux Metapackage: kali-linux-top10
+ Z. Cliffe Schreuders
+ GPLv3
+ Installs a collection of software onto Kali.
+ kali-linux-top10
+ In Kali Linux, we have a sub-menu called “Top 10 Security Tools”. The kali-linux-top10 metapackage will install all of these tools for you in one fell swoop.
+ Installation Size: 3.5 GB
+
+ attack_tools
+ linux
+
+
+ Kali Light.*
+ attack
+ desktop
+
+
+ update
+
+
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_web/kali_web.pp b/modules/utilities/unix/attack_tools/kali_metapackages/kali_web/kali_web.pp
new file mode 100644
index 000000000..00df4deed
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_web/kali_web.pp
@@ -0,0 +1 @@
+include kali_web::install
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_web/manifests/install.pp b/modules/utilities/unix/attack_tools/kali_metapackages/kali_web/manifests/install.pp
new file mode 100644
index 000000000..9b0c523c2
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_web/manifests/install.pp
@@ -0,0 +1,5 @@
+class kali_web::install{
+ package { ['kali-linux-web']:
+ ensure => 'installed',
+ }
+}
diff --git a/modules/utilities/unix/attack_tools/kali_metapackages/kali_web/secgen_metadata.xml b/modules/utilities/unix/attack_tools/kali_metapackages/kali_web/secgen_metadata.xml
new file mode 100644
index 000000000..62a788d0a
--- /dev/null
+++ b/modules/utilities/unix/attack_tools/kali_metapackages/kali_web/secgen_metadata.xml
@@ -0,0 +1,25 @@
+
+
+
+ Kali Linux Metapackage: kali-linux-web
+ Z. Cliffe Schreuders
+ GPLv3
+ Installs a collection of software onto Kali.
+ kali-linux-web
+ Web application assessments are very common in the field of penetration testing and for this reason, Kali includes the kali-linux-web metapackage containing dozens of tools related to web application hacking.
+ Installation Size: 4.9 GB
+
+ attack_tools
+ linux
+
+
+ Kali Light.*
+ attack
+ desktop
+
+
+ update
+
+
diff --git a/modules/utilities/unix/labtainers/files/labtainer.files/trunk/setup_scripts/install-docker-debian.sh b/modules/utilities/unix/labtainers/files/labtainer.files/trunk/setup_scripts/install-docker-debian.sh
new file mode 100755
index 000000000..261e410ea
--- /dev/null
+++ b/modules/utilities/unix/labtainers/files/labtainer.files/trunk/setup_scripts/install-docker-debian.sh
@@ -0,0 +1,90 @@
+#!/bin/bash
+: <<'END'
+This software was created by United States Government employees at
+The Center for the Information Systems Studies and Research (CISR)
+at the Naval Postgraduate School NPS. Please note that within the
+United States, copyright protection is not available for any works
+created by United States Government employees, pursuant to Title 17
+United States Code Section 105. This software is in the public
+domain and is not subject to copyright.
+END
+#
+#Install Docker on a Debian system, along with other packages required by Labtainers
+#
+type sudo >/dev/null 2>&1 || { echo >&2 "Please install sudo. Aborting."; exit 1; }
+sudo -v || { echo >&2 "Please make sure user is sudoer. Aborting."; exit 1; }
+#needed packages for Docker install
+sudo apt-get update
+sudo apt-get -y install apt-transport-https ca-certificates curl gnupg2 software-properties-common
+
+#adds Docker�s official GPG Key
+curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
+
+#used to verify matching Key ID (optional)
+#sudo apt-key fingerprint 0EBFCD88
+
+#sets up stable repository
+sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
+
+#installs Docker:Community Edition
+sudo apt-get update
+# SecGen change: repo is unauthenticated
+sudo apt-get -y --allow-unauthenticated install docker-ce
+
+#gives user access to docker commands
+sudo groupadd docker
+sudo usermod -aG docker $USER
+
+#enables and starts docker
+sudo systemctl start docker
+sudo systemctl enable docker
+
+#additional packages needed for labtainers
+sudo apt-get -y install python-pip
+sudo pip install --upgrade pip
+sudo pip install netaddr parse python-dateutil
+sudo apt-get -y install openssh-server
+
+#---Checking if packages have been installed. If not, the system will not reboot and allow the user to investigate.
+declare -a packagelist=("apt-transport-https" "ca-certificates" "curl" "gnupg2" "software-properties-common" "docker-ce" "python-pip" "openssh-server")
+packagefail="false"
+
+for i in "${packagelist[@]}"
+do
+#echo $i
+packagecheck=$(dpkg -s $i 2> /dev/null | grep Status)
+#echo $packagecheck
+ if [ "$packagecheck" != "Status: install ok installed" ]; then
+ if [ $i = docker-ce ];then
+ echo "ERROR: '$i' package did not install properly. Please check the terminal output above for any errors related to the pacakge installation. Run the install script two more times. If the issue persists, go to docker docs and follow the instructions for installing docker. (Make sure the instructions is CE and is for your Linux distribution,e.g., Ubuntu and Fedora.)"
+ else
+ echo "ERROR: '$i' package did not install properly. Please check the terminal output above for any errors related to the pacakge installation. Try installing the '$i' package individually by executing this in the command line: 'sudo apt-get install $i"
+ fi
+ packagefail="true"
+ #echo $packagefail
+ fi
+done
+
+pipcheck=$(pip list 2> /dev/null | grep -F netaddr)
+#echo $pipcheck
+if [ -z "$pipcheck" ]; then
+ echo "ERROR: 'netaddr' package did not install properly. Please check the terminal output for any errors related to the pacakge installation. Make sure 'python-pip' is installed and then try running this command: 'sudo -H pip install netaddr' "
+ packagefail="true"
+ #echo $packagefail
+fi
+
+pipcheck=$(pip list 2> /dev/null | grep -F parse)
+#echo $pipcheck
+if [ -z "$pipcheck" ]; then
+ echo "ERROR: 'parse' package did not install properly. Please check the terminal output for any errors related to the package installation. Make sure 'python-pip' is installed and then try running this command: 'sudo -H pip install parse' "
+ packagefail="true"
+ #echo $packagefail
+fi
+
+if [ $packagefail = "true" ]; then
+ exit 1
+fi
+
+exit 0
+
+#Notes: The �-y� after each install means that the user doesn�t need to press �y� in between each package download. The install script is based on this page: https://docs.docker.com/engine/installation/linux/docker-ce/debian/
diff --git a/modules/utilities/unix/labtainers/manifests/config.pp b/modules/utilities/unix/labtainers/manifests/config.pp
new file mode 100644
index 000000000..dfb24ddb1
--- /dev/null
+++ b/modules/utilities/unix/labtainers/manifests/config.pp
@@ -0,0 +1,12 @@
+class labtainers::config{
+ require labtainers::install
+
+ $secgen_parameters = secgen_functions::get_parameters($::base64_inputs_file)
+ $lab = $secgen_parameters['lab'][0]
+
+ exec { 'start lab':
+ command => "/opt/labtainers/labtainer-student/labtainer $lab",
+ provider => shell,
+ }
+
+}
diff --git a/modules/utilities/unix/labtainers/manifests/install.pp b/modules/utilities/unix/labtainers/manifests/install.pp
new file mode 100644
index 000000000..c140d6ea6
--- /dev/null
+++ b/modules/utilities/unix/labtainers/manifests/install.pp
@@ -0,0 +1,27 @@
+class labtainers::install{
+ # $json_inputs = base64('decode', $::base64_inputs)
+ # $secgen_parameters = parsejson($json_inputs)
+ # $server_ip = $secgen_parameters['server_ip'][0]
+ # $port = $secgen_parameters['port'][0]
+
+
+ # these are also installed by the install script, but good to use puppet where possible
+ package { ['apt-transport-https', 'ca-certificates', 'curl', 'gnupg2', 'software-properties-common', 'python-pip', 'openssh-server']:
+ ensure => 'installed',
+ } ->
+
+ file { '/opt/labtainers':
+ ensure => directory,
+ recurse => true,
+ source => 'puppet:///modules/labtainers/labtainer.files',
+ mode => '0766',
+ owner => 'root',
+ group => 'root',
+ } ->
+
+ exec { 'install script':
+ command => '/opt/labtainers/install-labtainer.sh',
+ provider => shell,
+ }
+
+}
diff --git a/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/.gitignore b/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/.gitignore
index 319a2c383..723dba7b5 100644
--- a/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/.gitignore
+++ b/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/.gitignore
@@ -1,2 +1,5 @@
config/config.inc.php
-Dockerfile
\ No newline at end of file
+Dockerfile
+
+# Vim swap files
+.*swp
diff --git a/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/README.md b/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/README.md
index 9c90823db..4908c787d 100644
--- a/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/README.md
+++ b/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/README.md
@@ -12,7 +12,7 @@ Damn Vulnerable Web Application is damn vulnerable! **Do not upload it to your h
### Disclaimer
-We do not take responsibility for the way in which any one uses this application (DVWA). We have made the purposes of the application clear and it should not be used maliciously. We have given warnings and taken measures to prevent users from installing DVWA on to live web servers. If your web server is compromised via an installation of DVWA it is not our responsibility it is the responsibility of the person/s who uploaded and installed it.
+We do not take responsibility for the way in which any one uses this application (DVWA). We have made the purposes of the application clear and it should not be used maliciously. We have given warnings and taken measures to prevent users from installing DVWA on to live web servers. If your web server is compromised via an installation of DVWA, it is not our responsibility, it is the responsibility of the person/s who uploaded and installed it.
- - -
@@ -37,8 +37,8 @@ along with Damn Vulnerable Web Application (DVWA). If not, see http://www.gnu.o
## Download and install as a docker container
- [dockerhub page](https://hub.docker.com/r/vulnerables/web-dvwa/)
`docker run --rm -it -p 80:80 vulnerables/web-dvwa`
-
-Please ensure you are using aufs due to previous MySQL issues. Run `docker info` to check your storage driver. If it isn't aufs, please change it as such. There are guides for each operating system on how to do that, but they're quite different so we won't cover that here.
+
+Please ensure you are using aufs due to previous MySQL issues. Run `docker info` to check your storage driver. If it isn't aufs, please change it as such. There are guides for each operating system on how to do that, but they're quite different so we won't cover that here.
## Download
@@ -74,7 +74,7 @@ Simply unzip dvwa.zip, place the unzipped files in your public html folder, then
If you are using a Debian based Linux distribution, you will need to install the following packages _(or their equivalent)_:
-`apt-get -y install apache2 mysql-server php php-mysqli php-gd libapache2-mod-php`
+`apt-get -y install apache2 mysql-server php php-mysqli php-gd libapache2-mod-php`
### Database Setup
@@ -84,30 +84,36 @@ If you receive an error while trying to create your database, make sure your dat
The variables are set to the following by default:
-```php
+```php
$_DVWA[ 'db_user' ] = 'root';
$_DVWA[ 'db_password' ] = 'p@ssw0rd';
$_DVWA[ 'db_database' ] = 'dvwa';
-```
-
-Note, if you are using MariaDB rather than MySQL (MariaDB is default in Kali), then you can't use the database root user, you must create a new database user. To do this, connect to the database as the root user then use the following commands:
-
-```mysql
-mysql> create database dvwa;
-Query OK, 1 row affected (0.00 sec)
-
-mysql> grant all on dvwa.* to dvwa@localhost identified by 'xxx';
-Query OK, 0 rows affected, 1 warning (0.01 sec)
-
-mysql> flush privileges;
-Query OK, 0 rows affected (0.00 sec)
-
-
-```
-
+```
+
+Note, if you are using MariaDB rather than MySQL (MariaDB is default in Kali), then you can't use the database root user, you must create a new database user. To do this, connect to the database as the root user then use the following commands:
+
+```mysql
+mysql> create database dvwa;
+Query OK, 1 row affected (0.00 sec)
+
+mysql> grant all on dvwa.* to dvwa@localhost identified by 'SuperSecretPassword99';
+Query OK, 0 rows affected, 1 warning (0.01 sec)
+
+mysql> flush privileges;
+Query OK, 0 rows affected (0.00 sec)
+```
+
+You will then need to update the config file, the new entries will look like this:
+
+```php
+$_DVWA[ 'db_user' ] = 'dvwa';
+$_DVWA[ 'db_password' ] = 'SuperSecretPassword99';
+$_DVWA[ 'db_database' ] = 'dvwa';
+```
+
### Other Configuration
-Depending on your Operating System as well as version of PHP, you may wish to alter the default configuration. The location of the files will be different on a per-machine basis.
+Depending on your Operating System, as well as version of PHP, you may wish to alter the default configuration. The location of the files will be different on a per-machine basis.
**Folder Permissions**:
@@ -143,7 +149,7 @@ https://github.com/ethicalhack3r/DVWA/issues
+Q. SQL Injection won't work on PHP v5.2.6.
--A.If you are using PHP v5.2.6 or above you will need to do the following in order for SQL injection and other vulnerabilities to work.
+-A.If you are using PHP v5.2.6 or above, you will need to do the following in order for SQL injection and other vulnerabilities to work.
In `.htaccess`:
@@ -171,6 +177,12 @@ With:
-A. Apache may not have high enough privileges to run commands on the web server. If you are running DVWA under Linux make sure you are logged in as root. Under Windows log in as Administrator.
++Q. Why can't the database connect on CentOS?
+
+-A. You may be running into problems with SELinux. Either disable SELinux or run this command to allow the webserver to talk to the database:
+```
+setsebool -P httpd_can_network_connect_db 1
+```
- - -
diff --git a/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/config/config.inc.php.dist b/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/config/config.inc.php.dist
index a03dd25fd..41d9ce582 100644
--- a/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/config/config.inc.php.dist
+++ b/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/config/config.inc.php.dist
@@ -25,7 +25,7 @@ $_DVWA[ 'db_port '] = '5432';
# ReCAPTCHA settings
# Used for the 'Insecure CAPTCHA' module
-# You'll need to generate your own keys at: https://www.google.com/recaptcha/admin/create
+# You'll need to generate your own keys at: https://www.google.com/recaptcha/admin
$_DVWA[ 'recaptcha_public_key' ] = '';
$_DVWA[ 'recaptcha_private_key' ] = '';
diff --git a/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/dvwa/includes/DBMS/MySQL.php b/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/dvwa/includes/DBMS/MySQL.php
index 3af6617eb..c39061288 100644
--- a/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/dvwa/includes/DBMS/MySQL.php
+++ b/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/dvwa/includes/DBMS/MySQL.php
@@ -47,17 +47,14 @@ dvwaMessagePush( "'users' table was created." );
// Insert some data into users
-// Get the base directory for the avatar media...
-$baseUrl = 'http://' . $_SERVER[ 'SERVER_NAME' ] . $_SERVER[ 'PHP_SELF' ];
-$stripPos = strpos( $baseUrl, 'setup.php' );
-$baseUrl = substr( $baseUrl, 0, $stripPos ) . 'hackable/users/';
+$avatarUrl = '/hackable/users/';
$insert = "INSERT INTO users VALUES
- ('1','admin','admin','admin',MD5('password'),'{$baseUrl}admin.jpg', NOW(), '0'),
- ('2','Gordon','Brown','gordonb',MD5('abc123'),'{$baseUrl}gordonb.jpg', NOW(), '0'),
- ('3','Hack','Me','1337',MD5('charley'),'{$baseUrl}1337.jpg', NOW(), '0'),
- ('4','Pablo','Picasso','pablo',MD5('letmein'),'{$baseUrl}pablo.jpg', NOW(), '0'),
- ('5','Bob','Smith','smithy',MD5('password'),'{$baseUrl}smithy.jpg', NOW(), '0');";
+ ('1','admin','admin','admin',MD5('password'),'{$avatarUrl}admin.jpg', NOW(), '0'),
+ ('2','Gordon','Brown','gordonb',MD5('abc123'),'{$avatarUrl}gordonb.jpg', NOW(), '0'),
+ ('3','Hack','Me','1337',MD5('charley'),'{$avatarUrl}1337.jpg', NOW(), '0'),
+ ('4','Pablo','Picasso','pablo',MD5('letmein'),'{$avatarUrl}pablo.jpg', NOW(), '0'),
+ ('5','Bob','Smith','smithy',MD5('password'),'{$avatarUrl}smithy.jpg', NOW(), '0');";
if( !mysqli_query($GLOBALS["___mysqli_ston"], $insert ) ) {
dvwaMessagePush( "Data could not be inserted into 'users' table SQL: " . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)) );
dvwaPageReload();
diff --git a/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/dvwa/includes/dvwaPage.inc.php b/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/dvwa/includes/dvwaPage.inc.php
index 114e7fd49..2ded275de 100644
--- a/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/dvwa/includes/dvwaPage.inc.php
+++ b/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/dvwa/includes/dvwaPage.inc.php
@@ -208,6 +208,8 @@ function dvwaHtmlEcho( $pPage ) {
$menuBlocks[ 'vulnerabilities' ][] = array( 'id' => 'xss_d', 'name' => 'XSS (DOM)', 'url' => 'vulnerabilities/xss_d/' );
$menuBlocks[ 'vulnerabilities' ][] = array( 'id' => 'xss_r', 'name' => 'XSS (Reflected)', 'url' => 'vulnerabilities/xss_r/' );
$menuBlocks[ 'vulnerabilities' ][] = array( 'id' => 'xss_s', 'name' => 'XSS (Stored)', 'url' => 'vulnerabilities/xss_s/' );
+ $menuBlocks[ 'vulnerabilities' ][] = array( 'id' => 'csp', 'name' => 'CSP Bypass', 'url' => 'vulnerabilities/csp/' );
+ $menuBlocks[ 'vulnerabilities' ][] = array( 'id' => 'javascript', 'name' => 'JavaScript', 'url' => 'vulnerabilities/javascript/' );
}
$menuBlocks[ 'meta' ] = array();
@@ -229,7 +231,7 @@ function dvwaHtmlEcho( $pPage ) {
foreach( $menuBlock as $menuItem ) {
$selectedClass = ( $menuItem[ 'id' ] == $pPage[ 'page_id' ] ) ? 'selected' : '';
$fixedUrl = DVWA_WEB_PAGE_TO_ROOT.$menuItem[ 'url' ];
- $menuBlockHtml .= "
A is a program that can tell whether its user is a human or a computer. You've probably seen
+
A is a program that can tell whether its user is a human or a computer. You've probably seen
them - colourful images with distorted text at the bottom of Web registration forms. CAPTCHAs are used by many websites to prevent abuse from
"bots", or automated programs usually written to generate spam. No computer program can read distorted text as well as humans can, so bots
cannot navigate sites protected by CAPTCHAs.
Content Security Policy (CSP) is used to define where scripts and other resources can be loaded or executed from. This module will walk you through ways to bypass the policy based on common mistakes made by developers.
+
None of the vulnerabilities are actual vulnerabilities in CSP, they are vulnerabilities in the way it has been implemented.
+
+
+
+
Objective
+
Bypass Content Security Policy (CSP) and execute JavaScript in the page.
+
+
+
+
Low Level
+
Examine the policy to find all the sources that can be used to host external script files.
+
Spoiler: Scripts can be included from Pastebin, try storing some JavaScript on there and then loading it in.
+
+
+
+
Medium Level
+
The CSP policy tries to use a nonce to prevent inline scripts from being added by attackers.
+
Spoiler: Examine the nonce and see how it varies (or doesn't).
+
+
+
+
High Level
+
The page makes a JSONP call to source/jsonp.php passing the name of the function to callback to, you need to modify the jsonp.php script to change the callback function.
+
Spoiler: The JavaScript on the page will execute whatever is returned by the page, changing this to your own code will execute that instead
+
+
+
+
Impossible Level
+
+ This level is an update of the high level where the JSONP call has its callback function hardcoded and the CSP policy is locked down to only allow external scripts.
+
+
+
+
+
+
+
+
+
+
Reference:
+
Reference:
+
Reference:
+
diff --git a/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/csp/index.php b/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/csp/index.php
new file mode 100644
index 000000000..aa189ff07
--- /dev/null
+++ b/modules/vulnerabilities/unix/web_training/dvwa/files/DVWA-master/vulnerabilities/csp/index.php
@@ -0,0 +1,57 @@
+
+
" . dvwaExternalLinkUrlGet( 'https://blog.mozilla.org/security/2014/10/04/csp-for-the-web-we-have/', "Mozilla Security Blog - CSP for the web we have" ) . "
The attacks in this section are designed to help you learn about how JavaScript is used in the browser and how it can be manipulated. The attacks could be carried out by just analysing network traffic, but that isn't the point and it would also probably be a lot harder.
+
+
+
+
Objective
+
Simply submit the phrase "success" to win the level. Obviously, it isn't quite that easy, each level implements different protection mechanisms, the JavaScript included in the pages has to be analysed and then manipulated to bypass the protections.
+
+
+
Low Level
+
All the JavaScript is included in the page. Read the source and work out what function is being used to generate the token required to match with the phrase and then call the function manually.
+
Spoiler: Change the phrase to success and then use the function generate_token() to update the token.
+
+
+
+
Medium Level
+
+ The JavaScript has been broken out into its own file and then minimized. You need to view the source for the included file and then work out what it is doing. Both Firefox and Chrome have a Pretty Print feature which attempts to reverse the compression and display code in a readable way.
+
+
Spoiler: The file uses the setTimeout function to run the do_elsesomething function which generates the token.
+
+
+
+
High Level
+
+ The JavaScript has been obfuscated by at least one engine. You are going to need to step through the code to work out what is useful, what is garbage and what is needed to complete the mission.
+
Spoiler 2: This deobfuscation tool seems to work the best on this code deobfuscate javascript.
+
Spoiler 3: This is one way to do it... run the obfuscated JS through a deobfuscation app, intercept the response for the obfuscated JS and swap in the readable version. Work out the flow and you will see three functions that need to be called in order. Call the functions at the right time with the right parameters.
+
+
+
+
Impossible Level
+
You can never trust the user and have to assume that any code sent to the user can be manipulated or bypassed and so there is no impossible level.