Add drupal 7.5

Also make some changes to other recipes as I learn more about chef.
This commit is contained in:
James Barnett 2017-06-06 14:46:22 -05:00
parent 31af07a5d1
commit 1570bf7117
No known key found for this signature in database
GPG Key ID: 647983861A4EC5EA
9 changed files with 4735 additions and 10 deletions

1
Vagrantfile vendored
View File

@ -175,6 +175,7 @@ Vagrant.configure("2") do |config|
chef.add_recipe "metasploitable::cups"
chef.add_recipe "metasploitable::readme_app"
chef.add_recipe "metasploitable::payroll_app"
chef.add_recipe "metasploitable::drupal"
end
end
end

View File

@ -2,8 +2,9 @@
# Cookbook:: metasploitable
# Attributes:: default
#
default['metasploitable']['docker_users'] = ['boba_fett',
default[:metasploitable][:docker_users] = ['boba_fett',
'jabba_hutt',
'greedo',
'chewbacca',]
default[:metasploitable][:files_path] = '/vagrant/chef/cookbooks/metasploitable/files/'

View File

@ -0,0 +1,7 @@
default[:drupal][:files_path] = File.join(default[:metasploitable][:files_path], 'drupal')
default[:drupal][:install_dir] = '/var/www/html/drupal'
default[:drupal][:sites_dir] = File.join(default[:drupal][:install_dir], 'sites')
default[:drupal][:all_site_dir] = File.join(default[:drupal][:sites_dir], 'all')
default[:drupal][:default_site_dir] = File.join(default[:drupal][:sites_dir], 'default')
default[:drupal][:version] = '7.5'
default[:drupal][:download_url] = 'https://ftp.drupal.org/files/projects'

File diff suppressed because one or more lines are too long

View File

@ -11,5 +11,5 @@ end
group 'docker' do
action [:create, :modify]
append true
members node['metasploitable']['docker_users']
members node[:metasploitable][:docker_users]
end

View File

@ -0,0 +1,67 @@
#
# Cookbook:: metasploitable
# Recipe:: drupal
#
# Copyright:: 2017, Rapid7, All Rights Reserved.
include_recipe 'metasploitable::apache'
include_recipe 'metasploitable::mysql'
include_recipe 'metasploitable::php_545'
drupal_tar = "drupal-#{node[:drupal][:version]}.tar.gz"
coder_tar = "coder-7.x-2.5.tar.gz"
remote_file "#{Chef::Config[:file_cache_path]}/#{drupal_tar}" do
source "#{node[:drupal][:download_url]}/#{drupal_tar}"
mode 00644
end
remote_file "#{Chef::Config[:file_cache_path]}/#{coder_tar}" do
source "#{node[:drupal][:download_url]}/#{coder_tar}"
mode 00644
end
directory node[:drupal][:install_dir] do
owner 'www-data'
group 'www-data'
recursive true
mode '0755'
end
log "debug logging" do
message "#{Dir["#{node[:drupal][:install_dir]}/*"]}"
level :info
end
execute 'untar drupal' do
cwd node[:drupal][:install_dir]
command "tar xvzf #{Chef::Config[:file_cache_path]}/#{drupal_tar} --strip-components 1"
only_if { Dir["#{node[:drupal][:install_dir]}/*"].empty? }
end
execute 'untar default site' do
cwd node[:drupal][:sites_dir]
command "tar xvzf #{node[:drupal][:files_path]}/default_site.tar.gz"
not_if { ::File.exists?(File.join(node[:drupal][:default_site_dir], 'settings.php')) }
not_if { ::File.directory?(File.join(node[:drupal][:default_site_dir], 'files')) }
end
execute 'untar coder module' do
cwd File.join(node[:drupal][:all_site_dir], 'modules')
command "tar xvzf #{Chef::Config[:file_cache_path]}/#{coder_tar}"
not_if { ::File.directory?(File.join(node[:drupal][:all_site_dir], 'modules', 'coder')) }
end
execute "set permissions" do
command "chown -R www-data:www-data #{node[:drupal][:install_dir]}"
end
bash "create drupal database and inject data" do
code <<-EOH
mysql -h 127.0.0.1 --user="root" --password="sploitme" --execute="CREATE DATABASE drupal;"
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" drupal < #{File.join(node[:drupal][:files_path], 'drupal.sql')}
EOH
not_if "mysql -h 127.0.0.1 --user=\"root\" --password=\"sploitme\" --execute=\"SHOW DATABASES LIKE 'drupal'\" | grep -c drupal"
end

View File

@ -8,13 +8,9 @@ execute "apt-get update" do
command "apt-get update"
end
mysql_client 'default' do
action :create
end
mysql_service 'default' do
initial_root_password 'sploitme'
bind_address '0.0.0.0'
port '3306'
action [:create, :start]
end
end

View File

@ -15,7 +15,7 @@ execute "install prereqs" do
libxml2-dev libcurl4-openssl-dev libpcre3-dev libbz2-dev libjpeg-dev \
libpng12-dev libfreetype6-dev libt1-dev libmcrypt-dev libmhash-dev \
freetds-dev libmysqlclient-dev unixodbc-dev \
libxslt1-dev php5-mysql apache2-dev"
libxslt1-dev apache2-dev"
end
execute "fix freetype bug" do
@ -35,7 +35,7 @@ end
bash "compile and install php" do
code <<-EOH
cd /home/vagrant/php-5.4.5
./configure --with-apxs2=/usr/bin/apxs --with-mysqli --enable-embedded-mysqli
./configure --with-apxs2=/usr/bin/apxs --with-mysqli --enable-embedded-mysqli --with-gd --with-mcrypt --enable-mbstring --with-pdo-mysql
make
make install
EOH