mirror of
https://github.com/rapid7/metasploitable3.git
synced 2024-07-12 06:22:49 +02:00
72dc282aa0
Tweaks to the recipes to avoid repetition of work, and ub1404 dev, * let apt cookbook handle apt-update globally * do not download, configure, make, make install if the package is already installed * add guards for file deletion to first check whether file is present * use docker cookbook for image building and running, to only build if not alrady built and only run if not already running * drop mysql table and recreate each time Also, * bump Docker cookbook to 4.9.3 * bump mysql cookbook to 8.5.1 * add apt cookbook for better apt-update management * bump depends versions and add apt * modify readme with customization instructions * modify all chef runlists to call apt first in the runlist * add a vagrantfile for dev of ub1404
91 lines
2.1 KiB
Ruby
91 lines
2.1 KiB
Ruby
#
|
|
# Cookbook:: metasploitable
|
|
# Recipe:: proftpd
|
|
#
|
|
# Copyright:: 2017, Rapid7, All Rights Reserved.
|
|
|
|
# Install steps taken from https://github.com/rapid7/metasploit-framework/pull/5224
|
|
|
|
include_recipe 'metasploitable::apache'
|
|
|
|
proftpd_tar = 'proftpd-1.3.5.tar.gz'
|
|
|
|
execute "extract proftpd" do
|
|
cwd Chef::Config[:file_cache_path]
|
|
command 'tar zxfv proftpd-1.3.5.tar.gz'
|
|
not_if { ::File.exists?(File.join(Chef::Config[:file_cache_path], 'proftpd-1.3.5'))}
|
|
action :nothing
|
|
end
|
|
|
|
bash 'compile and install proftpd' do
|
|
cwd "#{Chef::Config[:file_cache_path]}/proftpd-1.3.5"
|
|
code <<-EOH
|
|
./configure --prefix=/opt/proftpd --with-modules=mod_copy \
|
|
&& make && make install
|
|
EOH
|
|
not_if { ::File.exist?( '/opt/proftpd/sbin/proftpd') }
|
|
action :nothing
|
|
end
|
|
|
|
remote_file "#{Chef::Config[:file_cache_path]}/#{proftpd_tar}" do
|
|
source "#{node[:proftpd][:download_url]}/#{proftpd_tar}"
|
|
mode '0644'
|
|
action :create_if_missing
|
|
not_if { File.exists?( '/opt/proftpd/sbin/proftpd' ) }
|
|
notifies :run, 'execute[extract proftpd]', :immediately
|
|
notifies :run, 'bash[compile and install proftpd]', :immediately
|
|
end
|
|
|
|
execute 'add hostname to /etc/hosts' do
|
|
command "echo #{node[:ipaddress]} #{node[:hostname]} >> /etc/hosts"
|
|
not_if 'grep -q "#{node[:ipaddress]} #{node[:hostname]}" /etc/hosts'
|
|
end
|
|
|
|
cookbook_file '/etc/init.d/proftpd' do
|
|
source 'proftpd/proftpd'
|
|
mode '760'
|
|
end
|
|
|
|
execute 'remove_carriage_returns' do
|
|
command "sed -i -e 's/\r//g' /etc/init.d/proftpd"
|
|
end
|
|
|
|
|
|
# Setup the IP Renewer
|
|
cookbook_file '/opt/proftpd/proftpd_ip_renewer.rb' do
|
|
source 'proftpd/proftpd_ip_renewer.rb'
|
|
mode '744'
|
|
owner 'root'
|
|
group 'root'
|
|
end
|
|
|
|
|
|
cookbook_file '/etc/init/proftpd_ip_renewer.conf' do
|
|
source 'proftpd/proftpd_ip_renewer.conf'
|
|
mode '0644'
|
|
end
|
|
|
|
cookbook_file '/opt/proftpd/hosts_renewer.rb' do
|
|
source 'proftpd/hosts_renewer.rb'
|
|
mode '744'
|
|
owner 'root'
|
|
group 'root'
|
|
end
|
|
|
|
cookbook_file '/etc/init/hosts_renewer.conf' do
|
|
source 'proftpd/hosts_renewer.conf'
|
|
mode '0644'
|
|
end
|
|
|
|
service 'proftpd' do
|
|
action [:enable, :start]
|
|
end
|
|
|
|
service 'proftpd_ip_renewer' do
|
|
action [:enable, :start]
|
|
end
|
|
|
|
service 'hosts_renewer' do
|
|
action [:enable, :start]
|
|
end
|