diy hardware implant over i2c - part of the nsa playset

60
DIY Hardware implant over I2C Part of the NSA Playset Josh Datko and Teddy Reed DEF CON 2 2 August 10, 2014 Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 1 / 60

Upload: dangngoc

Post on 01-Jan-2017

230 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DIY Hardware implant over I2C - Part of the NSA Playset

DIY Hardware implant over I2CPart of the NSA Playset

Josh Datko and Teddy Reed

DEF CON 2 2

August 10, 2014

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 1 / 60

Page 2: DIY Hardware implant over I2C - Part of the NSA Playset

Outline

1 IntroductionNSA Playset DEF CON Series

2 DeconstructionI2C Attack Surfaces

3 ReconstructionI2C ModuleController DeviceGSM Module

4 Improvements and Future WorkCHUCKWAGON ImprovementsGSM Exfil Alternaive: Audio

5 Wrapup

6 Demo

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 2 / 60

Page 3: DIY Hardware implant over I2C - Part of the NSA Playset

NSA Playset Series

What is the NSA Playset?

We hope the NSA Playset will make cutting edge security tools moreaccessible, easier to understand, and harder to forget.

NSA Playset Talks

RF Retroreflector Penn & Teller Friday 12:00DIY Hardware Implant Track 1 Sunday 11:00GSM Sniffing Track 1 Sunday 12:00PCIe Track 2 Sunday 14:00

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 3 / 60

Page 4: DIY Hardware implant over I2C - Part of the NSA Playset

Inspired by the NSA

The NSA apparently has a hardware hacking catalog.1

Flip. . . Flip. . . Flip. . .

Oh look honey, there’s an I2C controller board we can get. Itattaches to a computer and it’s modular, so you can add a GSMcell phone for exfil.

That’s nice dear.

I wonder how that works. . .

1like SkyMall for spies and without the Bigfoot.Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 4 / 60

Page 5: DIY Hardware implant over I2C - Part of the NSA Playset

Requirements for the implant

From the docs:

Must attach over I2C to the target.

Must include GSM reachback to the implant.

Our requirements:

Easy to use.

Open Source Hardware.

Flexible: Allow for multiple communication and software protocols.

Fun. Single chip solutions aren’t as fun.

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 5 / 60

Page 6: DIY Hardware implant over I2C - Part of the NSA Playset

Implant Control Diagram

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 6 / 60

Page 7: DIY Hardware implant over I2C - Part of the NSA Playset

Background: What is I2C

Serial bus.

Two-wires: (plus power and ground).2

I Data: SDAI Clock: SCL

Multi-master.

Multi-slave.

Addressable.

Standard speed is 100kHz (100kbps). High Speed: 3.2Mbpstheoretical max.

2Typically 5 or 3.3VJosh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 7 / 60

Page 8: DIY Hardware implant over I2C - Part of the NSA Playset

Background: I2C in visual form

VddSDASCL

Rp

μCMaster

μCMasterSlave

EEPROMSlaveSensor

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 8 / 60

Page 9: DIY Hardware implant over I2C - Part of the NSA Playset

I2C attack surfaces

RAM EEPROMs

PCI and PCIe

Battery controllers

Video . . .

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 9 / 60

Page 10: DIY Hardware implant over I2C - Part of the NSA Playset

Video I2C

Why is there I2C on your monitor adapter?

How does your computer “automatically detect” monitor resolution?

EDID

Extended Display Identification Data

DDC

Data Display Channel, a.k.a. 5V I2C

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 10 / 60

Page 11: DIY Hardware implant over I2C - Part of the NSA Playset

EDID

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 11 / 60

Page 12: DIY Hardware implant over I2C - Part of the NSA Playset

$ edid-decode

ioreg -lw0 -r -c "IODisplayConnect"

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 12 / 60

Page 13: DIY Hardware implant over I2C - Part of the NSA Playset

EDID Extension Blocks

Tag Number Extension Block Description

00h Timing Extension02h CEA-EXT: CEA 861 Series Extension10h VTB-EXT: Video Timing Block Extension20h EDID 2.0 Extension40h DI-EXT: Display Information Extension50h LS-EXT: Localized String Extension60h DPVL-EXT: Digital Packet Video Link Extension

A7h, AFh, BFh DTCDB-EXT: Display Transfer CharacteristicsF0h EXTENSION Block MapFFh EXTENSIONS defined by the OEM

Parsing implemented by the OS-supplied VESA driver or GPU drivermanufacturer.

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 13 / 60

Page 14: DIY Hardware implant over I2C - Part of the NSA Playset

Exploiting EDID/EDID Extension parsing

Hacking Displays Made InterestingBlackhat EU 2012Andy Davis - NGS Securehttps://github.com/nccgroup/EDIDFuzzer

Simple adaptation for BeagleBoneImplemented in Python (BBIO)https://github.com/theopolis/bone-edidfuzzer

Discover proprietary EDID extensions! Moar fuzzing!Or assume a-priori software control...

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 14 / 60

Page 15: DIY Hardware implant over I2C - Part of the NSA Playset

I2C everywhere IC3

A video card may have multiple I2C buses and devices. NVIDIA cards mayhave I2C for the following:

EEPROM for encrypted HDCP keys

Onboard voltage regulator

Thermal sensor

TV decoder chip (older cards)

3C’mon, it’s punnyJosh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 15 / 60

Page 16: DIY Hardware implant over I2C - Part of the NSA Playset

Exploring VGA I2C

Let’s start exploring our attack surface.

Pin Name Description

1 RED Red Video2 GREEN Green Video3 BLUE Blue Video...

......

5 GND Ground9 KEY Optional +5V output from graphics card

12 SDA I2C data15 SCL I2C data clock

VGA Pinout

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 16 / 60

Page 17: DIY Hardware implant over I2C - Part of the NSA Playset

I want my I2C 4

4Dire Straights fans, anyone?Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 17 / 60

Page 18: DIY Hardware implant over I2C - Part of the NSA Playset

Filling in the details

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 18 / 60

Page 19: DIY Hardware implant over I2C - Part of the NSA Playset

Controller Selection

BeagleBone Black is theembedded hacker’s friend:

1GHz AM3358 ARM®

Cortex-A8

512MB DDR3 RAM

Two independentProgrammable Real-TimeUnits (32bit)

Crypto accelerators forAES, SHA, MD5

UARTs, PWM, LCD,GPMC, SPI, ADC, CAN,Timers

Two I2C buses

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 19 / 60

Page 20: DIY Hardware implant over I2C - Part of the NSA Playset

CryptoCape

The BBB ecosystem enables easy hardware expansion with Capes.Let’s add some hardware crypto and a micro:

Authenticators: ECC &MAC (SHA256)

Encrypted EEPROM(AES-128-CCM)

Battery backed upReal-time clock

Trusted PlatformModule

ATmega328p, all sorts ofhandy. Plus it’s aprogrammable I2C slave.

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 20 / 60

Page 21: DIY Hardware implant over I2C - Part of the NSA Playset

Add the controller

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 21 / 60

Page 22: DIY Hardware implant over I2C - Part of the NSA Playset

GSM Module

Seeed Studo GPRS Shield v2:

Arduino form factor

GSM Quad band support

TCP support

SIM card holder

Works with Tmobile,AT&T

I You can buy pre-paidSIMs with cash.

I T-Mobile has unlimitedtalk & text for 35USD.

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 22 / 60

Page 23: DIY Hardware implant over I2C - Part of the NSA Playset

Add the GSM module

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 23 / 60

Page 24: DIY Hardware implant over I2C - Part of the NSA Playset

Moar Power?

BBB draws 460mA onboot

CryptoCape

GSM Shield draws 300mAon average for “talk”, butpeak of 2.0 A!?

Meet the LiPoWerCapeI Switching voltage

regulator with noisefiltering

I Dual cell LiPo inputI Output to 5V Power

Rail

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 24 / 60

Page 25: DIY Hardware implant over I2C - Part of the NSA Playset

CHUCKWAGON

We still need a way to easilyconnect to the video adapter.Meet CHUCKWAGON:

DDC to I2C converter.

Breadboard friendly.

Logic level converters forI2C .

Supplies 5V from target(not on all VGAconnectors).

Power indicator.

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 25 / 60

Page 26: DIY Hardware implant over I2C - Part of the NSA Playset

CHUCKWAGON schematic

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 26 / 60

Page 27: DIY Hardware implant over I2C - Part of the NSA Playset

CHUCKWAGON board

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 27 / 60

Page 28: DIY Hardware implant over I2C - Part of the NSA Playset

I2C hack not that new. . .

As seen on Hackaday

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 28 / 60

Page 29: DIY Hardware implant over I2C - Part of the NSA Playset

Add the CHUCKWAGON

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 29 / 60

Page 30: DIY Hardware implant over I2C - Part of the NSA Playset

Connect to GSM module

Ok, so let’s connect to theGSM Shield from the Beagle!

BBB’s UART4,broken-out by ATmega’sprogram jumpers.

GSM’s shieldsoftware-serial, D7 andD8

/me checks datasheet onelast time...

Needs logic levelconverters!

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 30 / 60

Page 31: DIY Hardware implant over I2C - Part of the NSA Playset

Completed Hardware with Battery

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 31 / 60

Page 32: DIY Hardware implant over I2C - Part of the NSA Playset

Measuring current

Dave Jones’ µCurrent Gold

Trusted by hardware implant designers.

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 32 / 60

Page 33: DIY Hardware implant over I2C - Part of the NSA Playset

Completed Hardware without Battery

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 33 / 60

Page 34: DIY Hardware implant over I2C - Part of the NSA Playset

Software flow

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 34 / 60

Page 35: DIY Hardware implant over I2C - Part of the NSA Playset

Usage

1 Get malware on target.

2 Attach CHUCWAGON for exfil or control.

If software on the target can communicate with the implant then:

Target can exfil out to implant to GSM.

Target can exfil out to implant for storage.

Implant can provide code for target to run.

Control the implant over GSM → control the target over GSM

Why is this significant?

I2C via the video adapter is an always on, bi-directional bus on everylaptop, PC, or server.

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 35 / 60

Page 36: DIY Hardware implant over I2C - Part of the NSA Playset

Accessorize!

Prepared for anything or NSA hacking toolkit?

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 36 / 60

Page 37: DIY Hardware implant over I2C - Part of the NSA Playset

How to improve the CHUCKWAGON

What does CHUCKWAGON rev. B look like?

Consolidate into one board: ImplantCape

HDMI footprint vs. VGA

Could all be done from AVR (less power), but BBB is more fun andprovides more options.

VGA Tap.I Combine with SALSAFLOCK for a implant plus RF retroreflector.

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 37 / 60

Page 38: DIY Hardware implant over I2C - Part of the NSA Playset

Using Crypto for Evil!

Long history of Cryptography and Malware!

Cryptoviral Extortion:

1989 PC Cybord, Joseph Popp

1996 Macintosh SE/30 crytovirus PoC, Young and Yung

2006 Gpcode.AG/AK, Cryzip

2013 CryptoLocker, CryptorBit

Reversing Anti-Analysis:

Packers, Obfuscator, VM-based JIT

2011 TPM ”cloaking” malware

2014 Uroburos, encrypted VFS

2014 TPM-enabled super-targeted malware

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 38 / 60

Page 39: DIY Hardware implant over I2C - Part of the NSA Playset

Using Crypto for Evil!

The CryptoCape includes a TPM...

I2C friendly

Protected RSA private key storage

Windows 8 friendly

More or less optional, as there is most likely an onboard TPM

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 39 / 60

Page 40: DIY Hardware implant over I2C - Part of the NSA Playset

Cloaking Malware with the Trusted Platform Module

2011 USENIX SecurityAlan M. Dunn, Owen S. Hofmann, Brent Waters, Emmett WitchelSummary: Use TPM-protected keys and an Intel TXT PAL to protectmalicious code execution from observation, analysis, and tamperment.

Intel TXT and remote attestation are hard!But generating a public key on a TPM and using that to encryptadditional payloads is easy...

Put a TPM on your implant and protect against nasty networkinterception. Also restrict analysis to the target machine upon discovery(or force memory analysis).

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 40 / 60

Page 41: DIY Hardware implant over I2C - Part of the NSA Playset

TPM-enabled super-targeted Malware

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 41 / 60

Page 42: DIY Hardware implant over I2C - Part of the NSA Playset

TPM-enabled super-targeted Malware

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 42 / 60

Page 43: DIY Hardware implant over I2C - Part of the NSA Playset

TPM-enabled super-targeted Malware

Windows 8 automatically enables/initializes a TPM, then creates andmanages your owner password. Access to TPM is abstracted throughMicrosoft CSP.

Windows PcpTool Kit:NCryptOpenStorageProviderNCryptCreatePersistedKeyNCryptExportKeyNCryptDecrypt

In memory process creation:CreateProcessZwUnmapViewOfSectionVirtualAllocExWriteProcessMemory

Python pefile to injectencrypted PE section into adecryption stub.

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 43 / 60

Page 44: DIY Hardware implant over I2C - Part of the NSA Playset

TPM-enabled super-targeted Malware

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 44 / 60

Page 45: DIY Hardware implant over I2C - Part of the NSA Playset

tpm-malcrypt

fork tpm-malcrypt!

https://github.com/theopolis/tpm-malcrypt

tpm-keyextract, create and exfil a storage public key

malcrypter, encrypt and inject into decryption stub

malcrypt, decryption stub, process creation/injection

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 45 / 60

Page 46: DIY Hardware implant over I2C - Part of the NSA Playset

Malicious Exfiltration via AudioBackstory: #badBIOS thought to use Audio as an out-of-bandexfiltration or C&C mechanism. Dismissed as infeasable by BIOSdevelopment SMEs.

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 46 / 60

Page 47: DIY Hardware implant over I2C - Part of the NSA Playset

Malicious Exfiltration via Audio

Data of Audio Protocols are very well defined and resiliant.

QPSK10 (10 baud), QPSK05 (5 baud), quadrature phase shift keyingmodulation to provide forward error correction.

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 47 / 60

Page 48: DIY Hardware implant over I2C - Part of the NSA Playset

Malicious Exfiltration via Audio

Possible to ”pivot” through colluding machines. Local network exploitationcreates a mesh of audio-capable relays such as idle headphones.

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 48 / 60

Page 49: DIY Hardware implant over I2C - Part of the NSA Playset

Demos, Learning, and Fabulous Prizes

Join us in the HHV for CryptoCape and WAGONBED demos!

Challenge: Solve the puzzle here:theopolis.github.io/tpm-malcrypt/challenge.html

The first 5 correct submissions win a DIY hardware implant kit(No hardware hacking experience required)

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 49 / 60

Page 50: DIY Hardware implant over I2C - Part of the NSA Playset

Demos, Learning, and Fabulous Prizes

Thank you!

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 50 / 60

Page 51: DIY Hardware implant over I2C - Part of the NSA Playset

Upcoming Book

Preorder with code: BBSAeBat packtpub.com.

Setting up a Tor bridgeand building custom frontpanel.

Two factor authenticationwith a Fingerprint scannerand the CryptoCape

Using the TPM to protectGPG keys

Running an IRC gatewaywith BitlBee, ZNC, andusing OTR for protectedchat.

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 51 / 60

Page 52: DIY Hardware implant over I2C - Part of the NSA Playset

POC Code

CHUCKWAGON sketch and scripts

https://github.com/NSAPlayset/CHUCKWAGON

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 52 / 60

Page 53: DIY Hardware implant over I2C - Part of the NSA Playset

i2cdetect on BBB

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 53 / 60

Page 54: DIY Hardware implant over I2C - Part of the NSA Playset

i2cdetect on target

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 54 / 60

Page 55: DIY Hardware implant over I2C - Part of the NSA Playset

chuckwagon util on BBB

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 55 / 60

Page 56: DIY Hardware implant over I2C - Part of the NSA Playset

chuckwagon util on target

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 56 / 60

Page 57: DIY Hardware implant over I2C - Part of the NSA Playset

BBB starting the GSM module

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 57 / 60

Page 58: DIY Hardware implant over I2C - Part of the NSA Playset

BBB waiting on text message

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 58 / 60

Page 59: DIY Hardware implant over I2C - Part of the NSA Playset

Receiving the message on the target

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 59 / 60

Page 60: DIY Hardware implant over I2C - Part of the NSA Playset

Executing the text message

Josh Datko and Teddy Reed (DEF CON 2 2) DIY Hardware implant over I2C August 10, 2014 60 / 60