-
Notifications
You must be signed in to change notification settings - Fork 6
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
169 changed files
with
241,227 additions
and
50 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
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,24 @@ | ||
# SekaiCTF 2023 | ||
|
||
## CTF Information | ||
|
||
- Event: https://ctftime.org/event/1923 | ||
- Format: Jeopardy, 48 hours | ||
- Website: https://ctf.sekai.team/ | ||
- Official writeups: https://github.com/project-sekai-ctf/sekaictf-2023 | ||
- Participated teams: 981 (529 teams have solved a challenge besides sanity check and survey) | ||
|
||
## My challenges | ||
|
||
I have authored 8 challenges. Difficulty of each challenge is listed in the table below. | ||
|
||
| Challenge Name | Category | Difficulty (out of 5) | Solves | | ||
| :--------------: | :----------: | :------: | :----: | | ||
| [**cryptoGRAPHy1**](./crypto_cryptography1/) | Crypto | 1 | 76 | | ||
| [**cryptoGRAPHy2**](./crypto_cryptography2/) | Crypto | 2 | 55 | | ||
| [**cryptoGRAPHy3**](./crypto_cryptography3/) | Crypto | 4 | 31 | | ||
| [**DEFCON Invitation**](./forensics_defcon-invitation/) | Forensics | 2 | 148 | | ||
| [**Wiki Game**](./ppc_wiki-game/) | PPC | 1 | 284 | | ||
| [**Mikusweeper**](./ppc_mikusweeper/) | PPC | 3 | 35 | | ||
| [**Teyvat Travel Guide**](./reverse_teyvat-travel-guide/) | Reverse | 3 | 31 | | ||
| [**Conquest Of Camelot**](./reverse_conquest-of-camelot/) | Reverse | 4 | 10 | |
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,13 @@ | ||
## cryptoGRAPHy 1 | ||
|
||
### Difficulty: 1 | ||
|
||
### Description | ||
|
||
Graphs have gained an increasing amount of attention in the world of Cryptography. They are used to model many real-world problems ranging from social media to traffic routing networks. Designing a secure Graph Encryption Scheme (GES) is important as querying plaintext graph database can leak sensitive information about the users. | ||
|
||
In this challenge I have implemented a novel GES. Please help me verify if the cryptosystem works. | ||
|
||
Author: sahuang | ||
|
||
<div style="background:#75fbde;border-radius:1rem;padding:1rem"><b>❖ Note</b><br><code>lib.zip</code> remains unchanged in this series. The flag for this challenge will be used to access the next one when unlocked.</div> |
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 python:3.9-slim-buster | ||
|
||
RUN apt-get update -y && \ | ||
apt-get install -y lib32z1 xinetd && \ | ||
pip3 install networkx pycryptodome && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN useradd -m user && \ | ||
chown -R root:root /home/user | ||
|
||
COPY app /home/user/ | ||
COPY xinetd /etc/xinetd.d/user | ||
|
||
WORKDIR /home/user | ||
|
||
EXPOSE 9999 | ||
|
||
CMD ["/usr/sbin/xinetd", "-dontfork"] |
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,68 @@ | ||
from __future__ import annotations | ||
from typing import * | ||
from Crypto.Random import get_random_bytes | ||
from itertools import product | ||
from multiprocessing import Pool | ||
import utils | ||
|
||
class DESClass: | ||
''' | ||
Implementation of dictionary encryption scheme | ||
''' | ||
def __init__(self, encrypted_db: dict[bytes, bytes] = {}): | ||
self.encrypted_db = encrypted_db | ||
|
||
def keyGen(self, security_parameter: int) -> bytes: | ||
''' | ||
Input: Security parameter | ||
Output: Secret key | ||
''' | ||
return get_random_bytes(security_parameter) | ||
|
||
def encryptDict(self, key: bytes, plaintext_dx: dict[bytes, bytes], cores: int) -> dict[bytes, bytes]: | ||
''' | ||
Input: A key and a plaintext dictionary | ||
Output: An encrypted dictionary EDX | ||
''' | ||
encrypted_db = {} | ||
chunk = int(len(plaintext_dx)/cores) | ||
iterable = product([key], plaintext_dx.items()) | ||
|
||
with Pool(cores) as pool: | ||
for ct_label, ct_value in pool.istarmap(encryptDictHelper, iterable, chunksize=chunk): | ||
encrypted_db[ct_label] = ct_value | ||
return encrypted_db | ||
|
||
def tokenGen(self, key: bytes, label: bytes) -> bytes: | ||
''' | ||
Input: A key and a label | ||
Output: A token on label | ||
''' | ||
K1 = utils.HashMAC(key, b'1'+label)[:16] | ||
K2 = utils.HashMAC(key, b'2'+label)[:16] | ||
return K1 + K2 | ||
|
||
def search(self, search_token: bytes, encrypted_db: dict[bytes, bytes]) -> bytes: | ||
''' | ||
Input: Search token and EDX | ||
Output: The corresponding encrypted value. | ||
''' | ||
K1 = search_token[:16] | ||
K2 = search_token[16:] | ||
hash_val = utils.Hash(K1) | ||
if hash_val in encrypted_db: | ||
ct_value = encrypted_db[hash_val] | ||
return utils.SymmetricDecrypt(K2, ct_value) | ||
else: | ||
return b'' | ||
|
||
def encryptDictHelper(key, dict_item): | ||
label = dict_item[0] | ||
value = dict_item[1] | ||
|
||
K1 = utils.HashMAC(key, b'1'+label)[:16] | ||
K2 = utils.HashMAC(key, b'2'+label)[:16] | ||
|
||
ct_label = utils.Hash(K1) | ||
ct_value = utils.SymmetricEncrypt(K2, value) | ||
return ct_label, ct_value |
Oops, something went wrong.