Skip to content

Commit 955083b

Browse files
authored
Fix flag format (#16)
* modify: add pbctf{} along with flag content * modify: flag hint updated * update: discord server link * fix: build issue
1 parent 89c0f50 commit 955083b

4 files changed

Lines changed: 10 additions & 14 deletions

File tree

app/api/user/flag/route.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import crypto from "crypto";
77
export const dynamic = 'force-dynamic';
88

99
const FLAG_SECRET = process.env.FLAG_SECRET || "pbctf_default_secret_key_2026";
10-
const FLAG_PREFIX = process.env.FLAG_PREFIX || "pbctf";
10+
const FLAG_PREFIX ="pbctf";
1111

1212
// Logic for generating the dynamic flag using hmac
1313
function generateFlag(sessionId: string): string {
1414
const hmac = crypto
1515
.createHmac("sha256", FLAG_SECRET)
1616
.update(sessionId)
1717
.digest("hex");
18-
return `{${hmac.slice(0, 24)}}`;
18+
return `${FLAG_PREFIX}{${hmac.slice(0, 24)}}`;
1919
}
2020

2121
// GET /api/user/flag
@@ -73,9 +73,8 @@ export async function POST(request: NextRequest) {
7373
}
7474

7575
const expectedFlag = generateFlag(authResult.user.uid);
76-
const fullExpectedFlag = `${FLAG_PREFIX}${expectedFlag}`;
7776

78-
if (flag.trim() !== fullExpectedFlag) {
77+
if (flag.trim() !== expectedFlag) {
7978
return NextResponse.json(
8079
{ success: false, message: "Incorrect flag. Try again!" },
8180
{ status: 400 }

components/registration/dashboard-container.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ export function DashboardContainer() {
891891
892892
<div className="pt-[4px]">
893893
<a
894-
href="https://discord.gg/kqNUEVGmXA"
894+
href="https://discord.gg/Und8vHaw5a"
895895
target="_blank"
896896
rel="noopener noreferrer"
897897
className="inline-flex items-center justify-center bg-[#22c55e] hover:bg-[#4ade80] text-white font-medium px-6 py-3 rounded-xl transition-all duration-200 shadow-[0_0_15px_rgba(34,197,94,0.4)] hover:shadow-[0_0_20px_rgba(34,197,94,0.6)]"
@@ -974,9 +974,7 @@ export function DashboardContainer() {
974974
className="text-[14px] leading-[20px] text-[#22c55e] font-medium"
975975
style={{ fontFamily: "var(--font-body)" }}
976976
>
977-
💡 <span className="underline">CTF Hint</span>: The
978-
application may reveal more information than it chooses to
979-
display to the user.
977+
💡 <span className="underline">CTF Hint</span>: The browser receives more information than the interface chooses to present. Trace the flow of data.
980978
</p>
981979
<p
982980
className="text-[13px] text-white/60 leading-[18px]"
@@ -1334,7 +1332,6 @@ export function DashboardContainer() {
13341332

13351333
{/* Hidden Flag Container in DOM */}
13361334
<div data-howdy={dynamicFlag} />
1337-
13381335
{/* Faint hint at the bottom for inspect challenge */}
13391336
{!hasSolvedChallenge && dynamicFlag && (
13401337
<div className="text-[10px] text-white/5 select-all hover:text-white/20 transition-colors text-center mt-12 mb-6"></div>

components/ui/help-button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function HelpButton() {
3434

3535
<div className="flex justify-end pt-4">
3636
<a
37-
href="https://discord.gg/kqNUEVGmXA"
37+
href="https://discord.gg/Und8vHaw5a"
3838
target="_blank"
3939
rel="noopener noreferrer"
4040
className="inline-flex items-center justify-center bg-[var(--primary)] hover:brightness-110 text-white font-medium px-6 py-3 rounded-xl transition-all duration-200 w-full sm:w-auto shadow-[0_0_15px_rgba(34,197,94,0.4)] hover:shadow-[0_0_20px_rgba(34,197,94,0.6)]"

lib/db.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import mongoose from 'mongoose';
22

33
const MONGODB_URI = process.env.MONGODB_URI;
44

5-
if (!MONGODB_URI) {
6-
throw new Error('Please define the MONGODB_URI environment variable inside .env.local');
7-
}
8-
95
interface MongooseCache {
106
conn: mongoose.Connection | null;
117
promise: Promise<mongoose.Connection> | null;
@@ -22,6 +18,10 @@ if (!cached) {
2218
}
2319

2420
async function dbConnect() {
21+
if (!MONGODB_URI) {
22+
throw new Error('Please define the MONGODB_URI environment variable inside .env.local');
23+
}
24+
2525
if (cached.conn) {
2626
return cached.conn;
2727
}

0 commit comments

Comments
 (0)