forked from hugbed/ringzer0_scoreboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpwnable.js
42 lines (40 loc) · 1.07 KB
/
pwnable.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
"use strict"
const cheerio = require('cheerio');
const rp = require('request-promise');
const loginUri = "https://pwnable.tw/user/login";
module.exports = {
fetch: function({site_id, site_user_id, name}) {
const jar = rp.jar();
return rp({
uri: loginUri,
jar: jar,
transform: function(body) {
return cheerio.load(body);
}
}).then((body) => {
return body("input[name='csrfmiddlewaretoken']").first().val();
}).then((token) => {
return rp({
method: 'POST',
uri: loginUri,
jar: jar,
followAllRedirects: true,
form: {
csrfmiddlewaretoken: token,
username: "[email protected]",
password: "dkk9QxeY1QWfZ7me9wztGVaqfDcMIFc4",
next: `/user/${site_user_id}`
},
transform: function(body) {
return cheerio.load(body);
},
headers: { // complains if not explicit
Referer: loginUri
}
})
});
},
parse: function(body) {
return body("div:contains(Score)").eq(3).next().text();
}
}