Skip to content

Commit

Permalink
Add SekaiCTF 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
sahuang committed Aug 27, 2023
1 parent f6c691b commit 0d21714
Show file tree
Hide file tree
Showing 169 changed files with 241,227 additions and 50 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Xiaohai Xu
Copyright (c) 2023 Xiaohai Xu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
111 changes: 62 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,34 @@

Source code and solution of CTF challenges that I created.

## vsCTF 2022
## SekaiCTF 2023

| Challenge Name | Category | Difficulty | Solves |
| :------------------------------------------------------------------------------: | :-------: | :--------: | :----: |
| [**Baby RSA**](./vsctf-2022/Crypto/Baby%20RSA/) | Crypto | Easy | 68 |
| [**Strongest RSA**](./vsctf-2022/Crypto/Strongest%20RSA/) | Crypto | Easy | 53 |
| [**Secure Grading System**](./vsctf-2022/Crypto/Secure%20Grading%20System/) | Crypto | Medium | 21 |
| [**NIST Finalist: Revisited**](./vsctf-2022/Crypto/NIST%20Finalist%20Revisited/) | Crypto | Hard | 12 |
| [**Let's play osu!**](./vsctf-2022/Forensics/Lets%20play%20osu/) | Forensics | Medium | 10 |
| [**Lost Assignment**](./vsctf-2022/Misc/Lost%20Assignment/) | Misc | Easy | 93 |
| [**Egg Hunt**](./vsctf-2022/Misc/Egg%20Hunt/) | Misc | Hard | 10 |
| [**Flag Checker**](./vsctf-2022/Reverse/Flag%20Checker/) | Reverse | Easy | 19 |
| [**Functional CPP**](./vsctf-2022/Reverse/Functional%20CPP/) | Reverse | Easy | 7 |
| [**Tuning Test**](./vsctf-2022/Reverse/Tuning%20Test/) | Reverse | Easy | 20 |
| [**Binary Flood**](./vsctf-2022/Reverse/Binary%20Flood/) | Reverse | Medium | 30 |
| [**Hex-A-Gone**](./vsctf-2022/Reverse/Hex-A-Gone/) | Reverse | Hard | 6 |

## SekaiCTF 2022

| Challenge Name | Category | Difficulty (out of 5) | Solves |
| :--------------------------------------------------------------------------------: | :------: | :-------------------: | :----: |
| [**Time Capsule**](./sekaictf-2022/Crypto/Time%20Capsule/) | Crypto | 1 | 178 |
| [**Secure Image Encryption**](./sekaictf-2022/Crypto/Secure%20Image%20Encryption/) | Crypto | 2 | 49 |
| [**Robust CBC**](./sekaictf-2022/Crypto/SRobust%20CBC/) | Crypto | 4 | 10 |
| [**Let's Play Osu!Mania**](./sekaictf-2022/PPC/Let's%20Play%20Osu!Mania/) | PPC | 1 | 273 |
| [**Electric Box**](./sekaictf-2022/PPC/Electric%20Box/) | PPC | 3 | 36 |
| [**Perfect Match X-treme**](./sekaictf-2022/Reverse/Perfect%20Match%20Xtreme/) | Reverse | 1 | 111 |
| [**Matrix Lab 1**](./sekaictf-2022/Reverse/Matrix%20Lab%201/) | Reverse | 1 | 191 |
| [**Matrix Lab 2**](./sekaictf-2022/Reverse/Matrix%20Lab%202/) | Reverse | 2 | 80 |
| [**Matrix Lab 3**](./sekaictf-2022/Reverse/Matrix%20Lab%203/) | Reverse | 3 | 19 |
| [**Baby Chicken**](./sekaictf-2022/Reverse/Baby%20Chicken/) | Reverse | 4 | 6 |
| Challenge Name | Category | Difficulty (out of 5) | Solves |
| :--------------: | :----------: | :------: | :----: |
| [**cryptoGRAPHy1**](./sekaictf-2023/crypto_cryptography1/) | Crypto | 1 | 76 |
| [**cryptoGRAPHy2**](./sekaictf-2023/crypto_cryptography2/) | Crypto | 2 | 55 |
| [**cryptoGRAPHy3**](./sekaictf-2023/crypto_cryptography3/) | Crypto | 4 | 31 |
| [**DEFCON Invitation**](./sekaictf-2023/forensics_defcon-invitation/) | Forensics | 2 | 148 |
| [**Wiki Game**](./sekaictf-2023/ppc_wiki-game/) | PPC | 1 | 284 |
| [**Mikusweeper**](./sekaictf-2023/ppc_mikusweeper/) | PPC | 3 | 35 |
| [**Teyvat Travel Guide**](./sekaictf-2023/reverse_teyvat-travel-guide/) | Reverse | 3 | 31 |
| [**Conquest Of Camelot**](./sekaictf-2023/reverse_conquest-of-camelot/) | Reverse | 4 | 10 |

## Security BSides Ahmedabad CTF 2022
## CryptoverseCTF 2023

| Challenge Name | Category | Difficulty | Solves |
| :---------------------------------------------------------------------------------------: | :-------: | :--------: | :----: |
| [**Password Checker**](./security-bsides-ahmedabad-ctf-2022/Reverse/Password%20Checker/) | Reverse | Easy | 2 |
| [**Cyrene**](./security-bsides-ahmedabad-ctf-2022/Reverse/Cyrene/) | Reverse | Medium | 1 |
| Challenge Name | Category | Difficulty | Solves |
| :--------------: | :----------: | :------: | :----: |
| [**Knapsack vs. Backpack**](./cryptoversectf-2023/Crypto/Knapsack%20vs.%20Backpack/) | Crypto | Medium | 31 |
| [**PicoChip 1**](./cryptoversectf-2023/Crypto/PicoChip%201/) | Crypto | Medium | 18 |
| [**PicoChip 2**](./cryptoversectf-2023/Crypto/PicoChip%202/) | Crypto | Hard | 7 |
| [**Fractional Flag**](./cryptoversectf-2023/Crypto/Fractional%20Flag/) | Crypto | Hard | 17 |
| [**OJail**](./cryptoversectf-2023/Misc/OJail/) | Misc | Easy | 74 |
| [**Two and a half years**](./cryptoversectf-2023/Misc/Two%20and%20a%20half%20years/) | Misc | Hard | 16 |
| [**Solid Reverse**](./cryptoversectf-2023/Reverse/Solid%20Reverse/) | Reverse | Medium | 49 |
| [**Java Not Interesting**](./cryptoversectf-2023/Reverse/Java%20Not%20Interesting/) | Reverse | Medium | 22 |
| [**東方ダンマクカグラ**](./cryptoversectf-2023/Reverse/Touhou%20Danmaku%20Kagura/) | Reverse | Medium | 19 |
| [**Safe Locker**](./cryptoversectf-2023/Web/Safe%20Locker/) | Web | Easy | 36 |
| [**Safe Locker++**](./cryptoversectf-2023/Web/Safe%20Locker%20Plus%20Plus/) | Web | Hard | 5 |

## CryptoverseCTF 2022

Expand All @@ -58,18 +48,41 @@ Source code and solution of CTF challenges that I created.
| [**Baby CUDA**](./cryptoversectf-2022/Reverse/Baby%20CUDA/) | Reverse | Hard | 4 |
| [**Cheney-on-the-MTA**](./cryptoversectf-2022/Reverse/Cheney-on-the-MTA/) | Reverse | Hard | 2 |

## CryptoverseCTF 2023
## Security BSides Ahmedabad CTF 2022

| Challenge Name | Category | Difficulty | Solves |
| :--------------: | :----------: | :------: | :----: |
| [**Knapsack vs. Backpack**](./cryptoversectf-2023/Crypto/Knapsack%20vs.%20Backpack/) | Crypto | Medium | 31 |
| [**PicoChip 1**](./cryptoversectf-2023/Crypto/PicoChip%201/) | Crypto | Medium | 18 |
| [**PicoChip 2**](./cryptoversectf-2023/Crypto/PicoChip%202/) | Crypto | Hard | 7 |
| [**Fractional Flag**](./cryptoversectf-2023/Crypto/Fractional%20Flag/) | Crypto | Hard | 17 |
| [**OJail**](./cryptoversectf-2023/Misc/OJail/) | Misc | Easy | 74 |
| [**Two and a half years**](./cryptoversectf-2023/Misc/Two%20and%20a%20half%20years/) | Misc | Hard | 16 |
| [**Solid Reverse**](./cryptoversectf-2023/Reverse/Solid%20Reverse/) | Reverse | Medium | 49 |
| [**Java Not Interesting**](./cryptoversectf-2023/Reverse/Java%20Not%20Interesting/) | Reverse | Medium | 22 |
| [**東方ダンマクカグラ**](./cryptoversectf-2023/Reverse/Touhou%20Danmaku%20Kagura/) | Reverse | Medium | 19 |
| [**Safe Locker**](./cryptoversectf-2023/Web/Safe%20Locker/) | Web | Easy | 36 |
| [**Safe Locker++**](./cryptoversectf-2023/Web/Safe%20Locker%20Plus%20Plus/) | Web | Hard | 5 |
| Challenge Name | Category | Difficulty | Solves |
| :---------------------------------------------------------------------------------------: | :-------: | :--------: | :----: |
| [**Password Checker**](./security-bsides-ahmedabad-ctf-2022/Reverse/Password%20Checker/) | Reverse | Easy | 2 |
| [**Cyrene**](./security-bsides-ahmedabad-ctf-2022/Reverse/Cyrene/) | Reverse | Medium | 1 |

## SekaiCTF 2022

| Challenge Name | Category | Difficulty (out of 5) | Solves |
| :--------------------------------------------------------------------------------: | :------: | :-------------------: | :----: |
| [**Time Capsule**](./sekaictf-2022/Crypto/Time%20Capsule/) | Crypto | 1 | 178 |
| [**Secure Image Encryption**](./sekaictf-2022/Crypto/Secure%20Image%20Encryption/) | Crypto | 2 | 49 |
| [**Robust CBC**](./sekaictf-2022/Crypto/SRobust%20CBC/) | Crypto | 4 | 10 |
| [**Let's Play Osu!Mania**](./sekaictf-2022/PPC/Let's%20Play%20Osu!Mania/) | PPC | 1 | 273 |
| [**Electric Box**](./sekaictf-2022/PPC/Electric%20Box/) | PPC | 3 | 36 |
| [**Perfect Match X-treme**](./sekaictf-2022/Reverse/Perfect%20Match%20Xtreme/) | Reverse | 1 | 111 |
| [**Matrix Lab 1**](./sekaictf-2022/Reverse/Matrix%20Lab%201/) | Reverse | 1 | 191 |
| [**Matrix Lab 2**](./sekaictf-2022/Reverse/Matrix%20Lab%202/) | Reverse | 2 | 80 |
| [**Matrix Lab 3**](./sekaictf-2022/Reverse/Matrix%20Lab%203/) | Reverse | 3 | 19 |
| [**Baby Chicken**](./sekaictf-2022/Reverse/Baby%20Chicken/) | Reverse | 4 | 6 |

## vsCTF 2022

| Challenge Name | Category | Difficulty | Solves |
| :------------------------------------------------------------------------------: | :-------: | :--------: | :----: |
| [**Baby RSA**](./vsctf-2022/Crypto/Baby%20RSA/) | Crypto | Easy | 68 |
| [**Strongest RSA**](./vsctf-2022/Crypto/Strongest%20RSA/) | Crypto | Easy | 53 |
| [**Secure Grading System**](./vsctf-2022/Crypto/Secure%20Grading%20System/) | Crypto | Medium | 21 |
| [**NIST Finalist: Revisited**](./vsctf-2022/Crypto/NIST%20Finalist%20Revisited/) | Crypto | Hard | 12 |
| [**Let's play osu!**](./vsctf-2022/Forensics/Lets%20play%20osu/) | Forensics | Medium | 10 |
| [**Lost Assignment**](./vsctf-2022/Misc/Lost%20Assignment/) | Misc | Easy | 93 |
| [**Egg Hunt**](./vsctf-2022/Misc/Egg%20Hunt/) | Misc | Hard | 10 |
| [**Flag Checker**](./vsctf-2022/Reverse/Flag%20Checker/) | Reverse | Easy | 19 |
| [**Functional CPP**](./vsctf-2022/Reverse/Functional%20CPP/) | Reverse | Easy | 7 |
| [**Tuning Test**](./vsctf-2022/Reverse/Tuning%20Test/) | Reverse | Easy | 20 |
| [**Binary Flood**](./vsctf-2022/Reverse/Binary%20Flood/) | Reverse | Medium | 30 |
| [**Hex-A-Gone**](./vsctf-2022/Reverse/Hex-A-Gone/) | Reverse | Hard | 6 |
24 changes: 24 additions & 0 deletions sekaictf-2023/README.md
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 |
13 changes: 13 additions & 0 deletions sekaictf-2023/crypto_cryptography1/README.md
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>
19 changes: 19 additions & 0 deletions sekaictf-2023/crypto_cryptography1/challenge/Dockerfile
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"]
68 changes: 68 additions & 0 deletions sekaictf-2023/crypto_cryptography1/challenge/app/DES.py
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
Loading

0 comments on commit 0d21714

Please sign in to comment.