mirror of
https://github.com/rapid7/metasploitable3.git
synced 2024-07-01 01:06:05 +02:00
Add drupal 7.5
Also make some changes to other recipes as I learn more about chef.
This commit is contained in:
parent
378e049574
commit
1826f8540c
10
chef/cookbooks/metasploitable/attributes/default.rb
Normal file
10
chef/cookbooks/metasploitable/attributes/default.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#
|
||||||
|
# Cookbook:: metasploitable
|
||||||
|
# Attributes:: default
|
||||||
|
#
|
||||||
|
default[:metasploitable][:docker_users] = ['boba_fett',
|
||||||
|
'jabba_hutt',
|
||||||
|
'greedo',
|
||||||
|
'chewbacca',]
|
||||||
|
|
||||||
|
default[:metasploitable][:files_path] = '/vagrant/chef/cookbooks/metasploitable/files/'
|
7
chef/cookbooks/metasploitable/attributes/drupal.rb
Normal file
7
chef/cookbooks/metasploitable/attributes/drupal.rb
Normal 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'
|
BIN
chef/cookbooks/metasploitable/files/drupal/default_site.tar.gz
Normal file
BIN
chef/cookbooks/metasploitable/files/drupal/default_site.tar.gz
Normal file
Binary file not shown.
4653
chef/cookbooks/metasploitable/files/drupal/drupal.sql
Normal file
4653
chef/cookbooks/metasploitable/files/drupal/drupal.sql
Normal file
File diff suppressed because one or more lines are too long
15
chef/cookbooks/metasploitable/recipes/docker.rb
Normal file
15
chef/cookbooks/metasploitable/recipes/docker.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#
|
||||||
|
# Cookbook:: metasploitable
|
||||||
|
# Recipe:: docker
|
||||||
|
#
|
||||||
|
|
||||||
|
docker_service 'default' do
|
||||||
|
action [:create, :start]
|
||||||
|
group 'docker'
|
||||||
|
end
|
||||||
|
|
||||||
|
group 'docker' do
|
||||||
|
action [:create, :modify]
|
||||||
|
append true
|
||||||
|
members node[:metasploitable][:docker_users]
|
||||||
|
end
|
67
chef/cookbooks/metasploitable/recipes/drupal.rb
Normal file
67
chef/cookbooks/metasploitable/recipes/drupal.rb
Normal 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
|
16
chef/cookbooks/metasploitable/recipes/mysql.rb
Normal file
16
chef/cookbooks/metasploitable/recipes/mysql.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#
|
||||||
|
# Cookbook:: metasploitable
|
||||||
|
# Recipe:: mysql
|
||||||
|
#
|
||||||
|
# Copyright:: 2017, Rapid7, All Rights Reserved.
|
||||||
|
|
||||||
|
execute "apt-get update" do
|
||||||
|
command "apt-get update"
|
||||||
|
end
|
||||||
|
|
||||||
|
mysql_service 'default' do
|
||||||
|
initial_root_password 'sploitme'
|
||||||
|
bind_address '0.0.0.0'
|
||||||
|
port '3306'
|
||||||
|
action [:create, :start]
|
||||||
|
end
|
|
@ -15,7 +15,7 @@ execute "install prereqs" do
|
||||||
libxml2-dev libcurl4-openssl-dev libpcre3-dev libbz2-dev libjpeg-dev \
|
libxml2-dev libcurl4-openssl-dev libpcre3-dev libbz2-dev libjpeg-dev \
|
||||||
libpng12-dev libfreetype6-dev libt1-dev libmcrypt-dev libmhash-dev \
|
libpng12-dev libfreetype6-dev libt1-dev libmcrypt-dev libmhash-dev \
|
||||||
freetds-dev libmysqlclient-dev unixodbc-dev \
|
freetds-dev libmysqlclient-dev unixodbc-dev \
|
||||||
libxslt1-dev php5-mysql apache2-dev"
|
libxslt1-dev apache2-dev"
|
||||||
end
|
end
|
||||||
|
|
||||||
execute "fix freetype bug" do
|
execute "fix freetype bug" do
|
||||||
|
@ -35,7 +35,7 @@ end
|
||||||
bash "compile and install php" do
|
bash "compile and install php" do
|
||||||
code <<-EOH
|
code <<-EOH
|
||||||
cd /home/vagrant/php-5.4.5
|
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
|
||||||
make install
|
make install
|
||||||
EOH
|
EOH
|
||||||
|
|
Loading…
Reference in New Issue
Block a user