Pages

Tuesday, November 16, 2010

[eBook] Hacking - The art of exploitation

Jon Erickson's Hacking: The Art of Exploitation, 2nd Edition
Excellent book describing the fundamental techniques of serious hacking (in an ethical sense).
It includes major sections on programming, networking, and cryptography. All material is covered with an eye towards exploitation. Languages used in the book material consist of C, PERL, and Assembly for X86.
The techniques described in this book are fundamental to any hacker or security professional who takes their work seriously :).
The examples are relevant and fresh.
I will describe the steps for getting the book together with the cd and start working the examples. The price on amazon is way below the book's value, you will soon realize that it deserves the money. But anyway, if you wish to try it first, here we go...
  1. Download the torrent  (that contains the book and also the CD). The cd is an .iso file, that we'll use later.  
  2. Tools needed:  MagicIso, vmware player, vmx builder
  3. Create a new virtual machine in Vmx Builder.
    • In the Hardware tab, add a new cdrom, that will use the iso just downloaded in step 1.
    • Also add a new hard disk, that will be used for saving the changes (casper-rw persistent partition).
      • I've selected a 300 MB single growable virtual disk, on IDE
      • For Mode, select Independent and check Persistent
    • You may also disable the floppy disc, and adjust the memory (I've set 500 MB. With default 128 it didn't start).
    • I have also added an ethernet controller, with network connection set to Custom, and VMnet8 (NAT).
    • The Windows services VMware Nat and VMware DHCP should be started.
  4. Start vmx file to boot. After booting into Ubuntu Feisty, we will create a partition on the virtual hard disk, format it as ext3 and assign it the label casper-rw. This will be used for saving changes for all users. 
  5. # Log in as root
    sudo su
    
    # Check our new disk, in my case the disk has been picked up as hdb
    # hd for ide, sd for SCSI
    dmesg |grep hd
    
    # Create disk
    fdisk /dev/sdb
    p
    n
    p
    1
    <enter>
    <enter>
    w
    
    # Format
    mkfs.ext3 -b 4096 -L casper-rw /dev/sdb1
    
    # Restart
    reboot
    
    The system will not reboot entirely, you will have to close manually the virtual machine. For now.
  6. Make the linux persistent.
    • Step 1 : update initrd.gz
      • Open a terminal and type sudo su (to become root)
      • Type mkdir /projectinit (to make our project directory)
      • Type cd /projectinit (to change to the project directory)
      • Type gzip -dc /cdrom/casper/initrd.gz | cpio -i (to extract the initrd.gz)
      • Type gedit init (to edit the init file)
      • From gedit, find the following section:
      • break)
        break=premount
        ;;
        esac
      • Directly above esac add the following:
      • persistent)
        PERSISTENT=yes
        root_persistence=casper-rw
        home_persistence=casper-rw
        ;;
        
      • It should end up up like the following:
      • break)
        break=premount
        ;;
        
        persistent)
        PERSISTENT=yes
        root_persistence=casper-rw
        home_persistence=casper-rw
        ;;
        
        esac
        
      • Save the changes to update the init file
      • Type find . | cpio -o -H newc | gzip -9 > initrd.gz (to zip the new initrd.gz file)
      • If you booted with network support, you could email initrd.gz file and update the ubuntu iso with this new modified file. (Use MagicIso to update the iso)
    • Step 2: modify isolinux.cfg like this:
      LABEL live
      menu label ^Start Hacking LiveCD (Persistent Ubuntu Linux)
      kernel /casper/vmlinuz
      append file=/cdrom/preseed/ubuntu.seed boot=casper persistent initrd=/casper/initrd.gz quiet --
      
    Shutdown and restart the machine.
  7. Remove the prompt to eject CD.
    After restart, delete those files to get rid of the prompt.
    rm -r /etc/rc0.d/*casper
    
    rm -r /etc/rc6.d/*casper
    
  8. Update package repository and install a chm viewer. I used gnochm.
    Officially the 7.04 repos are down but unofficially there are still here. They were moved to:
    http://old-releases.ubuntu.com/
    so you could edit your sources.list file and change the urls accordingly. To easily edit the file, using for example gedit, open terminal and do
    sudo gedit /etc/apt/sources.list
    modify the file and save it. Then
    sudo apt-get update
    sudo apt-get install gnochm
    
  9. Now you should have a persistent Ubuntu Feisty Fawn 7.04 in a virtual machine, the chm viewer installed, internet and network functional and a great book full of examples. Success at getting your hands dirty with code :)
Good links:
  1. Article about Ubuntu 7.04 repositories
  2. This shows how to make Ubuntu 7.04 persistent 
  3. Article about how to remove the prompt to eject CD message
  4. Great article  about how to install Backtrack4 on VMware on Windows with persistent changes (some things also applied from here)

No comments:

Post a Comment