50
0 DAY HUNTING A.K.A. THE STORY OF A PROPER CPE TEST Balazs Bucsay - Research Director @ MRG Effitas OSCE, OSCP, OSWP, GIAC GPEN @xoreipeip # http://rycon.hu

0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

Embed Size (px)

Citation preview

Page 1: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

0DAY HUNTING A.K.A.

THE STORY OF A PROPER CPE TESTBalazs Bucsay - Research Director @ MRG Effitas

OSCE, OSCP, OSWP, GIAC GPEN @xoreipeip # http://rycon.hu

Page 2: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

BIO / BALAZS BUCSAY

• Hungarian hacker

@xoreipeip

Page 3: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay
Page 4: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

BIO / BALAZS BUCSAY

• Hungarian hacker • Research Director @ MRG Effitas • Strictly technical certificates: OSCE, OSCP,

OSWP and GIAC GPEN • Previously worked as an ethical hacker • Started with ring0 debuggers and

disassemblers in 2000 (13 years old) • Major project in 2009: GI John

@xoreipeip

Page 5: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

• Webpage: http://rycon.hu • Twitter: @xoreipeip • Linkedin:

https://www.linkedin.com/in/bucsayb

BIO / BALAZS BUCSAY

@xoreipeip

Page 6: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

PRESENTATIONS• Talks around the world: • Atlanta (US)

• Moscow (RU) • London (UK) • Oslo (NO) • Vienna (AT) • Budapest (HU)

• Latest presentation: • Chw00t: Breaking unices’ chroot solutions • https://github.com/earthquake/chw00t • Slides: http://bit.ly/1T78dfM

@xoreipeip

Page 7: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

WORK VS PASSION

• This presentation and findings are not related to my daily work • Did all this research in my free time • Don’t like black boxes and closed source • Although if you are interested in testing your device contact us!

@xoreipeip

Page 8: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

• None of the vendors care about security • I was afraid of all the juicy RCE bugs are gone now • Truth is: nobody cares, old bugs are there and will be there • Most of the embedded devices are running on old 2.4 kernels • Worked for the second largest mobile operator doing CPE tests • Found several RCE, Auth bypasses, XSSs in different devices

CUSTOMER PREMISES EQUIPMENT - CPE

@xoreipeip

Page 9: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

• Not gonna mention the ISP’s name • Huge ISP in Europe, it has subsidiaries at least in 8 EU countries • Distributed to more than 6 million customers around Europe

(based on the ISP’s website) • Mostly covered by the following devices

TODAY’S DEVICE

@xoreipeip

Page 10: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

CISCO EPC3925@xoreipeip

Page 11: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

CISCO EPC3925 - PWNED@xoreipeip

Page 12: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

TECHNICOLOR TC7200@xoreipeip

Page 13: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

TECHNICOLOR TC7200 - PWNEDNice walk-through by Peter Geissler (@bl4sty) on Hack in The box Amsterdam: http://bit.ly/215GwaN @xoreipeip

Page 14: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

TECHNICOLOR TC7200 - PWNED

• Blasty dumped the memory • Reverse engineered the ESSID and WPA2-PSK generator • PSK generator based on ESSID: http://bit.ly/1UnMvTT

(TC7200 only)

Long story short:

@xoreipeip

Page 15: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

UBEE EVW3226 - PWNED??@xoreipeip

Page 16: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

UBEE EVW3226 - PWNED??

• People started to play seriously with the device around January of 2016

• 0day exploit released (physical access needed) - did not work for me

• Flash content was dumped and uploaded in the same month • SEC Consult identified overlapping vulns: http://bit.ly/25KdjFK • Yolosec released a tool as well: http://bit.ly/29isodH

@xoreipeip

Page 17: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

THE PLAN

• GOAL 0: get the dump of the filesystem • GOAL 1: get full access to the device • GOAL 2: get unauthenticated command/code execution • GOAL 3: get access to the network • … • Profit

@xoreipeip

Page 18: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

GOAL 1: GET FULL ACCESS TO THE DEVICE

• Blackbox approach did not succeed • Filesystem dump was released • Device is using lighttpd with a custom .cgi binary • Fired up IDA Pro to look for injection points

@xoreipeip

Page 19: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

JUST A FEW TO MENTION

@xoreipeip

Page 20: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

JUST A FEW TO MENTION

@xoreipeip

Page 21: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

JUST A FEW TO MENTION

@xoreipeip

Page 22: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

CAN YOU SPOT IT?

@xoreipeip

Page 23: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

RCE AS IT’S BEST

Page 24: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

EXPLOITATION

• The code can be invoked by starting a certain feature of the device • Two injection points • ESSID: max 32 ASCII character - although does not accept

everything • PSK: max 64 ASCII character - accepts all necessary characters • Admin must be authenticated and connected to the internal

network

@xoreipeip

Page 25: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

*BA DUM TSSS*

@xoreipeip

Page 26: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

GOAL 2: FIND UNAUTHENTICATED RCE/BOF

• Although we have full access to the device, we still need an admin user to exploit it

• Authentication bypass can be a solution • Unauthenticated RCE or BOF can help too

@xoreipeip

Page 27: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

CAN YOU SPOT IT?

@xoreipeip

Page 28: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

VANILLA STACK OVERFLOW

Pros: • Unauthenticated like I wished for • Trivial? vanilla stack overflow

Cons: • Big endian Linux on ARM - no public shell code • No experience with ARM • No qemu-system for big endian ARM, only qemu-user

@xoreipeip

Page 29: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

SHELLCODING

• Compiling big endian toolchain with Buildroot • Compiling static gdbserver for the device • Debugging the binary for exploitation • Writing shellcode based on tutorials and others • Linux ARM big endian bind shell code merged into Metasploit

https://github.com/rapid7/metasploit-framework/pull/6959

@xoreipeip

Page 30: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

IN THE GDBSERVER

• No next or nexti, must put breakpoints on every instruction • Most of the features are gone • stack is not executable - no features, did not check… • turns off stack randomisation (not vanilla anymore) - had to

write ROP • turns off ASLR (infoleak needed)

@xoreipeip

Page 31: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

EPIC FAIL

• Only 11bit is randomised, 1/2048 chance to hit the address • Webserver forked the process, new memory address every time • Watchdog restarts the web server • Then realised that lighttpd filters most of the characters ->

unexploitable

@xoreipeip

Page 32: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

AUTHENTICATION BYPASS

• Found by Search-lab • Makes authenticated RCE to unauthenticated • http://www.search-lab.hu/advisories/122-ubee-evw3226-

modem-router-multiple-vulnerabilities

@xoreipeip

Page 33: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

GOAL 3: GET ACCESS TO THE NETWORK

• Fallback options: • admin:admin account still could work in default cases • previously generated backup can be downloaded

• We only need access to the internal network to get full access • Let’s dig the binaries

@xoreipeip

Page 34: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

BACK OF THE BLACKBOX@xoreipeip

Page 35: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

FEW SYMBOLS FROM THE BINARIESSome of these could be interesting

@xoreipeip

Page 36: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

WPA2-PSK GENERATION ALGORITHM

@xoreipeip

Page 37: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

WPA2-PSK, SSID, WPS PIN GENERATION ALGORITHM

• Based only on MAC address, nothing else • Depends on whether it is 5G or 2.4G • MAC can be sniffed • WPS-PIN generation is based on the same idea • Algorithm released 3rd of July by Yolosec

@xoreipeip

Page 38: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

SURPRISE SURPRISE! WPS-PIN ENABLED BY DEFAULT

@xoreipeip

Page 39: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

GETTING INTO THE NETWORK

• What if the user changed the SSID?

@xoreipeip

Page 40: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

GETTING INTO THE NETWORK

• If the user changed the SSID: you can still get the passphrase

@xoreipeip

Page 41: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

GETTING INTO THE NETWORK

• If the user changed the SSID: you can still get the passphrase • What if the user changed the PSK?

@xoreipeip

Page 42: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

GETTING INTO THE NETWORK

• If the user changed the SSID: you can still get the passphrase • If the user changed the PSK: let’s generate the WPS-PIN • All of these can be generated from the MAC address • From nothing to root in 2 minutes (default credentials)

@xoreipeip

Page 43: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

DEMO

@xoreipeip

Page 44: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

THE VENDOR HELPS YOUit’s easier when you have a map - blue dots are the modems

@xoreipeip

Page 45: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

Authenticated firmware upgrade^W^W^W buffer overflow

WHO NEEDS MORE?

@xoreipeip

Page 46: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

and if you are too lazy to crack a password…

WHO NEEDS MORE?

@xoreipeip

Page 47: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

and if you are too lazy to crack a password…

WHO NEEDS MORE?

@xoreipeip

Page 48: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

FURTHER VULNERABILITIES

• Previously requested backup can be downloaded without authentication

• Plaintext passwords all over the device (nvram, heap, configs) • Backdoor users in passwd and shadow files • Command injections and buffer overflows

@xoreipeip

Page 49: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

IMPACT

• Few million customer is potentially vulnerable • Anybody can access their network, get root in a few minutes • Botnets, jump hosts, tor gateways, etc. • Newest Snowden leaks: secret services use MiTM on routers • You cannot be sure that you don’t have a device like this at home

!

!

@xoreipeip

Page 50: 0Day Hunting A.K.A. The Story of a Proper CPE Test by Balazs Bacsay

Balazs Bucsay - @xoreipeip

Thank you for your attention! !

Q&A