Repository navigation
Expand file tree
/
Copy pathserver.js
More file actions
212 lines (194 loc) ยท 6.98 KB
/
Copy pathserver.js
File metadata and controls
212 lines (194 loc) ยท 6.98 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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
require("dotenv").config();
const express = require("express"),
app = express(),
path = require("path"),
mongoose = require("mongoose"),
passport = require("passport"),
flash = require("express-flash"),
session = require("express-session"),
PORT = process.env.PORT || 5001,
loginRouter = require("./routers/loginRouter"),
browserRouter = require("./routers/browserRouter"),
proxyRouter = require("./routers/proxyRouter"),
regRouter = require("./routers/regRouter"),
adminRouter = require("./routers/adminRouter"),
checkRouter = require("./routers/checkRouter"),
{ checkCmd } = require("./utils/bash"),
{
ensureAuthenticated,
forwardAuthenticated,
ensureAdmin,
forwardBanned,
} = require("./utils/authenticate"),
User = require("./schemas/userSchema"),
Challenge = require("./schemas/challengeSchema"),
passportInit = require("./utils/passport-config"),
bcrypt = require("bcrypt"),
MongooseSessionStore = require("./utils/mongoose-store");
mongoose.connect(process.env.MONGO_URI, console.log("MONGODB CONNECTED"));
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
app.set("view engine", "ejs");
app.use(express.static("public"));
passportInit(passport);
app.use(flash());
app.use(
session({
secret: process.env.SESSION_SECRET,
resave: true,
saveUninitialized: true,
store: new MongooseSessionStore(),
cookie: {
secure: "auto",
maxAge: 30 * 24 * 60 * 60 * 1000,
},
}),
);
app.use(passport.initialize());
app.use(passport.session());
app.get("/", async (req, res) => {
try {
const myUser = req.user;
if (!myUser) return res.redirect("/login");
if (myUser.banned) return res.redirect("/banned");
if (!myUser.admin) {
const currentDate = Date.now();
if (currentDate < 1786734000000) return res.redirect("/countdown");
}
const allUsers = await User.find().select("-logs").sort({
points: "desc",
lastAnswered: "asc",
});
const foundChallenges = await Challenge.find().sort({ challengeId: 1 });
const cryptChallenges = await Challenge.find({ type: "cryptic" }).sort({
title: 1,
});
res.render("index", {
challenges: foundChallenges,
user: myUser,
allUsers,
});
} catch (error) {
console.log(error);
res.end("something went wrong. please try again.");
}
});
app.get("/leaderboard", async (req, res) => {
const allUsers = await User.find().select("-logs").sort({
points: "desc",
lastAnswered: "asc",
});
res.render("leaderboard", { allUsers: allUsers });
});
app.get("/countdown", ensureAuthenticated, (req, res) => {
res.render("countdown");
});
app.post("/check/cmd", async (req, res) => {
if (!req.user) return res.end("no user found");
const { cmd } = req.body;
const cmdResult = await checkCmd(cmd, req.user);
return res.end(cmdResult);
});
app.post("/getuser", async (req, res) => {
if (!req.user) return res.end("guest");
return res.end(req.user.name);
});
app.get("/banned", (req, res) => {
res.render("banned");
});
app.get("/logout", (req, res) => {
req.logout((err) => {
if (err) console.log(err);
return res.redirect("/login");
});
});
app.post("/changeProfile", async (req, res) => {
try {
const user = req.user,
{ displayName } = req.body;
if (displayName == user.name) return res.json({ success: true });
if (!displayName || displayName == "")
return res.json({ success: false, message: "Display name is empty!" });
const foundUser = await User.findOne({ name: displayName });
if (foundUser)
return res.json({
success: false,
message: "Display name already exists!",
});
await User.findByIdAndUpdate(user.id, {
name: displayName,
});
res.json({ success: true });
} catch (error) {
console.log(error);
res.json({ success: false, message: "Something went wrong." });
}
});
app.use("/login", forwardAuthenticated, loginRouter);
app.use("/register", forwardAuthenticated, regRouter);
app.use("/browser", ensureAuthenticated, forwardBanned, browserRouter);
app.use(
"/enableAndConfigureProxy",
ensureAuthenticated,
forwardBanned,
proxyRouter,
);
app.use("/admin", ensureAuthenticated, ensureAdmin, forwardBanned, adminRouter);
app.use("/check", ensureAuthenticated, forwardBanned, checkRouter);
// app.get("/christopherjudge", (req, res) => {
// res.redirect("https://docs.google.com/document/d/1My90xlY84EarocIPKw02JpBQCXczTr0Lze0lRRh5DJo/edit?tab=t.0")
// })
app.get("/timessquare", (req, res) => {
return res.end(`1) By day I am non-existent, but by night I hold full sway,
I weave vivid worlds from shadows when the light has faded away.
I can craft you soaring castles or lead you down dark halls,
Painting landscapes in your mind before the morning calls.
I am the architect of your sleeping mind - Who Am I?
2) (64,2,1) (193,8,10) (209, 8, 20) ( 269,6,1) (141,4,13)
(56, 5, 19) (56, 7, 4) (205, 3, 1) (237, 5 ,28) (138, 6, 14)`);
});
app.get("/apollo11", (req, res) => {
return res.end(`๐ฉ๐ค๐ฌ๐๐ค๐๐ก๐๐ฅ๐ฉ๐๐๐๐๐ฑ๐ฌ๐ง๐ฉ๐๐น๐ฎ๐๐๐ฑ๐ฌ๐ง๐ช`);
});
app.get("/nooneelse", (req, res) => {
return res.end(`3VH9dtxW`);
});
app.get("/mclaren", (req, res) => {
return res.end(`https://www.dropbox.com/scl/fi/bxh39g9uiv7mq60785nmg/spectrotraceaudio.wav?rlkey=ol4a05nn3t4wymg1oqowp8oed&st=373m61t9&dl=0
แแขแ แแแแก แแแกแแแแแแแ, แแแ แแแ แ แแแจแ, แกแแแฃแแแ แ แแแแ แฃแแแ แแแแแแแ.`);
});
app.get("/christopherjudge", (req, res) => {
return res.redirect(
"https://drive.google.com/file/d/1IgpRCk8jqJYtNxNwQHq21SzqxwOyZZdR/view?usp=sharing",
);
});
app.get("/godlike", (req, res) => {
// return res.redirect("https://www.dropbox.com/scl/fi/ziuiekgb1b0l6lua868jc/whats-this.png?rlkey=53xicvrstdk8hncfhbwv9o28m&st=grvb7x6o&dl=0")
res.render("godlike");
});
app.get("/025114592", (req, res) => {
// return res.redirect("https://www.dropbox.com/scl/fi/ziuiekgb1b0l6lua868jc/whats-this.png?rlkey=53xicvrstdk8hncfhbwv9o28m&st=grvb7x6o&dl=0")
res.render(
"https://www.dropbox.com/scl/fi/ffmfqvm38e88wsigequ3z/puzzlepiece4.png?rlkey=u0s53r1l0l23fqhfwrwm4pzcm&st=geusjrey&dl=0",
);
});
app.get("/michaeladamthwaite", (req, res) => {
// return res.redirect("https://www.dropbox.com/scl/fi/ziuiekgb1b0l6lua868jc/whats-this.png?rlkey=53xicvrstdk8hncfhbwv9o28m&st=grvb7x6o&dl=0")
res.render("michaeladamthwaite");
});
app.get("/charliekirk", (req, res) => {
return res.redirect("https://drive.google.com/file/d/1lGzYFbPhyOHDb67U04Da_6CsXNwYUoU3/view?usp=sharing");
})
app.listen(PORT, console.log(`RoboVM listening on port ${PORT}`));
// const User = require('./schemas/userSchema')
// async function testDo() {
// const hashedPassword = await bcrypt.hash('test', 10)
// const newUser = new User({
// fname: 'Test',
// lname: 'Test',
// username: 'ctfuser',
// password: hashedPassword
// })
// await newUser.save()
// }
// testDo()