41
Defeating Forensic Analysis CEIC 2006 – Technical Lecture 1 Thursday, May 4 – 10:30 am to 11:30 am Presented by Vincent Liu and Patrick Stach

Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Forensic Analysis

CEIC 2006 – Technical Lecture 1Thursday, May 4 – 10:30 am to 11:30 am

Presented by Vincent Liu and Patrick Stach

Page 2: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Welcome

Vincent LiuManaging Director, Stach & LiuResearcher, Metasploit ProjectFormer Fortune 100, Big 4 consulting, and government [email protected]

Patrick StachDirector of Research and Development, Stach & LiuResearcher & Developer, Metasploit ProjectFormer security industry developer and freelance [email protected]

Page 3: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Agenda

Weaknesses in current forensic analysis tools and techniques

Metasploit Anti-Forensics Tools

Specific recommendations on how to improve

Page 4: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Rapid History

Basic Utilitiestouchmv and renamerm and del

Repurpose Existing TechnologiesADS, encryption, Gutmann secure deletion (Eraser)

Targeted Research into Anti-ForensicsMetasploit Anti-Forensics ProjectDeflier’s ToolkitConferences: BlackHat, BlueHat, ToorCon, and now CEIC

Page 5: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Timestamps

TechniqueExamine timestamps for temporal locality

Anti-techniquetouch for UNIX & MAC in FAT

MACE in NTFStimestomp.exe from the Metasploit Anti-Forensics ProjectNtQueryInformationFile() and NtSetInformationFile()

Page 6: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Timestamps

MCA E

modified (M), accessed (A), created (C), entry modified (E)

Page 7: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating EnCase

• normal

• after setting values (-z “Monday 05/05/2005 05:05:05 AM”)

• example EnCase weakness (-b)

Page 8: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating EnCase

Page 9: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating EnCase

Page 10: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating MS Antispyware

Page 11: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating MS Antispyware

Page 12: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Windows

Live WindowsExplorer Demo

Page 13: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Improving Timestamps

Entry Header

SIAttribute

MACE

FN Attribute

MACE

OtherAttributes

Every file stores MACE values in more than one attribute!

Standard Information (SI)Currently used by EnCase and other tools.

Filename (FN)Not used by EnCase or other tools.

Page 14: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Improving Timestamps

SI MACE

earlier time later time

FN MACE

1. MACE values always updated in SI.2. MACE values only updated in FN when a file is

created and/or moved.3. Therefore, MACE values from FN should always

be older when compared to the SI values.

Page 15: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Anti-counter Anti-technique

Entry Header SI Attribute FN Attribute Other …Entry Header SI Attribute FN Attribute Other …

… … … …

Modify the Filename (FN) attributeCalculate the offsetsModify via raw disk I/O.

Modify the Data attributeSwap out the data.Timestomp it back.

Page 16: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Signature Analysis

Two Detection TechniquesFile extensionsFile signatures

Anti-detection TechniqueChange the file extensionChange the file signature

Page 17: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Signature Analysis

Page 18: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Signature Analysis

Page 19: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Signature Analysis

Page 20: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Signature Analysis

• one byte modified

Page 21: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Signature Analysis

Page 22: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Signature Analysis

Page 23: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Improving Signature Analysis

Perform statistical analysis against headers & footers.

PE/ELF binary headers have a fixed format/structure.Data for JPEG, GIF, and other have repeatable patterns.

Perform file content analysisText files usually ASCII text.

Open the file ☺

Page 24: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Hashing

File SystemGood Files Bad Files

TechniqueIdentify known good files with hashing white lists and known bad files with black listsIdentify known bad files with hashing black listsExamine the remaining files

Anti-techniqueGet off of the black listGet on the white list

Page 25: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Hashing

4e65745d42c70ac0a5f697e22b8bb033eafcc942c7960f921c64c1682792923c

Page 26: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Hashing

EXE header EXE headerif (collision == 0) {

goto good} else {

goto bad}

if (collision == 0) { goto good

} else {goto bad

}

collision = 0 collision = 1good goodbad bad

• We can generate hash collisions in MD4, MD5 (public)• We can generate hash collisions in SHA1 (not public)

Page 27: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Hashing

Live Executable Collision Demo

Page 28: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Improving Hashing

Use only trusted hash white lists

Don’t rely on black lists to find bad files

Perform bit-by-bit file comparisons

Stack multiple hashing algorithms

http://www.stachliu.com/collision.html

Page 29: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Disk Analysis

TechniqueCapture everything on disk and analyzeCapture list of active processes, open files, open ports, etc…

Anti-techniqueNever touch the disk, Never open a new portNever open a fileNever create a new processAnd so on…

Page 30: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Disk Analysis

registry

disk

services

memory/lsass

remote share

remote registry

old techniques (pwdump)1. open a remote share2. touches disk3. starts a service to do dll injection4. open the registry5. creates remote registry conn6. failure leaves evidence

Page 31: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Defeating Disk Analysis

Meterpreter+ sam juicer

registry

disk

services

memory/lsass

meterpreter channel

1. slides over Meterpreter channel2. direct memory injection3. never hits disk & never hits the registry4. never starts a service5. data flows back over existing

connection6. failure doesn’t leave evidence

Page 32: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Improving Disk Analysis

Capture live system informationlsof, netstat, dd, ifconfig

Capture live memory informationmemparser, kntlist, Windows Memory Forensic ToolkitImmature technologies that can be subverted

Use trusted external hardware to verifyCoPilot – expensive, use on mission critical systems

Page 33: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Hiding in Slack Space

TechniqueAnalyze the existing file system for informationLook for file fragments in slack space

Anti-techniqueLeverage an NTFS implementation oddityAvoid NTFS zeroing your dataStore a larger file in smaller slack space areas

Page 34: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Hiding in Slack Space

standard file setup

sector sector sector sector sector

valid data slack spaceend of file

sector sector sector

file pointer end of valid data

1 cluster = 8 sectors

Page 35: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Hiding in Slack Space

writing to slackend of valid data

end of file

sector sector sector sector sector sector sector sector

file pointer

safe data!

1 cluster = 8 sectors

Page 36: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Hiding in Slack Space

reading from slack end of valid data

end of file

sector sector sector sector sector sector sector sector

file pointerReadFile()

1 cluster = 8 sectors

Page 37: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Hiding in Slack Space

closing outend of valid

data

end of file

sector sector sector sector sector sector sector sector

file pointer

1 cluster = 8 sectors

Page 38: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Hiding in Slack Space

Proper selection of slack spaceDumb – first N filesRandom – random selection of filesSafe – selects oldest (last modified) files

Obfuscationnone - no obfuscationXOR key – random 8 bit keyone-time pad – use a known fixed file

Message = 100 bitsMessage = 100 bits

XOR Key = 100 bits

Encrypted Message = 100 bits

Page 39: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Improving Slack Space

Perform statistical analysis against slack space information to locate anomalous patterns.

Routinely clear slack spaceEraserPGP Disk Wipe

Page 40: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Future Directions

TechniquesCross-disciplinary tools i.e. slacker, Meterpreter

AvailabilityActively researched, discussed, and distribution of tools

SophisticationTargeted research into anti-forensicsMore brainpower is being directed this way

Page 41: Defeating Forensic Analysis€¦ · Defeating Disk Analysis registry disk services memory/lsass remote share remote registry old techniques (pwdump) 1. open a remote share 2. touches

Thank you for your time.

Questions?

Slides available @http://www.metasploit.com/projects/antiforensics/