Sliim / pentest-env

Pentest environment deployer (kali linux + targets) using vagrant and chef.
http://sliim.github.io/pentest-env/
GNU General Public License v3.0
631 stars 169 forks source link

`vagrant provision` fails, after a successful `vagrant up` using tor-proxy.pentestrc #47

Closed jeffhx closed 6 years ago

jeffhx commented 6 years ago

Note: i'm not sure if i'm doing the correct step since i'm new to all this.

After a successful vagrant up:

$ PENTESTRC=examples/tor-proxy.pentestrc vagrant up 
Bringing machine 'kali' up with 'virtualbox' provider...
==> kali: Checking if box 'Sliim/kali-2018.1-amd64' is up to date...
==> kali: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> kali: flag to force provisioning. Provisioners marked to run always will still run

when I do

$ PENTESTRC=examples/tor-proxy.pentestrc vagrant provision kali

I got following output:

==> kali: Running provisioner: shell...
    kali: Running: inline script
==> kali: Running provisioner: chef_solo...
==> kali: Generating chef JSON and uploading...
==> kali: Running chef-solo...
==> kali: [2018-10-01T20:28:48-04:00] INFO: Started chef-zero at chefzero://localhost:1 with repository at /tmp/vagrant-chef/2993b48a6912fb37af194703e2dff78b
==> kali:   One version per cookbook
==> kali:   roles at /tmp/vagrant-chef/22fc37727897b737d7a8c6e1a6deb80d/roles
==> kali: Starting Chef Client, version 14.3.37
==> kali: [2018-10-01T20:28:48-04:00] INFO: *** Chef 14.3.37 ***
==> kali: [2018-10-01T20:28:48-04:00] INFO: Platform: x86_64-linux
==> kali: [2018-10-01T20:28:48-04:00] INFO: Chef-client pid: 1747
==> kali: [2018-10-01T20:28:48-04:00] INFO: The plugin path /etc/chef/ohai/plugins does not exist. Skipping...
==> kali: [2018-10-01T20:28:50-04:00] INFO: Setting the run_list to ["recipe[apt]", "role[kali-base]", "role[tor-proxy]"] from CLI options
==> kali: [2018-10-01T20:28:51-04:00] INFO: Run List is [recipe[apt], role[kali-base], role[tor-proxy]]
==> kali: [2018-10-01T20:28:51-04:00] INFO: Run List expands to [apt, kali, tor-full, proxychains]
==> kali: [2018-10-01T20:28:51-04:00] INFO: Starting Chef Run for vagrant-d3b8c460
==> kali: [2018-10-01T20:28:51-04:00] INFO: Running start handlers
==> kali: [2018-10-01T20:28:51-04:00] INFO: Start handlers complete.
==> kali: resolving cookbooks for run list: ["apt", "kali", "tor-full", "proxychains"]
==> kali: [2018-10-01T20:29:02-04:00] INFO: Loading cookbooks [apt@7.1.0, kali@2.0.0, tor-full@0.2.0, proxychains@0.2.0, yum@3.13.0]
==> kali: Synchronizing Cookbooks:
==> kali:   
==> kali: - apt (7.1.0)
==> kali:   
==> kali: - tor-full (0.2.0)
==> kali:   
==> kali: - yum (3.13.0)
==> kali:   - kali (2.0.0)
==> kali:   
==> kali: - proxychains (0.2.0)
==> kali: Installing Cookbook Gems:
==> kali: Compiling Cookbooks...
==> kali: 
==> kali: ================================================================================
==> kali: Recipe Compile Error in /var/chef/cache/cookbooks/tor-full/recipes/default.rb
==> kali: ================================================================================
==> kali: 
==> kali: 
==> kali: NoMethodError
==> kali: -------------
==> kali: undefined method `tor' for #<Chef::Node::Attribute:0x0000000004c387d8>
==> kali: 
==> kali: 
==> kali: Cookbook Trace:
==> kali: ---------------
==> kali:   /var/chef/cache/cookbooks/tor-full/recipes/default.rb:90:in `block in from_file'
==> kali: 
==> kali:   /var/chef/cache/cookbooks/tor-full/recipes/default.rb:85:in `from_file'
==> kali: 
==> kali: Relevant File Content:
==> kali: ----------------------
==> kali: /var/chef/cache/cookbooks/tor-full/recipes/default.rb:
==> kali: 
==> kali:  83:  
==> kali:  84:  # Build torrc configuration file
==> kali:  85:  template '/etc/tor/torrc' do
==> kali:  86:    source 'torrc.erb'
==> kali:  87:    notifies :restart, 'service[tor]', :immediately
==> kali:  88:    notifies :run, "ruby_block[read-hostnames]"
==> kali:  89:    # Set default HiddenServiceDir
==> kali:  90>>   node.tor.HiddenServices.each do |name, service|
==> kali:  91:      node.default['tor']['HiddenServices'][name]['HiddenServiceDir'] = File.join("/var/lib/tor/", name, "/")
==> kali:  92:    end
==> kali:  93:  end
==> kali:  94:  
==> kali:  95:  # Install exit policy notice
==> kali:  96:  template '/etc/tor/tor-exit-notice.html' do
==> kali:  97:    source 'tor-exit-notice.html.erb'
==> kali:  98:  end
==> kali:  99:  
==> kali: 
==> kali: System Info:
==> kali: ------------
==> kali: chef_version=14.3.37
==> kali: platform=debian
==> kali: platform_version=kali-rolling
==> kali: ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
==> kali: program_name=/usr/bin/chef-solo
==> kali: executable=/opt/chef/bin/chef-solo
==> kali: 
==> kali: 
==> kali: 
==> kali: Running handlers:
==> kali: [2018-10-01T20:29:02-04:00] ERROR: Running exception handlers
==> kali: Running handlers complete
==> kali: 
==> kali: [2018-10-01T20:29:02-04:00] ERROR: Exception handlers complete
==> kali: Chef Client failed. 0 resources updated in 14 seconds
==> kali: [2018-10-01T20:29:02-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> kali: [2018-10-01T20:29:02-04:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
==> kali: [2018-10-01T20:29:02-04:00] FATAL: NoMethodError: undefined method `tor' for #<Chef::Node::Attribute:0x0000000004c387d8>
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

Is this something related to this error?

kali: Recipe Compile Error in /var/chef/cache/cookbooks/tor-full/recipes/default.rb

info regarding versions:

$ uname -a
Linux mymachine 4.15.0-34-generic #37-Ubuntu SMP Mon Aug 27 15:21:48 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:    18.04
Codename:   bionic

- $ ruby --version
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]

-- $ vagrant --version
Vagrant 2.1.5
Sliim commented 6 years ago

Hi,

Thanks for your report, this is the tor-full cookbook that is not compatible with latest Chef.

I fixed this issue on my fork : https://github.com/sliim-cookbooks/tor-full/tree/fix-attributes but pentest-env use the original cookbook (I will fix that). There is also an other issue with Kali OS that I fixed in kali-support branch. Both fixes are merged in the custom branch.

So the fix should be relatively easy, can you try to change the following line in the Berksfile:

cookbook 'tor-full'

by:

cookbook 'tor-full', git: 'https://github.com/sliim-cookbooks/tor-full', ref: 'custom'

Then, rm the Berksfile.lock, run berks vendor and retry to provision the machine.

jeffhx commented 6 years ago

The suggested steps work for me. I'm seeing the success message:

==> kali: Chef Client finished, 23/42 resources updated in 01 minutes 05 seconds

I can do a quick regression test once your fix is merged to the master branch

Thanks for the help.

Sliim commented 6 years ago

Fixed, thanks! :)