+ All Categories
Home > Software > The internet of $h1t

The internet of $h1t

Date post: 19-Feb-2017
Category:
Upload: amit-serper
View: 1,158 times
Download: 2 times
Share this document with a friend
78
The internet of $h1T Or: Root all things (of the internet of things) By: Amit Serper, ADhD
Transcript
Page 1: The internet of $h1t

The internet of $h1TOr: Root all things (of the internet of things)

By: Amit Serper, ADhD

Page 2: The internet of $h1t

/bin/whoami●Now: Lead Mac OSX security researcher @ Cybereason (we’re

hiring!)

●Before: ~9 years @ PMO, Lead security researcher, doing mostly embedded security research in the last 3 years.

●Terrible coder

●Reverse Engineer

●Hardcore Linux guy, Now I use Mac :( and Windows :((

●I like to make stuff that break stuff

●I tweet: @0xAmit

●Public speaker, publisher (Wired, SC mag, DigitalWhisper, etc…):○ HackngTeam research: http://ht.amit.wtf

Page 3: The internet of $h1t

cat /home/amit/agenda.txt●Our subject: Command execution injection via WebServer

●IoT? - Examples

●Embedded Linux - quick overview

●Firmware - Quick overview

●Embedded webserver command injection - Quick overview

●Case study - Bezeq router

●Exploitation demo

Page 4: The internet of $h1t

The internet of (shitty) things

Page 5: The internet of $h1t

A chain of revolutions...

Page 6: The internet of $h1t

~10-15 years ago

Page 7: The internet of $h1t
Page 8: The internet of $h1t

Now

Page 9: The internet of $h1t
Page 10: The internet of $h1t
Page 11: The internet of $h1t
Page 12: The internet of $h1t
Page 13: The internet of $h1t
Page 14: The internet of $h1t
Page 15: The internet of $h1t
Page 16: The internet of $h1t

A router!

Page 17: The internet of $h1t

~10-15 years ago, a router looked like this

Page 18: The internet of $h1t
Page 19: The internet of $h1t

A router!

Page 20: The internet of $h1t

AKA that box with lights that makes the internet work

Page 21: The internet of $h1t

Why do we care so much about routers?

Page 22: The internet of $h1t

They’re routing our traffic == they see EVERYTHING

Page 23: The internet of $h1t

Nobody cares == they’re not monitored

Page 24: The internet of $h1t

They’re always on!

Page 25: The internet of $h1t
Page 26: The internet of $h1t
Page 27: The internet of $h1t

Specs as you see them

Page 28: The internet of $h1t

Specs as I see them

Page 29: The internet of $h1t

Every one of those little bastards is a computer!

(that handles all of your traffic!)

Page 30: The internet of $h1t

Ok… So it’s a “computer” - woo-friggin’-hoo

A calculator is also a computer

Page 31: The internet of $h1t

You’re right. Routers used to have custom RTOS O/S’s that worked on custom architectures and instruction sets

Page 32: The internet of $h1t

But all of a sudden, it wasn’t the standard anymore, care to guess why?

Page 33: The internet of $h1t
Page 34: The internet of $h1t

Linux is built around networking, it’s easy to develop for and deploy, it’s totally cross

platform and ITS FREE!

Page 35: The internet of $h1t

Plus, it has tons of ALREADY written code that vendors can use!

Page 36: The internet of $h1t

Used in Xbox, Cable/SAT STB’s, PS4, roku, etc...

libdlna:Used in smartTVs, routers, streamers, Cable/SAT STB’s, etc...

A small webserver, used in almost EVERY router in some variation.

Page 37: The internet of $h1t

ALL OF THE PREVIOUSLY MENTIONED SOFTWARE HAVE BEEN AND IS EXPLOITED

ALL THE TIME!

Page 38: The internet of $h1t

The transition to Linux started a whole wave of vendors using Linux, some even

took pride in it

Linksys WRT54GL

Page 39: The internet of $h1t

It had a Linux based (HyperWRT) firmware and most of its code was open sourced

Page 40: The internet of $h1t

Entire communities of firmware spin-offs were founded to enhance and add extra

features to products

Page 41: The internet of $h1t

Firmware●permanent software programmed into a read-only memory.

(wikipedia)

●One file which includes a Linux distro consisting of:○ Bootloader

○ Kernel

○ Root filesystem (userland)

○ Swap (product dependent)

Page 42: The internet of $h1t

DD-WRT firmware (as illustrated by binwalk)

Page 43: The internet of $h1t

Firmware (continued)● Drivers/modules (kernel mode)

● Software and Daemons/Services (User mode) :○ Busybox

○ DHCP server

○ NTP (server/client)

○ FTP server

○ Telnet/ssh server

○ UPnP server

○ Webserver

Page 44: The internet of $h1t

Limitations when developing a firmware●Very little memory - Code has to be really efficient, even on the cost

of security

●Very little disk space - No bells and whistles - Just the barebones!

●Very weak cpu

●You think you’re invincible - if it compiles its fine! ← PROBLEM

Page 45: The internet of $h1t

Let’s talk about security research

Page 46: The internet of $h1t

We’ve established that those devices have poor security measures

Page 47: The internet of $h1t

So let’s map the attack vectors

Page 48: The internet of $h1t

Attack vectors:●Backdoors in firmware (a very specific url or service that’s running

on a specific port)

●Physical/Local access - uploading a patched firmware

●Attack from afar - own the webserver!

Page 49: The internet of $h1t

Enter the webserver:●It is our common configuration interface with the device

●Everything is controlled through there

●Gives us a direct interface with User-controlled data

●Often listens for connections form the0.0.0.0 (everywhere!)

●Often badly configured by the vendor/user

●Runs as root!!!!1!!!!!1!

Page 50: The internet of $h1t

We want to run code/pop a shell on the router

Page 51: The internet of $h1t

Wait, user controlled data?

Page 52: The internet of $h1t

Hooray! Let’s smash the stack!

Page 53: The internet of $h1t

There’s not necessarily a need to do that...

Page 54: The internet of $h1t

Emulating this environment is hard

Page 55: The internet of $h1t

We don’t want to debug stuff

Page 56: The internet of $h1t

Making gdb run on those thing is not easy...

Page 57: The internet of $h1t

But what if we can hijack the “instruction pointer” on a higher level?

Page 58: The internet of $h1t
Page 59: The internet of $h1t

What is injection?

Page 60: The internet of $h1t

http://example.com/viewfile.php?file=bill.txt

Page 61: The internet of $h1t

;&&`

Page 62: The internet of $h1t

; - run this after you’re done&& - run this if first command exited with

status 0`statement` - run the command between

the backticks and use it as a value

Page 63: The internet of $h1t

http://example.com/redirect.php?r=info.php;cat /etc/passwd

Page 64: The internet of $h1t
Page 65: The internet of $h1t

Another example

Page 66: The internet of $h1t
Page 67: The internet of $h1t

system(‘/usr/bin/mailer --user %s --password %s --dest %s’)

Page 68: The internet of $h1t

How can we avoid that?

Page 69: The internet of $h1t

Sanitation and verification of user input.Especially special characters such as &, ; and `

(and their http encoded form)

Page 70: The internet of $h1t

DEMO

Page 71: The internet of $h1t

Netgear VEGN2610AKA Bezeq n600

ADSL2+ Modem/router

Page 72: The internet of $h1t

Runs custom compiled Linux kernel version 2.6.30

(Released in June 2009)

Page 73: The internet of $h1t

Uses a custom version of GoAhead WEBS as its webserver

Page 74: The internet of $h1t

Has multiple Command Injection Vulnerabilities and even has an anti CSRF protection with a

vulnerability… Amazing.

Page 75: The internet of $h1t

What we are going to see is how we can execute commands as root on the router using

command injection and turn on it’s telnetd server.

Page 76: The internet of $h1t

Oh, the root user on the router has a password (which I don’t know, but it’s ok)

telnetd -p 2323 -l /bin/sh

Page 77: The internet of $h1t

Ok ok, demo! :)

Page 78: The internet of $h1t

Thank you!(Questions?)


Recommended