SlideShare une entreprise Scribd logo
1  sur  50
USB Flash Drive Forensics Philip A. Polstra, Sr. University of Dubuque
Overview Very brief review of USB basics USB flash drives – your best friend USB flash drive forensics Fun with microcontrollers A potential problem and a great solution (trust me)
USB Basics History Hardware Software
History Non-universal serial, PS/2 ports, & LPT 1996 USB 1.0 (1.5 or 12 Mbps) 1998 USB 1.1 2000 USB 2.0 (1.5, 12, or 480 Mbps) Long pause 2008 USB 3.0 (up to 5 Gbps)
Hardware Simple 4-wire connection (power, ground, 2 data wires) Cabling prevents improper connections Hot pluggable Differential voltages provide greater immunity to noise Cable lengths up to 16 feet are possible
Software Automatic configuration No settable jumpers Enumeration Standard device classes with corresponding drivers HID Printer Audio Mass Storage
USB Flash Drives Hardware Software Filesystems Windows
Hardware
Software Usually implemented in firmware within specialized controller chips Must: Detect communication directed at drive Respond to standard requests Check for errors Manage power Exchange data
Filesystems Most preformatted with FAT or FAT32 NTFS TrueFFS ExtremeFFS JFFS YAFFS Various UNIX/Linux file systems
USB Flash Drives and Windows Connecting a Drive Blocking write operations Who was here?
Connecting a Drive Device is connected Hub detects Host (PC) is informed of new device Hub determines device speed capability as indicated by location of pull-up resistors Hub resets the device Host determines if device is capable of high speed (using chirps) Hub establishes a signal path Host requests descriptor from device to determine max packet size Host assigns an address Host learns devices capabilities Host assigns and loads an appropriate device driver (INF file) Device driver selects a configuration
Blocking Write Operations (sometimes) Some flash drives have write-protect switches (somewhat rare) HKEY_LOCAL_MACHINEYSTEMurrentControlSetontroltorageDevicePoliciesWriteProtect Blocks writing to ALL USB devices Commercial write-blockers Microcontroller-based device (discussed later)
Who Was Here? Windows records all USB device connections in registry Utilities such as USBDeview will easily display this information
Forensics Flash Drive as Memory Flash Drive as Storage Media
Flash Drive as Memory Typically utilize NAND flash memory Memory degrades after 10,000 write cycles  Most chips not even close to high-speed USB speed (480 Mbps) Can only be written in blocks (usually 512, 2048, or 4096 bytes) Chips are somewhat easily removed from damaged drives for forensic recovery Some controllers have JTAG capability which can be used for memory access Some controller chips steal some flash memory for themselves
Flash Drive as Storage Media Nearly all flash drives present themselves as SCSI hard drives “Hard drive” sectors are typically 512, 2048, or 4096 bytes SCSI transparent command set is used Most drives are formatted as one partition or logical unit Should check for additional logical units (max LUN >0) Should check reported versus actual media size Info can be hidden in higher sectors Some cheap drives are out there that grossly over report size A typical 512 byte sector needs 16 bytes for error correction
Fun with Microcontrollers Chip Choice Talking to Flash Drives An Extremely Compact Duplicator A Slightly Larger User-Friendly Duplicator A Microcontroller-Based Write Blocker Future Directions
Chip Choice FTDI Vinculum II dual USB host controller 2 full-speed USB 2.0 interfaces (host or slave capable) 256 KB E-flash memory 16 KB RAM 2 SPI slave and 1 SPI master interfaces Easy-to-use IDE  Simultaneous multiple file access on BOMS devices Several development modules available Convenient for prototyping (only SMD chips available) Cheap enough to embed in final device
Chip Choice (continued)
Chip Choice (continued)
Chip Choice (continued)
Chip Choice (continued)
Chip Choice (continued)
Chip Choice (continued)
A Simple Duplicator Insert a flash drive to be copied Insert a target drive for copy Ideally the identical model Should be at least the same size Should use identical block size A sector by sector copy is performed Should work on majority of drives examined Requires approximately 11 minutes/GB Write speed of target is limiting factor
Talking to a Flash Drive Bulk-Only Mass Storage (aka BBB) protocol used All communications use bulk endpoints Three phases: CBW, data-transport (optional), CSW Commands sent to drive using a Command Block Wrapper (CBW) CBW contains Command Block (CB) with actual command Nearly all drives use a (reduced) SCSI command set Commands requiring data transport will send/receive on bulk endpoints All transactions are terminated by a Command Status Wrapper (CSW)
Command Block Wrapper typedefstruct _USB_MSI_CBW { 	unsigned long dCBWSignature; //0x43425355 	unsigned long dCBWTag; // associates CBW with CSW response 	unsigned long dCBWDataTransferLength; // bytes to send or receive 	unsigned char bCBWFlags; // bit 7 0=OUT, 1=IN all others zero 	unsigned char bCBWLUN; // logical unit number (usually zero) 	unsigned char bCBWCBLength; // 3 hi bits zero, rest bytes in CB 	unsigned char bCBWCB[16]; // the actual command block (>= 6 bytes) } USB_MSI_CBW;
Command Block 6-16 bytes depending on command Command is first byte Format Unit Example: typedefstruct _CB_FORMAT_UNIT { 	unsigned char OperationCode; //must be 0x04 	unsigned char LUN:3; // logical unit number (usually zero) 	unsigned char FmtData:1; // if 1, extra parameters follow command 	unsigned char CmpLst:1; // if 0, partial list of defects, 1, complete 	unsigned char DefectListFormat:3; //000 = 32-bit LBAs 	unsigned char VendorSpecific; //vendor specific code 	unsigned short Interleave; //0x0000 = use vendor default 	unsigned char Control; } CB_FORMAT_UNIT;
Command Block (continued) Read (10) Example: typedefstruct _CB_READ10 { 	unsigned char OperationCode; //must be 0x28 	unsigned char RelativeAddress:1; // normally 0 	unsigned char Resv:2; 	unsigned char FUA:1; // 1=force unit access, don't use cache 	unsigned char DPO:1; // 1=disable page out 	unsigned char LUN:3; //logical unit number 	unsigned long LBA; //logical block address (sector number) 	unsigned char Reserved; 	unsigned short TransferLength; 	unsigned char Control; } CB_READ10;
Command Block (continued) Some Common SCSI Commands: FORMAT_UNIT=0x4, //required 	INQUIRY=0x12, //required 	MODE_SELECT6=0x15, 	MODE_SELECT10=0x55, 	MODE_SENSE6=0x1A, 	MODE_SENSE10=0x5A, 	READ6=0x08, //required 	READ10=0x28, //required 	READ12=0xA8, 	READ_CAPACITY10=0x25, //required 	READ_FORMAT_CAPACITIES=0x23, 	REPORT_LUNS=0xA0, //required 	REQUEST_SENSE=0x03, //required 	SEND_DIAGNOSTIC=0x1D, //required 	START_STOP_UNIT=0x1B, 	SYNCHRONIZE_CACHE10=0x35, 	TEST_UNIT_READ=0x00, //required 	VERIFY10=0x2F, 	WRITE6=0x0A, //required 	WRITE10=0x2A, 	WRITE12=0xAA
Command Status Wrapper Read Sense command can be used for details on failed operations typedefstruct _USB_MSI_CSW { 	unsigned long dCSWSignature; //0x53425355 	unsigned long dCSWTag; // associate CBW with CSW response 	unsigned long dCSWDataResidue; // difference between requested data and actual 	unsigned char bCSWStatus; //00=pass, 01=fail, 02=phase error, reset } USB_MSI_CSW;
A Simple Duplicator (continued) void BOMSFindDevice() {    VOS_HANDLE hUsb2, hBoms; usbhost_device_handle *ifDev2; usbhost_ioctl_cb_thc_iocb; usbhost_ioctl_cb_classhc_iocb_class; fat_contextfatContext; msi_ioctl_cb_tboms_iocb; boms_ioctl_cb_attach_tboms_att;    // find BOMS class device hc_iocb_class.dev_class = USB_CLASS_MASS_STORAGE; hc_iocb_class.dev_subclass = USB_SUBCLASS_MASS_STORAGE_SCSI; hc_iocb_class.dev_protocol = USB_PROTOCOL_MASS_STORAGE_BOMS; hc_iocb.ioctl_code = VOS_IOCTL_USBHOST_DEVICE_FIND_HANDLE_BY_CLASS; hc_iocb.handle.dif = NULL;    hc_iocb.set = &hc_iocb_class;    hc_iocb.get = &ifDev2;    if (vos_dev_ioctl(hUsb2, &hc_iocb) != USBHOST_OK)    {       // no BOMS class found    }    // now we have a device, intialise a BOMS driver for it hBoms = vos_dev_open(VOS_DEV_BOMS);    // boms_attach boms_att.hc_handle = hUsb2; boms_att.ifDev = ifDev2; boms_iocb.ioctl_code = MSI_IOCTL_BOMS_ATTACH;    boms_iocb.set = &boms_att;    boms_iocb.get = NULL;    if (vos_dev_ioctl(hBoms, &boms_iocb) != MSI_OK)    {       // could not attach to device    }    // device has been found and opened    // now detach from the device boms_iocb.ioctl_code = MSI_IOCTL_BOMS_DETACH; vos_dev_ioctl(hBoms, &boms_iocb) }
A Simple Duplicator (continued) VOS_DEVICE hBoms; unsigned char fat_readSector(unsigned long sector, char *buffer) {    // transfer buffer msi_xfer_cb_txfer;    // completion semaphore vos_semaphore_tsemRead;    unsigned char status; vos_init_semaphore(&semRead, 0); xfer.sector = sector;    xfer.buf = buffer;    // 512 byte sector specific to keep it simple xfer.total_len = 512; xfer.buf_len = 512; xfer.status = MSI_NOT_ACCESSED; xfer.s = &semRead; xfer.do_phases = MSI_PHASE_ALL;    status = vos_dev_read(hBoms, (unsigned char *)&xfer, sizeof(msi_xfer_cb_t ), NULL);    If (status == MSI_OK)    {       status = FAT_OK;    }    else    {       status |= FAT_MSI_ERROR;    } 	   return status; 	}
Simple Duplicator Realized To improve performance a double-buffered multi-threaded algorithm is used Performance is still limited by write speed of target device Future enhancements Use format unit command to erase target, then check for and skip blank sectors on copy operation Verify target is large enough to complete copy successfully Uses the smallest (32-pin) Vincullum-II development board Solder directly to the development board to minimize size Device is easily updated via debug port
Simple Duplicator Realized (continued)
Simple Duplicator Realized (continued)
A More User-Friendly Duplicator Use the same chipset Use the same code Augment  blinking lights with LCD Display Make use of development boards for ease of construction Shave a little here and there to make it more portable Power with a 9V battery
User-Friendly Duplicator Realized
User-Friendly Duplicator Realized (cont.)
User-Friendly Duplicator Realized (cont.)
Microcontroller-Based Write Blocker Commercial write blockers are ridiculously expensive The ability to peek at a drive before bothering to make a copy is appealing Would like to prevent AV deletion Use the FTDI Vinco (formerly Vinculo) board Cheap at $30 (€25) No soldering! – already has USB host and slave ports Arduino form factor 100% of the solution is in software Anyone can just buy the board and upload software Could deliver preprogrammed boards with disabled programming port
Write Blocker (continued) Configure the slave port to enumerate as a USB bulk-only mass-storage device (BOMS) Inspect command blocks coming from the host PC Only commands known to not alter the drive are passed on to the subject USB BOMS device Whitelisting the commands makes design more future proof than blacklisting Still work in progress Due to some less than ideal documentation and some hardware issues, I have only recently  gotten the USB host port to work E-mail me if you want to follow this project
Write Blocker Realized
Write Blocker Realized (continued)
Future Directions Android Open Accessory Device Possibly based on Vinco interfaced to VNC2 development board Vinco board might permit a device that can be controlled by an Android device or a PC High-Speed Device Possibly based on Beagle Board $149 (€105) Higher cost, but also adds the ability to realistically duplicate and examine USB hard drives Higher processing power could be tapped for other uses Could be used stand alone or connected to standard keyboard, mouse, and monitor
A Potential Problem Problem: If you end up in court the other side may object to the use of home made devices Solution: Open Source Cyber-Forensics Association (OSCFA)
OSCFA The Arduino of computer security and forensics Community for sharing of  software and hardware designs for computer security and forensics stuff Ability to submit designs for peer review Hobbyists and students can build their own devices Persons not wishing to build devices could purchase from others Multiple vendors would be possible A slightly more expensive peer-reviewed and certified device could be purchased where required
References USB Complete: The Developers Guide (4th ed.) by Jan Axelson USB Mass Storage: Designing and Programming Devices and Embedded Hosts by Jan Axelson http://www.usb.org http://www.ftdichip.com Real Digital Forensics by Keith Jones, et. al Windows Forensic Analysis (2nd ed.) by Harlan Carvey Embedded USB Design by Example by John Hyde File System Forensic Analysis by Brian Carrier All schematics and source code are available on request via e-mail to ppolstra@dbq.edu
Questions?

Contenu connexe

Tendances

Chapter 1 Introducing Hardware
Chapter 1 Introducing HardwareChapter 1 Introducing Hardware
Chapter 1 Introducing Hardware
April Lorraine
 

Tendances (20)

ARM Architecture and Meltdown/Spectre
ARM Architecture and Meltdown/SpectreARM Architecture and Meltdown/Spectre
ARM Architecture and Meltdown/Spectre
 
Device tree support on arm linux
Device tree support on arm linuxDevice tree support on arm linux
Device tree support on arm linux
 
Embedding Linux On The Encore Simputer
Embedding Linux On The Encore SimputerEmbedding Linux On The Encore Simputer
Embedding Linux On The Encore Simputer
 
Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New Hardware
 
Writing Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxWriting Character driver (loadable module) in linux
Writing Character driver (loadable module) in linux
 
BeagleBone Black: Platform Bring-Up with Upstream Components
BeagleBone Black: Platform Bring-Up with Upstream ComponentsBeagleBone Black: Platform Bring-Up with Upstream Components
BeagleBone Black: Platform Bring-Up with Upstream Components
 
Linux SD/MMC device driver
Linux SD/MMC device driverLinux SD/MMC device driver
Linux SD/MMC device driver
 
Building
BuildingBuilding
Building
 
BeagleBone Black with Upstream Software
BeagleBone Black with Upstream SoftwareBeagleBone Black with Upstream Software
BeagleBone Black with Upstream Software
 
Basics of boot-loader
Basics of boot-loaderBasics of boot-loader
Basics of boot-loader
 
Linux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKBLinux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKB
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
 
Linux Device Driver parallelism using SMP and Kernel Pre-emption
Linux Device Driver parallelism using SMP and Kernel Pre-emptionLinux Device Driver parallelism using SMP and Kernel Pre-emption
Linux Device Driver parallelism using SMP and Kernel Pre-emption
 
To study about motherboard & its compponents
To study about motherboard & its compponentsTo study about motherboard & its compponents
To study about motherboard & its compponents
 
Chapter 1 Introducing Hardware
Chapter 1 Introducing HardwareChapter 1 Introducing Hardware
Chapter 1 Introducing Hardware
 
Device Tree for Dummies (ELC 2014)
Device Tree for Dummies (ELC 2014)Device Tree for Dummies (ELC 2014)
Device Tree for Dummies (ELC 2014)
 
Bootloader and MMU (english)
Bootloader and MMU (english)Bootloader and MMU (english)
Bootloader and MMU (english)
 
U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0
 
What is Bootloader???
What is Bootloader???What is Bootloader???
What is Bootloader???
 

En vedette

USB Port Protection that Hardens Endpoint Security and Streamlines Compliance
USB Port Protection that Hardens Endpoint Security and Streamlines ComplianceUSB Port Protection that Hardens Endpoint Security and Streamlines Compliance
USB Port Protection that Hardens Endpoint Security and Streamlines Compliance
Netwrix Corporation
 
How to Replace Your Legacy Antivirus Solution with CrowdStrike
How to Replace Your Legacy Antivirus Solution with CrowdStrikeHow to Replace Your Legacy Antivirus Solution with CrowdStrike
How to Replace Your Legacy Antivirus Solution with CrowdStrike
Adam Barrera
 

En vedette (12)

USB Port Protection that Hardens Endpoint Security and Streamlines Compliance
USB Port Protection that Hardens Endpoint Security and Streamlines ComplianceUSB Port Protection that Hardens Endpoint Security and Streamlines Compliance
USB Port Protection that Hardens Endpoint Security and Streamlines Compliance
 
Sophos Corporate Overview And End Poin 2016
Sophos Corporate Overview And End Poin 2016Sophos Corporate Overview And End Poin 2016
Sophos Corporate Overview And End Poin 2016
 
Understanding Malware Lateral Spread Used in High Value Attacks
Understanding Malware Lateral Spread Used in High Value AttacksUnderstanding Malware Lateral Spread Used in High Value Attacks
Understanding Malware Lateral Spread Used in High Value Attacks
 
How to Replace Your Legacy Antivirus Solution with CrowdStrike
How to Replace Your Legacy Antivirus Solution with CrowdStrikeHow to Replace Your Legacy Antivirus Solution with CrowdStrike
How to Replace Your Legacy Antivirus Solution with CrowdStrike
 
Activated Charcoal - Making Sense of Endpoint Data
Activated Charcoal - Making Sense of Endpoint DataActivated Charcoal - Making Sense of Endpoint Data
Activated Charcoal - Making Sense of Endpoint Data
 
Usb protocol
Usb protocol Usb protocol
Usb protocol
 
Malware evolution and Endpoint Detection and Response Technology
Malware evolution and Endpoint Detection and Response  TechnologyMalware evolution and Endpoint Detection and Response  Technology
Malware evolution and Endpoint Detection and Response Technology
 
Flash memory
Flash memoryFlash memory
Flash memory
 
USB protocol
USB protocolUSB protocol
USB protocol
 
Infosecurity Europe 2014 Case Study: Shamoon, a two stage targeted attack
Infosecurity Europe 2014 Case Study:  Shamoon, a two stage targeted attackInfosecurity Europe 2014 Case Study:  Shamoon, a two stage targeted attack
Infosecurity Europe 2014 Case Study: Shamoon, a two stage targeted attack
 
National Oil Company Conference 2014 - Evolving Cyber Security - A Wake Up Ca...
National Oil Company Conference 2014 - Evolving Cyber Security - A Wake Up Ca...National Oil Company Conference 2014 - Evolving Cyber Security - A Wake Up Ca...
National Oil Company Conference 2014 - Evolving Cyber Security - A Wake Up Ca...
 
What Is Next-Generation Endpoint Security and Why Do You Need It?
What Is Next-Generation Endpoint Security and Why Do You Need It?What Is Next-Generation Endpoint Security and Why Do You Need It?
What Is Next-Generation Endpoint Security and Why Do You Need It?
 

Similaire à 44con

5.6 Basic computer structure microprocessors
5.6 Basic computer structure   microprocessors5.6 Basic computer structure   microprocessors
5.6 Basic computer structure microprocessors
lpapadop
 
ICTCoreCh11
ICTCoreCh11ICTCoreCh11
ICTCoreCh11
garcons0
 

Similaire à 44con (20)

5.6 Basic computer structure microprocessors
5.6 Basic computer structure   microprocessors5.6 Basic computer structure   microprocessors
5.6 Basic computer structure microprocessors
 
3.1.computer foundations
3.1.computer foundations3.1.computer foundations
3.1.computer foundations
 
Vmfs
VmfsVmfs
Vmfs
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
07. Mainboard (System Board, Motherboard)
07. Mainboard (System Board, Motherboard)07. Mainboard (System Board, Motherboard)
07. Mainboard (System Board, Motherboard)
 
1 study of motherboard
1 study of motherboard1 study of motherboard
1 study of motherboard
 
COMPUTER HARDWARE - SHORT NOTES
COMPUTER HARDWARE - SHORT NOTESCOMPUTER HARDWARE - SHORT NOTES
COMPUTER HARDWARE - SHORT NOTES
 
Mobo.pptx
Mobo.pptxMobo.pptx
Mobo.pptx
 
IMD 203 - Ch08
IMD 203 - Ch08IMD 203 - Ch08
IMD 203 - Ch08
 
The Cell Processor
The Cell ProcessorThe Cell Processor
The Cell Processor
 
Os
OsOs
Os
 
Linux memory-management-kamal
Linux memory-management-kamalLinux memory-management-kamal
Linux memory-management-kamal
 
PV-Drivers for SeaBIOS using Upstream Qemu
PV-Drivers for SeaBIOS using Upstream QemuPV-Drivers for SeaBIOS using Upstream Qemu
PV-Drivers for SeaBIOS using Upstream Qemu
 
Hard disk PPT
Hard disk PPTHard disk PPT
Hard disk PPT
 
os
osos
os
 
Hardware hacking
Hardware hackingHardware hacking
Hardware hacking
 
Unit 1 four part pocessor and memory
Unit 1 four part pocessor and memoryUnit 1 four part pocessor and memory
Unit 1 four part pocessor and memory
 
ICTCoreCh11
ICTCoreCh11ICTCoreCh11
ICTCoreCh11
 
Laptop Basic Knowledge
Laptop Basic KnowledgeLaptop Basic Knowledge
Laptop Basic Knowledge
 
Memory Mapping Cache
Memory Mapping CacheMemory Mapping Cache
Memory Mapping Cache
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

44con

  • 1. USB Flash Drive Forensics Philip A. Polstra, Sr. University of Dubuque
  • 2. Overview Very brief review of USB basics USB flash drives – your best friend USB flash drive forensics Fun with microcontrollers A potential problem and a great solution (trust me)
  • 3. USB Basics History Hardware Software
  • 4. History Non-universal serial, PS/2 ports, & LPT 1996 USB 1.0 (1.5 or 12 Mbps) 1998 USB 1.1 2000 USB 2.0 (1.5, 12, or 480 Mbps) Long pause 2008 USB 3.0 (up to 5 Gbps)
  • 5. Hardware Simple 4-wire connection (power, ground, 2 data wires) Cabling prevents improper connections Hot pluggable Differential voltages provide greater immunity to noise Cable lengths up to 16 feet are possible
  • 6. Software Automatic configuration No settable jumpers Enumeration Standard device classes with corresponding drivers HID Printer Audio Mass Storage
  • 7. USB Flash Drives Hardware Software Filesystems Windows
  • 9. Software Usually implemented in firmware within specialized controller chips Must: Detect communication directed at drive Respond to standard requests Check for errors Manage power Exchange data
  • 10. Filesystems Most preformatted with FAT or FAT32 NTFS TrueFFS ExtremeFFS JFFS YAFFS Various UNIX/Linux file systems
  • 11. USB Flash Drives and Windows Connecting a Drive Blocking write operations Who was here?
  • 12. Connecting a Drive Device is connected Hub detects Host (PC) is informed of new device Hub determines device speed capability as indicated by location of pull-up resistors Hub resets the device Host determines if device is capable of high speed (using chirps) Hub establishes a signal path Host requests descriptor from device to determine max packet size Host assigns an address Host learns devices capabilities Host assigns and loads an appropriate device driver (INF file) Device driver selects a configuration
  • 13. Blocking Write Operations (sometimes) Some flash drives have write-protect switches (somewhat rare) HKEY_LOCAL_MACHINEYSTEMurrentControlSetontroltorageDevicePoliciesWriteProtect Blocks writing to ALL USB devices Commercial write-blockers Microcontroller-based device (discussed later)
  • 14. Who Was Here? Windows records all USB device connections in registry Utilities such as USBDeview will easily display this information
  • 15. Forensics Flash Drive as Memory Flash Drive as Storage Media
  • 16. Flash Drive as Memory Typically utilize NAND flash memory Memory degrades after 10,000 write cycles Most chips not even close to high-speed USB speed (480 Mbps) Can only be written in blocks (usually 512, 2048, or 4096 bytes) Chips are somewhat easily removed from damaged drives for forensic recovery Some controllers have JTAG capability which can be used for memory access Some controller chips steal some flash memory for themselves
  • 17. Flash Drive as Storage Media Nearly all flash drives present themselves as SCSI hard drives “Hard drive” sectors are typically 512, 2048, or 4096 bytes SCSI transparent command set is used Most drives are formatted as one partition or logical unit Should check for additional logical units (max LUN >0) Should check reported versus actual media size Info can be hidden in higher sectors Some cheap drives are out there that grossly over report size A typical 512 byte sector needs 16 bytes for error correction
  • 18. Fun with Microcontrollers Chip Choice Talking to Flash Drives An Extremely Compact Duplicator A Slightly Larger User-Friendly Duplicator A Microcontroller-Based Write Blocker Future Directions
  • 19. Chip Choice FTDI Vinculum II dual USB host controller 2 full-speed USB 2.0 interfaces (host or slave capable) 256 KB E-flash memory 16 KB RAM 2 SPI slave and 1 SPI master interfaces Easy-to-use IDE Simultaneous multiple file access on BOMS devices Several development modules available Convenient for prototyping (only SMD chips available) Cheap enough to embed in final device
  • 26. A Simple Duplicator Insert a flash drive to be copied Insert a target drive for copy Ideally the identical model Should be at least the same size Should use identical block size A sector by sector copy is performed Should work on majority of drives examined Requires approximately 11 minutes/GB Write speed of target is limiting factor
  • 27. Talking to a Flash Drive Bulk-Only Mass Storage (aka BBB) protocol used All communications use bulk endpoints Three phases: CBW, data-transport (optional), CSW Commands sent to drive using a Command Block Wrapper (CBW) CBW contains Command Block (CB) with actual command Nearly all drives use a (reduced) SCSI command set Commands requiring data transport will send/receive on bulk endpoints All transactions are terminated by a Command Status Wrapper (CSW)
  • 28. Command Block Wrapper typedefstruct _USB_MSI_CBW { unsigned long dCBWSignature; //0x43425355 unsigned long dCBWTag; // associates CBW with CSW response unsigned long dCBWDataTransferLength; // bytes to send or receive unsigned char bCBWFlags; // bit 7 0=OUT, 1=IN all others zero unsigned char bCBWLUN; // logical unit number (usually zero) unsigned char bCBWCBLength; // 3 hi bits zero, rest bytes in CB unsigned char bCBWCB[16]; // the actual command block (>= 6 bytes) } USB_MSI_CBW;
  • 29. Command Block 6-16 bytes depending on command Command is first byte Format Unit Example: typedefstruct _CB_FORMAT_UNIT { unsigned char OperationCode; //must be 0x04 unsigned char LUN:3; // logical unit number (usually zero) unsigned char FmtData:1; // if 1, extra parameters follow command unsigned char CmpLst:1; // if 0, partial list of defects, 1, complete unsigned char DefectListFormat:3; //000 = 32-bit LBAs unsigned char VendorSpecific; //vendor specific code unsigned short Interleave; //0x0000 = use vendor default unsigned char Control; } CB_FORMAT_UNIT;
  • 30. Command Block (continued) Read (10) Example: typedefstruct _CB_READ10 { unsigned char OperationCode; //must be 0x28 unsigned char RelativeAddress:1; // normally 0 unsigned char Resv:2; unsigned char FUA:1; // 1=force unit access, don't use cache unsigned char DPO:1; // 1=disable page out unsigned char LUN:3; //logical unit number unsigned long LBA; //logical block address (sector number) unsigned char Reserved; unsigned short TransferLength; unsigned char Control; } CB_READ10;
  • 31. Command Block (continued) Some Common SCSI Commands: FORMAT_UNIT=0x4, //required INQUIRY=0x12, //required MODE_SELECT6=0x15, MODE_SELECT10=0x55, MODE_SENSE6=0x1A, MODE_SENSE10=0x5A, READ6=0x08, //required READ10=0x28, //required READ12=0xA8, READ_CAPACITY10=0x25, //required READ_FORMAT_CAPACITIES=0x23, REPORT_LUNS=0xA0, //required REQUEST_SENSE=0x03, //required SEND_DIAGNOSTIC=0x1D, //required START_STOP_UNIT=0x1B, SYNCHRONIZE_CACHE10=0x35, TEST_UNIT_READ=0x00, //required VERIFY10=0x2F, WRITE6=0x0A, //required WRITE10=0x2A, WRITE12=0xAA
  • 32. Command Status Wrapper Read Sense command can be used for details on failed operations typedefstruct _USB_MSI_CSW { unsigned long dCSWSignature; //0x53425355 unsigned long dCSWTag; // associate CBW with CSW response unsigned long dCSWDataResidue; // difference between requested data and actual unsigned char bCSWStatus; //00=pass, 01=fail, 02=phase error, reset } USB_MSI_CSW;
  • 33. A Simple Duplicator (continued) void BOMSFindDevice() { VOS_HANDLE hUsb2, hBoms; usbhost_device_handle *ifDev2; usbhost_ioctl_cb_thc_iocb; usbhost_ioctl_cb_classhc_iocb_class; fat_contextfatContext; msi_ioctl_cb_tboms_iocb; boms_ioctl_cb_attach_tboms_att; // find BOMS class device hc_iocb_class.dev_class = USB_CLASS_MASS_STORAGE; hc_iocb_class.dev_subclass = USB_SUBCLASS_MASS_STORAGE_SCSI; hc_iocb_class.dev_protocol = USB_PROTOCOL_MASS_STORAGE_BOMS; hc_iocb.ioctl_code = VOS_IOCTL_USBHOST_DEVICE_FIND_HANDLE_BY_CLASS; hc_iocb.handle.dif = NULL; hc_iocb.set = &hc_iocb_class; hc_iocb.get = &ifDev2; if (vos_dev_ioctl(hUsb2, &hc_iocb) != USBHOST_OK) { // no BOMS class found } // now we have a device, intialise a BOMS driver for it hBoms = vos_dev_open(VOS_DEV_BOMS); // boms_attach boms_att.hc_handle = hUsb2; boms_att.ifDev = ifDev2; boms_iocb.ioctl_code = MSI_IOCTL_BOMS_ATTACH; boms_iocb.set = &boms_att; boms_iocb.get = NULL; if (vos_dev_ioctl(hBoms, &boms_iocb) != MSI_OK) { // could not attach to device } // device has been found and opened // now detach from the device boms_iocb.ioctl_code = MSI_IOCTL_BOMS_DETACH; vos_dev_ioctl(hBoms, &boms_iocb) }
  • 34. A Simple Duplicator (continued) VOS_DEVICE hBoms; unsigned char fat_readSector(unsigned long sector, char *buffer) { // transfer buffer msi_xfer_cb_txfer; // completion semaphore vos_semaphore_tsemRead; unsigned char status; vos_init_semaphore(&semRead, 0); xfer.sector = sector; xfer.buf = buffer; // 512 byte sector specific to keep it simple xfer.total_len = 512; xfer.buf_len = 512; xfer.status = MSI_NOT_ACCESSED; xfer.s = &semRead; xfer.do_phases = MSI_PHASE_ALL; status = vos_dev_read(hBoms, (unsigned char *)&xfer, sizeof(msi_xfer_cb_t ), NULL); If (status == MSI_OK) { status = FAT_OK; } else { status |= FAT_MSI_ERROR; } return status; }
  • 35. Simple Duplicator Realized To improve performance a double-buffered multi-threaded algorithm is used Performance is still limited by write speed of target device Future enhancements Use format unit command to erase target, then check for and skip blank sectors on copy operation Verify target is large enough to complete copy successfully Uses the smallest (32-pin) Vincullum-II development board Solder directly to the development board to minimize size Device is easily updated via debug port
  • 38. A More User-Friendly Duplicator Use the same chipset Use the same code Augment blinking lights with LCD Display Make use of development boards for ease of construction Shave a little here and there to make it more portable Power with a 9V battery
  • 42. Microcontroller-Based Write Blocker Commercial write blockers are ridiculously expensive The ability to peek at a drive before bothering to make a copy is appealing Would like to prevent AV deletion Use the FTDI Vinco (formerly Vinculo) board Cheap at $30 (€25) No soldering! – already has USB host and slave ports Arduino form factor 100% of the solution is in software Anyone can just buy the board and upload software Could deliver preprogrammed boards with disabled programming port
  • 43. Write Blocker (continued) Configure the slave port to enumerate as a USB bulk-only mass-storage device (BOMS) Inspect command blocks coming from the host PC Only commands known to not alter the drive are passed on to the subject USB BOMS device Whitelisting the commands makes design more future proof than blacklisting Still work in progress Due to some less than ideal documentation and some hardware issues, I have only recently gotten the USB host port to work E-mail me if you want to follow this project
  • 45. Write Blocker Realized (continued)
  • 46. Future Directions Android Open Accessory Device Possibly based on Vinco interfaced to VNC2 development board Vinco board might permit a device that can be controlled by an Android device or a PC High-Speed Device Possibly based on Beagle Board $149 (€105) Higher cost, but also adds the ability to realistically duplicate and examine USB hard drives Higher processing power could be tapped for other uses Could be used stand alone or connected to standard keyboard, mouse, and monitor
  • 47. A Potential Problem Problem: If you end up in court the other side may object to the use of home made devices Solution: Open Source Cyber-Forensics Association (OSCFA)
  • 48. OSCFA The Arduino of computer security and forensics Community for sharing of software and hardware designs for computer security and forensics stuff Ability to submit designs for peer review Hobbyists and students can build their own devices Persons not wishing to build devices could purchase from others Multiple vendors would be possible A slightly more expensive peer-reviewed and certified device could be purchased where required
  • 49. References USB Complete: The Developers Guide (4th ed.) by Jan Axelson USB Mass Storage: Designing and Programming Devices and Embedded Hosts by Jan Axelson http://www.usb.org http://www.ftdichip.com Real Digital Forensics by Keith Jones, et. al Windows Forensic Analysis (2nd ed.) by Harlan Carvey Embedded USB Design by Example by John Hyde File System Forensic Analysis by Brian Carrier All schematics and source code are available on request via e-mail to ppolstra@dbq.edu