# Usb Device Forensics

> Use when tracing USB and removable media use during an authorized forensic investigation. Covers USBSTOR and device Registry keys, setupapi device installation logs, Windows Event Logs for device connection, volume and mount artifacts, Linux udev and kernel logs, and first and last connection times for a device. Use when data may have left on a flash drive, when an unknown device was plugged in, or when you need to link a specific device serial to a specific host and time.

- Skill: `mizazhaider-ceh/usb-device-forensics` (Agent Skill)
- Install (CLI): `npx get-skill add mizazhaider-ceh/usb-device-forensics`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mizazhaider-ceh/usb-device-forensics/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: mizazhaider-ceh (https://skillmd.com/u/mizazhaider-ceh)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/mizazhaider-ceh/usb-device-forensics

---


A USB device leaves a trail on every host it touches, and the most useful
part of that trail is the device serial number, which ties the host
record to the physical device. Windows records the device in the Registry
and in setup logs, Linux records it in kernel and udev logs, and both
record volume mounts that show what was accessible and when. This skill
covers reconstructing that trail from forensic images and triage packages
you are authorized to analyze, with the caution that a serial number
alone does not prove a file transfer, only that a device was present.
Pair device presence with file access times, volume artifacts, and
timeline events before claiming exfiltration.

## Quick Workflow

1. Hash the image or triage package and work on a copy.
2. Extract the SYSTEM hive, setupapi logs, Event Logs, and volume
   artifacts from the image.
3. List USBSTOR devices with serial numbers, friendly names, and
   install times from the Registry.
4. Check setupapi logs for the first installation date of each device.
5. Check Event Logs for device connection, driver installation, and
   volume mount events.
6. Check LNK files, Recent files, and shell artifacts for files opened
   from removable volumes.
7. On Linux hosts, check kernel logs, udev records, and mount history
   for the same device serial.
8. Build a per-device timeline: first seen, last seen, volumes mounted,
   and files accessed, with UTC times and sources.

## 1. USBSTOR devices from the Registry

```python
# List USBSTOR devices from an offline SYSTEM hive copy.
# The device key name usually encodes the device type, vendor, product,
# and serial, which is the identifier to carry through the whole case.
from Registry import Registry

reg = Registry.Registry("/evidence/case01/windows/hives/SYSTEM")
base = r"ControlSet001\Enum\USBSTOR"
try:
    key = reg.open(base)
    for device in key.subkeys():
        print("device", device.name())
        for instance in device.subkeys():
            print("  instance", instance.name())
            for value in instance.values():
                if value.name() in ("FriendlyName", "DeviceDesc", "Mfg"):
                    print("   ", value.name(), value.value())
except Exception as exc:
    print("USBSTOR key missing or unreadable", exc)
```

```bash
# Search parsed Registry output for USB-related keys and serials
rg -i "USBSTOR|USB\\\\VID" /evidence/case01/windows/parsed/ | head -60

# List volumes that were mounted, with drive letters and volume names
rg -i "MountedDevices|Volume" /evidence/case01/windows/parsed/SYSTEM.txt | head -40
```

A device entry without a serial, or with a generic serial shared by a
whole product line, cannot be tied to one physical device. Note that
limitation instead of treating the product name as an identity, and look
for a volume serial or a unique file artifact to narrow it down.

## 2. Setupapi logs and first installation times

```bash
# Extract setupapi logs from the image and search for USB installs
fls -r -p /dev/loop0p2 | grep -i "setupapi" | head -20
icat /dev/loop0p2 23456 > /evidence/case01/windows/setupapi.dev.log

# First installation entries for USB storage devices
grep -i "USBSTOR" /evidence/case01/windows/setupapi.dev.log | head -40
grep -i "Device Install" /evidence/case01/windows/setupapi.dev.log | head -40

# Timestamps in setupapi logs mark installation, not every connection
grep -B 2 -A 2 "USBSTOR" /evidence/case01/windows/setupapi.dev.log | head -80
```

Setupapi logs record installation, which usually happens on first
connection, but later connections of an already installed device may
not create a new setupapi entry. Use Event Logs and Registry last-write
times for repeat connections, and do not present a setupapi date as the
only connection date when other sources show later activity.

## 3. Event Logs and volume mount events

```bash
# Device connection and driver events from the System log
jq -r 'select(.Event.System.EventID == 20001 or .Event.System.EventID == 20003 or .Event.System.EventID == 6416)
  | [.Event.System.TimeCreated["#attributes"].SystemTime,
     .Event.System.EventID,
     .Event.System.Computer] | @tsv' \
  /evidence/case01/windows/evtx_json/System.json | sort | head -60

# Volume mount and removal events
jq -r 'select(.Event.System.EventID == 1006 or .Event.System.EventID == 1000)
  | [.Event.System.TimeCreated["#attributes"].SystemTime,
     .Event.System.EventID] | @tsv' \
  /evidence/case01/windows/evtx_json/System.json | sort | head -40

# LNK files pointing at removable drive letters, a sign files were opened
fls -r -p /dev/loop0p2 | grep -i "\.lnk" | head -40
python3 /evidence/case01/scripts/parse_lnk.py /evidence/case01/windows/lnk/*.lnk | grep -E ":[\\\\/]" | head -40
```

An Event Log entry proves the system recorded the event, not that a
user intentionally used the device. A device plugged in by an automated
process, a docking station, or a charger with data pins can create the
same entry, so check the user context and the files accessed before
attributing intent.

## 4. Linux USB artifacts

```bash
# Kernel messages for USB device connection, with vendor and product IDs
grep -i "usb" /evidence/case01/linux/var_log_kern.log | grep -i "New USB device\|Product\|SerialNumber" | head -60

# udev and mount history for removable devices
grep -i "sd[a-z]" /evidence/case01/linux/var_log_syslog | grep -i "Attached SCSI removable disk" | head -40
cat /evidence/case01/linux/mount_history.txt | grep -i "/media\|/mnt" | head -40

# Block device history and filesystem labels from a triage package
lsblk -f 2>/dev/null | head -20
blkid /dev/sdb1 2>/dev/null
dmesg | grep -i "usb" | tail -40
```

Linux logs rotate, so the earliest USB event in the surviving logs is a
lower bound on first use, not necessarily the true first use. Check
rotated and compressed logs, and check whether log rotation dates fall
inside the incident window, before concluding a device was never seen
before a given date.

## Edge cases

- The device serial is blank, generic, or spoofed. Fall back to volume
  serial, filesystem label, and file artifacts, and state the weaker
  identification plainly.
- The host was reinstalled, which wipes Registry device history. Check
  backups, disk images taken before the reinstall, and network logs for
  the surviving record.
- A USB hub or dock presents many devices at once. Separate the hub
  itself from the storage device behind it, or the timeline will credit
  the wrong device.
- The device was connected but never mounted, for example because it
  was encrypted or faulty. Device presence is still a finding, but file
  access cannot be claimed from presence alone.
- Timestamps differ between Registry last-write times and Event Logs.
  Registry times are updated on key writes, which may lag the actual
  connection, so prefer Event Log times for connection timing and use
  Registry times as corroboration.

## Key references

- NIST SP 800-86 (Guide to Integrating Forensic Techniques into Incident
  Response).
- Microsoft documentation on USB device installation, setupapi logs,
  and USBSTOR Registry keys.
- SANS Windows Forensic Analysis poster and artifact reference material.
- Linux kernel and udev documentation on USB device enumeration.

