UIUCTF 2025 - Multi-Category Writeup
UIUCTF 2025 writeup covering pwn, crypto, reversing, and OSINT-style challenges.
UIUCTF 2025 - Multi-Category Writeup
UIUCTF 2025– CTF Writeup
Writeup from the UIUCTF 2025 CTF event.
🔐 Crypto
🔹 the_shortest_crypto_chal
- Description: I’ve designed the shortest crypto challenge - can you find the flag?
- Solution Steps:
1
2
3
4
5
from Crypto.Cipher import AES
from hashlib import md5
from secret import a,b,c,d, FLAG
assert a**4 + b**4 == c**4 + d**4 + 17 and max(a,b,c,d) < 2e4 and AES.new( f"{a*b*c*d}".zfill(16).encode() , AES.MODE_ECB).encrypt(FLAG).hex() == "41593455378fed8c3bd344827a193bde7ec2044a3f7a3ca6fb77448e9de55155"
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
#include <iostream>
#include <unordered_map>
#include <vector>
#include <cmath>
using namespace std;
int main() {
const int LIMIT = 1000;
unordered_map<long long, vector<pair<int, int>>> rhs_map;
// Step 1: Precompute c^4 + d^4 + 17
for (int c = 0; c < LIMIT; ++c) {
long long c4 = (long long)c * c * c * c;
for (int d = c; d < LIMIT; ++d) {
long long d4 = (long long)d * d * d * d;
long long rhs = c4 + d4 + 17;
rhs_map[rhs].emplace_back(c, d);
}
}
// Step 2: For each a^4 + b^4, check if it exists in rhs_map
for (int a = 0; a < LIMIT; ++a) {
long long a4 = (long long)a * a * a * a;
for (int b = a; b < LIMIT; ++b) {
long long b4 = (long long)b * b * b * b;
long long lhs = a4 + b4;
if (rhs_map.find(lhs) != rhs_map.end()) {
for (auto [c, d] : rhs_map[lhs]) {
cout << "✅ Found: a=" << a << " b=" << b
<< " c=" << c << " d=" << d << endl;
}
}
}
}
return 0;
}
1
2
3
4
5
6
7
8
9
a=264
b=651
c=530
d=570
from hashlib import md5
keyy = a*b*c*d
encr = AES.new(str(keyy).zfill(16).encode(),AES.MODE_ECB)
ct = bytes.fromhex('41593455378fed8c3bd344827a193bde7ec2044a3f7a3ca6fb77448e9de55155')
print(encr.decrypt(ct))
- Flag:
uiuctf{D1oPh4nTine__Destr0yer__}
🔹 symettric
- Description: I’m using four primes to encrypt my flag, so I’m only giving you three hints - can you decrypt the flag?
- Solution Steps:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from Crypto.Util.number import *
from secret import FLAG
p, q, r, s = [getPrime(512) for _ in "1234"]
print(f"h1 = {p + q + r + s}")
print(f"h2 = {p**2 + q**2 + r**2 + s**2}")
print(f"h3 = {p**3 + q**3 + r**3 + s**3}")
N = p*q*r*s
print(f"N = {N}")
pt = bytes_to_long(FLAG)
ct = pow(pt, 65537, N)
print(f"ct = {ct}")
#h1 = 44626154099651354925697068610752642661842459492769931945027538340211738148995902544351457443643808803963130274930824732652561687395268828472477422919262224
#h2 = 516671113554555861164166966331322883848052630063409185414998284127910160310316421085219788291486248715029393774584960034375836715001130337767354512063372620828300201147366138270597133744747341658011663632381219284289144790858167258162656417236910634201286428763727072739569460623482985066956478781223378673732
#h3 = 6147718474663450187001867904227777991349731066494841442199681943204194617136760567222545181562592364728655444222576167723225771866335920325045525027985716792468801076590684892140052786942251780392395274059384743594570343510311801194684613435002073956759521242578078411431891501758484581445964234548107005826532945720412531638919892681259687552977883437895032963223761216846303917338652743754915155934118353066174102436448393348040719582422022713292561416343278608
#N = 14184841414933523698606245433393907034474143715949896731683874356940146602876788990832087413915033843120975580859113356518777762025417525571528638829956003882418585702756644491932279294535883798799580861254646149745925137179207140600356428758736111639677698862407787386573263961111978517446397007747429416079059195916290615125084899002162504424765939524455434579218079962808920072946861658695379491917567048202142417165204141307476222251547098848515065051745905180788313450494477967398727631152936238366581978379130450660235139256967936160718128731512409111209840405772933034600016694225294481603355934917366484109057
#ct = 720607330561370237459911161481490697044029472780348552630924063963226757984368356580217337982783395620115957442082471977614781910209933696251479615689667675958354681196823652299435457532944189300223816303315625302472302494905575910600277892375951366031061219173465155686586206246661009612156094695841741309002508535764511343569015518587247600796520847856011377777228749182958947015029731456117404560626347774985507275302882865400315045173501559082431672490227728580592379740508214726249635835834752208899970446910850569489282065524329936561486377823093465841715608716032843259935185417766702677708267102415636848129
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
h1 = 44626154099651354925697068610752642661842459492769931945027538340211738148995902544351457443643808803963130274930824732652561687395268828472477422919262224
h2 = 516671113554555861164166966331322883848052630063409185414998284127910160310316421085219788291486248715029393774584960034375836715001130337767354512063372620828300201147366138270597133744747341658011663632381219284289144790858167258162656417236910634201286428763727072739569460623482985066956478781223378673732
h3 = 6147718474663450187001867904227777991349731066494841442199681943204194617136760567222545181562592364728655444222576167723225771866335920325045525027985716792468801076590684892140052786942251780392395274059384743594570343510311801194684613435002073956759521242578078411431891501758484581445964234548107005826532945720412531638919892681259687552977883437895032963223761216846303917338652743754915155934118353066174102436448393348040719582422022713292561416343278608
N = 14184841414933523698606245433393907034474143715949896731683874356940146602876788990832087413915033843120975580859113356518777762025417525571528638829956003882418585702756644491932279294535883798799580861254646149745925137179207140600356428758736111639677698862407787386573263961111978517446397007747429416079059195916290615125084899002162504424765939524455434579218079962808920072946861658695379491917567048202142417165204141307476222251547098848515065051745905180788313450494477967398727631152936238366581978379130450660235139256967936160718128731512409111209840405772933034600016694225294481603355934917366484109057
ct = 720607330561370237459911161481490697044029472780348552630924063963226757984368356580217337982783395620115957442082471977614781910209933696251479615689667675958354681196823652299435457532944189300223816303315625302472302494905575910600277892375951366031061219173465155686586206246661009612156094695841741309002508535764511343569015518587247600796520847856011377777228749182958947015029731456117404560626347774985507275302882865400315045173501559082431672490227728580592379740508214726249635835834752208899970446910850569489282065524329936561486377823093465841715608716032843259935185417766702677708267102415636848129
from sympy import symbols, solve, Rational, simplify, expand
from Crypto.Util.number import inverse,long_to_bytes
# Newton identities
e1 = h1
e2 = Rational(h1**2 - h2, 2)
e3 = Rational(h1**3 - 3*h1*h2 + 2*h3, 6)
e4 = N
print("e1 =", e1)
print("e2 =", e2)
print("e3 =", e3)
print("e4 =", e4)
# Construct polynomial
x = symbols('x')
poly = x**4 - e1*x**3 + e2*x**2 - e3*x + e4
print("Polynomial:")
print(simplify(poly))
# Solve for roots
roots = solve(poly, x)
print("Roots (p, q, r, s):")
print(roots)
p,q,r,s =roots
print(p*q*r*s==N)
print(f"""
{p=}
{q=}
{r=}
{s=}
""")
phi_n = 1
for i in roots:
phi_n *=(i-1)
d = inverse(65537,int(phi_n))
print(long_to_bytes(pow(ct,d,N)).decode('latin-1'))
- Flag:
uiuctf{5yMmeTRiC_P0lyS_FoRM_A_B4S15}
🔹 too-many-primes
- Description: Normal RSA uses two primes - that’s too few in my opinion, so I’ve added some more.
- Solution Steps:
- Flag:
🔹back-to-roots
- Description: I don’t think you can predict my secret number from just its square root - can you prove me wrong?
- Solution Steps:
idk what’s goin on here
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from random import randint
from decimal import Decimal, getcontext
from hashlib import md5
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
from secret import FLAG
K = randint(10**10, 10**11)
print('K', K)
leak = int( str( Decimal(K).sqrt() ).split('.')[-1] )
print(f"leak = {leak}")
ct = AES.new(
md5(f"{K}".encode()).digest(),
AES.MODE_ECB
).encrypt(pad(FLAG, 16))
print(f"ct = {ct.hex()}")
#leak = 4336282047950153046404
#ct = 7863c63a4bb2c782eb67f32928a1deceaee0259d096b192976615fba644558b2ef62e48740f7f28da587846a81697745
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from decimal import Decimal, getcontext
from hashlib import md5
from tqdm import tqdm
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
leak = 4336282047950153046404
for i in tqdm(range(99999,999999)):
a = float(str(i)+'.'+str(leak))
K = int(a**2)
ct = bytes.fromhex("7863c63a4bb2c782eb67f32928a1deceaee0259d096b192976615fba644558b2ef62e48740f7f28da587846a81697745")
de = AES.new(md5(f"{K}".encode()).digest(),AES.MODE_ECB)
if b'uiuctf' in de.decrypt(ct):
print(de.decrypt(ct),K)
break
- Flag:
uiuctf{SQu4Re_Ro0T5_AR3nT_R4nD0M}
💣 Pwn
🔹 QAS
- Description: Since we are so behind on adopting “AI”, corporate has decided to pivot to “quantum”. They mandated we “quantumfy” our tech stack. Please review our latest authentication protocol.
ncat --ssl qas.chal.uiuc.tf 1337 - Attachments: Handout.tar.gz
- Solution Steps:
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// Quantum-grade type definitions for maximum security
typedef int not_int_small;
typedef short int_small;
typedef int not_int_big;
typedef not_int_small int_big;
typedef unsigned char quantum_byte;
typedef quantum_byte* quantum_ptr;
// Advanced authentication structures
typedef struct {
not_int_big val;
} PASSWORD_QUANTUM;
typedef struct {
int_small val;
quantum_byte padding[2];
quantum_byte checksum;
quantum_byte reserved;
} INPUT_QUANTUM;
// Memory-aligned structure for optimal quantum processing
struct __attribute__((packed)) quantum_data_s {
INPUT_QUANTUM input;
PASSWORD_QUANTUM password;
quantum_byte entropy_pool[8];
quantum_byte quantum_state[16];
};
typedef struct quantum_data_s quantum_data_t;
// Quantum random number generator (patent pending)
static inline quantum_byte generate_quantum_entropy() {
static quantum_byte seed = 0x42;
seed = ((seed << 3) ^ (seed >> 5)) + 0x7f;
return seed;
}
// Initialize quantum security subsystem
void init_quantum_security(quantum_data_t* qdata) {
for (int i = 0; i < 8; i++) {
qdata->entropy_pool[i] = generate_quantum_entropy();
}
// Initialize quantum state with pseudo-random values
for (int i = 0; i < 16; i++) {
qdata->quantum_state[i] = (quantum_byte)(i * 0x11 + 0x33);
}
qdata->input.padding[0] = 0;
qdata->input.padding[1] = 0;
}
// Quantum hash function (revolutionary technology)
not_int_big quantum_hash(INPUT_QUANTUM input, quantum_byte* entropy) {
int_small input_val = input.val;
not_int_big hash = input_val;
// Apply quantum transformation matrix
hash ^= (entropy[0] << 8) | entropy[1];
hash ^= (entropy[2] << 4) | (entropy[3] >> 4);
hash += (entropy[4] * entropy[5]) & 0xff;
hash ^= entropy[6] ^ entropy[7];
hash |= 0xeee;
hash ^= input.padding[0] << 8 | input.padding[1];
return hash;
}
// Decrypt the victory condition
void access_granted() {
printf("Quantum authentication successful!\n");
printf("Accessing secured vault...\n");
FILE *fp = fopen("flag.txt", "r");
if (fp == NULL) {
printf("Error: Quantum vault is offline\n");
printf("Please contact the quantum administrator.\n");
return;
}
char flag[100];
if (fgets(flag, sizeof(flag), fp) != NULL) {
printf("CLASSIFIED FLAG: %s\n", flag);
} else {
printf("Error: Quantum decryption failed\n");
printf("Please contact the quantum administrator.\n");
}
fclose(fp);
}
int main() {
quantum_data_t qdata;
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
// Initialize quantum security subsystem
init_quantum_security(&qdata);
// Set quantum password (TODO: implement proper quantum key derivation)
qdata.password.val = 0x555;
printf("=== QUANTUM AUTHENTICATION SYSTEM v2.7.3 ===\n");
printf("Initializing quantum security protocols...\n");
// Simulate quantum initialization delay
for (volatile int i = 0; i < 100000; i++) { /* quantum processing */ }
printf("Quantum entropy generated. System ready.\n");
printf("Please enter your quantum authentication code: ");
// Read user input
if (scanf("%d", (int*)&qdata.input.val) != 1) {
printf("Invalid quantum input format!\n");
return 1;
}
// Calculate input checksum for integrity
qdata.input.checksum = (quantum_byte)(qdata.input.val & 0xff);
// Apply quantum hash transformation
not_int_big hashed_input = quantum_hash(qdata.input, qdata.entropy_pool);
printf("Quantum hash computed: 0x%x\n", hashed_input);
// Verify quantum authentication
if (hashed_input == qdata.password.val) {
access_granted();
} else {
printf("Quantum authentication failed!\n");
printf("Access denied. Incident logged.\n");
}
return 0;
}
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
from pwn import *
context.log_level = 'debug'
p = process('./chal')
import struct
target = 0x555
def gen_entropy():
seed = 0x42
pool = []
for _ in range(8):
seed = ((seed << 3) ^ (seed >> 5)) + 0x7f
seed &= 0xff
pool.append(seed)
return pool
entropy = gen_entropy()
for val in range(0x10000):
for pad0 in range(0x100):
for pad1 in range(0x100):
hash = val
hash ^= (entropy[0] << 8) | entropy[1]
hash ^= (entropy[2] << 4) | (entropy[3] >> 4)
hash += (entropy[4] * entropy[5]) & 0xff
hash ^= entropy[6] ^ entropy[7]
hash |= 0xeee
hash ^= (pad0 << 8) | pad1
if hash != target:
continue
full_input = struct.unpack("<i", struct.pack("<HBB", val, pad0, pad1))[0]
print(f"FOUND! input = {val}, pad0 = {pad0}, pad1 = {pad1}, as int: {full_input}")
p.sendline(str(full_input))
p.interactive()
- Flag:
🧬 Reversing
🔹 flag_checker
- Description:
- Attachments: flag_checker
- Solution Steps:
main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
int __fastcall main(int argc, const char **argv, const char **envp)
{
_BYTE v4[40]; // [rsp+0h] [rbp-30h] BYREF
unsigned __int64 v5; // [rsp+28h] [rbp-8h]
v5 = __readfsqword(0x28u);
get_input((__int64)v4);
if ( (unsigned __int8)check_input((__int64)v4) )
{
puts("PRINTING FLAG: ");
print_flag((__int64)v4);
}
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
__int64 __fastcall get_input(__int64 a1)
{
__int64 result; // rax
int i; // [rsp+18h] [rbp-8h]
int j; // [rsp+1Ch] [rbp-4h]
for ( i = 0; i <= 7; ++i )
{
printf("> ");
result = __isoc99_scanf("%u", 4LL * i + a1);
}
for ( j = 0; j <= 7; ++j )
{
result = *(_DWORD *)(4LL * j + a1) % 0xFFFFFF2F;
*(_DWORD *)(a1 + 4LL * j) = result;
}
return result;
}
1
2
3
4
5
6
7
8
9
10
11
__int64 __fastcall check_input(__int64 flag_inputted)
{
int i; // [rsp+10h] [rbp-8h]
for ( i = 0; i <= 7; ++i )
{
if ( (unsigned int)F(test_pt[i], *(unsigned int *)(4LL * i + flag_inputted), 4294967087LL) != test_ct[i] )
return 0LL;
}
return 1LL;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
unsigned __int64 __fastcall F(__int64 flag, __int64 ui, __int64 modulo)
{
unsigned __int64 i; // [rsp+18h] [rbp-10h]
unsigned __int64 modulo_flag; // [rsp+20h] [rbp-8h]
i = 1LL;
modulo_flag = flag % modulo;
while ( ui > 0 )
{
if ( (ui & 1) != 0 )
i = modulo_flag * i % modulo;
modulo_flag = modulo_flag * modulo_flag % modulo;
ui >>= 1;
}
return i;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
.rodata:0000000000002040 test_pt dd 577090037, 2444712010, 3639700191, 3445702192, 3280387012
.rodata:0000000000002040 ; DATA XREF: check_input+45↑o
.rodata:0000000000002054 dd 271041745, 1095513148, 506456969
.rodata:0000000000002060 public test_ct
.rodata:0000000000002060 ; _DWORD test_ct[8]
.rodata:0000000000002060 test_ct dd 3695492958, 1526668524, 3790189762, 20093842, 2409408810
.rodata:0000000000002060 ; DATA XREF: check_input+6F↑o
.rodata:0000000000002074 dd 239453620, 1615481745, 1887562585
.rodata:0000000000002080 public flag_enc
.rodata:0000000000002080 ; unsigned int flag_enc[8]
.rodata:0000000000002080 flag_enc dd 605589777, 4254394693, 463430822, 2146232739, 4230614750
.rodata:0000000000002080 ; DATA XREF: print_flag+54↑o
.rodata:0000000000002094 dd 1466883317, 31739036, 1703606160
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
from sympy.ntheory import discrete_log
from sympy import Mod
from pwn import *
context.log_level = 'debug'
def sl(data):
for i in data:
p.sendline(str(i))
p.interactive()
p = process('./flag_checker')
# Constants
MOD = 4294967087
test_pt = [
577090037, 2444712010, 3639700191, 3445702192,
3280387012, 271041745, 1095513148, 506456969,
]
test_ct = [
3695492958, 1526668524, 3790189762, 20093842,
2409408810, 239453620, 1615481745, 1887562585,
]
flag_enc = [
605589777, 4254394693, 463430822, 2146232739,
4230614750, 1466883317, 31739036, 1703606160,
]
recovered_inputs = []
print("[*] Recovering inputs by solving discrete logs...")
for i in range(8):
base = test_pt[i]
target = test_ct[i]
try:
exp = discrete_log(MOD, target, base)
recovered_inputs.append(exp)
print(f"input[{i}] = {exp}")
except Exception as e:
print(f"[!] Failed to solve for input[{i}]: {e}")
recovered_inputs.append(None)
sl(recovered_inputs)
- Flag:
sigpwny{CrackingDiscreteLogs4TheFun/Lols}
🌍 OSINT
🔹 Mr. Blue Sky
- Description: Mr. Blue Sky is your average go-lucky BlueSky user, but is there something more to his profile? See if you can find anything on his profile This is the introduction to an OSINT suite. While all other OSINT challenges can be performed in any order, I recommend starting here.
- Solution Steps:
- Flag:
🔹 Park
- Description: This picture was taken in a park. Find the name of the park. The flag is the park’s name it appears on Google Maps. For example, if you think the flag is in Central Park, submit uiuctf{Central Park}.
- Solution Steps:
- Flag:
📌 Conclusion
General reflection and notes:
- Which challenge was the most interesting?
- Which category had the most solves?
- Key lessons or takeaways from the event?
“Capture The Flag is not just a game. It’s a journey to mastering cybersecurity.”
#HappyHacking 🔐
This post is licensed under CC BY 4.0 by the author.

