diff --git a/Vagrantfile b/Vagrantfile index a7ad814..9f49176 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -169,6 +169,7 @@ Vagrant.configure("2") do |config| chef.add_recipe "metasploitable::docker" chef.add_recipe "metasploitable::samba" chef.add_recipe "metasploitable::unrealircd" + chef.add_recipe "metasploitable::readme_app" chef.add_recipe "metasploitable::payroll_app" end end diff --git a/chef/cookbooks/metasploitable/files/readme_app/readme_app b/chef/cookbooks/metasploitable/files/readme_app/readme_app new file mode 100644 index 0000000..377babf --- /dev/null +++ b/chef/cookbooks/metasploitable/files/readme_app/readme_app @@ -0,0 +1,40 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: readme_app +# Required-Start: $local_fs +# Required-Stop: $local_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# X-Interactive: false +# Short-Description: Init script for readme_app +# Description: Start/stop readme_app +### END INIT INFO + +DESC="readme_app" +NAME=readme_app +#DAEMON= + +do_start() +{ + echo "Starting readme_app."; + cd /opt/readme_app + rails s & +} + +do_stop() +{ + echo "Stopping readme_app." + killall ruby +} + + +case "$1" in + start) + do_start + ;; + stop) + do_stop + ;; +esac + +exit 0 \ No newline at end of file diff --git a/chef/cookbooks/metasploitable/files/readme_app/readme_app.conf b/chef/cookbooks/metasploitable/files/readme_app/readme_app.conf new file mode 100644 index 0000000..f76b220 --- /dev/null +++ b/chef/cookbooks/metasploitable/files/readme_app/readme_app.conf @@ -0,0 +1,5 @@ +description 'Run ReadMe App' +author 'metasploitable3' + +start on runlevel [2345] +exec "/opt/readme_app/start.sh" diff --git a/chef/cookbooks/metasploitable/files/readme_app/start.sh b/chef/cookbooks/metasploitable/files/readme_app/start.sh new file mode 100644 index 0000000..2e54d87 --- /dev/null +++ b/chef/cookbooks/metasploitable/files/readme_app/start.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +cd /opt/readme_app +bundle install +rails s -b 0.0.0.0 -p 3500 diff --git a/chef/cookbooks/metasploitable/recipes/readme_app.rb b/chef/cookbooks/metasploitable/recipes/readme_app.rb new file mode 100644 index 0000000..ba2f400 --- /dev/null +++ b/chef/cookbooks/metasploitable/recipes/readme_app.rb @@ -0,0 +1,38 @@ +# +# Cookbook:: metasploitable +# Recipe:: readme_app +# +# Copyright:: 2017, Rapid7, All Rights Reserved. +# +# + +include_recipe 'metasploitable::ruby23' + +package 'git' +package 'nodejs' + +directory '/opt/readme_app' do + mode '0777' +end + +bash "clone the readme app and install gems" do + code <<-EOH + cd /opt/ + git clone https://github.com/jbarnett-r7/metasploitable3-readme.git readme_app + EOH +end + +cookbook_file '/opt/readme_app/start.sh' do + source 'readme_app/start.sh' + mode '0777' +end + +cookbook_file '/etc/init/readme_app.conf' do + source 'readme_app/readme_app.conf' + mode '0777' +end + +service 'readme_app' do + supports restart: false, start: true, reload: false, status: false + action [:enable, :start] +end diff --git a/chef/cookbooks/metasploitable/recipes/ruby23.rb b/chef/cookbooks/metasploitable/recipes/ruby23.rb new file mode 100644 index 0000000..46eaabf --- /dev/null +++ b/chef/cookbooks/metasploitable/recipes/ruby23.rb @@ -0,0 +1,19 @@ +# +# Cookbook:: metasploitable +# Recipe:: ruby23 +# +# Copyright:: 2017, Rapid7, All Rights Reserved. +# +# + +apt_repository 'rvm' do + uri 'ppa:brightbox/ruby-ng' +end + +execute 'apt-get update' do + command 'apt-get update' +end + +package 'ruby2.3' +package 'ruby2.3-dev' +package 'bundler' diff --git a/chef/cookbooks/metasploitable/recipes/sinatra.rb b/chef/cookbooks/metasploitable/recipes/sinatra.rb index 72098d2..b3acf12 100644 --- a/chef/cookbooks/metasploitable/recipes/sinatra.rb +++ b/chef/cookbooks/metasploitable/recipes/sinatra.rb @@ -7,14 +7,7 @@ # include_recipe 'metasploitable::sinatra' - -apt_repository 'rvm' do - uri 'ppa:brightbox/ruby-ng' -end - -package 'ruby2.3' - -package 'bundler' +include_recipe 'metasploitable::ruby23' directory '/opt/sinatra' do mode '0777'