Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/ctf/miniapi/packet1/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { NextResponse } from "next/server";

export async function GET() {
return NextResponse.json({
fragment: "8720414d7ad2bdb65cd9",
param: "signal",
meta: {
processedAt: 1700000300,
serverId: "node-7f3a",
region: "us-east-2",
latency: 42
}
});
}
14 changes: 14 additions & 0 deletions app/ctf/miniapi/packet2/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { NextResponse } from "next/server";

export async function GET() {
return NextResponse.json({
fragment: "5b0125706439da",
param: "signal",
meta: {
processedAt: 1700000100,
serverId: "node-2b9c",
region: "us-west-1",
latency: 38
}
});
}
14 changes: 14 additions & 0 deletions app/ctf/miniapi/packet3/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { NextResponse } from "next/server";

export async function GET() {
return NextResponse.json({
fragment: "ee3111b1dd03a7",
param: "signal",
meta: {
processedAt: 1700000400,
serverId: "node-1a4d",
region: "eu-central-1",
latency: 91
}
});
}
14 changes: 14 additions & 0 deletions app/ctf/miniapi/packet4/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { NextResponse } from "next/server";

export async function GET() {
return NextResponse.json({
fragment: "1420c4108b01de39",
param: "signal",
meta: {
processedAt: 1700000200,
serverId: "node-9e1f",
region: "ap-southeast-1",
latency: 67
}
});
}
39 changes: 39 additions & 0 deletions app/ctf/miniapi/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { NextResponse } from "next/server";
import { derive } from "../utils";

async function sha256(text: string) {
const encoder = new TextEncoder();
const data = encoder.encode(text);

const hashBuffer = await crypto.subtle.digest("SHA-256", data);

return Array.from(new Uint8Array(hashBuffer))
.map(b => b.toString(16).padStart(2, "0"))
.join("");
}

const SERVER_SECRET = derive(["LWtleQ==", "ZWNyZXQ=", "dG9wLXM="]);

export async function GET() {
const flag = derive([
"MX0=",
"MW4xNHA=",
"YWc3LW0=",
"dGZ7Zmw=",
"aGFja2M="
]);
const hiddenFlag = derive([
"NzNyfQ==",
"cDFtNDU=",
"YWc4LTQ=",
"dGZ7Zmw=",
"aGFja2M="
]);

const secret = await sha256(hiddenFlag + SERVER_SECRET);

return NextResponse.json({
flag,
secret
});
}
63 changes: 63 additions & 0 deletions app/ctf/miniapi/unlock/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { NextResponse } from "next/server";
import { derive } from "../../utils";

async function sha256(text: string) {
const encoder = new TextEncoder();
const data = encoder.encode(text);

const hashBuffer = await crypto.subtle.digest("SHA-256", data);

return Array.from(new Uint8Array(hashBuffer))
.map(b => b.toString(16).padStart(2, "0"))
.join("");
}

const SERVER_SECRET = derive(["LWtleQ==", "ZWNyZXQ=", "dG9wLXM="]);

export async function GET(req: Request) {
const url = new URL(req.url);
const secret = url.searchParams.get("secret");
const signal = url.searchParams.get("signal");

if (!secret && !signal) {
return NextResponse.json(
{ error: "Missing query parameter" },
{ status: 400 }
);
}

if (secret && signal) {
return NextResponse.json(
{ error: "Only one query parameter allowed" },
{ status: 400 }
);
}

let param = secret ? secret : signal;
let hiddenFlag = secret
? derive(["NzNyfQ==", "cDFtNDU=", "YWc4LTQ=", "dGZ7Zmw=", "aGFja2M="])
: derive([
"fQ==",
"aDNjN2Y=",
"YjM0Nzc=",
"NzV5MHU=",
"MG5ncjQ=",
"YWc5LWM=",
"dGZ7Zmw=",
"aGFja2M="
]);

const expected = await sha256(hiddenFlag + SERVER_SECRET);
console.log(expected);

if (param !== expected) {
return NextResponse.json(
{ error: "Parameter value is incorrect" },
{ status: 400 }
);
}

return NextResponse.json({
decoded: hiddenFlag
});
}
140 changes: 140 additions & 0 deletions app/ctf/page.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
.ctfSection {
position: relative;
width: 100%;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
background: linear-gradient(to bottom, #020316, #16133e);
z-index: 1;
}

.ctfBackgrounds {
position: absolute;
inset: 0;
pointer-events: none;
z-index: 0;

-webkit-mask-image: linear-gradient(
to bottom,
rgba(0, 0, 0, 1) 90%,
rgba(0, 0, 0, 0) 100%
);
mask-image: linear-gradient(
to bottom,
rgba(0, 0, 0, 1) 90%,
rgba(0, 0, 0, 0) 100%
);
}

@keyframes tinyStarsGlow {
0% {
opacity: 0.2;
filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.2));
}
50% {
opacity: 0.4;
filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.8));
}
100% {
opacity: 0.2;
filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.2));
}
}

@media (max-width: 768px) {
.ctfSection {
min-height: 100vh;
}
}

.flagInput {
transition: all 0.3s ease;

&:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(163, 21, 214, 0.3);
}

&:focus {
transform: translateY(-2px);
box-shadow: 0 8px 30px rgba(253, 171, 96, 0.4);
}

&.correct {
border-color: #4caf50 !important;
background: rgba(76, 175, 80, 0.1) !important;
}

&.incorrect {
border-color: #f44336 !important;
background: rgba(244, 67, 54, 0.1) !important;
}
}

.progressBar {
background: rgba(255, 255, 255, 0.1);
border-radius: 10px;
overflow: hidden;
height: 12px;

.progressFill {
height: 100%;
background: linear-gradient(90deg, #a315d6, #fdab60, #a315d6);
background-size: 200% 100%;
animation: shimmer 2s linear infinite;
transition: width 0.5s ease;
}
}

@keyframes shimmer {
0% {
background-position: 200% 0;
}
100% {
background-position: -200% 0;
}
}

.flagCard {
background: rgba(255, 255, 255, 0.08);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 16px;
padding: 20px;
transition: all 0.3s ease;

&:hover {
transform: translateY(-4px);
box-shadow: 0 12px 35px rgba(163, 21, 214, 0.25);
border-color: rgba(163, 21, 214, 0.4);
}
}

.celebration {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
pointer-events: none;
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;

& svg {
animation: confetti 3s ease-out forwards;
}
}

@keyframes confetti {
0% {
transform: scale(0) rotate(0deg);
opacity: 1;
}
100% {
transform: scale(2) rotate(720deg);
opacity: 0;
}
}
Loading