The Taoof Hardware&The Te of Implants©2016 securinghardware.com

whoami?
● EE w/ some CS and Infosec● 10 years of fun with hardware○ silicon debug○ security research○ pen testing of CPUs
● 5 years of Hardware Security
Training:○ Applied Physical Attacks on
x86 Systems● Bside PDX!!!

Joe FitzPatrick@securelyfitz

joefitz@securinghardware.com©2016 securinghardware.com

OR©2016 securinghardware.com

Not this TAO

This Tao©2016 securinghardware.com

©2016 securinghardware.com

Tao of Hardware:Hardware is the absolute that underlies the world of computing©2016 securinghardware.com

©2016 securinghardware.com

Te of Implants:
Understanding and harnessing the inner strengthof minor additions to hardware systems©2016 securinghardware.com

Do the difficult things while they are simple
and do the great things while they are small-- Lao-Tze©2016 securinghardware.com

“Hardware Implants” pre-2013©2016 securinghardware.com

“Hardware Implants” pre-2013©2016 securinghardware.com

https://www.modchipcentral.com/store/images/xeno-gc-install-diagram.jpg

Der Spiegel - 30 December 2013
“Catalog Advertises NSA Toolbox”©2016 securinghardware.com

Der Spiegel - 30 December 2013
“Catalog Advertises NSA Toolbox”©2016 securinghardware.com

So What?
● Malicious hardware implants are real
● Hardware implants don t live in a vacuum● Use hardware to give software access, then back off©2016 securinghardware.com

Today’s Implants:
1. Blindly escalate privilege using JTAG
2. Patch kernels via DMA on an embedded device
3. Enable wireless control of an off-the-shelf PLC
4. Hot-plug a malicious PLC expansion
5. BadUSB-style display adapters©2016 securinghardware.com

Today’s Implants:
1. Blindly escalate privilege using JTAG
2. Patch kernels via DMA on an embedded device
3. Enable wireless control of an off-the-shelf PLC
4. Hot-plug a malicious PLC expansion©2016 securinghardware.com

Junk Hacking
1. Blindly escalate privilege using JTAG
2. Patch kernels via DMA on an embedded device
3. Enable wireless control of an off-the-shelf PLC
4. Hot-plug a malicious PLC expansion

Critical Infrastructure©2016 securinghardware.com

Today’s Implants:
1. Blindly escalate privilege using JTAG
2. Patch kernels via DMA on an embedded device
3. Enable wireless control of an off-the-shelf PLC
4. Hot-plug a malicious PLC expansion
5. BadUSB-style display adapters©2016 securinghardware.com

JTAG Model

Boundary scan, Halt/Resume,
Memory access--- (no one uses this crap)--- N/A - sessionless...
Target-specific configuration
IR/DR access
TAP FSM
TDI, TDO, TMS, TCK, TRST

Jtagsploitation: JTAG to Root, 5 ways
1.
2.
3.
4.
5.

Modify Non-Volatile Storage via Boundary Scan
Scrape memory for offline analysis
Patching bootargs
Live Kernel Patching
Finding & Patching a Process

44CON, Sept 2015 & Bsides Portland, Oct 2015 https://github.
com/syncsrc/jtagsploitation©2016 securinghardware.com

getty Parameters$ xxd /sbin/getty...
00006770 1b 5b 48 1b 5b 4a 00 2500006780 6f 6d 61 74 69 63 20 6c00006790 73 3a 20 72 65 61 64 3a000067a0 69 6e 70 75 74 20 6f 76000067b0 65 63 6b 6e 61 6d 65 20000067c0 25 6d 00 2d 68 00 2d 66000067d0 63 61 6e 27 74 20 65 78000067e0 6d 00 38 62 69 74 73 00

73 25 73 20 28 61 75 74
6f 67 69 6e 29 0a 00 2520 25 6d 00 25 73 3a 2065 72 72 75 6e 00 63 68
66 61 69 6c 65 64 3a 2000 2d 2d 00 25 73 3a 2065 63 20 25 73 3a 20 25
61 75 74 6f 6c 6f 67 69|.[H.[J.%s%s (aut||omatic login)..%||s: read: %m.%s: ||input overrun.ch||eckname failed: ||%m.-h.-f.--.%s: ||can't exec %s: %||m.8bits.autologi|

Changing -- to -f results in user being pre-authenticated©2016 securinghardware.com

21

NSA Playset: SOLDERPEEK©2016 securinghardware.com

NSA Playset: SOLDERPEEK©2016 securinghardware.com

Generating an SVF from OpenOCD©2016 securinghardware.com

Demo video©2016 securinghardware.com

Today’s Implants:
1. Blindly escalate privilege using JTAG
2. Patch kernels via DMA on an embedded device
3. Enable wireless control of an off-the-shelf PLC
4. Hot-plug a malicious PLC expansion
5. BadUSB-style display adapters©2016 securinghardware.com

So What?
●●●●●●Implant hardware is simple, cheap, and readily available
Payload can be prototyped with standard tools
When headers exist, installation is quick
Pinout is adaptable easily enoughIt s small enough to stick in lots of places
JTAG is JTAG is JTAG* - tested on ARM, MIPS and x86*mostly©2016 securinghardware.com

What is DMA?

Diagram: PCIe 2.1 specification©2016 securinghardware.com

28

A Brief History of DMA attacks©2016 securinghardware.com

Advancing ARM/MIPS systems©2016 securinghardware.com

PCIe on embedded hardware©2016 securinghardware.com

PCIe on embedded hardware©2016 securinghardware.com

PCIe on embedded hardware©2016 securinghardware.com

PCIe on embedded hardware©2016 securinghardware.com

Attack-side Software
Quick n dirty PCIe memory read/writewith PyUSB©2016 securinghardware.com

Linux File System ACL Enforcement
int generic_permission”struct inode *inode, int mask) {int ret;/** Do the basic permission checks.
*/
ret = acl_permission_check”inode, mask);
if ”ret != -EACCES)
return ret;……..
/*
* Searching includes executable on directories, else just read.
*/mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
if ”mask == MAY_READ)
if ”capable_wrt_inode_uidgid”inode, CAP_DAC_READ_SEARCH))
return 0;}

return -EACCES;©2016 securinghardware.com

37

Video Demo©2016 securinghardware.com

Implant-izing with 8051 code

©2016 securinghardware.com

39

Today’s Implants:
1. Blindly escalate privilege using JTAG
2. Patch kernels via DMA on an embedded device
3. Enable wireless control of an off-the-shelf PLC
4. Hot-plug a malicious PLC expansion
5. BadUSB-style display adapters©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

CPU©2016 securinghardware.com

RAMCPU©2016 securinghardware.com

RAMFlashCPU©2016 securinghardware.com

©2016 securinghardware.com

Output Buffers©2016 securinghardware.com

Output Buffers

Input Buffers©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

So What?
●●●●No software changes
All the original hardware is in there
No modification apparent from the outside
One signal can be wirelessly set/unset

That same header also connects the DB-9 programming port…
we could MITM that too if we wanted….

BUT! it proved to be nearly impossible to get a copy of the S7-200 software to
get this up and running. It was far cheaper to target a different
system:©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

60©2016 securinghardware.com

61©2016 securinghardware.com

62©2016 securinghardware.com

63©2016 securinghardware.com

64Video Demo©2016 securinghardware.com

So What?
●●●Again - a very cheap implant
Mostly off-the-shelf open source code
Can be retrofitted to most I/O types - if you know where©2016 securinghardware.com

Today’s Implants:
1. Blindly escalate privilege using JTAG
2. Patch kernels via DMA on an embedded device
3. Enable wireless control of an off-the-shelf PLC
4. Hot-plug a malicious PLC expansion
5. BadUSB-style display adapters©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

NXP
LPC1765
ARM
10-pin
JTAG©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

©2016 securinghardware.com

mww 0x2009c014 0xffff#turn all of bank 1 on

©2016 securinghardware.com

Relays

NXP
LPC1765
ARM
10-pinJTAG©2016 securinghardware.com

Video Demo©2016 securinghardware.com

So What?
●●●●

JTAG could be disabled ”but it s usually not)Test headers are quick and easy to accessCan be used on a unit IN OPERATIONWhen you get JTAG working - you win.

©2016 securinghardware.com

Today’s Implants:
1. Blindly escalate privilege using JTAG
2. Patch kernels via DMA on an embedded device
3. Enable wireless control of an off-the-shelf PLC
4. Hot-plug a malicious PLC expansion
5. BadUSB-style display adapters©2016 securinghardware.com

Evil Maid --> Evil Conference Projector?

BLINKERCOUGH, r00tkillah, BSLV ‘15©2016 securinghardware.com

©2016 securinghardware.com

The do-everything adapter
No wonder
it costs$80...

$20.
DFU updatableover USB©2016 securinghardware.com

So What?
●●When we have only one port - that port can do ANYTHING
Hardware isn t just hardware anymore:○○

There are no passive devices
There is no reasonable way for a user to know what a device does©2016 securinghardware.com

Today’s Implants:
1. Blindly escalate privilege using JTAG
2. Patch kernels via DMA on an embedded device
3. Enable wireless control of an off-the-shelf PLC
4. Hot-plug a malicious PLC expansion
5. BadUSB-style display adapters©2016 securinghardware.com

Today’s Implants:©2016 securinghardware.com

Today’s Implants:
1. Cost between ’5 and ’75
2. Can be built by hobbyists
3. Weigh less than an ounce
4. Can be customized to many different targets
5. Barely scratch the surface of what s possible©2016 securinghardware.com

Bad USB --> Bad USB Cable?

©2016 securinghardware.com

Takeaways●Hardware is cheap●

Standard interfaces really are standard●

Automating small devices is trivial●

If you can t trust the hardware, you can t trust the software●If you can control the hardware, you can control the software©2016 securinghardware.com

The Three Vinegar Tasters©2016 securinghardware.com

Confucius
Tastes Sour
Vinegar is
Polluted Wine
Conferencegoer
who missed theopen bar©2016 securinghardware.com

BuddhaTastes Bitter
Life is pain andsuffering
Incident
Responder?

©2016 securinghardware.com

Lao-Tze
Smiling
See Vinegar for its
positive uses
Hardware Hacker
who mixes some
Salt and Peroxide
to etch his PCBs
©2016 securinghardware.com

The Tao of Hardware
The Te of Implants
Questions?
Joe FitzPatrick - @securelyfitz
joefitz@securinghardware.com©2016 securinghardware.com