diff --git a/Vagrantfile b/Vagrantfile index 5bb8d2f..24f74d9 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -145,7 +145,7 @@ Vagrant.configure("2") do |config| trusty.vm.provider "virtualbox" do |v| v.name = "MetasploitableUB" - v.memory = 1024 + v.memory = 2048 end config.omnibus.chef_version = :latest diff --git a/chef/cookbooks/metasploitable/recipes/payroll_app.rb b/chef/cookbooks/metasploitable/recipes/payroll_app.rb index 94d8d2d..d933840 100644 --- a/chef/cookbooks/metasploitable/recipes/payroll_app.rb +++ b/chef/cookbooks/metasploitable/recipes/payroll_app.rb @@ -3,13 +3,17 @@ # Recipe:: payroll_app # Copyright:: 2017, Rapid7, All Rights Reserved. +include_recipe 'metasploitable::mysql' +include_recipe 'metasploitable::apache' +include_recipe 'metasploitable::php_545' + cookbook_file '/var/www/html/payroll_app.php' do source 'payroll_app/payroll_app.php' mode '0755' end -cookbook_file '/tmp/payroll.sql' do - source 'payroll_app/payroll.sql' +template '/tmp/payroll.sql' do + source 'payroll_app/payroll.sql.erb' mode '0755' end diff --git a/chef/cookbooks/metasploitable/recipes/users.rb b/chef/cookbooks/metasploitable/recipes/users.rb index bc6fe99..125d767 100644 --- a/chef/cookbooks/metasploitable/recipes/users.rb +++ b/chef/cookbooks/metasploitable/recipes/users.rb @@ -6,31 +6,15 @@ # See scripts/configs/create_users.bat for passwords -users = {'leah_organa' => { password: '$1$2ny4/xaH$tAFV5fbEqHx2OkOPIQhpx0' }, - 'luke_skywalker' => { password: '$1$n8tgrGRs$8xaS40CFS1J5iIAEmbnx50' }, - 'han_solo' => { password: '$1$L/2/AWAh$ZMUulbFhP2IesZ6xwBmaV0' }, - 'artoo_detoo' => { password: '$1$DlEuqBUm$u71bKO9I603kDCqEphmon1' }, - 'c_three_pio' => { password: '$1$4JMoAFqs$b5MwsiCfOASdUKktx6wQ7/' }, - 'ben_kenobi' => { password: '$1$vmHrrI9b$OyLulJjgi18GxgREG5V5c1' }, - 'darth_vader' => { password: '$1$c7AfQJ86$zvcdz7pPate7GdCQ.yfTf0' }, - 'anakin_skywalker' => { password: '$1$AvIldIHu$o1s2OCU4n/qSCGQMKMgkH/' }, - 'jarjar_binks' => { password: '$1$SNokFi0c$F.SvjZQjYRSuoBuobRWMh1' }, - 'lando_calrissian' => { password: '$1$8aWC7zHq$bz6K2rZVD7XlMNqBIIMGX.' }, - 'boba_fett' => { password: '$1$TjxlmV4j$k/rG1vb4.pj.z0yFWJ.ZD0' }, - 'jabba_hutt' => { password: '$1$1q5jRHYC$LIp/8O/g9qg3NaeGOxGSl/' }, - 'greedo' => { password: '$1$1lmZ0rOJ$GITT5.sX0tvOQeC2/wWQF1' }, - 'chewbacca' => { password: '$1$AjU5ZLh9$WjO.j9fYh3yms3HSDBKya1' }, - 'kylo_ren' => { password: '$1$Zcw3AKDA$1Mjgzmr/HpmFXuxUjj2Vv1' } - } uid = 1111 -users.each do |username, opts| - user username do +node[:users].each do |u, attributes| + user attributes[:username] do manage_home true - password opts[:password] + password attributes[:password_hash] uid uid gid '100' - home "/home/#{username}" + home "/home/#{attributes[:username]}" shell '/bin/bash' end uid += 1 diff --git a/chef/cookbooks/metasploitable/files/payroll_app/payroll.sql b/chef/cookbooks/metasploitable/templates/payroll_app/payroll.sql.erb similarity index 61% rename from chef/cookbooks/metasploitable/files/payroll_app/payroll.sql rename to chef/cookbooks/metasploitable/templates/payroll_app/payroll.sql.erb index 50a2079..3530112 100644 --- a/chef/cookbooks/metasploitable/files/payroll_app/payroll.sql +++ b/chef/cookbooks/metasploitable/templates/payroll_app/payroll.sql.erb @@ -39,21 +39,12 @@ CREATE TABLE IF NOT EXISTS `users` ( -- INSERT INTO `users` (`username`, `first_name`, `last_name`, `password`, `salary`) VALUES -('luke_skywalker', 'Luke', 'Skywalker', 'password', 102000), -('leia_organa', 'Leia', 'Organa', 'obiwan', 95600), -('han_solo', 'Han', 'Solo', 'sh00t-first', 12000), -('artoo_detoo', 'Artoo', 'Detoo', 'beep_b00p', 22000), -('c_three_pio', 'C', 'Threepio', 'pr0t0c0l', 32000), -('ben_kenobi', 'Ben', 'Kenobi', 'thats_no_moon', 1000000), -('darth_vader', 'Darth', 'Vader', 'd@rk_sid3', 666000), -('anakin_skywalker', 'Anakin', 'Skywalker', 'yipp33!!', 0), -('jarjar_binks', 'Jar-Jar', 'Binks', 'mesah_p@ssw0rd', 2000), -('lando_calrissian', 'Lando', 'Calrissian', 'b@ckstab', 4000000), -('boba_fett', 'Boba', 'Fett', 'mandalorian1', 2000000), -('jabba_hutt', 'Jabba', 'The Hutt', 'not-a-slug12', 10000000), -('greedo', 'Greedo', 'Rodian', 'hanShotFirst!', 500000), -('chewbacca', 'Chewbacca', '', 'rwaaaaawr5', 4500), -('kylo_ren', 'Kylo', 'Ren', 'daddy_issues1', 66600); +<%= values = "" + node[:users].keys.each do |u| + values << "('#{node[:users][u][:username]}', '#{node[:users][u][:first_name]}', '#{node[:users][u][:last_name]}', '#{node[:users][u][:password]}', '#{node[:users][u][:salary]}')," + end + values[0...-1] +%>; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;