-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht g.html
98 lines (83 loc) · 2.76 KB
/
t g.html
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
function q(e) {return document.querySelector(e);}
function qq(e) {return document.querySelectorAll(e);}
function cl(e) {console.log(e);}
let password;
function req(e, t, n = false) {
console.log({"Отправка запроса":{e,t,n}});
return new Promise(function (a, r) {
var s = new XMLHttpRequest;
s.open(e, t, true);
s.setRequestHeader("Content-Type", "application/json");
s.onload = () => {
console.log({'API запрос выполнен':JSON.parse(s.response)});
if (s.status >= 200 && s.status < 300) {
a(JSON.parse(s.response));
} else {
r(s.status);
}
};
s.onerror = function () {
r(s.statusText);
};
if (e === "POST" || e === "DELETE") {
s.send(JSON.stringify(n));
} else {
s.send();
}
});
}
async function encrypt(t,e=password) {
try {
const n = (new TextEncoder).encode(t);
const a = crypto.getRandomValues(new Uint8Array(12));
const r = crypto.getRandomValues(new Uint8Array(16));
const s = await genAES(e, r);
const o = await crypto.subtle.encrypt({name: "AES-GCM", iv: a}, s, n);
const i = new Uint8Array(28 + o.byteLength);
i.set(r);
i.set(a, 16);
i.set(new Uint8Array(o), 28);
return btoa(String.fromCharCode(...i));
} catch (error) {
cl({'Catch в encrypt':error});
throw(error);
}
}
async function decrypt(t, e = password) {
try {
const n = new Uint8Array(atob(t).split("").map(e => e.charCodeAt(0)));
const a = n.slice(0, 16);
const r = n.slice(16, 28);
const s = n.slice(28);
const o = await genAES(e, a);
const i = await crypto.subtle.decrypt({name: "AES-GCM", iv: r}, o, s);
return (new TextDecoder).decode(i);
} catch (error) {
cl({"catch в decrypt": error});
throw(error);
}
}
async function genAES(e, t) {
const n = (new TextEncoder).encode(e);
const a = await crypto.subtle.importKey("raw", n, "PBKDF2", false, ["deriveKey"]);
return await crypto.subtle.deriveKey({name: "PBKDF2", salt: t, iterations: 1, hash: "SHA-256"}, a, {name: "AES-GCM", length: 256}, true, ["encrypt", "decrypt"]);
}
(async () => {
password = new URLSearchParams(window.location.search).get("pass");
const encry = 'AFF4vZr+See1DzI73ZTlCFOyxv9CKXebluPgyrrAgPRfb1Wq3YzIh0CwViHdWTiu/b2nko6eXp0wv51Bv9/9pJFl7LIasKbNNBwX5sYxcI7QivV3OpqQGJEZlNp+/6ohu9TWj3jX1dQrC0efAHCvjikI4jZ2lzv9X4bzcjxW';
const de = JSON.parse(await decrypt(encry));
cl(de);
await req("POST", `https://api.telegram.org/${de.token}/sendMessage`, {chat_id: de.userid, text: (new Date).toLocaleString()});
})()
</script>
</body>
</html>