Saturday, February 22, 2014

Installing Virtual Box Guest Additions To Kali Linux.....

Installing Virtualbox Additions in Kali Linux, A Debian Distro

Kali Linux
The Rebirth of
Backtrack


Back track used to be the most popular penetration testing software based on Ubuntu, Which Offensive Security gave a rebirth named as Kali Linux, which is based on Debian. I cannot state all the differences because I am very new to Linux and started with Kali and Mint 16 Petra KDE. I am a computer geek myself and thats why I am digging on these. Now My Main topic is about installing Virtual Box Guest Additions in Kali Linux. What is Virtual Box? I will explain that in upcoming blogs. Now if you google, installing VBox additions in kali linux, there will be many search results, Showing 5 steps to do that. Seems easy right? As I said I am new to linux, when I installed Kali in VBox, I was unable to do what is said over there. After 5 - 8 re installs and trials, And after mixing my own moves, I was successful. Now I am sharing with you all noobies like me who are new to this Enviornment and struggeling about installing This addition.

Step 1 -> After installing Kali, you will see a windowed mode, driver less version of Linux. Go to VBox menu bar, click devices and from the drop down menu, go o install VBox Guest additions. The Image and shortcut of the CDRom will come in the desktop, and will promt you to run. If you click Run, It will say an autorun error. It cannot find the desired autorun progrum. So installing this is not very easy like of Windows.
Dont get frustrated. This was not the right way. I am going to explain the right way now. 

Go to Device - > Insert Guest additions CD


If you Click Run,

This Will Happen.
   

Step 2 -> There is a part during the installation. There is a place during installation, where you will be asked for a mirror link for updates. If you select yes, then Kali itself will figure out the essential repositories. If you click no, then installation will complete way faster and earlier. Now if you click no, you will have to add the repositories manually. This is the most easy technique to add. You can go to this link to see all the repositories, or just copy/paste these two repositories in the place shown in the following picture - 




  1. deb http://http.kali.org/kali kali main non-free contrib
  2. deb-src http://http.kali.org/kali kali main non-free contrib

Copy these two links to the sources list which is located in /etc/apt/sources.list in the following manner shown in the picture, and give hashes in the starting of CD ROM reposite to bypass CD ROM read as shown.

This is the picture of the Sources list file. Do as shown.

Step 3 -> Save and close this file and go to terminal and Run  apt-get update followed by apt-get upgrade. BTW Make sure you have the latest Kali installed and You are running as ROOT. These commands will update the base systems and Other relevant items. Picture as follows -

Go to Terminal

Write apt-get update and press enter.
After update done,
Type apt-get upgrade.
After updates done, go to next step

Step 4 -> Installing the Linux Header files. Now what are headers. Headers are files which help Linux or Any Kernals to Identify, Run, and Work with any Unknown softwares and Drivers. Remember? when you install Graphics drivers? or any unknown drivers, Windows ask you to varify driver signature? But Windows have a laid back attitude so you just click a couple of nexts and you are done. But in linux,  - In Hangover 1 COP accent - "NOT UPP IN HEREEEE" . In Layman language, You are the Kernal, Science is the Subject, Books are the Headers here which helps you to interact with science. Here Virtual Box and its additions are kind of a set of Virtual Rams, HDDs, CPUs, BIOS, and Drivers here, for which Linux needs Headers to interact with VB. So to install Headers -

Type in terminal  -  apt-get install linux-headers-$(uname -r)

There will be a little download session and the headers will be installed soon.



Now, the headers are successfully installed. Its time to install the Additions file now.
As we know, the files to be installed resides in The VBOXADDITIONS CD Rom. So as said in Kali Forums, We will have to first navigate to the file and copy it to the root. Now why to copy? because we have to give it root and read/write permissions which is not possible to do from the CD Rom because its Called ROM - Read Only Memory. To copy it, we will run the command cp. So the whole command will be


  1. cp /media/cd-rom/VBoxLinuxAdditions.run /root/         -   (Its now copied)
  2. chmod 755 /root/VBoxLinuxAdditions.run                     -   (Its given Read/Write Permissions)
  3. cd /root                                                                             -   (Changed directry to to Root)
  4. ./VBoxLinuxAdditions.run                                              -   (Ran the file named VBoxLinuxAdditions.run) 

Now You might have a question What the hell is chmod 775. Basically it has a complex permission protocol. each 7, 7, 5 here have different meanings, which I am currently studying about. You now only know that giving a file 775 or 777 permission means to make the file fully accessible to any users. If you write 777 instead of chmod 775, it will work no matter what.

Now I will post a picture where I used this and it didn't work. In my case, In place of "cd-rom" command, "cdrom0" worked. 

Now give it 2 minuits and Those additions will be installed successfully. Give it a restart. I am posting the pictures. Then will discuss the may come problems.

Did as Directed

Copy Error with cd-rom

In this case, cdrom0 worked for me

This is the case I struggled the most with. There are no blogs saying this cdrom thing. I saw this in a different site where it was stated the ways to Change Directry to CD Rom. I just kept this in mind. This will help you a lot. So This worked.



After the final ./VBoxLinuxAdditions.run    command, This will be the screen for 2 minuits showing successful loading. After this, Just restart. You are done.

Way 2 ->  If the CD ROM thing fails with any of the described ways, or you are too lazy for terminalling or a Passionate Windows user :p , There is another way. Navigate to CD ROM by opening it from My Computer. Copy the VBoxLinuxAdditions.run file to Desktop. Right-click the file on desktop and go to properties. There you will find a permissions Tab, Where change all the Privilages to READ/WRITE/EXECUTE. And Definitely check the "run as program" tick box. If you do not check this option, This will open with a Text Editor. And if you check the tick box, It will open in terminal and install the additions same as terminal installation one. Rest the Pictures will describe.

Go to - Computers/CD ROM and do the following

Copy the file to desktop

Change the file permissions to all read/write
and check allow executing file as program

Here you did the same thing what " chmod775/777 "command does in terminal.

Now you can see OPEN which came there
for enabling run file as program.
Click here and click run or run in terminal on the dialogue box.
Same installation will successfully occur and then restart.

Restart Now. Final Image -->
Full Resolution and
All Drivers Installed.

Possible Failures and Solutions :-

Possible Failure 1 --> The most common here is the Failure during installation of the Kernal Headers. After you write 
 apt-get install linux-headers-$(uname -r), This will appear

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package linux-headers-3.7-trunk-686-pae

E: Couldn't find any package by regex 'linux-headers-3.7-trunk-686-pae'

So, what to do. Make sure you have the correct sources and repositories installed. Repeat step 2 here. If you had clicked YES for mirrors during installation, this error is unlikely to happen. But if not, check sources list for correct repositories. Add more from lots of websites available up there. check software package manager for additional options, choose updates to install. etc.etc . Then again Run apt-get update && apt-get upgrade. Then again run the Headers installation. Another thing, Make sure that you have the latest Kali Version installed because, installing the headers of old linux from New updates of the server is a bit complicated.
Possible Failure 2 -->  When installing the Additions by commanding ./VBoxLinuxAdditions.run, If it is successful, It should say stuff like - building guest additions ------ done
bla bla bla  ---------- done
bla bla bla  ---------- done

But in case of failures, the error will be - building guest additions --------- fail . In case of  this fail, means the headers are not successfully installed. Run an apt-get update again and re-install the headers. 
Image samples -
This is the fail I was talking about.

I am currently working and studying on working with kali in Virtual networks : Outer LAN. Like/comment/share/follow to get more updates and ask any questions freely. Will try to answer as easy as I can. 

And - Don't just scan over. Go through it thoroughly or you will fail to understand why and what is done over there.....

THANK YOU

No comments:

Post a Comment