ext3/ext4
Design principles:
- Data blocks are closely together due to performance reasons.
- Important meta data is stored multiple times.
- Metadata of files and directories is stores in an index node (inode). A inode contains meta data (owner, group, permissions, …) and a reference to data blocks.
- inode = 2 => root directory
- Superblock:
- A block only with configuration data like number of blocks in the filesystem, number of blocks pro block group, …
- Is stored multiple times on a filesystem.
- Block group:
- A large area on the filesystem. Ext tries to store all blocks of a file in the same block group due to (HDD…) performance reasons.
- When a file is deleted, ext overwrites directly the address of an inode with zero and sets the changed data to the delete data. This makes it harder to retrieve deleted data.
- In NTFS, the filename is stored in the MFT master file table. In ext, the filenames are not in the inodes and can therefore not necessary be recovered when files / data was partially deleted. File carving can then be used.
- Process:
- The system opens inode = 2 for the root directory.
- This contains a list:
- 0 0 0600 etc 400
- 0 0 0777 tmp 500
- The user wants to open tmp. Then, the system reads the inode at position 500.
- This inode has
- 1000 1000 0644 file.txt 6330
- If the user wants to access the file at position 6330, the systems loads the memory from this position.
- Journaling
- Since ext3
- Changes are logged before the action was performed on the file system.
- Only when the action was logged and committet, then the changes were applied on the filesystem.
- Show the journal:
jls -o 4096 ext_image.img
Information about the file system
General information
fsstat /dev/sda1
Information of an inode (2 = root directory):
istat /dev/sda1 2
Get the partitions of an image
mmls server.img
mmls shows the start offset of each partition. Show details of the partition which starts at 4096:
fsstat -o 4096 server.img
Show all files of a partition:
fls -o 4096 server.img > /tmp/server_files.txt
Create a timelime of created files from the filesystem:
fls -pro 4096 -rm '/' server.img > bodyfile.txt
mactime -b bodyfile.txt -d -h > timeline.txt
Get the content of a file. Assume, we found this in the bodyfile. Here, we have also the inode.
0|/etc/ssh/sshd_config.d/hardening.conf|13437|r/rrw-r--r--|0|0|...
We can now use the inode to get the file info:
istat -o 4096 server.img 13437
And we cat get the (ascii) file with
icat -o 4096 server.img 13437
Tip: If you are analyzing an image, try to get inodes in a similar range. If you have an interesting file, e.g. a malware file, try to get inodes a bit before and afterwards. Maybe there are other files which were created in the same time.
Recovering data
- Try extundelete to recover files.
- extundelete /dev/sda1 –restore-file /tmp/SSH/file
- extundelete /dev/sda1 –restore-directory /tmp/SSH/
base64 search
Use GitHub — heyitsmikeyv/base64-keystrings: Find key search strings to locate base64-encoded versions of ASCII strings. to search also for base64 strings.
Leave a Reply
You must be logged in to post a comment.