Tuesday, February 25, 2014

CREATING A VMDK FROM YOUR PHYSICAL WIN7 INSTLN

I have a dual boot system with Ubuntu12.04 and Windows 7. Presently, I am using Grub2 to choose the OS to boot into.

Since I mostly operate in Ubuntu, I decided to give up my Windows 7 installation entirely by moving it from physical installation to a VM. . After all when I need Windows and I donot need to reboot and I can freeze / unfreeze the system in a short time.

So essentially I installed Ubuntu12.04 as my base system and installed VirtualBox in it. Now I created a VM from my physical Win7 install and I use it in the Virtual Box. The steps to do it are as follows:-

(a)    Download and install VMware-converter-en-5.5.0-1362012.exe from the
internet, on the win7.

(b)    Create a vmdk image of the win7 system and save it in an external HDD.

(c)    Create  a VM inside the Virtual Box and choose to create it from - Use an
existing Virtual Hard Drive File.

There is yet another way to accomplish this task :-

(a)   Download and install  in the windows partition, Disk2vhd.exe from the sysinternals suite.

(b)   Create a .vhd image of your live system. But the important thing is the external HDD where you store this image must be NTFS partition , otherwise you will always get insufficient disk space error! which ofcourse is not a correct prompt for the error. There is yet another problem, the .vhd image will also carry your Grub installation, and inside the VM this will always give a grub rescue prompt. Just proceed to next step and remove the Grub installation from the .vhd file and reinstate the mbr using a Win7 System Restore disk.

(c)   Start VirtualBox and create a new VM. Reboot the virtual machine and Select CD/DVD as boot option. Boot from Recovery Disk, log in when prompted
Select command line as utility and execute the following commands:

       Bootrec.exe /FixMbr
    Bootrec.exe /FixBoot
    Bootrec.exe /RebuildBcd


(the intention here is to get rid of grub( which was in the dual boot original system) in the VM,  otherwise you'd be getting grub rescue at boot)

(d)  Reboot Virtual Machine and use it.

Thanks !

Sunday, February 23, 2014

MAKING WIFI WK ON Ubuntu 12.04 : FOR BROADCOM 4313 CARD ON HP PAVILION G6

I couldnot make the Wi-fi connection work at all. I first ascertained the make and model of my wifi card using the follwoing commands :-

# lspci -nn lists the hardware

02:00.0 Network controller [0280]: Broadcom Corporation BCM4313 802.11b/g/n Wireless LAN Controller [14e4:4727] (rev 01)

# sudo lshw -C network

 
  *-network              
       description: Wireless interface
       product: BCM4313 802.11b/g/n Wireless LAN Controller
       vendor: Broadcom Corporation
       physical id: 0
       bus info: pci@0000:02:00.0
       logical name: eth1
       version: 01
       serial: c0:18:85:98:9f:a5
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list ethernet physical 

       wireless
       configuration: broadcast=yes driver=wl0 driverversion=5.100.82.112 

       latency=0 multicast=yes wireless=IEEE 802.11
       resources: irq:16 memory:a2500000-a2503fff


So I looked up on the net and found that there were different options- some felt that the default open source driver brcmsmac would work best , while there were others who felt that enabling the broadcom driver would be the best option.

I first checked which of the above two drivers were in use on my laptop :-
# sudo nm-tool

     - Device: eth1 -----------------------------------------------------------------
       Type:               802.11 WiFi
       Driver:            wl
       State:              disconnected
       Default:           no
       HW Address:   C0:18:85:98:9F:A5

     Capabilities:

     Wireless Properties
      WEP Encryption:  yes
      WPA Encryption:  yes
      WPA2 Encryption: yes


The driver is the broadcom driver, so I tried out the other one :-
 # sudo modprobe -r b43 bcma
 # sudo modprobe -r brcmsmac bcma
 # sudo modprobe -r wl

 # sudo modprobe brcmsmac


The first three commands essentially removed all the drivers, and ruled out any possible misconfigurations, the last command loaded the default driver.
Wi-fi started working!
However, the change was only temporary and on successive reboots it again reloaded the wl driver, which caused the problem. I decided to keep the wl driver, just in case I needed it later. So I did the following workaround for a permt solution ;-
I modified the /etc/rc.local file to add the following lines above exit 0

# modprobe -r wl
# modprobe brcmsmac


I still have some issues with the poor signal strength. So maybe an update will be posted later!

Tuesday, February 18, 2014

CREATING A PRISTINE NEW INSTALL : Ubuntu 12.04 (LTS)

I decided to install Ubuntu on my laptop and customise it to my liking.
So, I chose the Ubuntu 12.04 (LTS) and went through the following steps
to customize my system :-

1.    Additional softwares installed from terminal :-

    apt-get install gparted
    apt-get install git                  // to install metasploit and Veil
    sudo apt-get install freemind
    apt-get install gimp
    apt-get install vlc
    apt-get install apache2
    apt-get install liferea           // rss reader
    apt-get install unetbootin    // install a distro (iso) on USB device
    apt-get install zenmap
    apt-get install wireshark
    apt-get install proxychains
    apt-get install openjdk-7-jdk

    [add the following two lines to ~/.bashrc file]
      export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
      export PATH=$PATH:/usr/lib/jvm/java-7-openjdk-i386/bin


    ****REMASTERSYS****
    sudo su
    wget -O - http://www.remastersys.com/ubuntu/remastersys.gpg.key | apt-key
                add -
    Add the lines to /etc/apt/sources.list(sudo gedit /etc/apt/sources.list)
      #Remastersys Precise
      deb http://www.remastersys.com/ubuntu precise main

    sudo apt-get update && sudo apt-get install remastersys remastersys-gui

    ****FIREFOX******
    apt-get install firefox

    You can update your system with unsupported packages from this untrusted
    PPA by adding ppa:mozillateam/firefox-next to your system's Software
    Sources.
   

   deb http://ppa.launchpad.net/mozillateam/firefox-next/ubuntu  
       quantal main 
   deb-src http://ppa.launchpad.net/mozillateam/firefox-next/ubuntu  
       quantal main 


    install NetVideoHunter plugin for firefox
   
    ****MULTI MEDIA PLUGINS / CODECS****
    apt-get install mpg123
    apt-get install adobe-flashplugin
    apt-get install gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg 
                gstreamer0.10-plugins-ugly
    apt-get install ffmpeg    // needed to play .flv files in movie player or vlc
    (to see how to do a screencast from terminal or how to play back TV on
    desktop see other posts)

    apt-get install ubuntu-restricted-extras

   
2.    Installed using Software Centre

       recordmydesktop and the gui
       netbeans
       guvcview     // for video and audio recordings.

3.    Software downloaded as tarballs / .deb and installed :-

      Tor Browser Bundle

      theHarvester2.2 from Edge Security website

      tar -zxvf truecrypt-7.1a-linux-x86.tar.gz (Download and extract tarball)
      sudo ./truecrypt-7.1a-linux-x86

      ****RELINUX******
     relinux_0.4a1-5_i386.deb
     sudo dpkg -i relinux_0.4a1-5_i386.deb

      ****GOOGLE EARTH******
     download the .deb file for googleearth package
     apt-get install lsb-core
     sudo dpkg -i googleearth*.deb
       
     ****VIRTUAL BOX***
    sudo dpkg -i 'virtualbox-4.3_4.3.4-91027~Ubuntu~raring_i386.deb'

    In order to be able to use the usb and external cd drive etc :-
    (launch virtualbox -> File -> Preferences -> Extensions - > choose the
    extension pack you have downloaded for your install for example ,
    Oracle_VM_VirtualBox_Extension_Pack-4.3.4-91027.vbox-extpack -> Click
    OK and install the extension pack)

    Next switch off (DONOT FREEZE THE VM, TURN IT OFF) the virtual
    machine and then open the settings for the vm and enable USB2.0 EHCI    
    Controller checkbox.

    Next add user to vboxusers group and restart your host OS :-
    sudo usermod -aG vboxusers yourUserName

    (VIMP :- You will only see your usb after you have restarted the host OS)

    (Also install the guest Aditions for every VM you create to enable shared
    folder with host OS and clip board sharing)
    
4.    Installations using git

      (a)    Veil 
          sudo git clone https://github.com/Veil-Framework/Veil.git
          cd /opt/Veil-Evasion
          sudo ./update.sh

      (b)    MSF install
          First uninstall ruby1.8.3 which is part of the base install of Ubuntu12.04
          sudo apt-get purge ruby1.8.*
         
          Install ruby1.9.1 and gems and verify their versions :-

          sudo apt-get install ruby1.9.1
          ruby -v
          sudo apt-get install rubygems1.9.1
          gem -v
          sudo apt-get install ruby1.9.1-dev

          Install postgresql

          sudo apt-get install postgresql
          sudo apt-get install libpq-dev

          Additional installs

          sudo apt-get install libpcap-dev

          cd /opt
          mkdir metasploit
          cd /opt/metasploit
          sudo git init
          sudo  git clone git://github.com/rapid7/metasploit-framework.git
                                  /opt/metasploit

          Now install the gem bundler & invoke it to install remaining gem bundle :-
          sudo gem install bundler
          sudo bundle install
      
          note:- Remember, if you donot pull down metasploit and clone it into
          /opt/metasploit directory first, you will not have any Gemfile, which
          carries the gem dependencies, that are installed by gem install bundler.
         

5.    After going through all the hardwork of customizing my installation, I decided it would be best to create an ISO image of my system, which I may either install on any new machine or create a VM with. So I used Remastersys.

Thanks for Reading and Enjoy !

Monday, February 17, 2014

Restoring dual boot windows / Ubuntu system : Using Clonezilla backup files


After I restored the /dev/sda3 partition of my laptop using the clonezilla backup of another Ubuntu system I had taken earlier,  I had to make the system bootable using grub2. Clonezilla had only put the ubuntu image on /dev/sda3 and not installed the grub in /boot folder of /dev/sda3  or the stage 1 files in /dev/sda.

1.    Make the ubuntu installation bootable

    (a) Use a live cd(Ubuntu) to boot up and mount the ubuntu partition  
         (/dev/sda3) at mount point /mnt

        sudo fdisk -l
        sudo mount -t auto /dev/sda3 /mnt

    (b) Install grub
       
        sudo grub-install --boot-directory=/mnt /dev/sda

    (c) Update grub to identify the win7 instln loc at /dev/sda1

        sudo update-grub

2.   Reboot. After rebooting the system, I could boot into my Ubuntu instln without any problem. But when I tried to boot up my win7 from the grub the system halted with the following error :-

    Status : 0xc000000e

    Info   : The boot  selection failed because a required dev is inaccessible.


A little bit of search on google suggested that the boot files of win7 were
corrupted somehow during the process.

3.    Getting win7 up and running :-
   
    Boot up the machine using a win7 recovery disk and after selecting the
    language etc click on Next button. In the next screen press Shift +F10 
    to get a terminal and execute the following commands :-
        c:/> bootrec /fixboot

        c:/> bootrec /fixmbr

        c:/> bootrec /rebuildbcd
        (this gave an error......Couldnot detect any windows installation!)

        To fix this, type the following commands at the Windows Recovery
        command prompt:

            c:/> bcdedit /export C:\BCD_Backup
            c:/> cd boot
            c:/> attrib bcd -s -h -r
            c:/> ren c:\boot\bcd bcd.old
            c:/> bootrec /RebuildBcd

    Close the terminal window and exit.

4.    On the next attempt I booted up both my win7 and Ubuntu without any problem.

Thanks !

CREATING AN ISO OF YOUR UBUNTU INSTLN

I have a nicely configured Ubuntu instln on my laptop. It is optimised and customized for my personal use. I wouldnot like to do it over and over again in case I format my dual boot system or due to some hardware failure, my linux distro stops. How to achieve that  ? Simple, use Remastersys.

1. Installation

   (a)   In the terminal window as root - issue the following commands :-
              'sudo su'
                     
               wget -O - http://www.remastersys.com/ubuntu/remastersys.gpg.key |   
               apt-key add -
                   
  (b)   Add the following line to /etc/apt/sources.list (sudo gedit /etc/apt
          /sources.list):-

            
              #Remastersys Precise
              deb http://www.remastersys.com/ubuntu precise main

  (c)   Now in the terminal type
              sudo apt-get update && sudo apt-get install remastersys
              && sudo apt-get install remastersys-gui
2. Usage

   (a)   Launch Remastersys gui and choose the first option:-
           create a live ISO backup of your system including your personal data

   (b)   Installing back the system from the iso image can be done in two ways:-

          (i)   You can copy the .iso on DVD and install on different machine as you
          would install any linux distro.

          (ii)  Copy the .iso on a usb device. Create a Virtual Box ubuntu linux vm
          and configure the Settings -> Storage -> Controller :IDE -> Attributes ->
          CD/DVD Drive, to point to the .iso image stored on the usb device. Then
          boot up the machine from the iso , you may use the live image of your
          system or install it as needed on the VM.
    
Enjoy!