repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2024/web/MOC_Inc./app.py
ctfs/BCACTF/2024/web/MOC_Inc./app.py
from flask import Flask, request, render_template import datetime import sqlite3 import random import pyotp import sys random.seed(datetime.datetime.today().strftime('%Y-%m-%d')) app = Flask(__name__) @app.get('/') def index(): return render_template('index.html') @app.post('/') def log_in(): with sqlite3....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2023/crypto/Superstitious/superstitious.py
ctfs/BCACTF/2023/crypto/Superstitious/superstitious.py
from Crypto.Util.number import * import math def myGetPrime(): while True: x = getRandomNBitInteger(1024) for i in range(-10,11): if isPrime(x*x+i): return x*x+i p = myGetPrime() q = myGetPrime() n = p * q e = 65537 message = open('flag.txt', 'rb') m = bytes_to_long(messa...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2023/crypto/Many_Time_Pad/many-time-pad.py
ctfs/BCACTF/2023/crypto/Many_Time_Pad/many-time-pad.py
from Crypto.Util.number import * secret_key = open("secret_key.txt", "rb").read() def enc(bstr): return long_to_bytes(bytes_to_long(bstr) ^ bytes_to_long(secret_key)) # gotta encode my grocery list groceries = b"I need to buy 15 eggs, 1.7 kiloliters of milk, 11000 candles, 12 cans of asbestos-free cereal, and 0.7...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2023/crypto/Signature_I/signature-i.py
ctfs/BCACTF/2023/crypto/Signature_I/signature-i.py
from Crypto.Util.number import getPrime, bytes_to_long, long_to_bytes from Crypto.Hash import SHA256 import random, string, binascii, re p = getPrime(2048) q = getPrime(2048) n = p*q e = 3 chars = string.digits + string.ascii_letters + string.punctuation t = "".join(random.sample(chars, 20)) h = SHA256.new() h.update(b...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2023/crypto/RSA_is_broken/rsa-broken.py
ctfs/BCACTF/2023/crypto/RSA_is_broken/rsa-broken.py
from Crypto.Util.number import * import math p = 892582974910679288224965877067 q = 809674535888980601722190167357 n = p * q e = 65537 message = open('flag.txt', 'rb') m = bytes_to_long(message.read()) c = pow(m, e, n) print(f'c = {c}') # OUTPUT: # c = 36750775360709769054416477187492778112181529855266342655304 d = p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2023/web/WORD_GAME/app.py
ctfs/BCACTF/2023/web/WORD_GAME/app.py
from flask import Flask, request, jsonify, render_template import sqlite3 as sl import random import string import os import re if os.path.exists("words.db"): os.remove("words.db") app = Flask("wordgame") db = sl.connect("words.db", check_same_thread=False) chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ?????????????????????...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2025/misc/locked_out/server.py
ctfs/BCACTF/2025/misc/locked_out/server.py
#!/usr/bin/env python3 while True: allowed = set("abcdefghijklm") code = input(">>> ") broke_the_rules = False for c in code: if c.lower() not in allowed and c not in "\"'()=+:;. 1234567890": print(f"Character {c} not allowed!") broke_the_rules = True break...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2025/misc/locked_out_again/server.py
ctfs/BCACTF/2025/misc/locked_out_again/server.py
#!/usr/bin/env python3 class DescriptorTrap: def __init__(self, name): self.name = name self.access_count = 0 def __get__(self, obj, objtype=None): self.access_count += 1 if self.access_count > 3: raise Exception(f"Too many accesses to {self.name}!") return...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2025/misc/expletive/expletive.py
ctfs/BCACTF/2025/misc/expletive/expletive.py
blacklist = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" def security_check(s): return any(c in blacklist for c in s) or s.count('_') > 50 BUFFER_SIZE = 36 while True: cmds = input("> ") if security_check(cmds): print("invalid input") else: if len(cmds) > BUFFER_S...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2025/algo/codeBusting/server.py
ctfs/BCACTF/2025/algo/codeBusting/server.py
import sys import json import random import time import unicodedata TIME_LIMIT = 15 # 15 seconds to solve em all! def remove_accents_preserve_n(text): """ Remove diacritics from text but preserve Ñ as its own character """ result = [] for char in text: if char in ["Ñ", "ñ"]: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2025/rev/5d_printing/source.py
ctfs/BCACTF/2025/rev/5d_printing/source.py
# oops i accidentally deleted everything except the comments!! you can still figure it out tho: """ Public 5MF Generator for the 5D Printer Challenge This script reads the flag from standard input and generates a scrambled 5MF file. The commands are intentionally output in a random order so that the correct ordering ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2025/crypto/Morse_Marsh/morse_encodings.py
ctfs/BCACTF/2025/crypto/Morse_Marsh/morse_encodings.py
MORSE_CODE = { 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-', ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2025/crypto/Q/server.py
ctfs/BCACTF/2025/crypto/Q/server.py
from os import urandom from secrets import randbelow secret_str = urandom(16).hex() secret = [ord(char) for char in secret_str] for _ in range(5000): encoded = [value + randbelow(2000) for value in secret] print(encoded) user_secret = input('What is the secret? ') if user_secret == secret_str: with open...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2022/rev/Ghost_Game/GhostGame.py
ctfs/BCACTF/2022/rev/Ghost_Game/GhostGame.py
########## ########## ########## ########## ########## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2022/rev/Pirates/encode.py
ctfs/BCACTF/2022/rev/Pirates/encode.py
from PIL import Image import numpy as np import cv2 FILE = 'original.png' img = Image.open(FILE) arr = np.asarray(img, dtype=np.float64) grayArr = np.zeros((len(arr), len(arr[0]))) for vert in range(len(arr)): for hori in range(len(arr[0])): grayArr[vert][hori] = arr[vert][hori] nHeight = len(grayArr) - len...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2022/rev/Password_Manager/PwdManager.py
ctfs/BCACTF/2022/rev/Password_Manager/PwdManager.py
HASHEDPWD = '111210122915474114123027144625104141324527134638392719373948' key = { 'a':10, 'b':11, 'c':12, 'd':13, 'e':14, 'f':15, 'g':16, 'h':17, 'i':18, 'j':19, 'k':20, 'l':21, 'm':22, 'n':23, 'o':24, 'p':25, 'q':26, 'r':27, 's':28, 't':2...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2022/rev/Bit_Shuffling/shuffle.py
ctfs/BCACTF/2022/rev/Bit_Shuffling/shuffle.py
# below from https://stackoverflow.com/a/10238140 # (licensed CC BY-SA 3.0, by John Gaines Jr.) def tobits(s): result = [] for c in s: bits = bin(ord(c))[2:] bits = '00000000'[len(bits):] + bits result.extend([b for b in bits]) return result # end copied text txt = open("flag.txt", ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2022/rev/Convoluted/convoluted.py
ctfs/BCACTF/2022/rev/Convoluted/convoluted.py
import numpy as np from scipy import ndimage from PIL import Image i = Image.open("flag.png") a = np.array(i) a = np.transpose(a,(2,0,1)) r = a[0] g = a[1] b = a[2] k = np.array([[0,0,0],[0,0.25,0.25],[0,0.25,0.25]]) r2 = ndimage.convolve(r,k,mode="constant",cval=0) g2 = ndimage.convolve(g,k,mode="constant",cval=0) b2...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2022/crypto/Ehrenfest/gs1.py
ctfs/BCACTF/2022/crypto/Ehrenfest/gs1.py
#!/usr/bin/env python3 import math import binascii from Crypto.Util.Padding import pad, unpad from Crypto.Util.number import bytes_to_long, long_to_bytes def chunks(l, n): assert(len(l) % n == 0) for i in range(0, len(l), n): yield l[i:i+n] FLAG_LEN = 72 M_SIZE = math.isqrt(FLAG_LEN * 8) flag = input...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2022/crypto/Gray-Scott/gs1.py
ctfs/BCACTF/2022/crypto/Gray-Scott/gs1.py
#!/usr/bin/env python3 import math import binascii from Crypto.Util.Padding import pad, unpad from Crypto.Util.number import bytes_to_long, long_to_bytes def chunks(l, n): assert(len(l) % n == 0) for i in range(0, len(l), n): yield l[i:i+n] FLAG_LEN = 72 M_SIZE = math.isqrt(FLAG_LEN * 8) flag = input...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AfricabattleCTF/2023/Quals/crypto/Sahara/generate.py
ctfs/AfricabattleCTF/2023/Quals/crypto/Sahara/generate.py
from cryptography.hazmat.primitives.asymmetric import rsa, padding from cryptography.hazmat.primitives import serialization from cryptography.hazmat.backends import default_backend from base64 import b64encode, b64decode FLAG = open("flag.txt").read() def load_public_key(): with open('pub.pem', 'rb') as pubf: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AfricabattleCTF/2023/Quals/crypto/ROCYOU/rocyou.py
ctfs/AfricabattleCTF/2023/Quals/crypto/ROCYOU/rocyou.py
from Crypto.Util.number import bytes_to_long FLAG = bytes_to_long(open("flag.txt").read().encode()) n = 14558732569295568217680262946946350946269492093750369718350618000766298342508431492935822827678025952146979183716519987777790434353113812051439651306232101 e = 65537 c = pow(FLAG, e, n) print(f"c = {c}") # c = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AfricabattleCTF/2023/Quals/crypto/SEA/chall.py
ctfs/AfricabattleCTF/2023/Quals/crypto/SEA/chall.py
from Crypto.Cipher import AES from Crypto.Util.Padding import pad from os import urandom iv = urandom(16) key = urandom(16) FLAG = b"battleCTF{REDACTED}" def encrypt(data): cipher = AES.new(key, AES.MODE_CFB, iv) return cipher.encrypt(pad(data, 16)) print(encrypt(FLAG).hex()) while True: print(encrypt(inpu...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AfricabattleCTF/2023/Quals/crypto/Gooss/gooss.py
ctfs/AfricabattleCTF/2023/Quals/crypto/Gooss/gooss.py
import random flag = 'battleCTF{******}' a = random.randint(4,9999999999) b = random.randint(4,9999999999) c = random.randint(4,9999999999) d = random.randint(4,9999999999) e = random.randint(4,9999999999) enc = [] for x in flag: res = (2*a*pow(ord(x),4)+b*pow(ord(x),3)+c*pow(ord(x),2)+d*ord(x)+e) enc.append(r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AfricabattleCTF/2023/Quals/crypto/Own_e/chall.py
ctfs/AfricabattleCTF/2023/Quals/crypto/Own_e/chall.py
from Crypto.Util.number import getPrime from os import urandom def message(secret, e): m = f'The invite token is {secret.hex()} and it is encrypted with e = {e}.'.encode() return int.from_bytes(m, 'big') def encrypt(data): out = [] i = 0 for pin in data: out.append((int(pin) + 5)^i) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/misc/Game_with_Rin/server.py
ctfs/CyberSpace/2024/misc/Game_with_Rin/server.py
from basement_of_rin import NanakuraRin, flag, generate_graph import time from random import Random def Server(m): print("Server> " + m) def Rin(m): print("Rin> " + m) def check_subset(_subset, set): subset = sorted(_subset) assert len(subset) != 0 for i in range(len(subset) - 1): subset[i] < subset[i + 1] ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/misc/quantum/quantum-dist.py
ctfs/CyberSpace/2024/misc/quantum/quantum-dist.py
# We ran this challenge on a quantum computer FLAG = "CSCTF{fake_flag_for_testing}" import random def gen(mn, mx): n = random.randint(mn, mx) global p p = [0] * n for i in range(n): p[i] = (random.randint(1, n), random.randint(1, n)) return p def ask(x0, y0): sum = 0 for x, y in...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/misc/quantum/server.py
ctfs/CyberSpace/2024/misc/quantum/server.py
import quantum, random N = 500 def bye(): print("bitset") exit(0) def main(): a = quantum.gen(N - N // 10, N) n = len(a) print(n) print("Ask me anything?") q = 0 while True: m = int(input().strip()) if m == -1: break q += m if q > 1.9 *...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/misc/SKK/chall.py
ctfs/CyberSpace/2024/misc/SKK/chall.py
import numpy as np import cv2 import random from datetime import datetime img = cv2.imread('flag.png') size_x, size_y = img.shape[:2] enc_negpos = np.zeros_like(img) random.seed(datetime.now().timestamp()) for i in range(size_x): for j in range(size_y): for rgb in range(3): negpos = random.r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/rev/Stubborn_Pickle_Jar/stubborn-pickle-jar.py
ctfs/CyberSpace/2024/rev/Stubborn_Pickle_Jar/stubborn-pickle-jar.py
import pickle from io import BytesIO with open("chall.pkl", 'rb') as f: p = f.read() up = pickle.Unpickler(BytesIO(p)) result = up.load()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/rev/Stubborn_Pickle_Jar/pickle.py
ctfs/CyberSpace/2024/rev/Stubborn_Pickle_Jar/pickle.py
# this is a clone of pickle.py. important... ...for reasons :) """Create portable serialized representations of Python objects. See module copyreg for a mechanism for registering custom picklers. See module pickletools source for extensive comments. Classes: Pickler Unpickler Functions: dump(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
true
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/jail/Swimming_to_Escape/fish.py
ctfs/CyberSpace/2024/jail/Swimming_to_Escape/fish.py
#!/usr/local/bin/python3.2 """ Python interpreter for the esoteric language ><> (pronounced /ˈfɪʃ/). Usage: ./fish.py --help More information: http://esolangs.org/wiki/Fish Requires python 2.7/3.2 or higher. """ import sys import time import random from collections import defaultdict # constants NCHARS = "012345...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/jail/Swimming_to_Escape/server.py
ctfs/CyberSpace/2024/jail/Swimming_to_Escape/server.py
from fish import Interpreter, StopExecution FLAG = open('flag.txt').read().strip() whitelist = r' +-*,%><^v~:&!?=()01\'/|_#l$@r{};"' if __name__ == '__main__': while True: print('Please input your code:') code = input() assert len(code) <= 26 assert all([c in whitelist for c in co...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/crypto/cipher_block_clock/chall.py
ctfs/CyberSpace/2024/crypto/cipher_block_clock/chall.py
import Crypto.Cipher.AES import Crypto.Random import Crypto.Util.Padding f = b"CSCTF{placeholder}" k = Crypto.Random.get_random_bytes(16) def enc(pt): iv = Crypto.Random.get_random_bytes(32) ct = Crypto.Cipher.AES.new(iv, Crypto.Cipher.AES.MODE_CBC, k) return iv.hex(), ct.encrypt(Crypto.Util.Padding.pad...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/crypto/Mask_RSA/chall.py
ctfs/CyberSpace/2024/crypto/Mask_RSA/chall.py
from Crypto.Util.number import getPrime, bytes_to_long FLAG = open('flag.txt', 'rb').read().strip() def mask_expr(expr): global e, n assert '**' not in expr, "My computer is weak, I can't handle this insane calculation" assert len(expr) <= 4, "Too long!" assert all([c in r'pq+-*/%' for c in expr]), "D...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/crypto/super_fnv/chall.py
ctfs/CyberSpace/2024/crypto/super_fnv/chall.py
from pwn import xor from random import randint from hashlib import sha256 from FLAG import flag cc = [randint(-2**67, 2**67) for _ in range(9)] key = sha256("".join(str(i) for i in cc).encode()).digest() enc = xor(key, flag) def superfnv(): x = 2093485720398457109348571098457098347250982735 k = 10238471029384...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/crypto/ezcoppersmith/chall.py
ctfs/CyberSpace/2024/crypto/ezcoppersmith/chall.py
import os from Crypto.Util.number import bytes_to_long, getPrime from random import getrandbits from sympy import nextprime flag = os.urandom(70)+b"CSCTF{fake_flag}"+os.urandom(70) flag = bytes_to_long(flag) e = 0x10001 p = getPrime(1024) q = nextprime(p+getrandbits(512)) n = p*q ct = pow(flag,e,n) print(f"{n = }") pr...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/crypto/Modulus_RSA/chall.py
ctfs/CyberSpace/2024/crypto/Modulus_RSA/chall.py
from Crypto.Util.number import bytes_to_long from sympy import randprime m = bytes_to_long(b'CSCTF{fake_flag}') p, q, r = sorted([randprime(0, 1<<128) for _ in range(3)]) n = p * q * r e = 65537 c = pow(m, e, n) w, x, y = q % p, r % p, r % q print(f'{w = }') print(f'{x = }') print(f'{y = }') print(f'{c = }') """ w = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/crypto/flagprinter/chall.py
ctfs/CyberSpace/2024/crypto/flagprinter/chall.py
from out import enc, R from math import prod flag = '' a = [0] for i in range(355): b = [_+1 for _ in a] c = [_+1 for _ in b] a += b + c if i%5 == 0: flag += chr(enc[i//5] ^ prod([a[_] for _ in R[i//5]])) print(flag)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSpace/2024/crypto/flagprinter/out.py
ctfs/CyberSpace/2024/crypto/flagprinter/out.py
enc = [65, 331, 1783, 6186, 6470, 17283, 25622, 49328, 75517, 80689, 148293, 164737, 256906, 285586, 529890, 453524, 486833, 612780, 995834, 1034513, 1164566, 1187257, 1195463, 1481795, 1456512, 2255447, 1918038, 2402807, 3279260, 2958036, 2881150, 3263588, 3820625, 4237730, 5185459, 5233235, 6049254, 6786968, 6183125,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/crypto/QRSA/main.py
ctfs/GreyCatTheFlag/2023/Quals/crypto/QRSA/main.py
from Crypto.Util.number import bytes_to_long from secret import qa, qb, pa, pb FLAG = b'fake_flag' class Q: d = 41 def __init__(self, a, b): self.a = a self.b = b def __add__(self, other): return Q(self.a + other.a, self.b + other.b) def __sub__(self, other): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/crypto/QRSA/secret.py
ctfs/GreyCatTheFlag/2023/Quals/crypto/QRSA/secret.py
# fake placeholder value qa = 1 qb = 1 pa = 1 pb = 1
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/crypto/OT/main.py
ctfs/GreyCatTheFlag/2023/Quals/crypto/OT/main.py
import secrets import hashlib from Crypto.Util.number import isPrime, long_to_bytes FLAG = b'grey{fake_flag}' e = 0x10001 def checkN(N): if (N < 0): return "what?" if (N.bit_length() != 4096): return "N should be 4096 bits" if (isPrime(N) or isPrime(N + 23)): return "Hey no cheati...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/crypto/The_Vault/chall.py
ctfs/GreyCatTheFlag/2023/Quals/crypto/The_Vault/chall.py
from hashlib import sha256 from Crypto.Util.number import long_to_bytes from Crypto.Cipher import AES from Crypto.Random import get_random_bytes from math import log10 FLAG = "grey{fake_flag}" n = pow(10, 128) def check_keys(a, b): if a % 10 == 0: return False # Check if pow(a, b) > n if b ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/crypto/GreyCat_Trial/chall.py
ctfs/GreyCatTheFlag/2023/Quals/crypto/GreyCat_Trial/chall.py
from random import randint FLAG = "grey{fake_flag}" print("Lo and behold! The GreyCat Wizard, residing within the Green Tower of PrimeLand, is a wizard of unparalleled prowess") print("The GreyCat wizard hath forged an oracle of equal potency") print("The oracle hath the power to bestow upon thee any knowledge that ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/crypto/EncryptService/chall.py
ctfs/GreyCatTheFlag/2023/Quals/crypto/EncryptService/chall.py
import os from Crypto.Cipher import AES from hashlib import sha256 FLAG = "grey{fake_flag_please_change_this}" assert(len(FLAG) == 40) secret_key = os.urandom(16) def encrypt(plaintext, iv): hsh = sha256(iv).digest()[:8] cipher = AES.new(secret_key, AES.MODE_CTR, nonce=hsh) ciphertext = cipher.encrypt...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/crypto/PLCG/main.py
ctfs/GreyCatTheFlag/2023/Quals/crypto/PLCG/main.py
import secrets from Crypto.Cipher import AES from Crypto.Util.Padding import pad FLAG = b'grey{fake_flag}' while True: sample = [3, 80] + [secrets.randbelow(256) for _ in range(2)] if len(sample) == len(set(sample)) and 0 not in sample: break def getBiasRandomByte(): return secrets.choice(sample)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/crypto/Encrypt/main.py
ctfs/GreyCatTheFlag/2023/Quals/crypto/Encrypt/main.py
from Crypto.Util.number import bytes_to_long from secrets import randbits FLAG = b'fake_flag' p = randbits(1024) q = randbits(1024) def encrypt(msg, key): m = bytes_to_long(msg) return p * m + q * m**2 + (m + p + q) * key n = len(FLAG) s = randbits(1024) print(f'n = {n}') print(f'p = {p}') print(f'q = {q}'...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/Microservices/admin_page/app.py
ctfs/GreyCatTheFlag/2023/Quals/web/Microservices/admin_page/app.py
from fastapi import FastAPI, Request, Response from dotenv import load_dotenv from requests import get import os load_dotenv() admin_cookie = os.environ.get("ADMIN_COOKIE", "FAKE_COOKIE") app = FastAPI() @app.get("/") async def index(request: Request): """ The base service for admin site """ # Curr...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/Microservices/gateway/constant.py
ctfs/GreyCatTheFlag/2023/Quals/web/Microservices/gateway/constant.py
routes = {"admin_page": "http://admin_page", "home_page": "http://home_page"} excluded_headers = [ "content-encoding", "content-length", "transfer-encoding", "connection", ]
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/Microservices/gateway/app.py
ctfs/GreyCatTheFlag/2023/Quals/web/Microservices/gateway/app.py
from flask import Flask, request, abort, Response from requests import get from constant import routes, excluded_headers import sys app = Flask(__name__) @app.route("/", methods=["GET"]) def route_traffic() -> Response: """Route the traffic to upstream""" microservice = request.args.get("service", "home_page...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/Microservices/homepage/app.py
ctfs/GreyCatTheFlag/2023/Quals/web/Microservices/homepage/app.py
from flask import Flask, request, render_template, Response, make_response from dotenv import load_dotenv import os load_dotenv() admin_cookie = os.environ.get("ADMIN_COOKIE", "FAKE_COOKIE") FLAG = os.environ.get("FLAG", "greyctf{This_is_fake_flag}") app = Flask(__name__) @app.route("/") def homepage() -> Response:...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/100_Questions/app.py
ctfs/GreyCatTheFlag/2023/Quals/web/100_Questions/app.py
from flask import Flask, render_template, request import sqlite3 app = Flask(__name__) @app.route("/", methods=["GET"]) def index(): qn_id, ans= request.args.get("qn_id", default="1"), request.args.get("ans", default="") # id check, i don't want anyone to pollute the inputs >:( if not (qn_id and qn_id.is...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/Microservices_Revenge/admin_page/app.py
ctfs/GreyCatTheFlag/2023/Quals/web/Microservices_Revenge/admin_page/app.py
from flask import Flask, Response, render_template_string, request app = Flask(__name__) @app.get("/") def index() -> Response: """ The base service for admin site """ user = request.cookies.get("user", "user") # Currently Work in Progress return render_template_string( f"Sorry {user...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/Microservices_Revenge/gateway/constant.py
ctfs/GreyCatTheFlag/2023/Quals/web/Microservices_Revenge/gateway/constant.py
routes = { "adminpage": "http://radminpage", "homepage": "http://rhomepage", "flagpage": "http://rflagpage/construction", } excluded_headers = [ "content-encoding", "content-length", "transfer-encoding", "connection", ]
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/Microservices_Revenge/gateway/app.py
ctfs/GreyCatTheFlag/2023/Quals/web/Microservices_Revenge/gateway/app.py
from flask import Flask, request, abort, Response from requests import Session from constant import routes, excluded_headers app = Flask(__name__) # Extra protection for my page. banned_chars = { "\\", "_", "'", "%25", "self", "config", "exec", "class", "eval", "get", } def i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/Microservices_Revenge/flag_page/app.py
ctfs/GreyCatTheFlag/2023/Quals/web/Microservices_Revenge/flag_page/app.py
from flask import Flask, Response, jsonify import os app = Flask(__name__) app.secret_key = os.environ.get("SECRET_KEY", os.urandom(512).hex()) FLAG = os.environ.get("FLAG", "greyctf{fake_flag}") @app.route("/") def index() -> Response: """Main page of flag service""" # Users can't see this anyways so there ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/Microservices_Revenge/homepage/app.py
ctfs/GreyCatTheFlag/2023/Quals/web/Microservices_Revenge/homepage/app.py
from flask import Flask, request, render_template, Response, make_response app = Flask(__name__) @app.route("/") def homepage() -> Response: """The homepage for the app""" cookie = request.cookies.get("cookie", "") # Render normal page response = make_response(render_template("index.html", user=cook...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/Baby_Web/adminbot.py
ctfs/GreyCatTheFlag/2023/Quals/web/Baby_Web/adminbot.py
from selenium import webdriver from constants import COOKIE import multiprocessing from webdriver_manager.chrome import ChromeDriverManager options = webdriver.ChromeOptions() options.add_argument("--headless") options.add_argument("--incognito") options.add_argument("--disable-dev-shm-usage") options.add_argument("--...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/Baby_Web/constants.py
ctfs/GreyCatTheFlag/2023/Quals/web/Baby_Web/constants.py
import os FLAG = os.getenv('FLAG', r'grey{fake_flag}') COOKIE = {"flag": FLAG}
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/Baby_Web/server.py
ctfs/GreyCatTheFlag/2023/Quals/web/Baby_Web/server.py
from flask import Flask, request, render_template, redirect, flash from adminbot import visit from urllib.parse import quote app = Flask(__name__) BASE_URL = "http://localhost:5000/" @app.route('/', methods=['GET', 'POST']) def index(): if request.method == "GET": return render_template('index.html') ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/Login_Bot/login/utils.py
ctfs/GreyCatTheFlag/2023/Quals/web/Login_Bot/login/utils.py
from urllib.parse import urlparse, urljoin from flask import request def is_safe_url(target): """Check if the target URL is safe to redirect to. Only works for within Flask request context.""" ref_url = urlparse(request.host_url) test_url = urlparse(urljoin(request.host_url, target)) return test_url.sc...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2023/Quals/web/Login_Bot/login/app.py
ctfs/GreyCatTheFlag/2023/Quals/web/Login_Bot/login/app.py
from flask import Flask, render_template, request, redirect, url_for, flash, Response from flask_sqlalchemy import SQLAlchemy from sqlalchemy import Column, Integer, String import re import os import sys from utils import is_safe_url from os import urandom, getenv import requests ## Constants ## URL_REGEX = r'(https...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2022/crypto/Baby/main.py
ctfs/GreyCatTheFlag/2022/crypto/Baby/main.py
from Crypto.Util.number import getPrime, bytes_to_long FLAG = <REDACTED> p = getPrime(1024); q = getPrime(1024) r = getPrime(4086); s = getPrime(4086) N = p * q e = 0x10001 m = bytes_to_long(FLAG) c = pow(m, e, N) print(c) print(r * p - s * q) print(r) print(s) # c = 87553617160370505937868023687405935058195419850...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2022/crypto/Block/main.py
ctfs/GreyCatTheFlag/2022/crypto/Block/main.py
from Crypto.Util.Padding import pad FLAG = <REDACTED> SUB_KEY = [ 0x11,0x79,0x76,0x8b,0xb8,0x40,0x02,0xec,0x52,0xb5,0x78,0x36,0xf7,0x19,0x55,0x62, 0xaa,0x9a,0x34,0xbb,0xa4,0xfc,0x73,0x26,0x4b,0x21,0x60,0xd2,0x9e,0x10,0x67,0x2c, 0x32,0x17,0x87,0x1d,0x7e,0x57,0xd1,0x48,0x3c,0x1b,0x3f,0x37,0x1c,0x93,0x16,0x2...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2022/crypto/Equation/main.py
ctfs/GreyCatTheFlag/2022/crypto/Equation/main.py
from Crypto.Util.number import bytes_to_long FLAG = <REDACTED> n = len(FLAG) m1 = bytes_to_long(FLAG[:n//2]) m2 = bytes_to_long(FLAG[n//2:]) print(13 * m2 ** 2 + m1 * m2 + 5 * m1 ** 7) print(7 * m2 ** 3 + m1 ** 5) # 13 * m2 ** 2 + m1 * m2 + 5 * m1 ** 7 == 656182162469189571287337732006357039093994663995063565752777...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2022/crypto/Cube/main.py
ctfs/GreyCatTheFlag/2022/crypto/Cube/main.py
from Crypto.Util.number import bytes_to_long, getPrime, isPrime FLAG = <REDACTED> def gen(n): while True: p = getPrime(n - 1) * 2 + 1 if (isPrime(p)): return p def cube(m, n, p): res = m for i in range(n): res = (res * res * res) % p return res p = gen(1024) m = b...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2022/crypto/Catino/main.py
ctfs/GreyCatTheFlag/2022/crypto/Catino/main.py
from secrets import randbits from decimal import Decimal, getcontext FLAG = <REDACTED> ind = 100 randarr = [] maxRound = 5000 winTarget = 100000 winIncr = 1000 getcontext().prec = maxRound + 1000 def prep(): global randarr print("\nGenerating random numbers....", flush=True) n = Decimal(randbits(2048)) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2022/crypto/Permutation/main.py
ctfs/GreyCatTheFlag/2022/crypto/Permutation/main.py
from secrets import randbits from hashlib import shake_256 import random import perm FLAG = <REDACTED> def encrypt(key : str) -> str: otp = shake_256(key.encode()).digest(len(FLAG)) return xor(otp, FLAG).hex() def xor(a : bytes, b : bytes) -> bytes: return bytes([ x ^ y for x, y in zip(a, b)]) n = 5000 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2022/crypto/Permutation/perm.py
ctfs/GreyCatTheFlag/2022/crypto/Permutation/perm.py
class Perm(): def __init__(self, arr): assert self.valid(arr) self.internal = arr self.n = len(arr) def valid(self, arr): x = sorted(arr) n = len(arr) for i in range(n): if (x[i] != i): return False return True def __str__...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2022/crypto/Entry/main.py
ctfs/GreyCatTheFlag/2022/crypto/Entry/main.py
import secrets FLAG = b'grey{...}' assert len(FLAG) == 40 key = secrets.token_bytes(4) def encrypt(m): return bytes([x ^ y for x, y in zip(m,key)]) c = b'' for i in range(0, len(FLAG), 4): c += encrypt(bytes(FLAG[i : i + 4])) print(c.hex()) # 982e47b0840b47a59c334facab3376a19a1b50ac861f43bdbc2e5bb98b3375...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GreyCatTheFlag/2022/web/Quotes/server.py
ctfs/GreyCatTheFlag/2022/web/Quotes/server.py
import random from threading import Thread import os import requests import time from secrets import token_hex from flask import Flask, render_template, make_response, request from flask_sockets import Sockets from gevent import pywsgi from geventwebsocket.handler import WebSocketHandler from selenium.webdriver.firef...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CircleCityCon/2021/pwn/worm_2/instance/build.py
ctfs/CircleCityCon/2021/pwn/worm_2/instance/build.py
import os import random import subprocess import shutil max_depth = int(os.environ["MAX_DEPTH"]) name = lambda i: i % 2 left_index = lambda i: 2 * i + 1 right_index = lambda i: 2 * i + 2 parent = lambda i: (i - 1) // 2 depth = lambda i: (i + 1).bit_length() def build_node(i): d = depth(i) os.chmod(".", 0o55...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CircleCityCon/2021/pwn/worm/instance/build.py
ctfs/CircleCityCon/2021/pwn/worm/instance/build.py
import os import random import subprocess import shutil max_depth = int(os.environ["MAX_DEPTH"]) name = lambda i: i % 2 left_index = lambda i: 2 * i + 1 right_index = lambda i: 2 * i + 2 parent = lambda i: (i - 1) // 2 depth = lambda i: (i + 1).bit_length() def build_node(i): d = depth(i) os.chmod(".", 0o55...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CircleCityCon/2021/rev/Lonk/flag-674073a02c07184baaa6973219490ef3.py
ctfs/CircleCityCon/2021/rev/Lonk/flag-674073a02c07184baaa6973219490ef3.py
from lib import * 覺(非(67)) 覺(要(非(34), 非(33))) 覺(要(放(非(105), 非(58)), 非(20))) 覺(屁(非(3), 非(41))) 覺(然(非(811), 非(234))) 覺(睡(非(3), 非(5), 非(191))) 覺( 放( 然( 屁( 屁( 屁( 屁( 屁( 屁( ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CircleCityCon/2021/rev/Lonk/lib-7f31611a11cc4383f173fae857587a59.py
ctfs/CircleCityCon/2021/rev/Lonk/lib-7f31611a11cc4383f173fae857587a59.py
class 我: def __init__(self, n=None): self.n = n def 非(a): h = 我() c = h while a > 0: c.n = 我() c = c.n a -= 1 return h.n def 常(a): i = 0 while a: i += 1 a = a.n return i def 需(a): h = 我() b = h while a: b.n = 我() ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CircleCityCon/2021/crypto/No_Stone_Left_Unturned/no-stone-left-unturned.py
ctfs/CircleCityCon/2021/crypto/No_Stone_Left_Unturned/no-stone-left-unturned.py
from gmpy2 import next_prime, is_prime import random, os, sys if __name__ == "__main__": random.seed(os.urandom(32)) p = next_prime(random.randrange((1<<1024), (1<<1024) + (1<<600))) pp = (p * 7) // 11 q = next_prime(random.randrange(pp - (1<<520), pp + (1 << 520))) with open(sys.argv[1], "rb") as ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CircleCityCon/2021/crypto/Poison_Prime/server.py
ctfs/CircleCityCon/2021/crypto/Poison_Prime/server.py
import Crypto.Util.number as cun import Crypto.Random.random as crr import Crypto.Util.Padding as cup from Crypto.Cipher import AES import os import hashlib class DiffieHellman: def __init__(self, p: int): self.p = p self.g = 8 self.private_key = crr.getrandbits(128) def public_key(se...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CircleCityCon/2021/crypto/Baby_Meadows/baby-meadows.py
ctfs/CircleCityCon/2021/crypto/Baby_Meadows/baby-meadows.py
from Crypto.Util.number import getStrongPrime import sys, random; random.seed(0x1337) def generate_key(): p = getStrongPrime(2048) q = (p - 1) // 2 for g in range(2, p - 1): if pow(g, 2, p) != 1 and pow(g, q, p) != 1: return g, p def encrypt(msg): g, p = generate_key() yield (...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CircleCityCon/2021/web/Sticky_Notes/apps/web/notes.py
ctfs/CircleCityCon/2021/web/Sticky_Notes/apps/web/notes.py
import socket from socketserver import ThreadingTCPServer, StreamRequestHandler import time from email.utils import formatdate from pathlib import Path import re import os port = 3101 header_template = """HTTP/1.1 {status_code} OK\r Date: {date}\r Content-Length: {content_length}\r Connection: keep-alive\r Content-Ty...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CircleCityCon/2021/web/Sticky_Notes/apps/web/boards.py
ctfs/CircleCityCon/2021/web/Sticky_Notes/apps/web/boards.py
import uvicorn from fastapi import FastAPI, Request, HTTPException from fastapi.staticfiles import StaticFiles from fastapi.responses import FileResponse, RedirectResponse, JSONResponse from slowapi import Limiter, _rate_limit_exceeded_handler from slowapi.util import get_remote_address from slowapi.errors import RateL...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Tenable/2022/crypto/DIY_Crypto/crypt.py
ctfs/Tenable/2022/crypto/DIY_Crypto/crypt.py
# We wrote our own crypto... They won't even know where to begin! import random # AES is supposed to be good? We can steal their sbox then. sbox = ( 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Tenable/2022/crypto/Wifi_Password_of_The_Day/wifi.py
ctfs/Tenable/2022/crypto/Wifi_Password_of_The_Day/wifi.py
import zlib import json from Crypto.Cipher import AES import logging from twisted.internet.protocol import Protocol, Factory from twisted.internet import reactor import base64 # wifi password current_wifi_password = "flag{test_123}" # 128 bit key encryption_key = b'testing123456789' def encrypt_wifi_data(user): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HackersPlayground/2023/misc/pyJail/jail.py
ctfs/HackersPlayground/2023/misc/pyJail/jail.py
import string flag = open("./flag.txt").read() code = input("makeflag> ")[:100] if any(c not in string.printable for c in code): print("🙅") elif "__" in code: print("__nope__") else: if flag == eval(code, {"__builtins__": {}}, {"__builtins__": {}}): print("Oh, you know flag") else: pr...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HackersPlayground/2023/crypto/meaas/montgomery.py
ctfs/HackersPlayground/2023/crypto/meaas/montgomery.py
from math import gcd from functools import reduce from logger import Logger, noLog class Montgomery: def __init__(self, modulus, log=noLog): self.n = modulus self.R = (1 << modulus.bit_length())# % modulus if gcd(self.n, self.R) != 1: raise Exception("[Err] Invalid modulus.") self.np = self.R - pow(self.n,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HackersPlayground/2023/crypto/meaas/logger.py
ctfs/HackersPlayground/2023/crypto/meaas/logger.py
from sys import stdout, stderr class Logger: verbose, info, warning, error, none = 0, 1, 2, 3, 4 def __init__(self, loglevel=0, output=None): if type(output) is str: self.fp = open(output, "w") self.isStrPath = True else: self.fp = output self.isStrPath = False self.loglevel = loglevel def Log(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HackersPlayground/2023/crypto/meaas/app.py
ctfs/HackersPlayground/2023/crypto/meaas/app.py
from flask import Flask, request, render_template, jsonify from tempfile import NamedTemporaryFile from types import SimpleNamespace from os import remove from Crypto.Util.number import getPrime, long_to_bytes from hashlib import sha512 from logger import Logger from montgomery import rsa_crt, modExp import json rsa_k...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HackersPlayground/2023/crypto/RC_four/challenge.py
ctfs/HackersPlayground/2023/crypto/RC_four/challenge.py
from Crypto.Cipher import ARC4 from secret import key, flag from binascii import hexlify #RC4 encrypt function with "key" variable. def encrypt(data): #check the key is long enough assert(len(key) > 128) #make RC4 instance cipher = ARC4.new(key) #We don't use the first 1024 bytes from the key stream. #Actually...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HackersPlayground/2023/crypto/RSA_101/challenge.py
ctfs/HackersPlayground/2023/crypto/RSA_101/challenge.py
from base64 import b64encode, b64decode from Crypto.Util.number import getStrongPrime, bytes_to_long, long_to_bytes from os import system p = getStrongPrime(512) q = getStrongPrime(512) n = p * q e = 65537 d = pow(e, -1, (p - 1) * (q - 1)) print("[RSA parameters]") print("n =", hex(n)) print("e =", hex(e)) def sign(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BlueHens/2021/crypto/aHead_Of_The_curve/secdsa.py
ctfs/BlueHens/2021/crypto/aHead_Of_The_curve/secdsa.py
#Elliptic curve basics, tools for finding rational points, and ECDSA implementation. #Brendan Cordy, 2015 from fractions import Fraction from math import ceil, sqrt from random import SystemRandom, randrange from hashlib import sha256 from time import time import pyotp import datetime #Affine Point (+Infinity) on an ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BlueHens/2021/crypto/hot_diggity_dog_2/unbreakable.py
ctfs/BlueHens/2021/crypto/hot_diggity_dog_2/unbreakable.py
from Crypto.Util.number import * from os import urandom from gmpy2 import iroot def getKey(): e = 3 t = 3 N = 3 while not GCD(e,t) == 1 or (inverse(e,t)**4)*3 < N or inverse(e,t) < iroot(N,3)[0]: p = getStrongPrime(1024) q = getStrongPrime(1024) N = p*q t = (p-1)*(q-1) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BlueHens/2021/crypto/hot_diggity_dog/hot_diggity_dog.py
ctfs/BlueHens/2021/crypto/hot_diggity_dog/hot_diggity_dog.py
from Crypto.Util.number import * from os import urandom def getKey(): e = 3 t = 3 while not GCD(e,t) == 1: p = getStrongPrime(1024) q = getStrongPrime(1024) N = p*q t = (p-1)*(q-1) e = bytes_to_long(urandom(256)) return N,e def encrypt(pt,N,e): try: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BlueHens/2023/misc/Python_Jail/chall.py
ctfs/BlueHens/2023/misc/Python_Jail/chall.py
#!/usr/bin/env python blacklist = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" security_check = lambda s: any(c in blacklist for c in s) and s.count('_') < 50 def main(): while True: cmds = input("> ") if security_check(cmds): print("nope.") else: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BlueHens/2023/misc/Defective_Client/graph.py
ctfs/BlueHens/2023/misc/Defective_Client/graph.py
import typing import json import functools from random import SystemRandom import itertools import base64 class UndirectedAdjacencyMatrix(): matrix: typing.Tuple[typing.Tuple[int, ...], ...] _len: int = 0 @classmethod def from_compressed(cls, vertices: int, compressed: typing.Tuple[bool, ...])->"Undire...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BlueHens/2023/misc/Defective_Client/alice.py
ctfs/BlueHens/2023/misc/Defective_Client/alice.py
from graph import * import json with open("private_key.json","r") as f: key = json.loads(f.read()) G0 = Graph.from_dict(key["base"]) d = Isomorphism.loads(G0,key["transformation"]) G1 = G0.map_vertices(d) print(G0.dumps()) print(G1.dumps()) G2 = Graph.loads(input().strip()) i = Isomorphism.loads(G2,input().str...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BlueHens/2023/misc/Defective_Client/gen_key.py
ctfs/BlueHens/2023/misc/Defective_Client/gen_key.py
from graph import * import json G0 = random_graph(128,256) i = random_isomorphism(G0) while G0.is_automorphism(i): G0 = random_graph(128,256) i = random_isomorphism(G0) with open("private_key.json","w") as f: f.write(json.dumps({ "base": G0.to_dict(), "transformation": str(i) })) G...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BlueHens/2023/misc/Defective_Client/server.py
ctfs/BlueHens/2023/misc/Defective_Client/server.py
import json from graph import Graph, Isomorphism import typing import os ROUNDS = 16 with open("public_key.json",'r') as f: key = list(map(Graph.from_dict,json.load(f))) with open("flag.txt",'r') as f: flag = f.read() def authenticate(key: typing.List[Graph]): Graphs = [Graph.from_dict(json.loads(input(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BlueHens/2023/misc/Defective_Server/server.py
ctfs/BlueHens/2023/misc/Defective_Server/server.py
import enum import json CHALLENGES = [1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BlueHens/2023/misc/Forest_For_The_Trees/graph.py
ctfs/BlueHens/2023/misc/Forest_For_The_Trees/graph.py
import typing import json import functools from random import SystemRandom import itertools import base64 class UndirectedAdjacencyMatrix(): matrix: typing.List[typing.List[int]] @classmethod def from_compressed(cls, vertices: int, compressed: typing.List[bool])->"UndirectedAdjacencyMatrix": matrix...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BlueHens/2023/misc/Forest_For_The_Trees/gen_key.py
ctfs/BlueHens/2023/misc/Forest_For_The_Trees/gen_key.py
import graph import json import random RAND = random.SystemRandom() def generate_tree(depth: int, root, vertices, edges): if depth == 0: return else: size = RAND.randint(0,4) if size > len(vertices): return children = random.sample(list(vertices),size) for c...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false