Developers
From CGSecurity
Contents |
Using Git to get latest source code
Git is a modern source code manager
http://git.cgsecurity.org/testdisk.git is a Git repository to track TestDisk & PhotoRec source code, you can browse it using http://git.cgsecurity.org/cgit/testdisk/
Install git using
-
yum install gitfor Fedora, RedHat, Centos -
sudo apt-get install git-corefor Debian, Ubuntu
Configure your local settings
$ git config --global user.name "Your Name" $ git config --global user.email "Your Email"
Clone the current source code
$ git clone http://git.cgsecurity.org/testdisk.git
Compile TestDisk & PhotoRec
$ cd testdisk $ mkdir config $ aclocal -I config $ autoheader -W all $ autoconf -W all $ automake --gnits --add-missing --copy $ ./configure $ make
Read TestDisk Compilation if you have problems to compile TestDisk & PhotoRec
It's time to make your own modifications and submit the patch
$ (edit files) $ git add (files) $ git commit -a $ git format-patch origin/master $ ls *.patch
Download source code
If you have been unable to install git, download a snapshot of TestDisk & PhotoRec latest source code. Get the beta version, the Work-In-Progress (WIP) one.
Adding a new file format to PhotoRec
The first step is to check if PhotoRec already identify the file.
Run fidentify sample_file. If the file is identified with an incorrect extension, check if there is way to differentiate this file from files having the extension that has been found.
If fidentify reports the format as unknown, you have found a
candidate for inclusion.
If the file format specifications aren't available, compare several samples to identify constant fields. In example, PhotoRec identifies a JPEG file when a block begins with:
- 0xff,0xd8,0xff,0xe0
- 0xff,0xd8,0xff,0xe1
- or 0xff,0xd8,0xff,0xfe
To add a new file format to PhotoRec,
- edit src/file_list.c to add
extern const file_hint_t file_hint_<EXTENSION>;
- and in list_file_enable[]
{ .enable=0, .file_hint=&file_hint_<EXTENSION> },
- edit src/Makefile.am to modify file_C definition, add
file_<EXTENSION>.c
- If there is a header file, add it to file_H definition
- Create a file name
src/file_<EXTENSION>.c. - Register the various MAGIC header in register_header_check_EXTENSION()
In this example, file_check_EXTENSION() is used to check for a footer.
Check
- src/file_bmp.c for an example where the filesize is stored in the header.
- src/file_bac.c, src/file_mp3.c, src/file_m2ts.c, src/file_mov.c for file format using streaming
- src/file_gz.c, src/file_d2s.c, src/file_r3d.c for example where the file name is found in the header
- src/file_doc.c, src/file_exe.c where the file name may be found in the file itself
- src/file_doc.c, src/file_fits.c, src/file_jpg.c, src/file_tiff.c: date/time is extracted from the file
qphotorec: PhotoRec with a Qt4 GUI
Enable QPhotoRec compilation:
./configure --enable-qt && make
qphotorec isn't yet usable but you are welcome to work on it ;-)
