-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
49 lines (45 loc) · 1.3 KB
/
Copy pathadmin.html
File metadata and controls
49 lines (45 loc) · 1.3 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Admin Panel</title>
</head>
<body>
<h1>Admin Panel</h1>
<div id="message"></div>
<script>
// Helper: Base64 decode
function base64Decode(str) {
try {
return atob(str);
} catch {
return "";
}
}
// Get cookie value
function getCookie(name) {
const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
return match ? match[2] : null;
}
// Double decode the token
const tokenDouble = getCookie("token");
if (!tokenDouble) {
document.getElementById("message").innerText = "No token found.";
} else {
const onceDecoded = base64Decode(tokenDouble);
const twiceDecoded = base64Decode(onceDecoded);
// JWT format: header.payload.signature
const parts = twiceDecoded.split(".");
if (parts.length === 3) {
const payload = JSON.parse(base64Decode(parts[1]));
if (payload.role === "admin") {
document.getElementById("message").innerText = "Welcome Admin! Flag: HEYAAJWTMASTER";
} else {
document.getElementById("message").innerText = "Access Denied. You're not admin.";
}
} else {
document.getElementById("message").innerText = "Invalid token.";
}
}
</script>
</body>
</html>