2017-06-30 21:47:30 +02:00
#
# Cookbook:: metasploitable
# Recipe:: flags
#
# Copyright:: 2017, Rapid7, All Rights Reserved.
2017-07-14 22:13:15 +02:00
include_recipe 'metasploitable::knockd'
include_recipe 'metasploitable::docker'
2017-06-30 21:47:30 +02:00
directory '/opt/knock_knock' do
2017-07-22 00:32:29 +02:00
mode 0777
2017-06-30 21:47:30 +02:00
end
cookbook_file '/opt/knock_knock/five_of_diamonds' do
source 'flags/five_of_diamonds'
2017-07-22 00:32:29 +02:00
mode 0777
2017-06-30 21:47:30 +02:00
end
2017-07-22 00:32:29 +02:00
cookbook_file '/etc/init/five_of_diamonds_srv.conf' do
2017-06-30 21:47:30 +02:00
source 'flags/five_of_diamonds_srv'
2017-07-22 00:32:29 +02:00
mode '777'
2017-06-30 21:47:30 +02:00
end
service 'five_of_diamonds_srv' do
action [ :enable , :start ]
end
2017-07-14 19:14:01 +02:00
directory '/home/artoo_detoo/music' do
mode 700
end
2017-07-14 22:13:15 +02:00
cookbook_file '/home/artoo_detoo/music/10_of_clubs.wav' do
2017-07-14 19:14:01 +02:00
source 'flags/10_of_clubs.wav'
mode 400
end
cookbook_file '/etc/joker.png' do
2017-07-14 21:27:57 +02:00
source 'flags/joker.png'
2017-07-14 19:14:01 +02:00
mode 644
end
bash " load 8 of hearts into DB " do
code <<-EOH
mysql - h 127 . 0 . 0 . 1 - - user = " root " - - password = " sploitme " - - execute = " CREATE DATABASE super_secret_db; "
mysql - h 127 . 0 . 0 . 1 - - user = " root " - - password = " sploitme " - - execute = " GRANT SELECT, INSERT, DELETE, CREATE, DROP, INDEX, ALTER ON drupal.* TO 'root'@'localhost' IDENTIFIED BY 'sploitme'; "
mysql - h 127 . 0 . 0 . 1 - - user = " root " - - password = " sploitme " super_secret_db < #{File.join(node[:metasploitable][:files_path], 'flags', 'super_secret_db.sql')}
EOH
not_if " mysql -h 127.0.0.1 --user= \" root \" --password= \" sploitme \" --execute= \" SHOW DATABASES LIKE 'super_secret_db' \" | grep -c drupal "
end
2017-07-14 22:13:15 +02:00
directory '/opt/docker' do
mode 700
end
cookbook_file '/opt/docker/Dockerfile' do
source '/flags/Dockerfile'
mode 700
end
cookbook_file '/opt/docker/7_of_diamonds.zip' do
source '/flags/7_of_diamonds.zip'
mode 700
end
bash 'build docker image for 7 of diamonds' do
code <<-EOH
cd / opt / docker
docker build - t " 7_of_diamonds " .
docker run - dit - - restart always 7 _of_diamonds
EOH
end
file '/opt/docker/7_of_diamonds.zip' do
action :delete
2017-07-22 00:32:29 +02:00
end