Part 5: Create a Complete Virtual Environment for Penetration Testing

March 24, 2016 | Views: 10523

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATIONAlready a Member Login Here

Welcome back to the fifth part of the tutorial series. Today, we’re going to learn how to compact a VDI into less disk space. I’m going to compact Windows Server VDI and then Sysprep it for ready-to-go imaging or future cloning.

Tutorial Requirements:

 

Tutorial Guidelines:

  • 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

15.jpg– Go to the Tools tab and click on Optimization

21.jpg

– Choose C drive; click on optimize

23.jpg

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

     24.JPG

 

  • When the defragmentation is done, click close

      25.jpg

 

Step 2: Cleaning up the VDI

For this step, we’re going to do some cleaning that will save us some space. First, we’ll delete the Windows update file (unnecessary files), and second, we’re going to use sDelete for more efficient cleaning.

   1- Delete the Windows update files:

Open cmd or PowerShell as administrator and run services.msc

    13.jpg

–  When the Services window opens, go to Windows Updates services; right-click and choose Stop. If the service is already stopped, do not start it at this point.

       14.jpg

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

             16.jpg

– Go to Software Distribution folder and delete it. The 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.

 

           18.jpg

 

   18.jpg

     –  Click Yes

2- Download sDelete for addition cleaning:

30.JPG

NOTE: When you’re 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 can be embedded with viruses or Trojans. However, this one is clean.

39.jpg

 

– 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.

35.jpg

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

36.jpg

  • Add the website URL to the trusted sites list. Once you’re done, you’ll able to download it.

40.jpg

  • 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.

41.JPG

  • Now that you downloaded it, extract it using unzip or 7-zip compression utilities.

Right-click on the zip file and choose Extract all.

42.jpg

43.JPG

  • At this point, go back to the command line (cmd) and run the sDelete.exe. Use the commands below:

    • cd Downloads

    • cd  sDelete.

    • .sDelete   -z   c: (to run the exe file)

 

44.JPG

  • Click Agree to continue

45.JPG

  • The process of cleaning will start and it would take few minutes.

47.JPG

  • When it’s done, the driver will be shown as a zapped drive.

 

48.jpg

– After finishing the above process, shut down the Windows system.

49.JPG

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 errors, it means 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 Sysprep is (??), it’s 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

50.JPG

  • Choose OOBE

  • Check Generalize

  • Shutdown options as Shutdown

 

51.png

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

That’s all for this tutorial, stay tuned for more.

NOTE: Comments and suggestions on making better tutorials are welcomed!


@Z33Max

View Part 1: Create a Complete Virtual Environment for Penetration Testing – Part 1

View Part 2: Create a Complete Virtual Environment for Penetration Testing – Part 2

View Part 3: Create a Complete Virtual Environment for Penetration Testing – Part 3

View Part 4: Create a Complete Virtual Environment for Penetration Testing – Part 4

Share with Friends
FacebookTwitterLinkedInEmail
Use Cybytes and
Tip the Author!
Join
Share with Friends
FacebookTwitterLinkedInEmail
Ready to share your knowledge and expertise?
21 Comments
  1. Well Done. Looking forward to part 6.

  2. Excellent Article!

  3. Very nice. When will the next part be posted?

Page 4 of 4«1234
Comment on This

You must be logged in to post a comment.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Support Cybrary

Donate Here to Get This Month's Donor Badge

 

We recommend always using caution when following any link

Are you sure you want to continue?

Continue
Cancel