{"id":3180,"date":"2015-08-22T17:02:35","date_gmt":"2015-08-22T17:02:35","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=3180"},"modified":"2015-08-22T17:44:36","modified_gmt":"2015-08-22T17:44:36","slug":"craving-for-time-carve-some-timestamps-out-timecraver-v0-1","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2015\/08\/22\/craving-for-time-carve-some-timestamps-out-timecraver-v0-1\/","title":{"rendered":"Craving for time? Carve some timestamps out&#8230; &#8211; TimeCraver v0.1"},"content":{"rendered":"<p>Analysis of binary data is always challenging. Data can be encrypted, encoded, and stored in a number of proprietary formats. Understanding of what data represents and how it is stored is non-trivial. It typically involves either analysis of the code that writes stuff to a file, or trying our luck by guessing what is a possible structure of the actual data. The typical approach is to simply look at it and its properties.<\/p>\n<p>This can involve checking its entropy and how it changes over the file, looking for patterns typically associated with popular compression algorithms, attempting to brute-force various trivial encryption algos, checking if any data is recognized as a string, Unicode string, localized string, a potential absolute or relative offset to other data, or maybe a byte-, word-, dword- long length preceding data etc.<\/p>\n<p>One of the most popular tools that is used to analyze unknown data is <a href=\"http:\/\/binwalk.org\/\">binwalk<\/a> and it helped me on many occasions by providing hints on what is possibly &#8216;in the file&#8217;. Sometimes, even if it didn&#8217;t recognize anything interesting was also a good hint &#8211; typically meaning encryption, or something really unusual\/proprietary.<\/p>\n<p>Existing tools are always handy, but I can&#8217;t count how many quick &amp; dirty (and often completely stupid) scripts I wrote to get some data to look more &#8216;reasonable&#8217; and &#8216;normal&#8217;.<\/p>\n<p>In today&#8217;s post I am showing a simple example of such &#8216;unknown data analysis script&#8217;.<\/p>\n<p>When we see a binary file, we typically run &#8216;strings&#8217; on them and we gather a nice readable &#8216;printable&#8217; data for analysis.The &#8216;non-printable&#8217; is also interesting though, so another tool I often run is a strings-like script that carves timestamps out. This comes handy for smaller files, especially for these that look like a config, a quarantine, and anything really that looks like may have\u00a0 a potential timestamps embedded in it.<\/p>\n<p>Carving works following a simple rule &#8211; read 4\/8 bytes, convert it to an epoch using various conversion algos (based on assumed timestamp format), see if epoch converts to a date between years 2000-2015, and if it does &#8211; just print it out, together with the offset and some extra metadata.<\/p>\n<p>Example:<\/p>\n<pre>\u00a0\u00a0\u00a0\u00a0 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\u00a0\u00a0 0123456789ABCDEF\r\n---------------------------------------------------------------------------\r\n00 : 80 86 F6 34 00 C0 5D CE 56 CF CD 01 00 40 FA 13\u00a0\u00a0 ...4..].V....@.. 00\r\n10 : 0F 00 CE 01 00 40 8B B7 0F 16 CE 01 00 80 59 DA\u00a0\u00a0 .....@........Y. 16\r\n20 : 6B 2E CE 01 00 00 BE D2 FE 45 CE 01 00 A4 03 01\u00a0\u00a0 k........E...... 32\r\n30 : 85 95 C2 01\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ....\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 36<\/pre>\n<p>Looking at such binary data doesn&#8217;t give us much useful information.<\/p>\n<p>Running timecraver over it, gives us the following:<\/p>\n<pre>===========================================\r\n\u00a0TimeCraver v0.1, Hexacorn.com, 2015-08-23\r\n===========================================\r\n00000000,DOSTIME ,44C257B0,2006-07-22 16:52:00,8086F634\r\n00000004,FILETIME,50B94880,2012-12-01 00:00:00,00C05DCE56CFCD01\r\n0000000A,EPOCH\u00a0\u00a0 ,400001CD,2004-01-10 13:44:45,CD010040\r\n0000000C,FILETIME,510B0580,2013-02-01 00:00:00,0040FA130F00CE01\r\n00000012,EPOCH\u00a0\u00a0 ,400001CE,2004-01-10 13:44:46,CE010040\r\n00000014,FILETIME,512FEF7F,2013-02-28 23:59:59,00408BB70F16CE01\r\n0000001C,FILETIME,5158CDFF,2013-03-31 23:59:59,008059DA6B2ECE01\r\n00000024,FILETIME,51805B00,2013-05-01 00:00:00,0000BED2FE45CE01\r\n00000026,EPOCH\u00a0\u00a0 ,45FED2BE,2007-03-19 18:13:18,BED2FE45\r\n0000002C,FILETIME,3DE3D068,2002-11-26 19:50:00,00A403018595C201<\/pre>\n<p>The first column is an offset, followed by the timestamp type, then hexadecimal EPOCH calculated from the data, then its YYYY-MM-DD hh:mm:ss representation and finally the actual bytes from the file that are converted to EPOCH.<\/p>\n<p>The data is immediately more readable and certain conclusions can be drawn. If you look at the offsets, distance between them and type of timestamps you may actually &#8216;see through&#8217; the data and potentially &#8216;define&#8217; a reasonable structure.<\/p>\n<p>In this particular case, we can see that FILETIME is<\/p>\n<pre>00000004, 0000000C<\/pre>\n<pre>00000014, 0000001C<\/pre>\n<pre>00000024, 0000002C<\/pre>\n<p>&#8211; looks like a sequence of FILETIME records. Following this logic, we can guess that structure of the file is potentially like this:<\/p>\n<pre>00000000,DOSTIME ,44C257B0,2006-07-22 16:52:00,8086F634\r\n00000004,FILETIME,50B94880,2012-12-01 00:00:00,00C05DCE56CFCD01\r\n0000000C,FILETIME,510B0580,2013-02-01 00:00:00,0040FA130F00CE01\r\n00000014,FILETIME,512FEF7F,2013-02-28 23:59:59,00408BB70F16CE01\r\n0000001C,FILETIME,5158CDFF,2013-03-31 23:59:59,008059DA6B2ECE01\r\n00000024,FILETIME,51805B00,2013-05-01 00:00:00,0000BED2FE45CE01\r\n0000002C,FILETIME,3DE3D068,2002-11-26 19:50:00,00A403018595C201<\/pre>\n<p>I can confirm it since it is one of the test files I created \ud83d\ude42<\/p>\n<p>The script can be found <a href=\"https:\/\/www.hexacorn.com\/tools\/TimeCraver.pl\">here<\/a>.<\/p>\n<p>Happy craving &amp; carving !<\/p>\n<p>Bonus: if you look at the data in Registry, you will find more timestamps than you thought are actually there. This is a subject for another post \ud83d\ude42<\/p>\n<p><strong>Update<br \/>\n<\/strong><\/p>\n<p>Bonus will be here faster than expected &#8211; turns out Andrew Case, Jerry Stormo, Joseph Sylve, and Vico Marziale wrote an awesome python script for <a href=\"https:\/\/github.com\/504ensicsLabs\/find_times\/blob\/master\/find_times.py\">timestamp carving in Registry<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Analysis of binary data is always challenging. Data can be encrypted, encoded, and stored in a number of proprietary formats. Understanding of what data represents and how it is stored is non-trivial. It typically involves either analysis of the code &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2015\/08\/22\/craving-for-time-carve-some-timestamps-out-timecraver-v0-1\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[21,19,9,5],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/3180"}],"collection":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/comments?post=3180"}],"version-history":[{"count":10,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/3180\/revisions"}],"predecessor-version":[{"id":3190,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/3180\/revisions\/3190"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=3180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=3180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=3180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}