Preorder drugiego tomu książki sekuraka: Wprowadzenie do bezpieczeństwa IT. -15% z kodem: sekurak-book
More information about TP-Link backdoor
During the analysis of this TP-Link backdoor, I found other issues, which can be handy when analyzing other devices. Finally the following path leads to remote root exec (useful for debugging purposes). Let’s see.
The router allows for ftp connections. But the ftp session is somehow chrooted (ie. one can access only ftp root and USB shared directories), standard router credentials used here:
Let’s try a little trick now. After plugging a USB flash drive into the router we can share a folder from the USB to be available on FTP:
By clicking 'Save’ I issue an HTTP request, which I can intercept in local http proxy, and modify it like this (ie. path traversal):
After this I can traverse all the filesystem – also in write mode:
But how can I have interactive root-shell? OK, after searching /tmp directory, there is /tmp/samba/smb.conf which can be overwritten. Brief analysis of samba documentation shows many ways of executing external binary. For example:
root preexec (S) This is the same as the preexec parameter except that the command is run as root. This is useful for mounting filesystems (such as CDROMs) when a connection is opened.
As you can see, this option (root preexec) apart from CDROM mounting can be used to debug routers ;-) After modification the config looks like this:
/tmp/szel is just a netcat binary (compiled for MIPS architecture) and uploaded by ftp (see the earlier path traversal trick). Now we can try out remote root shell:
Interactive root is nice, but how can it help with locating issues like this? OK, let’s search httpd binary for strings (httpd can be downloaded from the router – for example – using ftp):
Here we can see start_art.html string mentioned in the original disclosure. But how does it work? Let’s check what is going on on the router when start_art.html is launched:
Now it’s clear – 192.168.0.100 is my IP address and nart.out is 777 chmoded and then executed…
–Michał Sajdak (michal.sajdak<at>securitum.pl)
Great article. Pure hacking in action! Keep it up.
Good Job
Awesome work!
How did you manage to get the Samba server to re-read the smb.conf by the way?
@Security – samba rereads it automatically (I didn’t have time to check if it’s normal samba behaviour).
Other method would be to just restart print server.
–ms
If I understand correctly this is SW issue and not HW.
Easily correctable via alternative firmware (WRT based)
Or you can disable http admin that is opened to the WAN
– http admin to WAN is a bad practice anyway regardless of the router model by my opinion
– minimum is https if you must open admin to WAN
– better still is that there is nothing opend to WAN, or only SSH (secured by a digital certificate)
– you can allways get to http admina via VPN and then access it via LAN
Andrej, yes, it is SW issue and is correctable by alt firmwares.
Your recommendations are OK, but https wouldn’t be helpful here – the start_art.html request could be made by https (if a router supports https).
Burp – it was used on Securitum training, very useful tool :)
Such a geek! :)
Firmware Version: 3.13.6 Build 110923 Rel.53137n
Hardware Version: WR2543ND v1 00000000
Issuing the request sees tftp request for the below, haven’t checked any further though.
Filename: mdk_client.out
Thx. Check also comments in Polish version of the text:
http://sekurak.pl/nowy-backdoor-na-urzadzeniach-tp-link/
We don’t know if the reports are 100% valid, but they can be helpful.
Theory:
From messing with OpenWRT I learned a while ago that next to the uboot and firmware partitions, the SPI flash has also an „ART” partition.
ART = Atheros Radio Test = calibration data for the wireless chip, that won’t come up without them.
This „feature” might be used for in-factory loading the per-chip specific data into the flash, somehow.
In spanish blog unaaldia say this is an undocumented funcion of chips atheros: http://unaaldia.hispasec.com/2013/03/ejecucion-remota-de-codigo-en-diversos.html
Hi! thanks for share
As I tried before update to the lastests version of fw
(3.13.31 Build 130319 Rel.57876n) this „bug” was repaired.
As you can read on description on TPLink page:
„Fixed some vulnerabilities and improved security”
Great article and great work.
Almost nobody update firmware of the routers, so I guess this will be available for years.
Witam.
Leży mi router , którego za żadne skarby nie mogę wrócić do ustawień fabrycznych (uszkodzony przycisk reset).
Czy istnieje możliwość zmiany hasła do logowania na router mając go na biurku ?
Hello,
How can I test if my TP-Link Archer D7 is vulnerable?
Thank you
Yoy, nawet Fortinet zalinkował Sekurakowy artykuł o TP-Link’u w tabelce w tym artykule:
https://www.fortinet.com/blog/threat-research/hide–n-seek–from-home-routers-to-smart-home-insecurities.html