SlideShare a Scribd company logo
2
Most read
Forensic Analysts are on the front lines of
computer investigations. This guide aims to
support Forensic Analysts in their quest to
uncover the truth.
grep's strength is extracting information from
text files. grep operates on one or multiple
files when provided with a command line
argument(s) that can also include wildcards:
Example: grep "John" addressbook
Would return the lines that contained the
"John" string in the addressbook text file
Some useful flags:
-A Print number of lines after the match
-B Print number of lines before match
-c Report number of occurrences
-f Reads one or more patterns from a file.
Pattern are terminated by a newline
-h Suppress the file names on the output
-i Ignore case
-l Report matching files, not matching lines
-P Interpret pattern as a Perl Regex
-v Reverse operation: return the lines not
matching the string
The egrep (extended grep) utility can be useful
to match several possible strings at the same
time (in an OR mode):
egrep "John|Peter" addressbook
grep "John|Peter" addressbook
grep/egrep
Purpose
How To Use This Sheet
When performing an investigation it is helpful to be
reminded of the powerful options available to the
investigator. This document is aimed to be a
reference to the tools that could be used.
This sheet is split into these sections:
โ€ข Hex File Headers
โ€ข grep/egrep
โ€ข sort
โ€ข awk
โ€ข sed
โ€ข uniq
โ€ข date
โ€ข Windows findstr
The key to successful forensics is minimizing
your data loss, accurate reporting, and a
thorough investigation.
File headers are used to identify a file by
examining the first 4 or 5 bytes of its
hexadecimal content.
Filetype Start Start ASCII
Translation
ani 52 49 46 46 RIFF
au 2E 73 6E 64 snd
bmp 42 4D F8 A9 BM
bmp 42 4D 62 25 BMp%
bmp 42 4D 76 03 BMv
cab 4D 53 43 46 MSCF
dll 4D 5A 90 00 MZ
Excel D0 CF 11 E0
exe 4D 5A 50 00 MZP (inno)
exe 4D 5A 90 00 MZ
flv 46 4C 56 01 FLV
gif 47 49 46 38 39 61 GIF89a
gif 47 49 46 38 37 61 GIF87a
gz 1F 8B 08 08
ico 00 00 01 00
jpeg FF D8 FF E1
jpeg FF D8 FF E0 JFIF
jpeg FF D8 FF FE JFIF
Linux bin 7F 45 4C 46 ELF
png 89 50 4E 47 PNG
msi D0 CF 11 E0
mp3 49 44 33 2E ID3
mp3 49 44 33 03 ID3
OFT 4F 46 54 32 OFT2
PPT D0 CF 11 E0
PDF 25 50 44 46 %PDF
rar 52 61 72 21 Rar!
sfw 43 57 53 06/08 cws
tar 1F 8B 08 00
tgz 1F 9D 90 70
Word D0 CF 11 E0
wmv 30 26 B2 75
zip 50 4B 03 04 PK
Hex File Header and ASCII Equivalent
Hex File Headers and
Regex for Forensics
Cheat Sheet v1.0
SANS Forensics
http://computer-forensics.sans.org
http://blogs.sans.org/computer-forensics
By Guy Bruneau, gbruneau@sans.org
sort
sort, as its name implies, will sort the
output. There are a few interesting options you
can use:
-d Uses dictionary order. Only letters,
digits and blanks.
-n will sort the output assuming it is
numerical (instead of string)
-u will remove redundant line, 'uniquing'
the results
awk is an extremely useful tool, especially for
parsing data structured in columns. It is
straightforward to use for simple purposes. Its
basic use is to select some particular columns
from the output: column 1 is referred to as $1,
column 2 as $2, etc.
The space is the default awk separator. However
if you want to be able to parse data separated
by some other character, e.g. ":", you can use
the -F flag.
Example: echo "hello:goodbye" | awk -F:
'{print $2}'
Would return "goodbye" as an output
awk
sed is an excellent command for character
substitution. Example: if you want to
substitute the first occurrence of the 'a'
character by an 'e':
echo "hallo" | sed 's/a/e/'
The output would be: hello
You can use the g modifier to substitute all
instances:
echo "Hallo Janny" | sed 's/a/e/g'
The output would be: Hello Jenny
sed
Forensic Analysis
Cheat Sheet
Forensics
MANDIANT
contact@mandiant.com
703.683.3141
http://www.mandiant.org
The Windows findstr has one interesting
feature that differs from grep. If you need
to search for multiple strings, you need to
separate them with a space.
For example, you want or need to look for a
match for WHITE or GREEN in a text file, you
write your command like this:
findstr "WHITE GREEN" textfile
To make the search case insensitive, add the
/I to print all variant of WHITE or GREEN.
Windows findstr Command List
/B Matches pattern if at the beginning of
a line.
/E Matches pattern if at the end of a
line.
/L Uses search strings literally.
/R Uses search strings as regular
expressions.
/S Searches for matching files in the
current directory and all
subdirectories.
/I Specifies that the search is not to be
case-sensitive.
/X Prints lines that match exactly.
/V Prints only lines that do not contain
a match.
/N Prints the line number before each
line that matches.
/M Prints only the filename if a file
contains a match.
/O Prints character offset before each
matching line.
/P Skip files with non-printable
characters.
Windows findstr
Check the date man page for more options.
Returns the real date from epoch time:
date โ€“d @1284127201
Return an epoch time of 1288756800:
date +%s -d โ€œ2010-11-03โ€
Return a 2 days old date:
date --date="-2 days" +"%Y-%m-%d"
Return 20:00 hours:
date -d @1288310401 +%k:%M
The uniq command reads the input and compares
adjacent lines. If two or more adjacent lines
are identical, all but one is removed.
Here is a list of the most common options used
with uniq:
-c Prefix line with number of occurrence
-f Avoid comparing the first N fields
-i Ignore case
-s Avoid comparing the first N characters
-u Only print unique lines
Consider this input file:
a
b
c
b
Now run uniq on it: sort testfile | uniq
a
b
c
Now run uniq -c on it:
1 a
2 b
1 c
uniq
Date

More Related Content

PPTX
Hosting a website on IIS Server
PDF
Introduction to Progressive web app (PWA)
PPTX
Postman. From simple API test to end to end scenario
PDF
Introduction to Nexus Repository Manager.pdf
PDF
Kubernetes vs Docker Swarm | Container Orchestration War | Kubernetes Trainin...
PPTX
Cypress Testing.pptx
PPTX
Rest assured
PDF
[๋ฐœํ‘œ์ž๋ฃŒ] ์˜คํ”ˆ์†Œ์Šค ๊ธฐ๋ฐ˜ ํด๋ผ์šฐ๋“œ ๋„ค์ดํ‹ฐ๋ธŒ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ตฌ์ถ• ๋ฐฉ์•ˆ (feat. Kubernetes)
Hosting a website on IIS Server
Introduction to Progressive web app (PWA)
Postman. From simple API test to end to end scenario
Introduction to Nexus Repository Manager.pdf
Kubernetes vs Docker Swarm | Container Orchestration War | Kubernetes Trainin...
Cypress Testing.pptx
Rest assured
[๋ฐœํ‘œ์ž๋ฃŒ] ์˜คํ”ˆ์†Œ์Šค ๊ธฐ๋ฐ˜ ํด๋ผ์šฐ๋“œ ๋„ค์ดํ‹ฐ๋ธŒ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ตฌ์ถ• ๋ฐฉ์•ˆ (feat. Kubernetes)

What's hot (9)

PDF
Test Automation
PPTX
An introduction to DevOps
PDF
Virtual meetup - Exploring the Runtime Fabric deployment model
PDF
Partnerships: A Primer
PPTX
API Model Canvas (APIDays Mediterranea 2015)
ย 
PPTX
Overview of API Management Architectures
PDF
AWS์˜ ๋‹ค์–‘ํ•œ Compute ์„œ๋น„์Šค(EC2, Lambda, ECS, Batch, Elastic Beanstalk)์˜ ํŠน์ง• ์ดํ•ดํ•˜๊ธฐ - ๊น€...
PPTX
Performance Testing REST APIs
PDF
apidays Australia 2023 - API Strategy In The Era Of Generative AI,Shreshta Sh...
ย 
Test Automation
An introduction to DevOps
Virtual meetup - Exploring the Runtime Fabric deployment model
Partnerships: A Primer
API Model Canvas (APIDays Mediterranea 2015)
ย 
Overview of API Management Architectures
AWS์˜ ๋‹ค์–‘ํ•œ Compute ์„œ๋น„์Šค(EC2, Lambda, ECS, Batch, Elastic Beanstalk)์˜ ํŠน์ง• ์ดํ•ดํ•˜๊ธฐ - ๊น€...
Performance Testing REST APIs
apidays Australia 2023 - API Strategy In The Era Of Generative AI,Shreshta Sh...
ย 
Ad

Viewers also liked (20)

PDF
Linux ็ณป็ตฑ็ฎก็†่ˆ‡ๅฎ‰ๅ…จ๏ผš็ณป็ตฑ้˜ฒ้งญ่ˆ‡่ณ‡่จŠๅฎ‰ๅ…จ
PPTX
Web_DBใฎ็›ฃ่ฆ–
PPT
Donate Organs
PDF
้…ๅธƒ็”จCacti running with cherokee
DOC
Nagios็š„ๅฎ‰่ฃ…้ƒจ็ฝฒๅ’ŒไธŽcacti็š„ๆ•ดๅˆ๏ผˆlinuxtone๏ผ‰
PPTX
Groovy Introduction for Java Programmer
ย 
PDF
Linux ็ณป็ตฑ็ฎก็†่ˆ‡ๅฎ‰ๅ…จ๏ผšๅŸบๆœฌ Linux ็ณป็ตฑ็Ÿฅ่ญ˜
PDF
Tmux quick-reference
PDF
Webใ‚ตใƒผใƒๅ‹‰ๅผทไผš#5mod sedใซใคใ„ใฆ
PDF
RHEL roadmap
PDF
UNIX SHELL IN DBA EVERYDAY
PDF
Cacti manual
PPT
Sorting techniques in Perl
PDF
Unix interview questions
PDF
Hadoopp0f 150325024427-conversion-gate01
TXT
PDF
shell script introduction
ย 
PPTX
Recommender system
ย 
PDF
Course 102: Lecture 13: Regular Expressions
PPTX
sed -- A programmer's perspective
ย 
Linux ็ณป็ตฑ็ฎก็†่ˆ‡ๅฎ‰ๅ…จ๏ผš็ณป็ตฑ้˜ฒ้งญ่ˆ‡่ณ‡่จŠๅฎ‰ๅ…จ
Web_DBใฎ็›ฃ่ฆ–
Donate Organs
้…ๅธƒ็”จCacti running with cherokee
Nagios็š„ๅฎ‰่ฃ…้ƒจ็ฝฒๅ’ŒไธŽcacti็š„ๆ•ดๅˆ๏ผˆlinuxtone๏ผ‰
Groovy Introduction for Java Programmer
ย 
Linux ็ณป็ตฑ็ฎก็†่ˆ‡ๅฎ‰ๅ…จ๏ผšๅŸบๆœฌ Linux ็ณป็ตฑ็Ÿฅ่ญ˜
Tmux quick-reference
Webใ‚ตใƒผใƒๅ‹‰ๅผทไผš#5mod sedใซใคใ„ใฆ
RHEL roadmap
UNIX SHELL IN DBA EVERYDAY
Cacti manual
Sorting techniques in Perl
Unix interview questions
Hadoopp0f 150325024427-conversion-gate01
shell script introduction
ย 
Recommender system
ย 
Course 102: Lecture 13: Regular Expressions
sed -- A programmer's perspective
ย 
Ad

Similar to Cheatsheet: Hex file headers and regex (20)

PDF
Unit 8 text processing tools
PPT
CInputOutput.ppt
PDF
Unix Tutorial
PDF
Awk A Pattern Scanning And Processing Language
PDF
Awk --- A Pattern Scanning And Processing Language (Second Edition)
PPT
ShellAdvanced shell scripting programm.ppt
PPT
ShellAdvanced aaรคaaaaaaaaaaaaaaaaaaaaaaaaaaa
ย 
PDF
Beginning with vi text editor
PPT
intro unix/linux 05
ย 
PPTX
terminal command2.pptx with good explanation
PPT
typemap in Perl/XS
PDF
awkbash quick ref for Red hat Linux admin
PPT
Talk Unix Shell Script 1
ย 
PPT
Talk Unix Shell Script
ย 
PPT
L5_regular expression command for linux unix
ODP
Vim and Python
DOCX
C cheat sheet for varsity (extreme edition)
PPTX
Grep - A powerful search utility
PDF
Advanced perl finer points ,pack&unpack,eval,files
PPTX
Unix Trainning Doc.pptx
Unit 8 text processing tools
CInputOutput.ppt
Unix Tutorial
Awk A Pattern Scanning And Processing Language
Awk --- A Pattern Scanning And Processing Language (Second Edition)
ShellAdvanced shell scripting programm.ppt
ShellAdvanced aaรคaaaaaaaaaaaaaaaaaaaaaaaaaaa
ย 
Beginning with vi text editor
intro unix/linux 05
ย 
terminal command2.pptx with good explanation
typemap in Perl/XS
awkbash quick ref for Red hat Linux admin
Talk Unix Shell Script 1
ย 
Talk Unix Shell Script
ย 
L5_regular expression command for linux unix
Vim and Python
C cheat sheet for varsity (extreme edition)
Grep - A powerful search utility
Advanced perl finer points ,pack&unpack,eval,files
Unix Trainning Doc.pptx

More from Kasper de Waard (12)

PDF
Cheatsheet: Netcat
PDF
Cheatsheet: Metasploit
PDF
Cheatsheet: Google Search
PDF
Irm 15-trademark infringement
PDF
Irm 14-scam
PDF
Irm 13-phishing
PDF
Irm 12-insiderabuse
PDF
Irm 10-social engineering
PDF
Irm 8-blackmail
PDF
Irm 6-website-defacement
PDF
Irm 5-malicious networkbehaviour
PDF
Irm 4-ddos
Cheatsheet: Netcat
Cheatsheet: Metasploit
Cheatsheet: Google Search
Irm 15-trademark infringement
Irm 14-scam
Irm 13-phishing
Irm 12-insiderabuse
Irm 10-social engineering
Irm 8-blackmail
Irm 6-website-defacement
Irm 5-malicious networkbehaviour
Irm 4-ddos

Recently uploaded (20)

PPT
tcp ip networks nd ip layering assotred slides
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PDF
๐Ÿ’ฐ ๐”๐Š๐“๐ˆ ๐Š๐„๐Œ๐„๐๐€๐๐†๐€๐ ๐Š๐ˆ๐๐„๐‘๐Ÿ’๐ƒ ๐‡๐€๐‘๐ˆ ๐ˆ๐๐ˆ ๐Ÿ๐ŸŽ๐Ÿ๐Ÿ“ ๐Ÿ’ฐ
ย 
PPTX
Internet___Basics___Styled_ presentation
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PPTX
artificial intelligence overview of it and more
PPTX
international classification of diseases ICD-10 review PPT.pptx
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
DOCX
Unit-3 cyber security network security of internet system
PPTX
QR Codes Qr codecodecodecodecocodedecodecode
PPTX
innovation process that make everything different.pptx
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
ย 
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
tcp ip networks nd ip layering assotred slides
INTERNET------BASICS-------UPDATED PPT PRESENTATION
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
๐Ÿ’ฐ ๐”๐Š๐“๐ˆ ๐Š๐„๐Œ๐„๐๐€๐๐†๐€๐ ๐Š๐ˆ๐๐„๐‘๐Ÿ’๐ƒ ๐‡๐€๐‘๐ˆ ๐ˆ๐๐ˆ ๐Ÿ๐ŸŽ๐Ÿ๐Ÿ“ ๐Ÿ’ฐ
ย 
Internet___Basics___Styled_ presentation
PptxGenJS_Demo_Chart_20250317130215833.pptx
Module 1 - Cyber Law and Ethics 101.pptx
artificial intelligence overview of it and more
international classification of diseases ICD-10 review PPT.pptx
introduction about ICD -10 & ICD-11 ppt.pptx
Unit-3 cyber security network security of internet system
QR Codes Qr codecodecodecodecocodedecodecode
innovation process that make everything different.pptx
Introuction about WHO-FIC in ICD-10.pptx
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
An introduction to the IFRS (ISSB) Stndards.pdf
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
ย 
Unit-1 introduction to cyber security discuss about how to secure a system
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...

Cheatsheet: Hex file headers and regex

  • 1. Forensic Analysts are on the front lines of computer investigations. This guide aims to support Forensic Analysts in their quest to uncover the truth. grep's strength is extracting information from text files. grep operates on one or multiple files when provided with a command line argument(s) that can also include wildcards: Example: grep "John" addressbook Would return the lines that contained the "John" string in the addressbook text file Some useful flags: -A Print number of lines after the match -B Print number of lines before match -c Report number of occurrences -f Reads one or more patterns from a file. Pattern are terminated by a newline -h Suppress the file names on the output -i Ignore case -l Report matching files, not matching lines -P Interpret pattern as a Perl Regex -v Reverse operation: return the lines not matching the string The egrep (extended grep) utility can be useful to match several possible strings at the same time (in an OR mode): egrep "John|Peter" addressbook grep "John|Peter" addressbook grep/egrep Purpose How To Use This Sheet When performing an investigation it is helpful to be reminded of the powerful options available to the investigator. This document is aimed to be a reference to the tools that could be used. This sheet is split into these sections: โ€ข Hex File Headers โ€ข grep/egrep โ€ข sort โ€ข awk โ€ข sed โ€ข uniq โ€ข date โ€ข Windows findstr The key to successful forensics is minimizing your data loss, accurate reporting, and a thorough investigation. File headers are used to identify a file by examining the first 4 or 5 bytes of its hexadecimal content. Filetype Start Start ASCII Translation ani 52 49 46 46 RIFF au 2E 73 6E 64 snd bmp 42 4D F8 A9 BM bmp 42 4D 62 25 BMp% bmp 42 4D 76 03 BMv cab 4D 53 43 46 MSCF dll 4D 5A 90 00 MZ Excel D0 CF 11 E0 exe 4D 5A 50 00 MZP (inno) exe 4D 5A 90 00 MZ flv 46 4C 56 01 FLV gif 47 49 46 38 39 61 GIF89a gif 47 49 46 38 37 61 GIF87a gz 1F 8B 08 08 ico 00 00 01 00 jpeg FF D8 FF E1 jpeg FF D8 FF E0 JFIF jpeg FF D8 FF FE JFIF Linux bin 7F 45 4C 46 ELF png 89 50 4E 47 PNG msi D0 CF 11 E0 mp3 49 44 33 2E ID3 mp3 49 44 33 03 ID3 OFT 4F 46 54 32 OFT2 PPT D0 CF 11 E0 PDF 25 50 44 46 %PDF rar 52 61 72 21 Rar! sfw 43 57 53 06/08 cws tar 1F 8B 08 00 tgz 1F 9D 90 70 Word D0 CF 11 E0 wmv 30 26 B2 75 zip 50 4B 03 04 PK Hex File Header and ASCII Equivalent Hex File Headers and Regex for Forensics Cheat Sheet v1.0 SANS Forensics http://computer-forensics.sans.org http://blogs.sans.org/computer-forensics By Guy Bruneau, gbruneau@sans.org sort sort, as its name implies, will sort the output. There are a few interesting options you can use: -d Uses dictionary order. Only letters, digits and blanks. -n will sort the output assuming it is numerical (instead of string) -u will remove redundant line, 'uniquing' the results
  • 2. awk is an extremely useful tool, especially for parsing data structured in columns. It is straightforward to use for simple purposes. Its basic use is to select some particular columns from the output: column 1 is referred to as $1, column 2 as $2, etc. The space is the default awk separator. However if you want to be able to parse data separated by some other character, e.g. ":", you can use the -F flag. Example: echo "hello:goodbye" | awk -F: '{print $2}' Would return "goodbye" as an output awk sed is an excellent command for character substitution. Example: if you want to substitute the first occurrence of the 'a' character by an 'e': echo "hallo" | sed 's/a/e/' The output would be: hello You can use the g modifier to substitute all instances: echo "Hallo Janny" | sed 's/a/e/g' The output would be: Hello Jenny sed Forensic Analysis Cheat Sheet Forensics MANDIANT contact@mandiant.com 703.683.3141 http://www.mandiant.org The Windows findstr has one interesting feature that differs from grep. If you need to search for multiple strings, you need to separate them with a space. For example, you want or need to look for a match for WHITE or GREEN in a text file, you write your command like this: findstr "WHITE GREEN" textfile To make the search case insensitive, add the /I to print all variant of WHITE or GREEN. Windows findstr Command List /B Matches pattern if at the beginning of a line. /E Matches pattern if at the end of a line. /L Uses search strings literally. /R Uses search strings as regular expressions. /S Searches for matching files in the current directory and all subdirectories. /I Specifies that the search is not to be case-sensitive. /X Prints lines that match exactly. /V Prints only lines that do not contain a match. /N Prints the line number before each line that matches. /M Prints only the filename if a file contains a match. /O Prints character offset before each matching line. /P Skip files with non-printable characters. Windows findstr Check the date man page for more options. Returns the real date from epoch time: date โ€“d @1284127201 Return an epoch time of 1288756800: date +%s -d โ€œ2010-11-03โ€ Return a 2 days old date: date --date="-2 days" +"%Y-%m-%d" Return 20:00 hours: date -d @1288310401 +%k:%M The uniq command reads the input and compares adjacent lines. If two or more adjacent lines are identical, all but one is removed. Here is a list of the most common options used with uniq: -c Prefix line with number of occurrence -f Avoid comparing the first N fields -i Ignore case -s Avoid comparing the first N characters -u Only print unique lines Consider this input file: a b c b Now run uniq on it: sort testfile | uniq a b c Now run uniq -c on it: 1 a 2 b 1 c uniq Date