SlideShare una empresa de Scribd logo
1 de 30
Descargar para leer sin conexión
Hardware hacking
Tavish Naruka
About me
What I do:
I studied electronics from JIIT and have been working at Baseapp Systems, in
Delhi. I do software/system design for embedded systems.
Hardware hacking?
● looking at how a consumer product
does what it does
● making something from scratch
● making things do what they were not
meant to do.
Outline
● Introduction to some common protocols
used in low level electronics (rs 232, spi, i2c)
● Sniffing/speaking these protocols
● USB protocol, Sniffing USB
● A few interesting hardware hacks
● Router hacking
● Chips follow standard protocols
● You can google most device datasheets
● exception is some chips with limited/restricted distribution
There are a few common protocols you will see in a lot of places
Things follow rules
SPI Serial and SPI communication waveforms
Rs 232
Often called just Serial, can be found in many
places
Often used as a debug output in systems, or
even control terminal.
Often used to just transfer readable text, so
you can even read what transfers are going on.
$GPRMC,081836,A,3751.65,S,14507.36,E,
000.0,360.0,130998,011.3,E*62
I2C protocolMultiple I2C devices wired together
A sample I2C transaction
● I2c comm. initiated by master, and
there is only 1 master at a time
● All devices have a unique address,
and they respond to only that
● All transfers require
acknowledgement
● Start and stop condition to indicate
start/stop of data
A lot of things, memories, wireless chips, all kinds of
sensors, batteries, ADCs, even some LEDs, speak I2C or
SPI
Also called SMBUS, on PCs
Some places where I2c is used
EEPROM Laptop batteries
Various sensors
Sniffing/Speaking
A logic analyzer connected
to a beaglebone
Logic analyzer output on its
software tool
Speaking
Arduino - really quick prototyping
PIC32 Fubarino mini
STM32F4 Discovery
FTDI USB serial chips can also do many
protocols. Can use C/python libraries
FTDI chips (FT232h ^)
FT232H (module is pic UM232h)
● Most often used as usb to serial
● Can also do SPI/I2C, GPIO/bitbang
● FTDI provides C libraries for using
these
● Can do JTAG, openOCD or other
debuggers
● code on right -> read 1MB SPI flash
libmpsse, python wrapper over ftdi C libraries(libftdi)
from mpsse import *
MPSSE(SPI0, THIRTY_MHZ, MSB)
Start()
Write("x03x00x00x00")
data = Read(0x100000)
Stop()
Close()
open('flash.bin', 'wb').write(data)
Some mcu suggestions
Arduino
1. Has a serial bootloader, so dont
need programmer
2. IDE comes with many ready to use
libraries, not good
3. code written in C++, in IDE, which
is not the best text editor
4. Don’t really need IDE
5. AVR-gcc and clib, avrdude etc.
STM32
1. ARM cortex M0/1/3/4
2. GCC arm compilers are free and/or open source
3. Need programmer/debugger, but discovery kits
come with one, can also use FTDI chip from last
slide as JTAG with Openocd(olimex Tiny-usb jtag
etc.)
4. no ide, free to setup anything
Microchip PICs
1. Series of 8, 16, 32 bit microcontrollers
2. Also have an IDE, based on Netbeans
3. no completely free toolchain. Some code
optimizations are paid features
4. Provide some libraries for USB stack and
peripherals etc
5. Need a programmer, like ICD3, which is a bit
expensive but can program/debug any microchip
PIC
Introduction
● USB cable has 4 wires, gnd, 5V, D+, D-
● When you connect a device to a host, host
does ‘enumeration’
● device describes itself to host during this
● You communicate with USB device on
“Endpoints”, which are like port number on
an IP in a network. Descriptors sent on
endpoint 0, which is always present
● After enumeration, host OS may decide to
load a driver for device, depending on
device class, or if not class, then VID/PID
USB
Bus 002 Device 003: ID 0079:0006 DragonRise Inc.
Generic USB Joystick
Device Descriptor:
idVendor 0x0079 DragonRise Inc.
idProduct 0x0006 Generic USB Joystick
bNumConfigurations 1
Configuration Descriptor:
MaxPower 500mA
bNumInterfaces 1
Interface Descriptor:
bNumEndpoints 2
bInterfaceClass 3 Human Interface
bInterfaceSubClass 0 No Subclass
Endpoint Descriptor:
bEndpointAddress 0x81 EP 1 IN
Transfer Type Interrupt
wMaxPacketSize 0x0008 1x 8 bytes
Endpoint Descriptor:
bEndpointAddress 0x01 EP 1 OUT
Transfer Type Interrupt
wMaxPacketSize 0x0008 1x 8 bytes
Sniffing USB
USB sniffing
● Linux kernel facility called
‘usbmon’
● Sort of like tcpdump for USB
● wireshark, vusb analyser are
both free/open source
Wireshark
VUSB analyser
Talking USB
Libusb
http://libusb.info/ or
http://libusb.org/
You can talk to a device with a
class/subclass or vid/pid not associated
with a driver using this library.
C/C++, python
Microcontrollers:
most of STM32 series
many pic18 and 32
atmega32u4 etc
have USB device, some have host too
Linux USB gadget API
● kernel modules to act as a USB slave(instead of host)
● hardware should support usb peripheral, so most
desktops can’t, but many embedded ones can
● USB serial, ethernet
● USB HID, keyboard, mouse
● PTP (picture transfer protocol, like in camera, or android
phones)
● sound devices, webcam
● File backed storage, mass storage devices
USB mass storage device class as an example
Flash
USB controller
Computer
You plug in a USB pen drive
● Enumeration happens on Control endpoint(EP0)
● 2 Endpoints(1 IN, 1 OUT) are set up for
exchanging data
● Data exchanges are wrapped in SCSI
commands(read, write, disk size etc.)
● in linux, kernel loads USB mass storage driver,
which provides a block device interface like
/dev/sdb
● linux reads partition table to detect any
partitions, if present, /dev/sdb1, /dev/sdb2
● OS auto mounter may mount detected partitions
Android mass storage, uses usb gadgetfs driver
in linux. Unmounts microsd partition, makes it
available to gadgetfs.
Mp3 players and other devices do this.
Is a means for firmware update in some
devices.
Block devices
MBR - first sector 512 bytes
Valid boot sector signature
Partition table
● only 4 entries, hence 4
primary partitions
● first byte either 0x80 or 0x0,
bootable flag
● used by ibm compatible and
other computers during boot
Some tools for seeing binary data:
● hd, hexdump
● od - read as int uint, chars etc
● strings - show printable characters
in file
● xxd - hex dump to bin or reverse
● file - try to identify type of file
● dd - read parts of one file into
another, everything is a file
STM32
USBpendrive
Layers of Host code
● USB host
● usb mass storage
driver, bulk only
transfer, SCSI
● fat32 layer
SPI Oled display
USBdevicetopc
● Do not know, nor needed to know
all layers in detail
● Most of USB stack, and mass
storage driver is from STmicro
● fat32 layer is Chan’s fatfs library ● SPI oled initialization
sequence
● data write sequence
● Character fonts
● handling ‘frame buffer’
● adafruit had released
similar oled, used code
from there
USB device code
● Modify code for USB
CDC(or USB serial)
● Bulk only transfer,
and maximum packet
size(64 bytes, full
speed)
● Custom
class/subclass(0xff)
● Desktop application
uses libusb to
communicate
Samsung smart tv:
● ARM based, runs busybox based linux system
● has software packages like widgets/games
and firmware updates
● updates installed via USB pen drive
Some examples
Implemented on Gumstix board
● Linux usb file storage gadget
● TV reads and checks files
● on reading second time, the filesystem
is switched, copying own code onto tv,
which it runs as root
Some more examples, CHDK
Canon Hack Development Kit
● (2006) Programmer studies
disassembly of firmware upgrade
for his IXUS camera
● Figures out a way to boot from SD
card
● Dumps firmware of camera by
blinking the LED on camera, and
reading with a light dependant
resistor,
CHDK running on a point and shoot
● Enhancement to camera firmware, doesn’t void
warranty, GPL
● Features, RAW images, settings overrides(shutter
speed, exposure, ISO), exposure/focus bracketing,
● motion detection, HDR, time lapse
● User scripts in Lua, uBasic
● can make really cheap trigger using usb cable
● On screen displays, live histogram
Unlimited DOF using focus bracketing
HDR, by combining Exposure bracketing
Some more examples
Openkinect
● Microsoft was not willing to release
open source/otherwise drivers for
systems other than linux for kinect
● Adafruit(which is DIY/hobbyist
electronics company) launched a
bounty
● they put up dumps of USB traffic
from kinect on windows
● protocol reverse engineered,
libfreenect
PS3 jailbreak
● Buffer overflow in PS3 USB stack
● if device reports smaller descriptor length than
actual, PS3 copies the data into a small allocated
memory, causing overflow
● This allowed the jailbreak creators to run arbitrary
code on the ps3 somehow
Router hacking
Routers have always been closed source
● In 2003 linksys releases WRT54G
● turns out it runs linux
● community pressure on linksys to release
source because of linux GPL license
● Many router firmware projects started after
this
linksys later moved to Vxworks, but people got
linux working on new routers too.
Openwrt
Most active router firmware project
Actually a linux distribution for very space
constrained systems, and has router specific
additions
● has a web interface, like in normal routers
● generates images as squashfs/jffs2 filesystem
● these are written on flash chips on routers
● Based on buildroot/uClibc build system
TP-link WR841ND
SPI flash chip
Atheros ar9341
SoC
RAM
Serial port
Inside a typical router
OpenWrt buildroot menuconfig
OpenWrt flash layout4MB SPI flash
For just dumping flash contents, can desolder chip and read.
(never have to)
Some tools to analyse unknown flash contents:
● Binwalk
● Firmware mod kit - uses binwalk
binwalk, firmware-mod-kit
Binwalk scan results
Firmware-mod-kit
● it tries to detect different portions in firmware dump
● extracts them
● you modify them if you want
● repacks them, recreating CRCs or signatures again if need be
More examples
Kindle 4 no touch
Create empty file ‘ENABLE_DIAGS’,
restart from menu
● Apart from just breaking consumer stuff, this info is
useful for making hardware
● Many vendors are selling modules with router SoCs
you can use in own projects.
Ex. 8devices.com carambola
Has wifi, runs linux
easier to put in own projects
than these BGA chips
Arduino yun has same
ar9331 chip(also has
atmega32u4), runs openwrt.
Fon Wireless Ltd., runs a paid wifi
sharing network. Their own hardware
runs a OpenWrt derivative
A wireless audio receiver
This is a small wifi audio receiver we made.
Based on a router SoCs.
● Carambola2 SoM, wifi, 16MB flash, 64MB ram
● Custom openwrt
● each speaker is an alljoyn audio sink
● devices have master/slave modes, each mode has
a config mode
● in config mode you can connect to device with
phone using wifi AP
● network configuration, DHCP, wifi access point,
switching modes, starting/monitoring services etc
handled by custom scripts in Lua, since openwrt
code was suitable only for a router.
● Modifications to board specific code for kernel, for
LEDs, buttons, etc. hints taken from board specific
code for other routers.
Conclusion…
● Devices use standard protocols to communicate
● Logic analyzer is useful
● You can make routers run your own code

Más contenido relacionado

La actualidad más candente

Access Control Presentation
Access Control PresentationAccess Control Presentation
Access Control PresentationWajahat Rajab
 
ESP32 IoT presentation @ dev.bg
ESP32 IoT presentation @ dev.bgESP32 IoT presentation @ dev.bg
ESP32 IoT presentation @ dev.bgMartin Harizanov
 
Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...
Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...
Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...Sam Bowne
 
Attacker's Perspective of Active Directory
Attacker's Perspective of Active DirectoryAttacker's Perspective of Active Directory
Attacker's Perspective of Active DirectorySunny Neo
 
공인인증서 크래킹 - Inc0gnito 2015
공인인증서 크래킹 - Inc0gnito 2015공인인증서 크래킹 - Inc0gnito 2015
공인인증서 크래킹 - Inc0gnito 2015Hajin Jang
 
CCNA Course Training Presentation
CCNA Course Training PresentationCCNA Course Training Presentation
CCNA Course Training PresentationRohit Singh
 
Static partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-VStatic partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-VRISC-V International
 
End to End Encryption in 10 minutes -
End to End Encryption in 10 minutes - End to End Encryption in 10 minutes -
End to End Encryption in 10 minutes - Thomas Seropian
 
block ciphers
block ciphersblock ciphers
block ciphersAsad Ali
 
Bootloaders (U-Boot)
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot) Omkar Rane
 
Bit locker Drive Encryption: How it Works and How it Compares
Bit locker Drive Encryption: How it Works and How it ComparesBit locker Drive Encryption: How it Works and How it Compares
Bit locker Drive Encryption: How it Works and How it ComparesLumension
 

La actualidad más candente (20)

Access Control Presentation
Access Control PresentationAccess Control Presentation
Access Control Presentation
 
Getting started with BeagleBone Black - Embedded Linux
Getting started with BeagleBone Black - Embedded LinuxGetting started with BeagleBone Black - Embedded Linux
Getting started with BeagleBone Black - Embedded Linux
 
ESP32 IoT presentation @ dev.bg
ESP32 IoT presentation @ dev.bgESP32 IoT presentation @ dev.bg
ESP32 IoT presentation @ dev.bg
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
 
Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...
Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...
Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...
 
Attacker's Perspective of Active Directory
Attacker's Perspective of Active DirectoryAttacker's Perspective of Active Directory
Attacker's Perspective of Active Directory
 
공인인증서 크래킹 - Inc0gnito 2015
공인인증서 크래킹 - Inc0gnito 2015공인인증서 크래킹 - Inc0gnito 2015
공인인증서 크래킹 - Inc0gnito 2015
 
CCNA Course Training Presentation
CCNA Course Training PresentationCCNA Course Training Presentation
CCNA Course Training Presentation
 
Cryptography
CryptographyCryptography
Cryptography
 
Ospf.ppt
Ospf.pptOspf.ppt
Ospf.ppt
 
Key management
Key managementKey management
Key management
 
Embedded C
Embedded CEmbedded C
Embedded C
 
Password craking techniques
Password craking techniques Password craking techniques
Password craking techniques
 
Static partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-VStatic partitioning virtualization on RISC-V
Static partitioning virtualization on RISC-V
 
Linux Internals - Part III
Linux Internals - Part IIILinux Internals - Part III
Linux Internals - Part III
 
End to End Encryption in 10 minutes -
End to End Encryption in 10 minutes - End to End Encryption in 10 minutes -
End to End Encryption in 10 minutes -
 
Board Bringup
Board BringupBoard Bringup
Board Bringup
 
block ciphers
block ciphersblock ciphers
block ciphers
 
Bootloaders (U-Boot)
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot)
 
Bit locker Drive Encryption: How it Works and How it Compares
Bit locker Drive Encryption: How it Works and How it ComparesBit locker Drive Encryption: How it Works and How it Compares
Bit locker Drive Encryption: How it Works and How it Compares
 

Destacado

Internet of things - with routers
Internet of things - with routersInternet of things - with routers
Internet of things - with routersTavish Naruka
 
OpenWrt101 2007
OpenWrt101 2007OpenWrt101 2007
OpenWrt101 2007Rex Tsai
 
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdfamrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdfamrapalibuildersreviews
 
Intro to Hardware Firmware Hacking
Intro to Hardware Firmware HackingIntro to Hardware Firmware Hacking
Intro to Hardware Firmware HackingAndrew Freeborn
 
Hardware Hacking caso práctico Ingeniería Inversa Smartcards
Hardware Hacking caso práctico Ingeniería Inversa SmartcardsHardware Hacking caso práctico Ingeniería Inversa Smartcards
Hardware Hacking caso práctico Ingeniería Inversa SmartcardsAndres Lozano
 
Hardware Hacking in schools (ACEC2014)
Hardware Hacking in schools (ACEC2014)Hardware Hacking in schools (ACEC2014)
Hardware Hacking in schools (ACEC2014)Dan Bowen
 
BSides DFW2016-Hack Mode Enabled
BSides DFW2016-Hack Mode EnabledBSides DFW2016-Hack Mode Enabled
BSides DFW2016-Hack Mode Enabledpricemcdonald
 
A BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKING
A BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKINGA BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKING
A BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKINGSilvio Cesare
 
Hacker's and painters Hardware Hacking 101 - 10th Oct 2014
Hacker's and painters Hardware Hacking 101 - 10th Oct 2014Hacker's and painters Hardware Hacking 101 - 10th Oct 2014
Hacker's and painters Hardware Hacking 101 - 10th Oct 2014Takeda Pharmaceuticals
 
Coders need to learn hardware hacking NOW
Coders need to learn hardware hacking NOWCoders need to learn hardware hacking NOW
Coders need to learn hardware hacking NOWMatt Biddulph
 
JTAG Interface (Intro)
JTAG Interface (Intro)JTAG Interface (Intro)
JTAG Interface (Intro)Nitesh Bhatia
 
Hardware Reverse Engineering: From Boot to Root
Hardware Reverse Engineering: From Boot to RootHardware Reverse Engineering: From Boot to Root
Hardware Reverse Engineering: From Boot to RootYashin Mehaboobe
 
PyTriage: A malware analysis framework
PyTriage: A malware analysis frameworkPyTriage: A malware analysis framework
PyTriage: A malware analysis frameworkYashin Mehaboobe
 
CNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 DisassemblyCNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 DisassemblySam Bowne
 

Destacado (20)

Internet of things - with routers
Internet of things - with routersInternet of things - with routers
Internet of things - with routers
 
OpenWrt101 2007
OpenWrt101 2007OpenWrt101 2007
OpenWrt101 2007
 
Playful
PlayfulPlayful
Playful
 
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdfamrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
amrapali builders @@ hardware hacking and robotics using the raspberry pi.pdf
 
Intro to Hardware Firmware Hacking
Intro to Hardware Firmware HackingIntro to Hardware Firmware Hacking
Intro to Hardware Firmware Hacking
 
Hardware Hacking caso práctico Ingeniería Inversa Smartcards
Hardware Hacking caso práctico Ingeniería Inversa SmartcardsHardware Hacking caso práctico Ingeniería Inversa Smartcards
Hardware Hacking caso práctico Ingeniería Inversa Smartcards
 
Hardware Hacking in schools (ACEC2014)
Hardware Hacking in schools (ACEC2014)Hardware Hacking in schools (ACEC2014)
Hardware Hacking in schools (ACEC2014)
 
Hardware Hacking Primer
Hardware Hacking PrimerHardware Hacking Primer
Hardware Hacking Primer
 
BSides DFW2016-Hack Mode Enabled
BSides DFW2016-Hack Mode EnabledBSides DFW2016-Hack Mode Enabled
BSides DFW2016-Hack Mode Enabled
 
A BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKING
A BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKINGA BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKING
A BEGINNER’S JOURNEY INTO THE WORLD OF HARDWARE HACKING
 
Hacker's and painters Hardware Hacking 101 - 10th Oct 2014
Hacker's and painters Hardware Hacking 101 - 10th Oct 2014Hacker's and painters Hardware Hacking 101 - 10th Oct 2014
Hacker's and painters Hardware Hacking 101 - 10th Oct 2014
 
Coders need to learn hardware hacking NOW
Coders need to learn hardware hacking NOWCoders need to learn hardware hacking NOW
Coders need to learn hardware hacking NOW
 
Breaking Bad EACS Implementations
Breaking Bad EACS ImplementationsBreaking Bad EACS Implementations
Breaking Bad EACS Implementations
 
Arduino Forensics
Arduino ForensicsArduino Forensics
Arduino Forensics
 
Router forensics
Router forensicsRouter forensics
Router forensics
 
Hardware hacking 101
Hardware hacking 101Hardware hacking 101
Hardware hacking 101
 
JTAG Interface (Intro)
JTAG Interface (Intro)JTAG Interface (Intro)
JTAG Interface (Intro)
 
Hardware Reverse Engineering: From Boot to Root
Hardware Reverse Engineering: From Boot to RootHardware Reverse Engineering: From Boot to Root
Hardware Reverse Engineering: From Boot to Root
 
PyTriage: A malware analysis framework
PyTriage: A malware analysis frameworkPyTriage: A malware analysis framework
PyTriage: A malware analysis framework
 
CNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 DisassemblyCNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 Disassembly
 

Similar a Hardware hacking guide covering common protocols like I2C, SPI, USB and router hacking projects

Tac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PITac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PICliff Samuels Jr.
 
Embedded platform choices
Embedded platform choicesEmbedded platform choices
Embedded platform choicesTavish Naruka
 
Building Trojan Hardware at Home
Building Trojan Hardware at HomeBuilding Trojan Hardware at Home
Building Trojan Hardware at HomeE Hacking
 
Starting Raspberry Pi
Starting Raspberry PiStarting Raspberry Pi
Starting Raspberry PiLloydMoore
 
Is Rust Programming ready for embedded development?
Is Rust Programming ready for embedded development?Is Rust Programming ready for embedded development?
Is Rust Programming ready for embedded development?Knoldus Inc.
 
The eID on Linux in 2015
The eID on Linux in 2015The eID on Linux in 2015
The eID on Linux in 2015Wouter Verhelst
 
The internet of $h1t
The internet of $h1tThe internet of $h1t
The internet of $h1tAmit Serper
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to ArduinoDamien Magoni
 
2.2. Introduction to Arduino
2.2. Introduction to Arduino2.2. Introduction to Arduino
2.2. Introduction to Arduinodefconmoscow
 
Introduction to FreeRTOS
Introduction to FreeRTOSIntroduction to FreeRTOS
Introduction to FreeRTOSICS
 
Raspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application DevelopmentRaspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application DevelopmentCorley S.r.l.
 

Similar a Hardware hacking guide covering common protocols like I2C, SPI, USB and router hacking projects (20)

Tac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PITac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PI
 
Embedded platform choices
Embedded platform choicesEmbedded platform choices
Embedded platform choices
 
Building Trojan Hardware at Home
Building Trojan Hardware at HomeBuilding Trojan Hardware at Home
Building Trojan Hardware at Home
 
Let's begin io t with $10
Let's begin io t with $10Let's begin io t with $10
Let's begin io t with $10
 
Beagle board101 esc-boston-2009b
Beagle board101 esc-boston-2009bBeagle board101 esc-boston-2009b
Beagle board101 esc-boston-2009b
 
arduino.pdf
arduino.pdfarduino.pdf
arduino.pdf
 
Starting Raspberry Pi
Starting Raspberry PiStarting Raspberry Pi
Starting Raspberry Pi
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
Is Rust Programming ready for embedded development?
Is Rust Programming ready for embedded development?Is Rust Programming ready for embedded development?
Is Rust Programming ready for embedded development?
 
The eID on Linux in 2015
The eID on Linux in 2015The eID on Linux in 2015
The eID on Linux in 2015
 
The internet of $h1t
The internet of $h1tThe internet of $h1t
The internet of $h1t
 
Main notes (1)
Main notes (1)Main notes (1)
Main notes (1)
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
2.2. Introduction to Arduino
2.2. Introduction to Arduino2.2. Introduction to Arduino
2.2. Introduction to Arduino
 
Arduino
ArduinoArduino
Arduino
 
Indroduction arduino
Indroduction arduinoIndroduction arduino
Indroduction arduino
 
Indroduction the arduino
Indroduction the arduinoIndroduction the arduino
Indroduction the arduino
 
Introduction to FreeRTOS
Introduction to FreeRTOSIntroduction to FreeRTOS
Introduction to FreeRTOS
 
OpenOCD-K3
OpenOCD-K3OpenOCD-K3
OpenOCD-K3
 
Raspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application DevelopmentRaspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application Development
 

Último

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Último (20)

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Hardware hacking guide covering common protocols like I2C, SPI, USB and router hacking projects

  • 2. About me What I do: I studied electronics from JIIT and have been working at Baseapp Systems, in Delhi. I do software/system design for embedded systems.
  • 3. Hardware hacking? ● looking at how a consumer product does what it does ● making something from scratch ● making things do what they were not meant to do.
  • 4. Outline ● Introduction to some common protocols used in low level electronics (rs 232, spi, i2c) ● Sniffing/speaking these protocols ● USB protocol, Sniffing USB ● A few interesting hardware hacks ● Router hacking
  • 5. ● Chips follow standard protocols ● You can google most device datasheets ● exception is some chips with limited/restricted distribution There are a few common protocols you will see in a lot of places Things follow rules
  • 6. SPI Serial and SPI communication waveforms Rs 232 Often called just Serial, can be found in many places Often used as a debug output in systems, or even control terminal. Often used to just transfer readable text, so you can even read what transfers are going on. $GPRMC,081836,A,3751.65,S,14507.36,E, 000.0,360.0,130998,011.3,E*62
  • 7. I2C protocolMultiple I2C devices wired together A sample I2C transaction ● I2c comm. initiated by master, and there is only 1 master at a time ● All devices have a unique address, and they respond to only that ● All transfers require acknowledgement ● Start and stop condition to indicate start/stop of data A lot of things, memories, wireless chips, all kinds of sensors, batteries, ADCs, even some LEDs, speak I2C or SPI Also called SMBUS, on PCs
  • 8. Some places where I2c is used EEPROM Laptop batteries Various sensors
  • 9. Sniffing/Speaking A logic analyzer connected to a beaglebone Logic analyzer output on its software tool
  • 10. Speaking Arduino - really quick prototyping PIC32 Fubarino mini STM32F4 Discovery FTDI USB serial chips can also do many protocols. Can use C/python libraries
  • 11. FTDI chips (FT232h ^) FT232H (module is pic UM232h) ● Most often used as usb to serial ● Can also do SPI/I2C, GPIO/bitbang ● FTDI provides C libraries for using these ● Can do JTAG, openOCD or other debuggers ● code on right -> read 1MB SPI flash libmpsse, python wrapper over ftdi C libraries(libftdi) from mpsse import * MPSSE(SPI0, THIRTY_MHZ, MSB) Start() Write("x03x00x00x00") data = Read(0x100000) Stop() Close() open('flash.bin', 'wb').write(data)
  • 12. Some mcu suggestions Arduino 1. Has a serial bootloader, so dont need programmer 2. IDE comes with many ready to use libraries, not good 3. code written in C++, in IDE, which is not the best text editor 4. Don’t really need IDE 5. AVR-gcc and clib, avrdude etc. STM32 1. ARM cortex M0/1/3/4 2. GCC arm compilers are free and/or open source 3. Need programmer/debugger, but discovery kits come with one, can also use FTDI chip from last slide as JTAG with Openocd(olimex Tiny-usb jtag etc.) 4. no ide, free to setup anything Microchip PICs 1. Series of 8, 16, 32 bit microcontrollers 2. Also have an IDE, based on Netbeans 3. no completely free toolchain. Some code optimizations are paid features 4. Provide some libraries for USB stack and peripherals etc 5. Need a programmer, like ICD3, which is a bit expensive but can program/debug any microchip PIC
  • 13. Introduction ● USB cable has 4 wires, gnd, 5V, D+, D- ● When you connect a device to a host, host does ‘enumeration’ ● device describes itself to host during this ● You communicate with USB device on “Endpoints”, which are like port number on an IP in a network. Descriptors sent on endpoint 0, which is always present ● After enumeration, host OS may decide to load a driver for device, depending on device class, or if not class, then VID/PID USB Bus 002 Device 003: ID 0079:0006 DragonRise Inc. Generic USB Joystick Device Descriptor: idVendor 0x0079 DragonRise Inc. idProduct 0x0006 Generic USB Joystick bNumConfigurations 1 Configuration Descriptor: MaxPower 500mA bNumInterfaces 1 Interface Descriptor: bNumEndpoints 2 bInterfaceClass 3 Human Interface bInterfaceSubClass 0 No Subclass Endpoint Descriptor: bEndpointAddress 0x81 EP 1 IN Transfer Type Interrupt wMaxPacketSize 0x0008 1x 8 bytes Endpoint Descriptor: bEndpointAddress 0x01 EP 1 OUT Transfer Type Interrupt wMaxPacketSize 0x0008 1x 8 bytes
  • 14. Sniffing USB USB sniffing ● Linux kernel facility called ‘usbmon’ ● Sort of like tcpdump for USB ● wireshark, vusb analyser are both free/open source Wireshark VUSB analyser
  • 15. Talking USB Libusb http://libusb.info/ or http://libusb.org/ You can talk to a device with a class/subclass or vid/pid not associated with a driver using this library. C/C++, python Microcontrollers: most of STM32 series many pic18 and 32 atmega32u4 etc have USB device, some have host too Linux USB gadget API ● kernel modules to act as a USB slave(instead of host) ● hardware should support usb peripheral, so most desktops can’t, but many embedded ones can ● USB serial, ethernet ● USB HID, keyboard, mouse ● PTP (picture transfer protocol, like in camera, or android phones) ● sound devices, webcam ● File backed storage, mass storage devices
  • 16. USB mass storage device class as an example Flash USB controller Computer You plug in a USB pen drive ● Enumeration happens on Control endpoint(EP0) ● 2 Endpoints(1 IN, 1 OUT) are set up for exchanging data ● Data exchanges are wrapped in SCSI commands(read, write, disk size etc.) ● in linux, kernel loads USB mass storage driver, which provides a block device interface like /dev/sdb ● linux reads partition table to detect any partitions, if present, /dev/sdb1, /dev/sdb2 ● OS auto mounter may mount detected partitions Android mass storage, uses usb gadgetfs driver in linux. Unmounts microsd partition, makes it available to gadgetfs. Mp3 players and other devices do this. Is a means for firmware update in some devices.
  • 17. Block devices MBR - first sector 512 bytes Valid boot sector signature Partition table ● only 4 entries, hence 4 primary partitions ● first byte either 0x80 or 0x0, bootable flag ● used by ibm compatible and other computers during boot Some tools for seeing binary data: ● hd, hexdump ● od - read as int uint, chars etc ● strings - show printable characters in file ● xxd - hex dump to bin or reverse ● file - try to identify type of file ● dd - read parts of one file into another, everything is a file
  • 18. STM32 USBpendrive Layers of Host code ● USB host ● usb mass storage driver, bulk only transfer, SCSI ● fat32 layer SPI Oled display USBdevicetopc ● Do not know, nor needed to know all layers in detail ● Most of USB stack, and mass storage driver is from STmicro ● fat32 layer is Chan’s fatfs library ● SPI oled initialization sequence ● data write sequence ● Character fonts ● handling ‘frame buffer’ ● adafruit had released similar oled, used code from there USB device code ● Modify code for USB CDC(or USB serial) ● Bulk only transfer, and maximum packet size(64 bytes, full speed) ● Custom class/subclass(0xff) ● Desktop application uses libusb to communicate
  • 19. Samsung smart tv: ● ARM based, runs busybox based linux system ● has software packages like widgets/games and firmware updates ● updates installed via USB pen drive Some examples Implemented on Gumstix board ● Linux usb file storage gadget ● TV reads and checks files ● on reading second time, the filesystem is switched, copying own code onto tv, which it runs as root
  • 20. Some more examples, CHDK Canon Hack Development Kit ● (2006) Programmer studies disassembly of firmware upgrade for his IXUS camera ● Figures out a way to boot from SD card ● Dumps firmware of camera by blinking the LED on camera, and reading with a light dependant resistor, CHDK running on a point and shoot ● Enhancement to camera firmware, doesn’t void warranty, GPL ● Features, RAW images, settings overrides(shutter speed, exposure, ISO), exposure/focus bracketing, ● motion detection, HDR, time lapse ● User scripts in Lua, uBasic ● can make really cheap trigger using usb cable ● On screen displays, live histogram
  • 21. Unlimited DOF using focus bracketing
  • 22. HDR, by combining Exposure bracketing
  • 23. Some more examples Openkinect ● Microsoft was not willing to release open source/otherwise drivers for systems other than linux for kinect ● Adafruit(which is DIY/hobbyist electronics company) launched a bounty ● they put up dumps of USB traffic from kinect on windows ● protocol reverse engineered, libfreenect PS3 jailbreak ● Buffer overflow in PS3 USB stack ● if device reports smaller descriptor length than actual, PS3 copies the data into a small allocated memory, causing overflow ● This allowed the jailbreak creators to run arbitrary code on the ps3 somehow
  • 24. Router hacking Routers have always been closed source ● In 2003 linksys releases WRT54G ● turns out it runs linux ● community pressure on linksys to release source because of linux GPL license ● Many router firmware projects started after this linksys later moved to Vxworks, but people got linux working on new routers too. Openwrt Most active router firmware project Actually a linux distribution for very space constrained systems, and has router specific additions ● has a web interface, like in normal routers ● generates images as squashfs/jffs2 filesystem ● these are written on flash chips on routers ● Based on buildroot/uClibc build system
  • 25. TP-link WR841ND SPI flash chip Atheros ar9341 SoC RAM Serial port Inside a typical router OpenWrt buildroot menuconfig
  • 26. OpenWrt flash layout4MB SPI flash For just dumping flash contents, can desolder chip and read. (never have to) Some tools to analyse unknown flash contents: ● Binwalk ● Firmware mod kit - uses binwalk
  • 27. binwalk, firmware-mod-kit Binwalk scan results Firmware-mod-kit ● it tries to detect different portions in firmware dump ● extracts them ● you modify them if you want ● repacks them, recreating CRCs or signatures again if need be
  • 28. More examples Kindle 4 no touch Create empty file ‘ENABLE_DIAGS’, restart from menu ● Apart from just breaking consumer stuff, this info is useful for making hardware ● Many vendors are selling modules with router SoCs you can use in own projects. Ex. 8devices.com carambola Has wifi, runs linux easier to put in own projects than these BGA chips Arduino yun has same ar9331 chip(also has atmega32u4), runs openwrt. Fon Wireless Ltd., runs a paid wifi sharing network. Their own hardware runs a OpenWrt derivative
  • 29. A wireless audio receiver This is a small wifi audio receiver we made. Based on a router SoCs. ● Carambola2 SoM, wifi, 16MB flash, 64MB ram ● Custom openwrt ● each speaker is an alljoyn audio sink ● devices have master/slave modes, each mode has a config mode ● in config mode you can connect to device with phone using wifi AP ● network configuration, DHCP, wifi access point, switching modes, starting/monitoring services etc handled by custom scripts in Lua, since openwrt code was suitable only for a router. ● Modifications to board specific code for kernel, for LEDs, buttons, etc. hints taken from board specific code for other routers.
  • 30. Conclusion… ● Devices use standard protocols to communicate ● Logic analyzer is useful ● You can make routers run your own code