Skip to content

Commit 2ebed09

Browse files
author
Joshua Liu
committed
Initial Commit
0 parents  commit 2ebed09

File tree

559 files changed

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

559 files changed

+35186
-0
lines changed

.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
rev/nlibs/attachments/nlibs.tar.gz filter=lfs diff=lfs merge=lfs -text
2+
rev/nlibs-baby/attachments/baby.tar.gz filter=lfs diff=lfs merge=lfs -text
3+
misc/nmpz1/challenge/public/img.tar.gz filter=lfs diff=lfs merge=lfs -text
4+
misc/minecraft-hacked/challenge/idek.tar.gz filter=lfs diff=lfs merge=lfs -text

.gitignore

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+
.grunt
31+
32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
35+
# node-waf configuration
36+
.lock-wscript
37+
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
39+
build/Release
40+
41+
# Dependency directories
42+
node_modules/
43+
jspm_packages/
44+
45+
# Snowpack dependency directory (https://snowpack.dev/)
46+
web_modules/
47+
48+
# TypeScript cache
49+
*.tsbuildinfo
50+
51+
# Optional npm cache directory
52+
.npm
53+
54+
# Optional eslint cache
55+
.eslintcache
56+
57+
# Optional stylelint cache
58+
.stylelintcache
59+
60+
# Microbundle cache
61+
.rpt2_cache/
62+
.rts2_cache_cjs/
63+
.rts2_cache_es/
64+
.rts2_cache_umd/
65+
66+
# Optional REPL history
67+
.node_repl_history
68+
69+
# Output of 'npm pack'
70+
*.tgz
71+
72+
# Yarn Integrity file
73+
.yarn-integrity
74+
75+
# dotenv environment variable files
76+
.env
77+
.env.development.local
78+
.env.test.local
79+
.env.production.local
80+
.env.local
81+
82+
# parcel-bundler cache (https://parceljs.org/)
83+
.cache
84+
.parcel-cache
85+
86+
# Next.js build output
87+
.next
88+
out
89+
90+
# Nuxt.js build / generate output
91+
.nuxt
92+
dist
93+
94+
# Gatsby files
95+
.cache/
96+
# Comment in the public line in if your project uses Gatsby and not Next.js
97+
# https://nextjs.org/blog/next-9-1#public-directory-support
98+
# public
99+
100+
# vuepress build output
101+
.vuepress/dist
102+
103+
# vuepress v2.x temp and cache directory
104+
.temp
105+
.cache
106+
107+
# Docusaurus cache and generated files
108+
.docusaurus
109+
110+
# Serverless directories
111+
.serverless/
112+
113+
# FuseBox cache
114+
.fusebox/
115+
116+
# DynamoDB Local files
117+
.dynamodb/
118+
119+
# TernJS port file
120+
.tern-port
121+
122+
# Stores VSCode versions used for testing VSCode extensions
123+
.vscode-test
124+
125+
# yarn v2
126+
.yarn/cache
127+
.yarn/unplugged
128+
.yarn/build-state.yml
129+
.yarn/install-state.gz
130+
.pnp.*
131+
132+
# Python
133+
__pycache__/
134+
135+
*.pyc
136+
137+
# kctf
138+
kctf/

.gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "crypto/tensor-galore/challenge/vector-bundles-sagemath"]
2+
path = crypto/tensor-galore/challenge/vector-bundles-sagemath
3+
url = https://git.disroot.org/montessiel/vector-bundles-sagemath.git
4+
[submodule "crypto/tensor-galore/healthcheck/vector-bundles-sagemath"]
5+
path = crypto/tensor-galore/healthcheck/vector-bundles-sagemath
6+
url = https://git.disroot.org/montessiel/vector-bundles-sagemath.git

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# idekCTF 2024
2+
idekCTF 2024 public challenge repository
3+
4+
Notes:
5+
- All challenges which require a remote service is deployable using [kctf](https://google.github.io/kctf/google-cloud.html)
6+
- Any writeups from authors or competitors will be in the challenge's `README.md`
7+
- A majority of challenge contain a full solve script in `healthcheck/healthcheck.py`
8+
- Our instancer is in `klodd`
9+
- Our admin bot (which is outdated by 2 years) is in `terraform`

crypto/Heaven-or-Hell/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Heaven or Hell
2+
**Category:** Crypto
3+
**Difficulty:** Medium
4+
**Author:** EggRoll
5+
6+
## Description
7+
Do you believe in fate?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
primes = list(prime_range(3,117))
2+
p = 4 * prod(primes) - 1
3+
base = bytes((int(p).bit_length() + 7) // 8)
4+
Fp = GF(p)
5+
6+
def from_weierstrass(EC):
7+
a, b = EC.a4(), EC.a6()
8+
F = EC.base_field()
9+
PR = PolynomialRing(F, name="z")
10+
z = PR.gens()[0]
11+
roots = (z**3 + a*z + b).roots()
12+
assert len(roots) > 0
13+
alpha = roots[0][0]
14+
s = (3*alpha**2 + a).sqrt() ** (-1)
15+
return -3 * (-1)**s.is_square() * alpha * s
16+
17+
def to_weierstrass(A):
18+
while True:
19+
B = Fp.random_element()
20+
if B.is_square() and B != 0:
21+
break
22+
a = (3 - A**2) * pow(3 * B**2, -1, p)
23+
b = (2 * A**3 - 9 * A) * pow(27 * B**3, -1, p)
24+
return EllipticCurve(Fp, [a, b])
25+
26+
def group_action(pub, priv):
27+
es = priv.copy()
28+
A = pub
29+
assert len(es) == len(primes)
30+
EC = to_weierstrass(A)
31+
while True:
32+
if all(e == 0 for e in es):
33+
break
34+
x = Fp(randint(1, p-1))
35+
r = Fp(x ** 3 + A * x ** 2 + x)
36+
s = kronecker_symbol(r, p)
37+
assert (2 * is_square(r)) - 1 == s
38+
I = [i for i, e in enumerate(es) if sign(e) == s]
39+
if len(I) == 0:
40+
continue
41+
if s == -1:
42+
EC = EC.quadratic_twist()
43+
while True:
44+
tmp = EC.random_element()
45+
if not tmp.is_zero():
46+
break
47+
x = tmp.xy()[0]
48+
t = prod([primes[i] for i in I])
49+
P = EC.lift_x(x)
50+
assert (p + 1) % t == 0
51+
Q = ((p + 1) // t) * P
52+
for i in I:
53+
assert t % primes[i] == 0
54+
R = (t // primes[i]) * Q
55+
if R.is_zero():
56+
continue
57+
phi = EC.isogeny(R)
58+
EC = phi.codomain()
59+
Q = phi(Q)
60+
assert t % primes[i] == 0
61+
t = t // primes[i]
62+
es[i] -= s
63+
if s == -1:
64+
EC = EC.quadratic_twist()
65+
return from_weierstrass(EC)
66+
67+
def truncated(n, ratio):
68+
69+
kbits = int(n.bit_length() * ratio)
70+
return (n >> kbits) << kbits
71+
72+
class CSIDH:
73+
74+
def __init__(self):
75+
self.priv = [randint(-2, 2) for _ in primes]
76+
self.pub = group_action(0, self.priv)
77+
78+
def getPublic(self):
79+
return self.pub
80+
81+
def getShare(self, other):
82+
return group_action(other, self.priv)
83+
84+
Angel, Devil = CSIDH(), CSIDH()
85+
print(f"Angel's Public Key = {Angel.getPublic()}")
86+
print(f"Devil's Public Key = {Devil.getPublic()}")
87+
88+
choice = input("Deal with [A]ngel or [D]evil? Make your choice carefully: ")
89+
if choice == "A":
90+
for i in range(5):
91+
A = int(input("Enter the montgomery coefficient: "))
92+
print(truncated(int(Angel.getShare(A)), 0.4))
93+
elif choice == "D":
94+
for i in range(4):
95+
D = int(input("Enter the montgomery coefficient: "))
96+
print(truncated(int(Devil.getShare(D)), 0.3))
97+
else:
98+
print("Ok ... You are from Super Guesser, right?")
99+
100+
S = int(Angel.getShare(Devil.getPublic()))
101+
if int(input("Did Angel or Devil tell your the secret: ")) == S:
102+
try:
103+
f = open('flag.txt','r')
104+
FLAG = f.read()
105+
f.close()
106+
except:
107+
FLAG = "idek{debug}"
108+
print(f"FLAG = {FLAG}")
109+
else:
110+
print("G_G")
111+
112+

crypto/Heaven-or-Hell/challenge.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: kctf.dev/v1
2+
kind: Challenge
3+
metadata:
4+
name: heaven-or-hell
5+
spec:
6+
deployed: true
7+
powDifficultySeconds: 0
8+
network:
9+
public: true
10+
healthcheck:
11+
# TIP: disable the healthcheck during development
12+
enabled: true
13+
image: us.gcr.io/idekctf-374221/heaven-or-hell-healthcheck:43385b359212a69207cda5e7d2f4ed7336c22841905a3add073dc29c17718205
14+
image: us.gcr.io/idekctf-374221/heaven-or-hell-challenge:51746d19c08f367d629a1198372ea994a2d306b15ab445dc661874247a894858
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM sagemath/sagemath:latest AS chroot
2+
3+
USER root
4+
5+
RUN apt-get update && apt-get install -y socat python3 python3-pip && rm -rf /var/lib/apt/lists/*
6+
RUN sage -pip install pycryptodome
7+
8+
RUN mkdir -m 777 /app
9+
10+
USER sage
11+
12+
COPY server.sage /app/
13+
COPY flag.txt /app/
14+
15+
WORKDIR /app
16+
17+
RUN sage --preparse server.sage
18+
19+
FROM gcr.io/kctf-docker/challenge@sha256:eb0f8c3b97460335f9820732a42702c2fa368f7d121a671c618b45bbeeadab28
20+
21+
COPY --from=chroot / /chroot
22+
23+
COPY nsjail.cfg /home/user/
24+
25+
CMD ["bash", "-c", "kctf_setup && kctf_drop_privs socat TCP-LISTEN:1337,reuseaddr,fork EXEC:\"kctf_pow nsjail --config /home/user/nsjail.cfg --cwd /app -- /usr/bin/sage --nodotsage server.sage.py\""]
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
idek{wh0_t3lls_y0u_th3_s3cr3t!}
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# See options available at https://github.com/google/nsjail/blob/master/config.proto
16+
17+
name: "default-nsjail-configuration"
18+
description: "Default nsjail configuration for pwnable-style CTF task."
19+
20+
21+
mode: ONCE
22+
uidmap {
23+
inside_id: "1000"
24+
outside_id: "user"
25+
}
26+
gidmap {
27+
inside_id: "1000"
28+
outside_id: "user"
29+
}
30+
rlimit_as_type: HARD
31+
rlimit_cpu_type: HARD
32+
rlimit_nofile_type: HARD
33+
rlimit_nproc_type: HARD
34+
35+
envar: "HOME=/home/sage"
36+
37+
cwd: "/home/sage"
38+
39+
mount: [
40+
{
41+
src: "/chroot"
42+
dst: "/"
43+
is_bind: true
44+
},
45+
{
46+
src: "/dev"
47+
dst: "/dev"
48+
is_bind: true
49+
},
50+
{
51+
dst: "/tmp"
52+
fstype: "tmpfs"
53+
rw: true
54+
}
55+
]

0 commit comments

Comments
 (0)