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.
- Loading branch information
Showing
15 changed files
with
125 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,9 @@ | ||
from Crypto.PublicKey import RSA | ||
from Crypto.Cipher import PKCS1_v1_5 | ||
import sympy | ||
|
||
e = 65539 | ||
n = 4462776610810429874302099425257433084349 # It seems that n is very small... | ||
c = [b'\x06\x86\xbc}\x0f\xfc\xac\x80\x90&S\x98\xa1!+F>', # List of messages for you to decrypt | ||
b'\x04\xe9%7\xeb\xdd\xf6\xcd\x9e\x7f\xa2Z\x81\x16,\x9fh', | ||
b"\x00\xa3\x19lP'\x04\x02\xb1\xe0\x89p-\x99\xcc\xf1@"] |
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
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 @@ | ||
#add later |
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,19 @@ | ||
from Crypto.PublicKey import RSA | ||
from Crypto.Cipher import PKCS1_v1_5 | ||
import sympy | ||
|
||
e = 65539 | ||
n = 4462776610810429874302099425257433084349 # It seems that n is very small... | ||
c = [b'\x06\x86\xbc}\x0f\xfc\xac\x80\x90&S\x98\xa1!+F>', # List of messages for you to decrypt | ||
b'\x04\xe9%7\xeb\xdd\xf6\xcd\x9e\x7f\xa2Z\x81\x16,\x9fh', | ||
b"\x00\xa3\x19lP'\x04\x02\xb1\xe0\x89p-\x99\xcc\xf1@"] | ||
|
||
#-----SOLUTION------- | ||
|
||
totn = int(sympy.totient(n)) | ||
d = pow(e,-1,totn) | ||
for i in c: | ||
priv = RSA.construct((n,e,d)) | ||
ciph = PKCS1_v1_5.new(priv) | ||
plaintext = ciph.decrypt(i, None) | ||
print(plaintext.decode("utf-8")) |
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 python3-pip | ||
|
||
RUN adduser chal | ||
|
||
RUN mkdir -p /chal | ||
WORKDIR /chal | ||
|
||
COPY server.py ./ | ||
RUN chmod 555 server.py | ||
USER chal | ||
|
||
CMD socat -T60 TCP-LISTEN:1337,fork,reuseaddr EXEC:"python3 -u server.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,24 @@ | ||
name: "Safe Cracking" | ||
author: Sophia | ||
category: Crypto | ||
description: |- | ||
We found a magical safe. There are apparently many valuable items in it such as an invisibility cloak, an Amazon giftcard, and more! | ||
Can you please help us recover the original combination? | ||
`nc chal.cryptoctf.sigpwny.com 7001` | ||
**author**: Sophia | ||
value: 150 | ||
type: dynamic | ||
tags: | ||
- easy | ||
extra: | ||
initial: 150 | ||
decay: 50 | ||
minimum: 50 | ||
flags: | ||
- sigpwny{is_this_r3@lly_the_m0st_s3cure_s@f3_3ver?} | ||
files: | ||
hints: | ||
- Look up how to perform a Diffie-Hellman key exchange. | ||
state: hidden |
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 @@ | ||
sigpwny{is_this_r3@lly_the_m0st_s3cure_s@f3_3ver?} |
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,43 @@ | ||
import time | ||
import random | ||
|
||
FLAG = "sigpwny{is_this_r3@lly_the_m0st_s3cure_s@f3_3ver?}" | ||
combos = [11, 112, 81] | ||
|
||
def prompt(): | ||
for i in range(3): | ||
try: | ||
value = int(input(f"Enter the {['first', 'second', 'third'][i]} value: ").strip()) | ||
if value != combos[i]: | ||
return False | ||
except ValueError: | ||
print("Please enter a number.") | ||
return False | ||
return True | ||
|
||
def print_notes(): | ||
print("\nHints to help me remember the combination to my safe (since I always forget it).") | ||
print("The shared key of each problem corresponds to one part of the safe combination.") | ||
print("1. Anna and Beatrice perform a Diffie-Hellman key exchange where p = 17 and g = 3. Privately, Anna selects 5 and Beatrice chooses 11. What's their shared secret key?") | ||
print("2. The two perform another key exchange. Now, p = 157 and g = 2. Anna's new private key is 67, while Beatrice's public key is 73. What is Anna's public key?") | ||
print("3. Anna forgot her private key and wants to solve for it. However, we know the following:\n\tTheir shared secret key, s, is equal to xx.\n\tThe values of p and g are 67 and 2, respectively.\n\tThe result of Anna's public key is x.\n") #finish later | ||
print("Get ready to start guessing!") | ||
time.sleep(1) | ||
|
||
def main(): | ||
print("Welcome to my extremely secure safe!") | ||
print("Note to self: Just in case I forget the combination, here's a note that reminds me how to remember it.") | ||
view_notes = input("View notes {y/n}: ") | ||
|
||
if (view_notes == "y"): | ||
print_notes() | ||
else: | ||
print("Might want to view the notes...") | ||
|
||
if prompt(): | ||
print("You have unlocked the safe! Please don't take anything except for this flag:", FLAG) | ||
else: | ||
print("Incorrect, try again.") | ||
|
||
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 @@ | ||
#todo |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,2 @@ | ||
- Based on the blog post image, we can reason that the corresponding username is wanderlust_and_mountains. | ||
- jhlzhy_pz_tf_mhc_zhshk has been encrypted with a caeser cipher, decrypting it results in the flag. |