Data hiding and finding on Linux<br />Anton Chuvakin, Ph.D.<br />WRITTEN: 2002-2003<br />DISCLAIMER:<br />Security is a ra...
Data hiding and finding on Linux
Data hiding and finding on Linux
Data hiding and finding on Linux
Data hiding and finding on Linux
Data hiding and finding on Linux
Data hiding and finding on Linux
Upcoming SlideShare
Loading in …5
×

Data hiding and finding on Linux

2,400 views
2,239 views

Published on

The article briefly touches upon hiding, finding and destroying data
on Linux file systems. It should become clear that the area of computer
forensics, aimed at recovering the evidence from captured disk drives,
has many challenges, requiring knowledge of hardware, operating
systems and application software.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,400
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Data hiding and finding on Linux

  1. 1. Data hiding and finding on Linux<br />Anton Chuvakin, Ph.D.<br />WRITTEN: 2002-2003<br />DISCLAIMER:<br />Security is a rapidly changing field of human endeavor. Threats we face literally change every day; moreover, many security professionals consider the rate of change to be accelerating. On top of that, to be able to stay in touch with such ever-changing reality, one has to evolve with the space as well. Thus, even though I hope that this document will be useful for to my readers, please keep in mind that is was possibly written years ago. Also, keep in mind that some of the URL might have gone 404, please Google around.<br />The article briefly touches upon hiding, finding and destroying data<br />on Linux file systems. It should become clear that the area of computer<br />forensics, aimed at recovering the evidence from captured disk drives,<br />has many challenges, requiring knowledge of hardware, operating<br />systems and application software.<br />It is common knowledge, that what is deleted from the computer can<br />sometimes be brought back. Recent analysis of security implications<br />of " alternative datastreams" on Windows NT by Kurt Seifried<br />(http://seifried.org/security/advisories/kssa-003.html) has shown that<br />Windows NTFS filesystem allows data hiding in " alternative<br />datastreams" connected to files. These datastreams are not destroyed<br />by many file wiping utilities that promise irrecoverable removal of<br />information. Wiping the file means " securely" deleting it from disk<br />(unlike the usual removal of file entries from directories), so that<br />file restoration becomes extremely expensive or impossible.<br />Some overview of what remains on disk after file deletion, how it can<br />be discovered and how such discovery can be prevented are provided<br />here http://www.cs.auckland.ac.nz/~pgut001/pubs/secure_del.html The<br />author recommends overwriting files multiple times with special<br />patterns. Against casual adversaries, simply overwriting the file with<br />zeros once will help.<br />Linux has no alternative data streams, but files removed using /bin/rm<br />still remain on the disk. Most likely, Linux system uses ext2<br />filesystem (or its journaling version, ext3 by RedHat). A casual look<br />at the design of ext2 filesystem<br />(http://e2fsprogs.sourceforge.net/ext2intro.html) shows several places<br />where data can be hidden.<br />Let us start with the classic method to hide material on UNIX<br />filesystems (not even ext2 specific): run a process that keeps the<br />file open and then remove the file. The file contents are still on<br />disk and the space will not be reclaimed by other programs. It is<br />worthwhile to note, that if an executable erases itself, its contents<br />can be retrieved from /proc memory image: command " cp /proc/$PID/exe<br />/tmp/file" creates a copy of a file in /tmp.<br />If the file is removed by /bin/rm, its content still remains on disk,<br />unless overwritten by other files. Several Linux unerase utilities<br />(e2undel - http://e2undel.sourceforge.net/ or recover -<br />http://recover.sourceforge.net/) attempt automated recovery of<br />files. They are based on " Linux Ext2fs Undeletion mini-HOWTO" <br />(http://www.linuxdoc.org/HOWTO/mini/Ext2fs-Undeletion.html) that<br />provides a nice guide to file recovery from Linux partitions. Recovery<br />can also be performed manually using debugfs Linux utility (as<br />described in the above HOWTO).<br />Overall, if recovery is attempted shortly after file removal and the<br />partition is promptly unmounted, chances of complete recovery are<br />high. If the system was heavily used, the probability of successful<br />data undeletion significantly decreases. However, if we are to look at<br />the problem from the forensics point of view, the chances of<br />recovering *something* (such as a small part of the illegal image for<br />the prosecution) is still very high. It was reported that sometimes<br />parts of files from several years ago are found by forensic examiners.<br />Thus files can be hidden in free space. If many copies of the same<br />file are saved and then erased, the chance of getting the contents<br />back becomes higher using the above recovery methods. However, due to<br />the intricacies of ext2 filesystem, the process can only be reliably<br />automated for small files. <br />A more detailed look at ext2 internals reveals the existence of slack<br />space. Filesystem uses addressable parts of disk called blocks, that<br />have the same size. Ext2 filesystems typically use 1,2 or 4 KB<br />blocks. If a file is smaller than the block size, the remaining space<br />is wasted. It is called slack space. This problem long plagued early<br />Windows 9x users with FAT16 filesystems, which had to use block sizes<br />of up to 32K, thus wasting a huge amount of space if storing small<br />files.<br />On a 4GB Linux partition the block size might be 4K (chosen<br />automatically when the " mke2fs" utility is run to create a<br />filesystem). Thus one can reliably hide up to 4KB of data per file if<br />using a small file. The data will be invulnerable to disk usage,<br />invisible from the filesystem, and, which is more exciting for some<br />people, undetectable by file integrity checkers using file<br />checksumming algorithms and MAC times. Ext2 floppy (with a block size<br />of 1KB) allows hiding data as well, albeit in smaller chunks.<br />The obscure tool bmap (available<br />ftp://ftp.scyld.com/pub/forensic_computing/bmap/) exists to jam data<br />in slack space, take it out and also wipe the slack space, if<br />needed. Some of the examples follow:<br /># echo " evil data is here" | bmap --mode putslack /etc/passwd<br />puts the data in slack space produced by /etc/password file<br /># bmap --mode slack /etc/passwd<br />getting from block 887048<br />file size was: 9428<br />slack size: 2860<br />block size: 4096<br />evil data is here<br />shows the data<br /># bmap --mode wipeslack /etc/passwd<br />cleans the slack space.<br />Hiding data in slack space can be used to store secrets, plant<br />evidence (forensics software will find it, but the suspect probably<br />will not) and maybe hide tools from integrity checkers (if automated<br />splitting of the larger file into slack-sized chunks is implemented).<br />Now lets turn to discovering what is out there on the vast expanses of<br />the disk drive? If looking for strings of text, a simple " strings<br />/dev/hdaX | grep 'string we need'" will confirm the presence of string<br />on the partition (the process *will* take along time). Using a hex<br />editor on the raw partition can sometimes shed some light on the disk<br />contents, but the process is extremely messy. Thus further analysis<br />puts us firmly in the field of computer forensics. The great tools for<br />snooping around on the disk is Coroner Toolkit by Dan Farmer and<br />Wietse Venema (tct, can be obtained from<br />http://www.porcupine.org/forensics/tct.html) and a set of utilities<br />for it by Brian Carrier (tctutils, available at<br />http://www.cerias.purdue.edu/homes/carrier/forensics/). The software<br />provides functionality for gathering forensics data, recovering files,<br />analyzing drive contents for changes (using file timestamps), locating<br />content on disks (using inode and block numbers) and for other fun<br />forensics tasks. Detailed description of the toolkit goes well beyond<br />the scope of this paper.<br /> <br />Now lets briefly review how to prevent the adversaries from finding<br />private data Several Linux file wipe utilities exist. All but one can<br />only be used to wipe files, rather than empty disk space. GNU shred<br />(by Colin Plumb), srm (by Todd Burgess), wipe (by Tom Vier) and srm<br />from thc kit (by THC group, see<br />http://packetstorm.widexs.nl/groups/thc/). Some use the multiple<br />random passes as recommended in the above paper and some simply<br />overwrite the file with zeros once. Some does not work under certain<br />circumstances or for specific filesystems. As reported in shred man<br />page " shred relies on a very important assumption: that the filesystem<br />overwrites data in place" . If this condition is not met, no secure<br />deletion will be performed (with no error message!).<br />To eliminate the traces of old removed files, one might want to wipe<br />the empty space. The simple method is to use a standard Linux " dd" <br />utility. To wipe the empty space on /home partition use:<br />1. dd if=/dev/zero of=/home/bigfile<br />2. sync<br />3. rm /home/bigfile<br />4. sync<br />The commands will zero out the empty space on the partition. Doing the<br />same for /tmp partition might cause some applications to crash, thus<br />one must be cautious. Utility " sfill" from thc THC secure_delete<br />package (available at http://packetstorm.widexs.nl/groups/thc/) can<br />overwrite empty space using more stringent algorithm.<br />It should be noted that swap space can also contain pieces of private<br />data and should be wiped as well if additional security is<br />desired. Another program (sswap) from THC toolkit can be utilized for<br />the purpose.<br />The important fact to note is that when empty space is wiped, slack<br />space for all files remains intact. If file is wiped (at least using<br />current version of GNU shred), the associated slack space is NOT wiped<br />with it!<br />ABOUT THE AUTHOR:<br />This is an updated author bio, added to the paper at the time of reposting in 2009. <br />Dr. Anton Chuvakin (http://www.chuvakin.org) is a recognized security expert in the field of log management and PCI DSS compliance. He is an author of books " Security Warrior" and " PCI Compliance" and a contributor to " Know Your Enemy II" , " Information Security Management Handbook" and others. Anton has published dozens of papers on log management, correlation, data analysis, PCI DSS, security management (see list www.info-secure.org) . His blog http://www.securitywarrior.org is one of the most popular in the industry.<br />In addition, Anton teaches classes and presents at many security conferences across the world; he recently addressed audiences in United States, UK, Singapore, Spain, Russia and other countries. He works on emerging security standards and serves on the advisory boards of several security start-ups.<br />Currently, Anton is developing his security consulting practice, focusing on logging and PCI DSS compliance for security vendors and Fortune 500 organizations. Dr. Anton Chuvakin was formerly a Director of PCI Compliance Solutions at Qualys. Previously, Anton worked at LogLogic as a Chief Logging Evangelist, tasked with educating the world about the importance of logging for security, compliance and operations. Before LogLogic, Anton was employed by a security vendor in a strategic product management role. Anton earned his Ph.D. degree from Stony Brook University.<br />

×