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!

Wednesday, January 8, 2014

HOW TO CONFIGURE YOUR UBUNTU SYSTEM TO LOGIN/LOGOUT WITH USB KEY

1.    Install pamusb-tools  and libpam-usb as under :-

       sudo apt-get install pamusb-tools libpam-usb

2.    Add USB device

       sudo pamusb-conf --add-device gerardButlers-usb-stick

3.   Define a user for PAM authentication ( the user must exist on the linux system) :-

      sudo pamusb-conf --add-user gerardButler

4.   Edit the  /etc/pam.d/common-auth file, so that pam can use the pam_usb library :-

       Add
      auth    sufficient      pam_usb.so
      
    above
      auth    required        pam_unix.so nullok_secure
 
    Note :- FOR TWO FACTOR AUTHENTICATION
     If you wish to use both the usb key as well as your user 
     password then add the following:-
 
      auth    required        pam_usb.so 

5.  In the terminal window, execute  su gerardButler and then provide the 
     password for the account.

6.  The pam_usb agent (pamusb-agent) allows you to automatically execute
     commands upon locking and unlocking events. Those events are generated when
     you insert or remove your authentication device. To configure the commands, you
     have to edit pam_usb's configuration file (/etc/pamusb.conf) and add agent
     entries into your user section.

     For instance, you could automatically start your screensaver as soon as you
     remove the device, and deactivate it when you plug the device back.

     Open and modify the file /etc/pamusb.conf file's user section as under :-
    
   <user id="gerardButler">
    <device>gerardButlers-usb-stick</device>
    <agent event="lock">gnome-screensaver-command --lock</agent>
    <agent event="unlock">gnome-screensaver-command --deactivate</agent>
   </user>

     Now, you have to add pamusb-agent to the list of autostarted applications so it will
     be started automatically. It is important to note that for agent events to work you
     have to ensure pamusb-agent is running at all times:-

  • Select Startup Programs and press Add
  • Enter pamusb-agent and press OK
Refs :-
     https://github.com/aluzzardi/pam_usb/wiki/Getting-Started
     http://linuxconfig.org/linux-authentication-login-with-usb-device

7.  Note :- Pad checking failed
     Sometimes pamusb stopped authenticating with the message "Pad checking
     failed". Use the following command to flush previously stored pam  config
     files and pads from your home directory, as under :-
    
     sudo rm ~/.pamusb/*

Enjoy and Ubuntu!
      
  

Tuesday, September 11, 2012

CONKY SCRIPT



I have this simple conky script working on my laptop :-
# Conky sample configuration
#
# the list of variables has been removed from this file in favour
# of keeping the documentation more maintainable.
# Check http://conky.sf.net for an up-to-date-list.

# set to yes if you want Conky to be forked in the background
background yes

# X font when Xft is disabled, you can pick one with program xfontsel
#font 5x7
#font 6x10
#font 7x13
#font 8x13
#font 9x15
#font *mintsmild.se*
#font -*-*-*-*-*-*-34-*-*-*-*-*-*-*

# Use Xft?
use_xft yes

# Xft font when Xft is enabled
xftfont Bitstream Vera Sans Mono:size=8

# Text alpha when using Xft
xftalpha 0.8

# Print everything to stdout?
# out_to_console no

# MPD host/port
# mpd_host localhost
# mpd_port 6600
# mpd_password tinker_bell

# Print everything to console?
# out_to_console no

# mail spool
mail_spool $MAIL

# Update interval in seconds
update_interval 1.0

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

# Create own window instead of using desktop (required in nautilus)
own_window yes

# If own_window is yes, you may use type normal, desktop or override
own_window_type root

# Use pseudo transparency with own_window?
own_window_transparent yes

# If own_window_transparent is set to no, you can set the background colour here
own_window_colour black

# If own_window is yes, these window manager hints may be used
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
minimum_size 300 5
maximum_width 300

# Draw shades?
draw_shades yes

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Draw borders around graphs
draw_graph_borders no

# Stippled borders?
stippled_borders 8

# border margins
border_margin 4

# border width
border_width 1

# Default colors and also border colors
default_color OrangeRed
default_shade_color black
default_outline_color black

# Text alignment, other possible values are commented
#alignment top_left
alignment top_right
#alignment bottom_left
#alignment bottom_right
#alignment none

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 12
gap_y 12

# Subtract file system buffers from used memory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 2

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale no

# Add spaces to keep things from moving about?  This only affects certain objects.
use_spacer no

# Allow each port monitor to track at most this many connections (if 0 or not set, default is 256)
#max_port_monitor_connections 256

# Maximum number of special things, e.g. fonts, offsets, aligns, etc.
#max_specials 512

# Maximum size of buffer for user text, i.e. below TEXT line.
#max_user_text 16384




# variable is given either in format $variable or in ${variable}. Latter
# allows characters right after the variable and must be used in network
# stuff because of an argument

# stuff after 'TEXT' will be formatted on screen


TEXT
${font Verdana:style=Bold:size=9}Acer Aspire running....
$sysname $kernel $machine
$stippled_hr
To Do List
${execi 30 cat ~/TODO.txt}
$stippled_hr
${color lightgrey}Uptime:$color $uptime ${color lightgrey}- Load:$color $loadavg
${color lightgrey}CPU Usage:${color #cc2222} $cpu% ${cpubar}
${color red}${cpugraph 0000ff 00ff00}
${color lightgrey}RAM Usage:$color $mem/$memmax - $memperc% ${membar}
${color lightgrey}Swap Usage:$color $swap/$swapmax - $swapperc% ${swapbar}
${color lightgrey}Processes:$color $processes  ${color grey}Running:$color $running_processes
${color lightgrey}Battery: $color ${battery}
$color$stippled_hr
${color lightgrey}Networking:
 Down:${color #8844ee} ${downspeed eth0} k/s${color lightgrey} ${offset 80}Up:${color #22ccff} ${upspeed eth0} k/s
${color #0000ff}${downspeedgraph eth0 32,150 ff0000 0000ff} ${color #22ccff}${upspeedgraph eth0 32,150 0000ff ff0000}
${color lightgrey}File System Usage:
 / $color${fs_used /}/${fs_size /} ${fs_bar /}
enc: $color${fs_used /media/enc}/${fs_size /media/enc} ${fs_bar /media/enc}

${color}Name              PID     CPU%   MEM%
${color #ddaa00} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
${color}Mem usage
${color #ddaa00} ${top_mem name 1} ${top_mem pid 1} ${top_mem cpu 1} ${top_mem mem 1}
${color lightgrey} ${top_mem name 2} ${top_mem pid 2} ${top_mem cpu 2} ${top_mem mem 2}
${color lightgrey} ${top_mem name 3} ${top_mem pid 3} ${top_mem cpu 3} ${top_mem mem 3}

$stippled_hr
${color #ddaa00}Port(s)${alignr}#Connections  
${color}Inbound: ${tcp_portmon 1 32767 count}          Outbound: ${tcp_portmon 32768 61000 count}${alignr}ALL: ${tcp_portmon 1 65535 count}
${color #ddaa00}Inbound Connection ${alignr} Local Service/Port$color
 ${tcp_portmon 1 32767 rhost 0} ${alignr} ${tcp_portmon 1 32767 lservice 0}
 ${tcp_portmon 1 32767 rhost 1} ${alignr} ${tcp_portmon 1 32767 lservice 1}
 ${tcp_portmon 1 32767 rhost 2} ${alignr} ${tcp_portmon 1 32767 lservice 2}
${color #ddaa00}Outbound Connection ${alignr} Remote Service/Port$color
 ${tcp_portmon 32768 61000 rhost 0} ${alignr} ${tcp_portmon 32768 61000 rservice 0}
 ${tcp_portmon 32768 61000 rhost 1} ${alignr} ${tcp_portmon 32768 61000 rservice 1}
 ${tcp_portmon 32768 61000 rhost 2} ${alignr} ${tcp_portmon 32768 61000 rservice 2}