Tuesday, May 10, 2016

HDD Reverse Imaging Ft. Forward Imaging using Deepspar Disk Imager

Hi all  , After installing Deepspar Disk Imager  I have to try it with its great features for the first case my friend’s damaged hard disk drive which have more than 3000 bad sectors in HDD Regenerator so I decided to recover data from it the first phase as I learned in Scott Moulton Course the first step is to image the HDD but when I tried to image it with the normal process imaging from LBA0 to MAX LBA but it shows many skipped sectors due to ECC Errors , Bad sectors so it must be failed you know that when you tried more read/write process it will kill hard drive  so what should I do ??

we have 2 types of imaging the first is forward imaging which drive make sense to ECC i.e. Buffer Ram as imaging from LBA0 to MAX LBA from Outside to inner ring .There are many softwares and hardwares doing this like FTK Imager and DDI but when you find problems like I faced you should try the type 2 Reverse Imaging,
Reverse Imaging images HDD from MAXLBA to LBA 0 but what the difference is that there is no cache memory on HDD  caches only data forward imaging is from inner ring to outside but this is 5x slower than forward imaging but this imaging can be of a high quality and can recover more data than forward imaging .
When imaging you can see in status bar some words which are hard disk status like: BSY, ERR.
These error codes and Diagnostic info this is from Drive Status Register which are:

  •  BSY - drive busy
  • DRDY - Drive ready to accept commands
  • ERR - The Last Result was an Error 
  •  DREQ -exchange data with host 
  •  UNCR-Uncorrectable Error
  •   WRFT - Write Fault
  •  IDNF- Sector ID Not Found. If the sector that holds this information is corrupt there is no way for the hard drive to locate this sector and it will return the result IDNF.
  • AMNF-Address Marker Not Found. This is similar to the IDNF but relates to the data. If there is an error and this marker is corrupt then the data for this sector cannot be located. The data in this area is 512 bytes of user data
  •   ABRT- Command Aborted. - is an abort error and it will discontinue trying to read that block
  •   TONF - Track 0 not found

References:
1-      Deepspar Disk Imager User Manual.
2-      Forensic Hard Drive Data Recovery By Scott A. Moulton .

Tuesday, April 26, 2016

P-list and G-list .. where you can find your bad sectors

Hi all back with new article hope it useful for you.  Nowadays I install our data recovery lab in EG-CERT. You know you should learn more about tools you install especially if it likes from ACE Lab. During my study in DR in Scott Moulton course specifically some words stopped me I feel I must know more and more so if I learn I will share so let’s begin:
In HDD there are SA which is responsible for all info stored in it from manufacture what is G,P lists in it . We all know that SA has two lists called P-list and G-list. System area has many, modules as I described there. But what about these lists let’s know:
firstly we must know that the two lists contain bad sectors so what is bad sector? Why bad sector in G not in P? . Bad sector is a sector which is either unwriteable or inaccessible because of physical damage or any other failure so if we had a HDD has 100 sectors it will be :
0,1,2,3,4,5,6,7,8,9,10 ==> SA (system area) .
11,12,13,14,15,16,17,18,19,20,………………………90 ==> user data .
91,92,93,94,95,96,97,98,99. ==> reserved area or spare sector pool .
If sector from 11 to 90 is bad by any reason it will remapped by HDD translator to another sector from reserved area from 91 to 99. So say 51 is a bad sector it will remapped to 91. so user data in this area will 48,49,50,91,52,53 and so on user won’t know about this this is remapped by translator of HDD and you will see everything is normal but wait why two lists ?
P-list:
It is primary defect list which contains bad sector created after testing HDD at the factory when hdd is made it was tested by factory in this testing process bad sectors created so it will be in this list (P) but user never know anything about these bad sectors as it was remapped by translator to sector from reserved area and HDD is working good. testing must be made by factory but when you buy a hard disk 3 TB it will be 6 billion sectors if 1000 sectors are bad in P-list this is only small proportion of the total capacity . Remapping these sectors is done by translator as the above example :
11,12,13,14,15,16,17,18,19,20,………………………90 ==> user data .
91,92,93,94,95,96,97,98,99. ==> reserved area or spare sector pool .
 if sector number 13 is bad it will be marked in p list and  remapped to 92 so it will be :
11,12,92,13,14,15,16,17,18,19,20,…………………..90 .
so p list contains bad sectors which result from testing process at factory .
G-list:
It is grown defect list which contains bad sectors generated from life of your hard disk we all install, remove, read and write and so on. Bad sectors generally appear all the time but it can be fixed if not it will remapped to new sectors from reserved area and marked in G-list. but reserved sectors are limited so at some time some sectors will be marked as bad and there are no new sectors to be replaced and G-list will grow and grow, SMART will set a flag indicating check your disk, hdd will be slow so you need to recover these sectors or backup your data or keep hdd till you lose it and your data :P . Remapping these sectors like this as the above example:
11,12,13,14,15,16,17,18,19,20,………………………90 ==> user data .
91,92,93,94,95,96,97,98,99. ==> reserved area or spare sector pool .
during life of your hdd assume that sector number 19 is bad so it will be replaced by 98 like :
11,12,13,14,15,16,17,18,98,20,………………………90 .

You will notice that in p-list sector is shifted but in G-list sector is replaced for that reason there are two lists. you can recover data from sectors in G-list directly but in some cases can’t be recovered as recovery process has more values must be considered to recover data J  .
You can access these lists by special hardware like PC-3000.
Disk drive addressing LBA map and sectors here .

References :
1-                  https://www.mjm.co.uk/articles/bad-sector-remapping.html
2-                  https://en.wikipedia.org/wiki/Bad_sector
4-                  http://hdrconline.com/online_course_content.php







Monday, December 14, 2015

Disk Drive Addressing

Hello everybody , sorry for missed days before as I have some issues but now I have some issue to share with you as usual learn , share and learn then share :D that’s the closed loop which all must in and out = out of life J .
Prepare your triple espresso and come here we have a lot today about HDD addressing.
When you need data your request to access it from HDD especially from  sectors which contain as the sector is the minimal physical unit of transaction between disk and system, we can assume it as 512 bytes. Then there are two methods for addressing CHS, LBA. We have them in details.
Early HDDs have a method in addressing blocks of data that contain which is CHS as C for Cylinder, H for Head and S for sector so when your processor need to access data on your HDD, the last uses CHS to know where that data and access it all is by its controller then returned back to you as example it identifies sector by its position on track which the last is identified by head and cylinder number .  
so sector in this method are grouped under heads by factor called SectorPerHead then heads are grouped under cylinders by factor HeadsPerCylinder the last factor is for device to group all cylinders which is NumberOfCylinders so capacity  is calculated by :
CHS = NumberOfCylinders*HeadsPerCylinder*SectorsPerHead*512 .
Sure you know if one of all these parameters equals 0 so your HDD has something wrong.
CHS is started by (0, 0, 1) = (Cylinder, Head, Sector )
so as you see here:
CHS is designed for drives up to 504 MB sure I mean early IDE/ATA HDDs ,  where
C <= 1,024  , H <=16  and  S <= 63 .
Between 504 MB and 8 Gb there’s  ECHS where E is to Extended and its parameter is :
C < 1,023  , H <255  and  S <= 63 . also C is divided by 2 and H is multiplied by 2 this translation is handled by disk drive controller and you need to know if head is x and platter is y so when HDD contains y then it contains 2x .
Then the second method is called LBA (Logical Block Addressing) where the first sector is 0 so :
CHS (0,0,1) = LBA (0) .  Here the capacity is calculated by:
LBA=(Cylinder*HeadsPerCylinder+Head)*SectorsPerHead+Sector-1
As the device parameter is NumberOfSectors.


in order to optimize I/O the operating system  made cluster which is logical groups of sector that’s why you can see two option is size in any file’s properties like :  

the logical is for cluster and the physical is for sectors  . as the logical is 60952/512 = 119.046875 so this is not a valid number of sectors so the physical size is 120 sectors which is 20*512 = 61440 .

to convert between two modes LBA and CHS use this :
LBA = C x Num_Head x Num_Sec + H x Num_Sec + (S - 1) .


References :




Sunday, December 21, 2014

File Carving In Depth


“File carving,” or sometimes simply “carving,” is the process of extracting a collection of data from a larger data set. Data carving techniques frequently occur during a digital investigation when the
unallocated file system space is analyzed to extract files. The files are “carved” from the unallocated space using file type-specific header and footer values.

so File carving isn't file Recovery as in the last you need file system structure .. let's have this topic in some details
J

File carving is a powerful technique for recovering files and fragments of files when directory entries are corrupt or missing. The block of data is searched block by block for residual data matching the file type-specific header and footer values. Carving is also especially useful in criminal cases where the use of carving techniques can recover evidence. In certain cases related to child pornography, law enforcement agents are often able to recover more images from the suspect’s hard disks by using carving techniques .

Carving deals with the raw data on the media and doesn’t use the file system structure during its process. A file system (such as FAT16, FAT32, NTFS, EXT, and others) is a structure for storing and organizing computer files and the data they contain. Although carving doesn’t care about which file system is used to store the files, it could be very helpful to understand how a specific file system works. In the FAT file system for example, when a file is deleted, the file’s directory entry is changed to show that the file is no longer needed (unallocated). The first character of the filename is replaced with a marker, but the file data itself is left unchanged. Until it’s overwritten, the data is still present.

Carving makes use of the internal structure of a file. A file is a block of stored information like an image in a JPEG file. A computer uses file name extensions to identify files content.

File Recovery techniques make use of the file system information that remains after deletion of a file. By using this information, many files can be recovered. For this technique to work, the file system information needs to be correct. If not, the files can’t be recovered. If a system is formatted, the file recovery techniques will not work either.

Files are stored in file systems :
• Windows (FAT 12/16/32, NTFS)
• Linux (Ext2/Ext3/Ext4, Reiser)
• Mac (HFS, HFS+/HFSX)
• File systems store data in clusters or blocks
• Files are usually stored sequentially by the OS on media

So recovery has some levels from delete to recycle bin and empty it to format disk and overwrite some data or even bad sector :D .

General File Carving Techniques

The most common general file carving techniques are:
• Header-footer or header- “maximum file size” carving
• File structure based carving
• Content based carving

Header-footer Carving

• Recover files based on known Header and Footers or
maximum file size
• JPEG: “\xFF\xD8” header and “\xFF\xD9” ‘footer’
• GIF: “\x47\x49\x46\x38\x37\x61” header and “\x00\x3B”
footer
• PST: “!BDN” header and no footer
• If the file format has no footer a maximum file size is
used in the carving program
• Known header footers carvers are Scalpel, Foremost
and File finder (EnCase)

File Structure Based Carving

• This technique uses the internal layout of a file
• Elements are header, footer, identifier strings and size
information
• Known carvers which use this technique are Foremost
and PhotoRec

Content-based Carving

• Content structure
• Loose structure (MBOX, HTML, XML)
• Content characteristics
• Character count
• Text/Language recognition
• White and Black listing of data
• Statistical attributes (Chi^2)
• Information entropy


remember : File carving is a recovery technique that merely considers the contents and structures of files instead of file system structures or other meta-data which is used to organize data on storage media .


file carving terminology




Tools :

There are different carving tools available. Most of them are open source, and others are commercial solutions offered by companies. Due to the fact that carving is a developing technique, more and more tools are becoming available. Some of the most commonly used carving tools are:

Foremost—Originally designed by the US Air Force, it is a carver designed for recovering files based on their headers, footers, and internal data structures
Scalpel—Scalpel is a rewrite of Foremost focused on performance and a decrease of memory usage. It uses a database of header and footer definitions and extracts matching files from a set of image files or raw device files. Scalpel is file system independent and will carve files from FATx, NTFS, EXT2/3, or raw partitions. Scalpel will not allow you to output to the same directory you’re carving from.
Photorec—Photorec is a data recovery software tool designed to recover lost files from digital camera storage media (CompactFlash, Memory Stick, Secure Digital, SmartMedia, Microdrive, MMC, USB flash drives, and others), hard disks, and CD-ROMs. It recovers most common photo formats, audio files, document formats, such as Microsoft Office, PDF, HTML, and archive/compression formats. A complete list of supported file formats can be read on the Photorec website. PhotoRec does not attempt to write to the damaged media from where recovery is being performed. Recovered files are instead written to the directory from where you are running PhotoRec or any other directory you choose.
More information about data carving tools and recovery tools can be found on forensicwiki .

Datasets :
• FAT carving test dataset (15 files)
• DFRWS 2006 challenge image (32 files)

Monday, September 22, 2014

You wanna be certified : OSCP


Offensive Security Certified Professional


one of the most elite certification in security world . practical guide to pen testing although I don't have this Cert. but I found some small guides that will help us let's share . you have to complete Penetration Testing with Kali Linux (PWK) course 



Prerequisites :


Logic To write Code , TCP/IP ,  Linux


this all resources I have found it useful :

 

1- Pentesting with Backtrack/OSCP Review
2- Penetration Testing w/ BackTrack (OSCP) Course Review
3- My Journey to OSCP … complete blog
4- OSCP and Me
5- Offensive Security’s PWB and OSCP — My Experience
6- OSCP Series
7- OSCP at a glance
8- My OSCP Experience
9- Pentesting With BackTrack (PWB) & Offensive Security Certified Professional (OSCP) Reviews 2013
10- Offensive Security PWB (OSCP) – A Review
11- Offensive Security Certified Professional