-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoch.js
66 lines (61 loc) · 2.48 KB
/
doch.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
const csv = require("csv-parser");
const fetch = require("node-fetch");
const fs = require("fs");
//creates the debug.log
var log_file = fs.createWriteStream(__dirname + "/debug.log", { flags: "w" });
//reads from the cookies csv;
fs.createReadStream("cookies.csv")
.pipe(csv(["cookie", "name"]))
//calls DochOne for each of the rows
.on("data", (data) => fetchDochOne(data));
// CREDITS to Ilay Segev https://github.com/ilai23/fuck-doch-1/pulls
async function fetchDochOne(data) {
//sets the cookie from the CSV
const cookie = data.cookie;
//gets the userName from the CSV
const uName = data.name;
const randomBoundary = generateBoundary();
const mainCode = "01";
const secondaryCode = "01";
const reportBody = `------WebKitFormBoundary${randomBoundary}\r\nContent-Disposition: form-data; name=\"MainCode\"\r\n\r\n${mainCode}\r\n------WebKitFormBoundary${randomBoundary}\r\nContent-Disposition: form-data; name=\"SecondaryCode\"\r\n\r\n${secondaryCode}\r\n------WebKitFormBoundary${randomBoundary}--\r\n`;
await fetch("https://one.prat.idf.il/api/Attendance/InsertPersonalReport", {
headers: {
accept: "application/json, text/plain, */*",
"accept-language": "he-IL,he;q=0.9,en-US;q=0.8,en;q=0.7",
"access-control-allow-origin": "*",
"content-type": `multipart/form-data; boundary=----WebKitFormBoundary${randomBoundary}`,
crossdomain: "true",
pragma: "no-cache",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
cookie: cookie,
"user-agent": "Mozilla/5.0",
},
referrer: "https://one.prat.idf.il/finish",
referrerPolicy: "no-referrer-when-downgrade",
body: reportBody,
method: "POST",
mode: "cors",
}).then((response) => {
//writes the status to the log
log_file.write(
"responseStatus: " + response.status + " for " + uName + "\n"
);
//writes the text to the log
log_file.write(
"responseText: " + response.statusText + " for " + uName + "\n"
);
});
}
function generateBoundary() {
const randomSize = 16;
let result = "";
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
for (let i = 0; i < randomSize; i++) {
result += characters.charAt(
Math.floor(Math.random() * characters.length)
);
}
return result;
}