Friday, March 25, 2016

Create a complete Virtual Environment for Penetration Testing (PART- 5)

Compact VDI on VirtualBox

Welcome back,to the fifth part of the Tutorial series. Today we are going to learn how to compact a vdi into less disk space. I am going to compact Windows Server VDI and then Sysprep it for ready-to-go imaging or future cloning.
Tutorial Requirement:
Tutorial Guideline:
  • Defragmenting the VDI
  • Cleaning up the VDI
  • Compacting the VDI using sDelete
  • Sysprep Windows Server (Optional)
Step 1: Defragmentation of the VDI
– Open up Windows Server virtual machine and Go to your C drive
– Right click on it and choose properties
– Go to the Tools tab and Click on Optimization


– Choose C drive click on optimize


NOTE: Defragmentation might take sometime. (Grab cup of coffee and WAITT)




- When the defragmentation is done click Close



    Step 2: Cleaning up the VDI
For this step we are going to do some cleaning that will save us some space.first will delete windows update file (unnecessary files),and second we are going to use sDelete for more efficient cleaning.
1- Delete the Windows update files:
Open cmd or PowerShell as administrator and run services.msc


– When the Services window opens. Go to Windows Updates services and right click on and choose Stop. if the service is already stopped do not start it at this point.





– Now that the service is stopped, go to the C drive and navigate to Windows Folder 

– Go to Software Distribution folder and delete it. Software Distribution file is responsible for the Windows Updates

Note: if the Windows Update service is running you won’t be able to delete it. So that’s why we 
stopped the Windows Update service first.





– Click Yes
2- Download sDelete for addition cleaning:
NOTE: When you are trying to download the zip file,  Internet Explorer will flash up a warning sign as below. The warning is resulting from the file format (zip).Zip files are known in general that can be embedded with viruses  or Trojans. However, this one is clean.


– In order to continue with the download of the program you have to add the site (https://download.sysinternals.com) to the trusted sites in Internet Explorer .
– Go to menu bar and click on Tools.

  • Switch to Security tab and choose Trusted Sites >>>> click on Sites.




  • Add the website url to the trusted sites list. Once you are done, you will able to download it.


  • Once you add the site to the trusted websites list. Close the window and refresh the page. Then try downloading the zip file.
  • Click on Save.

  • Now that you download it. extract it using unzip or 7-zip compression utilities.
Right click on the zip file and choose Extract all.


  • At this point, go back to the command line (cmd) and run the sDelete.exe. use the below commands
  • cd Downloads
  • cd  sDelete.
  • .sDelete   -z   c:        (to run the exe file)

  • Click Agree to continue

  • The process of cleaning will start and it would take few minutes.
  • When it is done, the driver will be shown as a zapped drive.

– After finishing the above process, Shutdown windows system.

Step 3: Compacting the VDI
  • Once the machine is powered off. Go to the host command line (your computer CMD or PowerShell), and navigate to virtualbox folder.

 – When you get to the VirtualBox folder like the above picture,run the the compact command
Run :   .virtualbox.exe modifyvdi  (path of the vdi) -compact
Example:
C:Program FilesOracleVirtualBox>.VirtualBox.exe modifyvdi   C:UsersZ33MAXVirtualBox VMsNew groupWindows Server R 2012   -compact
 Note:
  • To find  path of your VDI check (PART- 4)
  • If you run the above command and you did not get any error. It means that the compact was successful
Step 4 : Sysprep Windows Server 2012 (optional)

Now that we have a cleaned compact VDI, we can go ahead and Sysprep the system for future cloning or imaging.

Terminology:
For those who do not know what is a Sysprep??. It is a System Preparation (Sysprep) tool prepares an installation of Windows for duplication, imaging or cloning. If you want to create an image with custom application or settings.
Sysprep is the tool for it.

1 – Fire up Windows Server machine
2- Open Cmd or PowerShell  and run:
Run : C:WindowsSystem32Sysprep ./sysprep.exe

  • Choose OOBE
  • Check Generalize
  • Shutdown options as Shutdown



Now we have a compact cleaned VDI , ready for future imaging or cloning.

That’s all for this tutorial, stay tuned for more, next one we will learn how to install Kali Linux on Virtual box and connect it to Pfsense.

No comments:

Post a Comment