generated from sigpwny/ctf-chal-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chal done(?) just need to deploy + sol script
- Loading branch information
Showing
5 changed files
with
132 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM ubuntu:20.04 | ||
|
||
RUN apt-get update && apt-get install -y socat python3 | ||
|
||
RUN adduser chal | ||
|
||
RUN mkdir -p /chal | ||
WORKDIR /chal | ||
|
||
COPY chal.py flag.txt ./ | ||
RUN chmod 555 chal.py | ||
USER chal | ||
|
||
CMD socat -T60 TCP-LISTEN:1337,fork,reuseaddr EXEC:"python3 -u chal.py",stderr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: "Diagonal" | ||
author: Anakin | ||
category: Crypto | ||
description: |- | ||
We've tried and failed with horizontal and vertical integration. | ||
Hopefully something more angular will catch on. | ||
`nc chal.fallctf.sigpwny.com 6001` | ||
**author**: Pete | ||
value: 500 | ||
type: dynamic | ||
tags: | ||
- medium | ||
extra: | ||
initial: 500 | ||
decay: 150 | ||
minimum: 100 | ||
flags: | ||
- sigpwny{mult1d1m3n510n4l} | ||
files: | ||
- public.py | ||
hints: | ||
- Play with some matrices, see how the exponent affects the entries, get some equations going | ||
state: hidden |
38 changes: 20 additions & 18 deletions
38
chals/crypto/diagonal/chal.py → chals/crypto/diagonal/public.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,55 @@ | ||
import numpy as np | ||
import random | ||
|
||
import sympy as sp | ||
|
||
FLAG = "sigpwny{testing_yay!}" | ||
FLAG = "sigpwny{????????????????}" | ||
|
||
def inputs(): | ||
print("Define a 3 x 3 Integer Matrix M") | ||
print("[D] Define a 3 x 3 Integer Matrix M") | ||
M = [ | ||
[0, 0, 0], | ||
[0, 0, 0], | ||
[0, 0, 0], | ||
] | ||
for i in range(3): | ||
for j in range(3): | ||
M[i][j] = int(input(f"[D] M[{i}][{j}] = ")) | ||
try: | ||
M[i][j] = int(input(f"[D] M[{i}][{j}] = ")) | ||
except: | ||
return None | ||
return M | ||
|
||
def fun(M_, d): | ||
M = np.matrix(M_) | ||
M = np.matrix(M_, dtype='object') | ||
M = M**d | ||
|
||
# [\\\] | ||
# [ \\] | ||
# [ \] | ||
return M[0, 0] + M[1, 1] + M[2, 2] + M[0, 1] + M[1, 2] + M[0, 2] | ||
|
||
def main(): | ||
secret = random.randint(1_000_000_000, 10_000_000_000) | ||
|
||
print("[D] Welcome") | ||
M = inputs() | ||
if M == None: | ||
print("[D] You tried something weird...") | ||
return | ||
|
||
res = fun(M, secret) | ||
print() | ||
print(f"[D] Have fun: {res}") | ||
print() | ||
guess = int(input(f"[D] Make a guess: ")) | ||
try: | ||
guess = int(input(f"[D] Make a guess: ")) | ||
except: | ||
print("[D] You tried something weird...") | ||
return | ||
|
||
if guess == secret: | ||
print(f"[D] {FLAG}") | ||
else: | ||
print(f"[D] Better luck next time!") | ||
|
||
|
||
# # Some test solutions | ||
# disc = (25 - 4 * (6 - 2*int(res)))**(0.5) | ||
# sec_ = (-5 + disc) // 2 | ||
# print(sec_) | ||
|
||
# n = sp.Symbol('n') | ||
# print(sp.solve(3 + 2*n + (n**2 + n) / 2 - res, n)) | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import numpy as np | ||
import random | ||
|
||
FLAG = "sigpwny{mult1d1m3n510n4l}" | ||
|
||
def inputs(): | ||
print("[D] Define a 3 x 3 Integer Matrix M") | ||
M = [ | ||
[0, 0, 0], | ||
[0, 0, 0], | ||
[0, 0, 0], | ||
] | ||
for i in range(3): | ||
for j in range(3): | ||
try: | ||
M[i][j] = int(input(f"[D] M[{i}][{j}] = ")) | ||
except: | ||
return None | ||
return M | ||
|
||
def fun(M_, d): | ||
M = np.matrix(M_, dtype='object') | ||
M = M**d | ||
|
||
# [\\\] | ||
# [ \\] | ||
# [ \] | ||
return M[0, 0] + M[1, 1] + M[2, 2] + M[0, 1] + M[1, 2] + M[0, 2] | ||
|
||
def main(): | ||
secret = random.randint(1_000_000_000, 10_000_000_000) | ||
|
||
print("[D] Welcome") | ||
M = inputs() | ||
if M == None: | ||
print("[D] You tried something weird...") | ||
return | ||
|
||
res = fun(M, secret) | ||
print() | ||
print(f"[D] Have fun: {res}") | ||
print() | ||
try: | ||
guess = int(input(f"[D] Make a guess: ")) | ||
except: | ||
print("[D] You tried something weird...") | ||
return | ||
|
||
if guess == secret: | ||
print(f"[D] {FLAG}") | ||
else: | ||
print(f"[D] Better luck next time!") | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import sympy as sp | ||
|
||
def main(): | ||
|
||
res = 18669237451167230340 | ||
|
||
# Some solutions | ||
disc = (25 - 4 * (6 - 2*int(res)))**(0.5) | ||
sec_ = (-5 + disc) // 2 | ||
print(int(sec_)) | ||
|
||
n = sp.Symbol('n') | ||
print(sp.solve(3 + 2*n + (n**2 + n) / 2 - res, n)[1]) | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
main() |