Skip to content

Commit 22f754c

Browse files
dimasma030553buahapeladzkyyyaimardcrhanasuru
committed
initial
Co-authored-by: 53buahapel <[email protected]> Co-authored-by: adzkyyy <[email protected]> Co-authored-by: aimardcr <[email protected]> Co-authored-by: Dimas Maulana <[email protected]> Co-authored-by: hanasuru <[email protected]> Co-authored-by: Merricx <[email protected]> Co-authored-by: zakigeyan <[email protected]>
1 parent aee3272 commit 22f754c

File tree

1,179 files changed

+232527
-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.

1,179 files changed

+232527
-0
lines changed

Crypto/.gitkeep

Whitespace-only changes.

Crypto/Alin/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Alin
2+
3+
rui
4+
5+
---
6+
7+
## Flag
8+
9+
```
10+
INTECHFEST{y3t_4n0th3r_m4tr1x_ch4ll_bu7_wr1tt3n_1n_j4v4}
11+
```
12+
13+
## Description
14+
> Just implement one of my class subject
15+
16+
## Difficulty
17+
easy
18+
19+
## Tags
20+
Java
21+
22+
## Notes
23+
intentionally left empty

Crypto/Alin/chall/Matrix.java

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import java.util.Scanner;
2+
3+
public class Matrix {
4+
static Scanner input = new Scanner(System.in);
5+
6+
public static int[][] multiply(int[][] a, int[][] b){
7+
int x = a.length;
8+
int y = b[0].length;
9+
int z = y;
10+
int[][] result = new int[x][y];
11+
for (int i = 0; i < x; i++) {
12+
for (int j = 0; j < y; j++) {
13+
for (int k = 0; k < z; k++) {
14+
result[i][j] += a[i][k] * b[k][j];
15+
}
16+
}
17+
}
18+
return result;
19+
}
20+
21+
public static int[][][] string_to_matrix(String text){
22+
23+
int[][][] matrix = new int[text.length() / 9][3][3];
24+
for (int i = 0; i < text.length(); i += 9){
25+
int[][] matrices = new int[3][3];
26+
for (int j = 0; j < 9; j++) matrices[j / 3][j % 3] = (int)text.charAt(i + j);
27+
matrix[i / 9] = matrices;
28+
}
29+
return matrix;
30+
}
31+
32+
public static void main(String[] args) {
33+
System.out.print("plaintext: ");
34+
String plaintext = input.nextLine();
35+
36+
if (plaintext.length() % 9 != 0)
37+
plaintext += "?".repeat(9 - (plaintext.length() % 9));
38+
39+
int[] cipher = new int[plaintext.length()];
40+
41+
int[][][] mat = string_to_matrix(plaintext);
42+
43+
for (int i = 0; i < mat.length; i++){
44+
int[][] A = mat[i];
45+
int[][] B = mat[0];
46+
int[][] C = multiply(A, B);
47+
for (int j = 0; j < 3; j++){
48+
for (int k = 0; k < 3; k++){
49+
cipher[i * 9 + j * 3 + k] = C[j][k];
50+
}
51+
}
52+
}
53+
54+
System.out.print("ciphertext: ");
55+
for (int i = 0; i < cipher.length; i++){
56+
System.out.print(cipher[i] + " ");
57+
}
58+
}
59+
}

Crypto/Alin/chall/flag.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INTECHFEST{y3t_4n0th3r_m4tr1x_ch4ll_bu7_wr1tt3n_1n_j4v4}

Crypto/Alin/challenge.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# yaml-language-server: $schema=../../challenge.schema.yaml
2+
name: "Alin"
3+
author: "rui"
4+
category: Crypto
5+
description: |
6+
Just implement one of my class subject.
7+
8+
value: 1000
9+
type: StaticAttachment
10+
11+
flags:
12+
- INTECHFEST{y3t_4n0th3r_m4tr1x_ch4ll_bu7_wr1tt3n_1n_j4v4}
13+
14+
provide: ./dist

Crypto/Alin/dist/Matrix.class

2.15 KB
Binary file not shown.

Crypto/Alin/dist/flag.enc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16591 16716 18720 14700 14839 16596 15681 15810 17737 23089 23142 25955 18377 18305 20521 14746 14738 16272 19214 19535 21465 22507 22778 25463 19780 19694 22182 18507 18417 20641 18043 18278 20120 21986 22215 24733 19077 19278 21221 23126 23249 26010 19701 19598 22096 17963 17903 20089 17817 17747 19921 19586 19894 22442 16831 16778 18597 13356 13482 15057 13356 13482 15057

Crypto/CRC32plus/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# crc32plus
2+
3+
deomkicer
4+
5+
## Flag
6+
7+
```
8+
INTECHFEST{m33t_in_the_m1ddle_is_b0ring__lets_meet_in_the_two_thirds}
9+
```
10+
11+
## Description
12+
13+
Pure crc32 is weak, that's why I tweaked it a little bit to make it more secure and then called it crc32plus.
14+
15+
## Difficuly
16+
17+
Hard
18+
19+
## Tags
20+
21+
crc32, meet-in-the-middle
22+
23+
## Notes
24+
25+
...

Crypto/CRC32plus/chall/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:3.11-slim
2+
3+
RUN apt-get update
4+
RUN apt-get install -y nano socat
5+
RUN pip install pycryptodome
6+
7+
WORKDIR /opt
8+
9+
COPY server.py .
10+
11+
CMD echo $GZCTF_FLAG > flag.txt && socat TCP-LISTEN:5000,fork,reuseaddr EXEC:'python3 server.py'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
crc32plus:
3+
build: .
4+
container_name: crc32plus
5+
ports:
6+
- 5301:5000
7+
restart: always
8+
environment:
9+
- GZCTF_FLAG=INTECHFEST{m33t_in_the_m1ddle_is_b0ring__lets_meet_in_the_two_thirds}

Crypto/CRC32plus/chall/flag.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INTECHFEST{m33t_in_the_m1ddle_is_b0ring__lets_meet_in_the_two_thirds}

Crypto/CRC32plus/chall/init.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
FLAG="$GZCTF_FLAG" python3 server.py

Crypto/CRC32plus/chall/server.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env python3
2+
from Crypto.Cipher import Salsa20
3+
from Crypto.Util.number import long_to_bytes
4+
import random
5+
import signal
6+
import string
7+
import os
8+
9+
CHARSET = string.digits + string.ascii_lowercase + "_"
10+
FLAG = os.getenv("GZCTF_FLAG", "INTECHFEST{redacted}")
11+
12+
13+
class crc32plus:
14+
def __init__(self, p):
15+
self.m = 0xFFFFFFFF
16+
self.p = p & self.m
17+
self.t = []
18+
for i in range(256):
19+
v = i
20+
for _ in range(8):
21+
v = (self.p ^ (v >> 1)) if (v & 1) == 1 else (v >> 1)
22+
self.t.append(v)
23+
24+
def _update(self, buf):
25+
v = self.m
26+
for c in buf:
27+
v = self.t[(v ^ c) & 0xFF] ^ (v >> 8)
28+
return v ^ self.m
29+
30+
def calc(self, buf):
31+
v = self.m
32+
buf = b"\x88" + buf + b"\x88"
33+
for i in range(len(buf) - 1):
34+
v = self._update(long_to_bytes(v, 4) + buf[i : i + 2])
35+
return long_to_bytes(v ^ self.m, 4)
36+
37+
def __repr__(self):
38+
return f"crc32plus(poly={hex(self.p)})"
39+
40+
41+
def gen_rand_str():
42+
return "crc32plus_" + "".join(random.choices(CHARSET[:-1], k=6))
43+
44+
45+
def user_input(s):
46+
try:
47+
inp = input(s).strip()
48+
assert len(inp) < 256 and all(c in CHARSET for c in inp)
49+
return inp.encode()
50+
except:
51+
exit()
52+
53+
54+
def main():
55+
poly = random.getrandbits(32)
56+
c32p = crc32plus(poly)
57+
58+
print(f"Prove that you can find collision on {c32p}")
59+
m1 = user_input("Message #1: ")
60+
m2 = user_input("Message #2: ")
61+
if m1 == m2 or c32p.calc(m1) != c32p.calc(m2):
62+
print("Nope")
63+
return
64+
65+
key = gen_rand_str().encode()
66+
ptx = gen_rand_str().encode()
67+
cipher = Salsa20.new(key)
68+
ctx = cipher.nonce + cipher.encrypt(ptx)
69+
hsh = c32p.calc(key)
70+
71+
print(f"Prove that you can reverse this crc32plus: {hsh.hex() + ctx.hex()}")
72+
m3 = user_input("Plaintext: ")
73+
if m3 != ptx:
74+
print("Nope")
75+
return
76+
77+
print(FLAG)
78+
79+
80+
if __name__ == "__main__":
81+
signal.alarm(90)
82+
main()

Crypto/CRC32plus/challenge.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# yaml-language-server: $schema=../../challenge.schema.yaml
2+
name: "CRC32plus"
3+
author: "deomkicer"
4+
category: Crypto
5+
description: |
6+
Pure crc32 is weak, that's why I tweaked it a little bit to make it more secure and then called it crc32plus.
7+
8+
Note: The timeout is changed to 90s
9+
10+
value: 1000
11+
type: DynamicContainer
12+
13+
scripts:
14+
start: cd chall && docker build -t crc32plus .
15+
16+
container:
17+
flagTemplate: INTECHFEST{m33t_in_the_m1ddle_is_b0ring__lets_meet_in_the_two_thirds_[TEAM_HASH]}
18+
containerImage: "crc32plus:latest"
19+
memoryLimit: 512
20+
cpuCount: 2
21+
storageLimit: 512
22+
containerExposePort: 5000
23+
enableTrafficCapture: false
24+
25+
provide: ./dist
26+
27+
hints:
28+
- This implementation (https://github.com/theonlypwner/crc32) might help, but you still need to tweak it for this challenge
29+
- You need some luck to get the "good" poly. Once you get the "good" poly, you also need another luck and optimization for solving the collision and reversing the crc32plus in a very short time. On average, author's solution takes ~5 mins to bruteforce and finally be able to get the flag.

Crypto/CRC32plus/dist/server.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env python3
2+
from Crypto.Cipher import Salsa20
3+
from Crypto.Util.number import long_to_bytes
4+
import random
5+
import signal
6+
import string
7+
8+
CHARSET = string.digits + string.ascii_lowercase + "_"
9+
FLAG = open("flag.txt").read()
10+
11+
12+
class crc32plus:
13+
def __init__(self, p):
14+
self.m = 0xFFFFFFFF
15+
self.p = p & self.m
16+
self.t = []
17+
for i in range(256):
18+
v = i
19+
for _ in range(8):
20+
v = (self.p ^ (v >> 1)) if (v & 1) == 1 else (v >> 1)
21+
self.t.append(v)
22+
23+
def _update(self, buf):
24+
v = self.m
25+
for c in buf:
26+
v = self.t[(v ^ c) & 0xFF] ^ (v >> 8)
27+
return v ^ self.m
28+
29+
def calc(self, buf):
30+
v = self.m
31+
buf = b"\x88" + buf + b"\x88"
32+
for i in range(len(buf) - 1):
33+
v = self._update(long_to_bytes(v, 4) + buf[i : i + 2])
34+
return long_to_bytes(v ^ self.m, 4)
35+
36+
def __repr__(self):
37+
return f"crc32plus(poly={hex(self.p)})"
38+
39+
40+
def gen_rand_str():
41+
return "crc32plus_" + "".join(random.choices(CHARSET[:-1], k=6))
42+
43+
44+
def user_input(s):
45+
try:
46+
inp = input(s).strip()
47+
assert len(inp) < 256 and all(c in CHARSET for c in inp)
48+
return inp.encode()
49+
except:
50+
exit()
51+
52+
53+
def main():
54+
poly = random.getrandbits(32)
55+
c32p = crc32plus(poly)
56+
57+
print(f"Prove that you can find collision on {c32p}")
58+
m1 = user_input("Message #1: ")
59+
m2 = user_input("Message #2: ")
60+
if m1 == m2 or c32p.calc(m1) != c32p.calc(m2):
61+
print("Nope")
62+
return
63+
64+
key = gen_rand_str().encode()
65+
ptx = gen_rand_str().encode()
66+
cipher = Salsa20.new(key)
67+
ctx = cipher.nonce + cipher.encrypt(ptx)
68+
hsh = c32p.calc(key)
69+
70+
print(f"Prove that you can reverse this crc32plus: {hsh.hex() + ctx.hex()}")
71+
m3 = user_input("Plaintext: ")
72+
if m3 != ptx:
73+
print("Nope")
74+
return
75+
76+
print(FLAG)
77+
78+
79+
if __name__ == "__main__":
80+
signal.alarm(60)
81+
main()

Crypto/Edward/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# edward
2+
3+
merricx
4+
5+
## Flag
6+
7+
```
8+
INTECHFEST{https://imgur.com/a/HsPr3EU}
9+
```
10+
11+
## Description
12+
13+
You've seen PoW with a hash function, but have you seen PoW with a digital signature?
14+
15+
## Difficulty
16+
17+
medium
18+
19+
## Tags
20+
21+
ecc, ed25519
22+
23+
## Notes
24+
25+
Somewhat 0day-ish since not all libraries are affected, but most of the time it's not considered security vulnerability

Crypto/Edward/chall/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM python:3.11-slim
2+
3+
RUN apt-get update
4+
RUN apt-get install -y nano socat gcc
5+
RUN pip install ed25519
6+
7+
WORKDIR /opt
8+
9+
COPY challenge.py .
10+
11+
12+
CMD echo $GZCTF_FLAG > flag.txt && socat TCP-LISTEN:5000,fork,reuseaddr EXEC:'python3 challenge.py'

0 commit comments

Comments
 (0)