Recover Data Like a Forensics Expert Using an Ubuntu Live CD

4/27/2010 0 Comments

Recover Data Like a Forensics Expert Using an Ubuntu Live CD:

There are lots of utilities to recover deleted files, but what if you can’t boot up your computer, or the whole drive has been formatted? We’ll show you some tools that will dig deep and recover the most elusive deleted files, or even whole hard drive partitions.

We’ve shown you simple ways to recover accidentally deleted files, even a simple method that can be done from an Ubuntu Live CD, but for hard disks that have been heavily corrupted, those methods aren’t going to cut it. In this article, we’ll examine four tools that can recover data from the most messed up hard drives, regardless of whether they were formatted for a Windows, Linux, or Mac computer, or even if the partition table is wiped out entirely.

Note: These tools cannot recover data that has been overwritten on a hard disk. Whether a deleted file has been overwritten depends on many factors – the quicker you realize that you want to recover a file, the more likely you will be able to do so.

Our setup

To show these tools, we’ve set up a small 1 GB hard drive, with half of the space partitioned as ext2, a file system used in Linux, and half the space partitioned as FAT32, a file system used in older Windows systems. We stored ten random pictures on each hard drive.

sshot-1


We then wiped the partition table from the hard drive by deleting the partitions in GParted.


sshot-2


Is our data lost forever?


Installing the tools


All of the tools we’re going to use are in Ubuntu’s universe repository.


To enable the repository, open Synaptic Package Manager by clicking on System in the top-left, then Administration > Synaptic Package Manager.


Click on Settings > Repositories and add a check in the box labelled “Community-maintained Open Source software (universe)”.


sshot-3


Click Close, and then in the main Synaptic Package Manager window, click the Reload button. Once the package list has reloaded, and the search index rebuilt, search for and mark for installation one or all of the following packages: testdisk, foremost, and scalpel.


Testdisk includes TestDisk, which can recover lost partitions and repair boot sectors, and PhotoRec, which can recover many different types of files from tons of different file systems.


sshot-4


Foremost, originally developed by the US Air Force Office of Special Investigations, recovers files based on their headers and other internal structures. Foremost operates on hard drives or drive image files generated by various tools.


sshot-6


Finally, scalpel performs the same functions as foremost, but is focused on enhanced performance and lower memory usage. Scalpel may run better if you have an older machine with less RAM.


sshot-5


Recover hard drive partitions


If you can’t mount your hard drive, then its partition table might be corrupted. Before you start trying to recover your important files, it may be possible to recover one or more partitions on your drive, recovering all of your files with one step.


Testdisk is the tool for the job. Start it by opening a terminal (Applications > Accessories > Terminal) and typing in:


sudo testdisk



sshot-8


If you’d like, you can create a log file, though it won’t affect how much data you recover. Once you make your choice, you’re greeted with a list of the storage media on your machine. You should be able to identify the hard drive you want to recover partitions from by its size and label.


sshot-9


TestDisk asks you select the type of partition table to search for. In most cases (ext2/3, NTFS, FAT32, etc.) you should select Intel and press Enter.


sshot-10


Highlight Analyse and press enter.


sshot-11


In our case, our small hard drive has previously been formatted as NTFS. Amazingly, TestDisk finds this partition, though it is unable to recover it.


sshot-12


It also finds the two partitions we just deleted. We are able to change their attributes, or add more partitions, but we’ll just recover them by pressing Enter.


sshot-13


If TestDisk hasn’t found all of your partitions, you can try doing a deeper search by selecting that option with the left and right arrow keys. We only had these two partitions, so we’ll recover them by selecting Write and pressing Enter.


sshot-14


Testdisk informs us that we will have to reboot.


sshot-15


Note: If your Ubuntu Live CD is not persistent, then when you reboot you will have to reinstall any tools that you installed earlier.


After restarting, both of our partitions are back to their original states, pictures and all.


sshot-16


Recover files of certain types


For the following examples, we deleted the 10 pictures from both partitions and then reformatted them.


PhotoRec


Of the three tools we’ll show, PhotoRec is the most user-friendly, despite being a console-based utility. To start recovering files, open a terminal (Applications > Accessories > Terminal) and type in:


sudo photorec



To begin, you are asked to select a storage device to search. You should be able to identify the right device by its size and label. Select the right device, and then hit Enter.


sshot-17


PhotoRec asks you select the type of partition to search. In most cases (ext2/3, NTFS, FAT, etc.) you should select Intel and press Enter.


sshot-18


You are given a list of the partitions on your selected hard drive. If you want to recover all of the files on a partition, then select Search and hit enter.


However, this process can be very slow, and in our case we only want to search for pictures files, so instead we use the right arrow key to select File Opt and press Enter.


sshot-19


PhotoRec can recover many different types of files, and deselecting each one would take a long time. Instead, we press “s” to clear all of the selections, and then find the appropriate file types – jpg, gif, and png – and select them by pressing the right arrow key.


sshot-20


Once we’ve selected these three, we press “b” to save these selections.


sshot-21


Press enter to return to the list of hard drive partitions. We want to search both of our partitions, so we highlight “No partition” and “Search” and then press Enter.


sshot-22


PhotoRec prompts for a location to store the recovered files. If you have a different healthy hard drive, then we recommend storing the recovered files there. Since we’re not recovering very much, we’ll store it on the Ubuntu Live CD’s desktop.


Note: Do not recover files to the hard drive you’re recovering from.


sshot-23


PhotoRec is able to recover the 20 pictures from the partitions on our hard drive!


sshot-24


A quick look in the recup_dir.1 directory that it creates confirms that PhotoRec has recovered all of our pictures, save for the file names.


sshot-25


Foremost

Foremost is a command-line program with no interactive interface like PhotoRec, but offers a number of command-line options to get as much data out of your had drive as possible.

For a full list of options that can be tweaked via the command line, open up a terminal (Applications > Accessories > Terminal) and type in:

foremost –h

In our case, the command line options that we are going to use are:



  • -t, a comma-separated list of types of files to search for. In our case, this is “jpeg,png,gif”.
  • -v, enabling verbose-mode, giving us more information about what foremost is doing.
  • -o, the output folder to store recovered files in. In our case, we created a directory called “foremost” on the desktop.
  • -i, the input that will be searched for files. This can be a disk image in several different formats; however, we will use a hard disk, /dev/sda.


Our foremost invocation is:


sudo foremost –t jpeg,png,gif –o foremost –v –i /dev/sda



Your invocation will differ depending on what you’re searching for and where you’re searching for it.


sshot-26


Foremost is able to recover 17 of the 20 files stored on the hard drive.


sshot-27


Looking at the files, we can confirm that these files were recovered relatively well, though we can see some errors in the thumbnail for 00622449.jpg.


sshot-28


Part of this may be due to the ext2 filesystem. Foremost recommends using the –d command-line option for Linux file systems like ext2.


We’ll run foremost again, adding the –d command-line option to our foremost invocation:


sudo foremost –t jpeg,png,gif –d –o foremost –v –i /dev/sda



sshot-29


This time, foremost is able to recover all 20 images!


sshot-30


A final look at the pictures reveals that the pictures were recovered with no problems.


sshot-31


Scalpel

Scalpel is another powerful program that, like Foremost, is heavily configurable. Unlike Foremost, Scalpel requires you to edit a configuration file before attempting any data recovery.

Any text editor will do, but we’ll use gedit to change the configuration file. In a terminal window (Applications > Accessories > Terminal), type in:

sudo gedit /etc/scalpel/scalpel.conf


sshot-32


scalpel.conf contains information about a number of different file types. Scroll through this file and uncomment lines that start with a file type that you want to recover (i.e. remove the “#” character at the start of those lines).


sshot-33


Save the file and close it. Return to the terminal window.


Scalpel also has a ton of command-line options that can help you search quickly and effectively; however, we’ll just define the input device (/dev/sda) and the output folder (a folder called “scalpel” that we created on the desktop).


Our invocation is:


sudo scalpel /dev/sda –o scalpel



sshot-34


Scalpel is able to recover 18 of our 20 files.


sshot-35


A quick look at the files scalpel recovered reveals that most of our files were recovered successfully, though there were some problems (e.g. 00000012.jpg).


sshot-36

Conclusion

In our quick toy example, TestDisk was able to recover two deleted partitions, and PhotoRec and Foremost were able to recover all 20 deleted images. Scalpel recovered most of the files, but it’s very likely that playing with the command-line options for scalpel would have enabled us to recover all 20 images.

These tools are lifesavers when something goes wrong with your hard drive. If your data is on the hard drive somewhere, then one of these tools will track it down!


My special thanks to HowtoGeek.com. Original post visit: http://www.howtogeek.com/howto/15761/recover-data-like-a-forensics-expert-using-an-ubuntu-live-cd/


0 comments :

PasswordCard – Encrypted Passwords in your wallet

4/23/2010 , 0 Comments

The PasswordCard itself is a printer in color has different symbols heading each column, and different color for each row. You can generate the card’s random character by typing a number into the field above and generating it a new. 

image

PasswordCard is free to use. Don’t recycle your password and keep one password to all the email, social networking site. Be smart and use PasswordCard.

Visit PasswordCard here.

0 comments :

Bash Scripting | Beginner Tutorial

4/16/2010 0 Comments

 
 

Sent to you by Balaji via Google Reader:

 
 

via PC Hacks by Ivan on 4/15/10

In this beginner tutorial I will show you some of the basics of shell script programming, and hopefully to introduce some of the possibilities of simple but powerful programming available under the shell.
Bash scripting is very useful, with simple commands you can do a lot, for example: create folder with name of current date , count lines, find words in files, search files and many more.

1)MKDIR

- mkdir dirname is bash command for creating folders
-dirname is the name of the directory that you wish to create

Example 1:

$ mkdir /home/ivan/hackspc.com/folder1
$ mkdir /home/ivan/hackspc.com/folder2
$ mkdir /home/ivan/hackspc.com/folder3

Example 2: Create folder with name of current date

mkdir $(date "+%d.%m.%Y")

Example 3: Create folder with name of current day

$ mkdir $(date "+%A")

Example 4: Create folders using brace expansion

$ mkdir /home/ivan/hackspc.com/{1..10}

$ mkdir /home/ivan/hackspc.com/project{1..10}

$ mkdir /home/ivan/hackspc.com/web{tools,masters,deseign}

Example 5: make all parent directories along with their children in a single command.

$ mkdir -p programming/BASHscripting/tutorials/StepByStep

$ mkdir -p programming/BASHscripting/tutorials/StepByStep is same as
~ $ mkdir programming
~ $ cd programming
~/programming $ mkdir BASHscripting
~/programming $ cd BASHscripting
~/programming/BASHscripting $ mkdir tutorials
~/programming/BASHscripting $ cd tutorials
~/programming/BASHscripting/tutorials/ $ mkdir StepByStep
~/programming/BASHscripting/tutorials/ $ cd StepByStep

As you can see above, mkdir with -p option can save you a lot of time an efforts.

2)WC (word count)

- wc displays a count of lines, words, and characters in a file.
-wc [options] [file]

-options: -c Count charachters
-l Count lines
-w Count words

- without options count Lines Words Characters
-in examples we'll use file hackspc.txt as show below

Example 1: Count lines in hackspc.txt

$ wc -l hackspc.txt

Output:

Example 2: Count words in hackspc.txt

$ wc -w hackspc.txt

Output:

Example 3: Count characters in hackspc.txt

$ wc -c hackspc.txt

Output:

Example 4: Count lines, words, characters

$ wc hackspc.txt

Example 5: count number of lines, words, characters from hackspc.txt and save it into filecounting.txt

$ wc hackspc.txt>filecounting.txt

Output: filecounting.txt

3)GREP

-grep command is one of the easiest methods of locating text contained within a file
-grep [options] PATTERN [FILE...]
Options:
-v invert the sense of matching, to select non-matching lines
-i ignore case distinctions in both the PATTERN and the input files
-c Suppress normal output; instead print a count of matching lines for each input file
-E Interpret PATTERN as an extended regular expression
-q do not write anything to standard output. Exit immediately with zero status if any match is found, even if an error was detected.

Let's look .txt file called hackspc.txt

Example 1 : find word hack in file hackspc.txt,

$ grep hack hackspc.txt

Output will be all lines that contains word hack

This command is case sensitive, so hack isn't same as Hack

Example 2: find lines that don't contain word hack

$ grep hack hackspc.txt

Output:

Example 3 : find word hack in file hackspc.txt, command isn't case sensitive

$ grep -i hack hackspc.txt

Output will be all lines that contains word hack, Hack, HACK,hAcK,HaCK…

Example 4 : find lines that contains words that end with g

$ grep -E "[a-z]+g" hackspc.txt

Output:

In this example I used regular expression , [a-z] all combinations of charachters a,b,c,d,e…z ,
+ repeat at least one or more. Regular expressions are very useful and complicated. In this beginner tutorial I will not write about them.

4)FIND

- Linux / Unix and their variants have several different ways of locating files find, locate, wheris. I mostly use find command. It offer a lot options and it can easly search for files that meet a desired criteria.
- find [option] [directory] [conditions]
-conditions:

-name true if pattern matches the current file name
-type -d (find folders) , -f (find files)
-size
-mtime n True if the file's data was modified n days ago.
-regex regular expression

Example 1: Search for any file named hackspc.txt in the directory home/ivan/hackspc.com/ and any subdirectory.

$ find /home/ivan/hackspc.com -name hackspc.txt

Output:

Example 2: search for any file that is larger then 2k

$ find /home/ivan/hackspc.com -name '*' -size +2k

Output:

Example 3: search folders

$ find /home/ivan/hackspc.com -type d

Output:

Example 4: Search .txt files that contains only 4 digits (dddd)

$ find /home/ivan/hackspc.com -regex ".*/[0-9][0-9][0-9][0-9]\.txt"

Output:

5)IF, ECHO, VARIABLES

Example 1: if variable a equal to 5 then print five if not then write not five

$ if [ "$a" = 5 ]; then echo "five"; else echo "not five"; fi

Output :

Output :

Example 2: If you find file called hackspc.txt in diretcory /home/ivan/hackspc.com/ then print "I found file called hackspc.txt" if not then print "File Not Found"

$ if find /home/ivan/hackspc.com -name hackspc.txt
lled hackspc.txt"; else echo "File Not Found"; fi


 
 

Things you can do from here:

 
 

0 comments :