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/WannaGameChampionship/2023/crypto/Council_of_Sheep/server.py
ctfs/WannaGameChampionship/2023/crypto/Council_of_Sheep/server.py
from random import shuffle from random import randint FLAG = open("./flag", "rb").read() flagbanner = f''' || || .,,;;;;;;,,.. ||.;;;;;;*;;;;;;;*;;, ..,,;;;;;;%%%%%, ||';*;;;;;;;;*;;;;;;,::*::;;;*;;%%%%%%>>%%%%%, .; || ';;;;;*;;;;;;;;*;;,:::::*;;;;;@@@##>>%%%%%%, ..,,;%%%%' || ;*;;;;;;...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/main.py
ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/main.py
from typing import Generator from rpcpy import RPC from typing_extensions import TypedDict app = RPC() @app.register def none() -> None: return @app.register def sayhi(name: str) -> str: return f"Hello {name} from Bocchi the Rock!" @app.register def yield_data(max_num: int) -> Generator[int, None, None]...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/rpcpy/client.py
ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/rpcpy/client.py
from __future__ import annotations import functools import inspect import typing from base64 import b64decode import httpx from rpcpy.exceptions import RemoteCallError from rpcpy.openapi import validate_arguments from rpcpy.serializers import BaseSerializer, JSONSerializer, get_serializer if typing.TYPE_CHECKING: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/rpcpy/application.py
ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/rpcpy/application.py
from __future__ import annotations import copy import os import inspect import json import sys import typing from base64 import b64encode from collections.abc import AsyncGenerator, Generator if sys.version_info[:2] < (3, 8): from typing_extensions import Literal, TypedDict else: from typing import Literal, T...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/rpcpy/serializers.py
ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/rpcpy/serializers.py
import json import os import pickle import subprocess import typing from abc import ABCMeta, abstractmethod import jsonpickle try: import msgpack except ImportError: # pragma: no cover msgpack = None # type: ignore try: import cbor2 as cbor except ImportError: # pragma: no cover cbor = None # typ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/rpcpy/exceptions.py
ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/rpcpy/exceptions.py
from __future__ import annotations from baize.exceptions import HTTPException class SerializerNotFound(Exception): """ Serializer not found """ class CallbackError(HTTPException[str]): """ Callback error """ class RemoteCallError(Exception): """ Remote call error """
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/rpcpy/__init__.py
ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/rpcpy/__init__.py
from .application import RPC __all__ = ["RPC"]
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/rpcpy/__version__.py
ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/rpcpy/__version__.py
VERSION = (0, 6, 0) __version__ = ".".join(map(str, VERSION))
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/rpcpy/openapi.py
ctfs/WannaGameChampionship/2023/web/Bocchi_The_RPC_Server/src/rpcpy/openapi.py
from __future__ import annotations import functools import inspect import typing import warnings __all__ = [ "create_model", "validate_arguments", "set_type_model", "is_typed_dict_type", "parse_typed_dict", "TEMPLATE", ] Callable = typing.TypeVar("Callable", bound=typing.Callable) try: f...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WannaGameChampionship/2023/web/Counting_Stars_2/src/database.py
ctfs/WannaGameChampionship/2023/web/Counting_Stars_2/src/database.py
from pymongo import MongoClient client = MongoClient("mongo", 27017, username="root", password="123456", serverSelectionTimeoutMS=5000) db = client["db"] User = db["users"] User.create_index("username", unique=True)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WannaGameChampionship/2023/web/Counting_Stars_2/src/app.py
ctfs/WannaGameChampionship/2023/web/Counting_Stars_2/src/app.py
import re import secrets import bcrypt from flask import Flask, request, render_template, session, redirect, url_for from pymongo.errors import DuplicateKeyError from database import User import shutil import os import subprocess import numpy as np from tensorflow.keras.models import load_model import time import glob ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WannaGameChampionship/2023/web/Counting_Stars/src/database.py
ctfs/WannaGameChampionship/2023/web/Counting_Stars/src/database.py
from pymongo import MongoClient client = MongoClient("mongo", 27017, username="root", password="123456", serverSelectionTimeoutMS=5000) db = client["db"] User = db["users"] User.create_index("username", unique=True)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WannaGameChampionship/2023/web/Counting_Stars/src/app.py
ctfs/WannaGameChampionship/2023/web/Counting_Stars/src/app.py
import re import secrets import bcrypt from flask import Flask, request, render_template, session, redirect, url_for from pymongo.errors import DuplicateKeyError from database import User import shutil import os import subprocess import numpy as np from tensorflow.keras.models import load_model import time import glob ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WannaGameChampionship/2025/crypto/Linear_101/chall.py
ctfs/WannaGameChampionship/2025/crypto/Linear_101/chall.py
import random import os n = 128 random.seed("Wanna Win?") def encrypt(A, x): b = [0] * n for i in range(n): for j in range(n): b[i] = max(b[i], A[i][j] + x[j]) return b def game(): for round in range(64): try: print(f"Round {round+1}/64") A = [rando...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WannaGameChampionship/2025/crypto/Clair_Obscur/chall.py
ctfs/WannaGameChampionship/2025/crypto/Clair_Obscur/chall.py
from sage.all import * from Crypto.Util.number import bytes_to_long class CO: def __init__(self, p: int, G: list[int], O: list[int]): assert is_prime(p) assert p.bit_length() == 256 self.Fp = GF(p) self.G = [self.Fp(c) for c in G] self.O = [self.Fp(c) for c in O] ass...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FacebookCTF/2019/kpets/pow.py
ctfs/FacebookCTF/2019/kpets/pow.py
#!/usr/bin/env python import sys import string import random import md5 import re alpha = string.lowercase + string.uppercase + string.digits def rand_string(length): return ''.join([random.choice(alpha) for _ in range(length)]) def check(inp, prefix): if not re.match('^[a-zA-Z0-9]+$', inp): return F...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KillerQueen/2021/pwn/Hammer_To_Fall/hammertofall.py
ctfs/KillerQueen/2021/pwn/Hammer_To_Fall/hammertofall.py
import numpy as np a = np.array([0], dtype=int) val = int(input("This hammer hits so hard it creates negative matter\n")) if val == -1: exit() a[0] = val a[0] = (a[0] * 7) + 1 print(a[0]) if a[0] == -1: print("flag!")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KillerQueen/2021/pwn/I_want_to_break_free/jail.py
ctfs/KillerQueen/2021/pwn/I_want_to_break_free/jail.py
#!/usr/bin/env python3 def server(): message = """ You are in jail. Can you escape? """ print(message) while True: try: data = input("> ") safe = True for char in data: if not (ord(char)>=33 and ord(char)<=126): safe = Fals...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2021/jail/baby_python_fixed/challenge.py
ctfs/UIUCTF/2021/jail/baby_python_fixed/challenge.py
import re bad = bool(re.search(r'[a-z\s]', (input := input()))) exec(input) if not bad else print('Input contained bad characters') exit(bad)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2021/jail/baby_python/challenge.py
ctfs/UIUCTF/2021/jail/baby_python/challenge.py
import re bad = bool(re.search(r'[^a-z\s]', (input := input()))) exec(input) if not bad else print('Input contained bad characters') exit(bad)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2021/crypto/pow_erful/pow_erful.py
ctfs/UIUCTF/2021/crypto/pow_erful/pow_erful.py
import os import secrets import hashlib # 2^64 = a lot of hashes, gpu go brr FLAG_DIFFICULTY = 64 def main(): for difficulty in range(1, FLAG_DIFFICULTY): print("You are on: Level", difficulty, "/", FLAG_DIFFICULTY) print("Please complete this Proof of Work to advance to the next level") p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2021/crypto/dhke_intro/dhkectf_intro.py
ctfs/UIUCTF/2021/crypto/dhke_intro/dhkectf_intro.py
import random from Crypto.Cipher import AES # generate key gpList = [ [13, 19], [7, 17], [3, 31], [13, 19], [17, 23], [2, 29] ] g, p = random.choice(gpList) a = random.randint(1, p) b = random.randint(1, p) k = pow(g, a * b, p) k = str(k) # print("Diffie-Hellman key exchange outputs") # print("Public key: ", g, p) # ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2021/crypto/dhke_adventure/dhke_adventure.py
ctfs/UIUCTF/2021/crypto/dhke_adventure/dhke_adventure.py
from random import randint from Crypto.Util.number import isPrime from Crypto.Cipher import AES from hashlib import sha256 print("I'm too lazy to find parameters for my DHKE, choose for me.") print("Enter prime at least 1024 at most 2048 bits: ") # get user's choice of p p = input() p = int(p) # check prime valid if p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2021/crypto/back_to_basics/main.py
ctfs/UIUCTF/2021/crypto/back_to_basics/main.py
from Crypto.Util.number import long_to_bytes, bytes_to_long from gmpy2 import mpz, to_binary #from secret import flag, key ALPHABET = bytearray(b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ#") def base_n_encode(bytes_in, base): return mpz(bytes_to_long(bytes_in)).digits(base).upper().encode() def base_n_decode(bytes_in, b...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2021/web/ponydb/ponydb.py
ctfs/UIUCTF/2021/web/ponydb/ponydb.py
from flask import Flask, render_template, session, request, redirect, flash import mysql.connector import secrets import time import json import os app = Flask(__name__) app.secret_key = os.environ['SECRET_KEY'] flag = os.environ['FLAG'] config = { 'host': os.environ['DB_HOST'], 'user': os.environ['DB_USER'], 'pa...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2021/web/miniaturehorsedb/ponydb.py
ctfs/UIUCTF/2021/web/miniaturehorsedb/ponydb.py
from flask import Flask, render_template, session, request, redirect, flash import mysql.connector import secrets import time import json import os app = Flask(__name__) app.secret_key = os.environ['SECRET_KEY'] flag = os.environ['FLAG'] config = { 'host': os.environ['DB_HOST'], 'user': os.environ['DB_USER'], 'pa...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2024/misc/Slot_Machine/chal.py
ctfs/UIUCTF/2024/misc/Slot_Machine/chal.py
from hashlib import sha256 hex_alpha = "0123456789abcdef" print("== Welcome to the onboard slot machine! ==") print("If all the slots match, you win!") print("We believe in skill over luck, so you can choose the number of slots.") print("We'll even let you pick your lucky number (little endian)!") lucky_number = inp...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2024/misc/Push_and_Pickle/chal_redacted.py
ctfs/UIUCTF/2024/misc/Push_and_Pickle/chal_redacted.py
import pickle import base64 import sys import pickletools def check_flag(flag_guess: str): """REDACTED FOR PRIVACY""" cucumber = base64.b64decode(input("Give me your best pickle (base64 encoded) to taste! ")) for opcode, _, _ in pickletools.genops(cucumber): if opcode.code == "c" or opcode.code == "\x93": pr...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2024/misc/Astea/chal.py
ctfs/UIUCTF/2024/misc/Astea/chal.py
import ast def safe_import(): print("Why do you need imports to make tea?") def safe_call(): print("Why do you need function calls to make tea?") class CoolDownTea(ast.NodeTransformer): def visit_Call(self, node: ast.Call) -> ast.AST: return ast.Call(func=ast.Name(id='safe_call', ctx=ast.Load()), args=[], ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2024/crypto/Without_a_Trace/server.py
ctfs/UIUCTF/2024/crypto/Without_a_Trace/server.py
import numpy as np from Crypto.Util.number import bytes_to_long from itertools import permutations from SECRET import FLAG def inputs(): print("[WAT] Define diag(u1, u2, u3. u4, u5)") M = [ [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2024/crypto/Snore_Signatures/chal.py
ctfs/UIUCTF/2024/crypto/Snore_Signatures/chal.py
#!/usr/bin/env python3 from Crypto.Util.number import isPrime, getPrime, long_to_bytes, bytes_to_long from Crypto.Random.random import getrandbits, randint from Crypto.Hash import SHA512 LOOP_LIMIT = 2000 def hash(val, bits=1024): output = 0 for i in range((bits//512) + 1): h = SHA512.new() ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2024/crypto/Groups/challenge.py
ctfs/UIUCTF/2024/crypto/Groups/challenge.py
from random import randint from math import gcd, log import time from Crypto.Util.number import * def check(n, iterations=50): if isPrime(n): return False i = 0 while i < iterations: a = randint(2, n - 1) if gcd(a, n) == 1: i += 1 if pow(a, n - 1, n) != 1: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2024/crypto/Determined/gen.py
ctfs/UIUCTF/2024/crypto/Determined/gen.py
from SECRET import FLAG, p, q, r from Crypto.Util.number import bytes_to_long n = p * q e = 65535 m = bytes_to_long(FLAG) c = pow(m, e, n) # printed to gen.txt print(f"{n = }") print(f"{e = }") print(f"{c = }")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2024/crypto/Determined/server.py
ctfs/UIUCTF/2024/crypto/Determined/server.py
from Crypto.Util.number import bytes_to_long, long_to_bytes from itertools import permutations from SECRET import FLAG, p, q, r def inputs(): print("[DET] First things first, gimme some numbers:") M = [ [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2024/crypto/Key_in_a_Haystack/chal.py
ctfs/UIUCTF/2024/crypto/Key_in_a_Haystack/chal.py
from Crypto.Util.number import getPrime from Crypto.Util.Padding import pad from Crypto.Cipher import AES from hashlib import md5 from math import prod import sys from secret import flag key = getPrime(40) haystack = [ getPrime(1024) for _ in range(300) ] key_in_haystack = key * prod(haystack) enc_flag = AES.new( ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2024/crypto/X_Marked_the_Spot/public.py
ctfs/UIUCTF/2024/crypto/X_Marked_the_Spot/public.py
from itertools import cycle flag = b"uiuctf{????????????????????????????????????????}" # len(flag) = 48 key = b"????????" # len(key) = 8 ct = bytes(x ^ y for x, y in zip(flag, cycle(key))) with open("ct", "wb") as ct_file: ct_file.write(ct)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2023/misc/Schrodingers_Cat/server.py
ctfs/UIUCTF/2023/misc/Schrodingers_Cat/server.py
#!/usr/bin/env python3 from os import system from base64 import b64decode import numpy as np from qiskit import QuantumCircuit import qiskit.quantum_info as qi from qiskit.circuit.library import StatePreparation WIRES = 5 def normalization(msg): assert(len(msg) <= WIRES**2) state = np.array([ord(c) for c i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2023/pwn/Rattler_Read/main.py
ctfs/UIUCTF/2023/pwn/Rattler_Read/main.py
from RestrictedPython import compile_restricted from RestrictedPython import Eval from RestrictedPython import Guards from RestrictedPython import safe_globals from RestrictedPython import utility_builtins from RestrictedPython.PrintCollector import PrintCollector def exec_poisonous(code): """Makes sure your code ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2023/rev/pwnykey/app.py
ctfs/UIUCTF/2023/rev/pwnykey/app.py
#!/usr/bin/env python3 from flask import Flask, request import threading import subprocess import re app = Flask(__name__) FLAG = open('flag.txt').read() lock = threading.Lock() @app.route('/') def index(): return app.send_static_file('index.html') key_to_check = "00000-00000-00000-00000-00000" key_format = re.c...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2023/crypto/At_Home/chal.py
ctfs/UIUCTF/2023/crypto/At_Home/chal.py
from Crypto.Util.number import getRandomNBitInteger flag = int.from_bytes(b"uiuctf{******************}", "big") a = getRandomNBitInteger(256) b = getRandomNBitInteger(256) a_ = getRandomNBitInteger(256) b_ = getRandomNBitInteger(256) M = a * b - 1 e = a_ * M + a d = b_ * M + b n = (e * d - 1) // M c = (flag * e) %...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2023/crypto/Morphing_Time/chal.py
ctfs/UIUCTF/2023/crypto/Morphing_Time/chal.py
#!/usr/bin/env python3 from Crypto.Util.number import getPrime from random import randint with open("/flag", "rb") as f: flag = int.from_bytes(f.read().strip(), "big") def setup(): # Get group prime + generator p = getPrime(512) g = 2 return g, p def key(g, p): # generate key info a = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2023/crypto/Group_Project/chal.py
ctfs/UIUCTF/2023/crypto/Group_Project/chal.py
from Crypto.Util.number import getPrime, long_to_bytes from random import randint import hashlib from Crypto.Cipher import AES from Crypto.Util.Padding import pad with open("/flag", "rb") as f: flag = f.read().strip() def main(): print("[$] Did no one ever tell you to mind your own business??") g, p = 2...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2023/crypto/Group_Projection/chal.py
ctfs/UIUCTF/2023/crypto/Group_Projection/chal.py
from Crypto.Util.number import getPrime, long_to_bytes from random import randint import hashlib from Crypto.Cipher import AES from Crypto.Util.Padding import pad with open("/flag", "rb") as f: flag = f.read().strip() def main(): print("[$] Did no one ever tell you to mind your own business??") g, p = 2...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2023/crypto/crack_the_safe/chal.py
ctfs/UIUCTF/2023/crypto/crack_the_safe/chal.py
from Crypto.Cipher import AES from secret import key, FLAG p = 4170887899225220949299992515778389605737976266979828742347 ct = bytes.fromhex("ae7d2e82a804a5a2dcbc5d5622c94b3e14f8c5a752a51326e42cda6d8efa4696") def crack_safe(key): return pow(7, int.from_bytes(key, 'big'), p) == 0x49545b7d5204bd639e299bc265ca987fb4...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2025/misc/Comments_Only/main.py
ctfs/UIUCTF/2025/misc/Comments_Only/main.py
#!/usr/bin/env python3 import tempfile import subprocess import os comment = input("> ").replace("\n", "").replace("\r", "") code = f"""print("hello world!") # This is a comment. Here's another: # {comment} print("Thanks for playing!")""" with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2025/crypto/back_to_roots/chal.py
ctfs/UIUCTF/2025/crypto/back_to_roots/chal.py
from random import randint from decimal import Decimal, getcontext from hashlib import md5 from Crypto.Cipher import AES from Crypto.Util.Padding import pad from secret import FLAG K = randint(10**10, 10**11) print('K', K) leak = int( str( Decimal(K).sqrt() ).split('.')[-1] ) print(f"leak = {leak}") ct = AES.new( ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2025/crypto/too_many_primes/chal.py
ctfs/UIUCTF/2025/crypto/too_many_primes/chal.py
from sympy import nextprime, randprime from sympy.core.random import seed from math import prod, gcd from Crypto.Util.number import bytes_to_long # from secret import phi_N, FLAG p = randprime(2**127, 2**128) N = 1 while N < 2**2048: N *= p p = nextprime(p) assert gcd(phi_N, 65537) == 1 pt = bytes_to_long(FLAG) ct...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2025/crypto/symmetric/chal.py
ctfs/UIUCTF/2025/crypto/symmetric/chal.py
from Crypto.Util.number import * from secret import FLAG p, q, r, s = [getPrime(512) for _ in "1234"] print(f"h1 = {p + q + r + s}") print(f"h2 = {p**2 + q**2 + r**2 + s**2}") print(f"h3 = {p**3 + q**3 + r**3 + s**3}") N = p*q*r*s print(f"N = {N}") pt = bytes_to_long(FLAG) ct = pow(pt, 65537, N) print(f"ct = {ct}") ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2025/crypto/the_shortest_crypto_chal/chal.py
ctfs/UIUCTF/2025/crypto/the_shortest_crypto_chal/chal.py
from Crypto.Cipher import AES from hashlib import md5 from secret import a,b,c,d, FLAG assert a**4 + b**4 == c**4 + d**4 + 17 and max(a,b,c,d) < 2e4 and AES.new( f"{a*b*c*d}".zfill(16).encode() , AES.MODE_ECB).encrypt(FLAG).hex() == "41593455378fed8c3bd344827a193bde7ec2044a3f7a3ca6fb77448e9de55155"
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2022/jail/AHorseWithNoNames/desert.py
ctfs/UIUCTF/2022/jail/AHorseWithNoNames/desert.py
#!/usr/bin/python3 import re import random horse = input("Begin your journey: ") if re.match(r"[a-zA-Z]{4}", horse): print("It has begun raining, so you return home.") elif len(set(re.findall(r"[\W]", horse))) > 4: print(set(re.findall(r"[\W]", horse))) print("A single horse cannot bear the weight of all th...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2022/jail/AHorseWithNoNeighs/desert.py
ctfs/UIUCTF/2022/jail/AHorseWithNoNeighs/desert.py
#!/usr/bin/python3 import re import random horse = input("Begin your journey: ") if re.search(r"[a-zA-Z]{4}", horse): print("It has begun raining, so you return home.") elif len(set(re.findall(r"[\W]", horse))) > 4: print(set(re.findall(r"[\W]", horse))) print("A dead horse cannot bear the weight of all tho...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2022/jail/safepy/main.py
ctfs/UIUCTF/2022/jail/safepy/main.py
from sympy import * def parse(expr): # learned from our mistake... let's be safe now # https://stackoverflow.com/questions/33606667/from-string-to-sympy-expression # return sympify(expr) # https://docs.sympy.org/latest/modules/parsing.html return parse_expr(expr) print('Welcome to the derivativ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2022/crypto/That-crete_Log/server.py
ctfs/UIUCTF/2022/crypto/That-crete_Log/server.py
from Crypto.Util.number import bytes_to_long from random import randrange from secret import FLAG from signal import alarm def miller_rabin(bases, n): if n == 2 or n == 3: return True r, s = 0, n - 1 while s % 2 == 0: r += 1 s //= 2 for b in bases: x = pow(b, s, n)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2022/crypto/MilitaryGradeEncryption/cipher.py
ctfs/UIUCTF/2022/crypto/MilitaryGradeEncryption/cipher.py
from Crypto.Cipher import AES from Crypto.Util.number import bytes_to_long, long_to_bytes from Crypto.Util.Padding import pad from hashlib import md5 from base64 import b64encode from itertools import cycle MD5 = lambda s: md5(s).digest() KEY_PAD = lambda key: b"\x00" * (16 - len(key)) + key def custom_encrypt(data...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2022/crypto/MilitaryGradeEncryption/app.py
ctfs/UIUCTF/2022/crypto/MilitaryGradeEncryption/app.py
from flask import Flask, render_template, request from cipher import custom_encrypt app = Flask(__name__) @app.route("/", methods = ["get"]) def home_page(): return render_template("home.html") @app.route("/encrypt", methods = ["get", "post"]) def encrypt(): if request.method == "POST": user_data = d...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2022/crypto/WringingRings/server.py
ctfs/UIUCTF/2022/crypto/WringingRings/server.py
import sympy as sp import random import signal from secret import FLAG secret = random.SystemRandom().randint(1, 500_000) _MAX = 10 ** (len(str(secret)) - 1) # generating a polynomial def _f(secret, minimum=3): coeffs = [secret] + [ random.SystemRandom().randint(1, _MAX) for _ in range(minimum - 1) ]...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2022/crypto/asr/chall.py
ctfs/UIUCTF/2022/crypto/asr/chall.py
from secret import flag from Crypto.Util.number import bytes_to_long, getPrime, isPrime from math import prod small_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37] def gen_prime(bits, lim = 7, sz = 64): while True: p = prod([getPrime(sz) for _ in range(bits//sz)]) for i in range(lim): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2022/crypto/mom_can_we_have_AES/client.py
ctfs/UIUCTF/2022/crypto/mom_can_we_have_AES/client.py
from Crypto.Util.Padding import pad from Crypto.PublicKey import RSA from Crypto.Cipher import AES, PKCS1_OAEP from Crypto.Hash import SHA256 from Crypto.Signature import PKCS1_v1_5 import random import string from fields import cert, block_size from secret import flag cipher_suite = {"AES.MODE_CBC": AES.MODE_CBC, "...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2022/crypto/mom_can_we_have_AES/server.py
ctfs/UIUCTF/2022/crypto/mom_can_we_have_AES/server.py
from Crypto.Util.Padding import pad, unpad from Crypto.PublicKey import RSA from Crypto.Cipher import AES, PKCS1_OAEP from Crypto.Hash import SHA256 from Crypto.Signature import PKCS1_v1_5 import random import string from fields import cert, block_size from secret import flag cipher_suite = {"AES.MODE_CBC" : AES.MOD...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2022/crypto/EllipticClockCrypto/ecc.py
ctfs/UIUCTF/2022/crypto/EllipticClockCrypto/ecc.py
# Code inspired by https://ecchacks.cr.yp.to/clockcrypto.py from random import seed, randrange from hashlib import md5 from Crypto.Cipher import AES from secret import FLAG # 256-bit security! p = 62471552838526783778491264313097878073079117790686615043492079411583156507853 class Fp: def __init__(self,x): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2022/web/modernism/app.py
ctfs/UIUCTF/2022/web/modernism/app.py
from flask import Flask, Response, request app = Flask(__name__) @app.route('/') def index(): prefix = bytes.fromhex(request.args.get("p", default="", type=str)) flag = request.cookies.get("FLAG", default="uiuctf{FAKEFLAG}").encode() #^uiuctf{[A-Za-z]+}$ return Response(prefix+flag, mimetype="text/plain")...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2022/web/precisionism/app.py
ctfs/UIUCTF/2022/web/precisionism/app.py
from flask import Flask, Response, request app = Flask(__name__) @app.route('/') def index(): prefix = bytes.fromhex(request.args.get("p", default="", type=str)) flag = request.cookies.get("FLAG", default="uiuctf{FAKEFLAG}").encode() #^uiuctf{[0-9A-Za-z]{8}}$ return Response(prefix+flag+b"Enjoy your flag!...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UIUCTF/2020/MuJS/run-remote.py
ctfs/UIUCTF/2020/MuJS/run-remote.py
#!/usr/bin/env python3 import requests import json import pprint import sys if len(sys.argv) != 2: print("Usage: %s [script.js]" % sys.argv[0]) sys.exit(1) script_path = sys.argv[1] url = 'https://mujs.chal.uiuc.tf/go' myobj = {'script': open(script_path).read()} results = json.loads(requests.post(url, dat...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/misc/safebox_pro/safebox.py
ctfs/TPCTF/2023/misc/safebox_pro/safebox.py
from Crypto.Cipher import ChaCha20 from hashlib import sha256 from itertools import cycle from pathlib import Path import os from secret import flag CHACHA20_KEY = b'3gn8C5j9PedPqf2tKANb91c5k5cxXx2n' SBOX = b'\x1b\x8e6\xa5\xd2+\xad\'S]\x16\xa8e\xa6G\xe44,\xb9\xe2m/&\xbe\xce\x1fR\xf3\x14\xcal\x9fH\xee\xe3\x11\xdb\xe...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/misc/safebox/safebox.py
ctfs/TPCTF/2023/misc/safebox/safebox.py
from Crypto.Cipher import ChaCha20 from hashlib import sha256 from itertools import cycle from pathlib import Path import os from secret import flag CHACHA20_KEY = b'3gn8C5j9PedPqf2tKANb91c5k5cxXx2n' CONTENT_SIZE = 32 IV_SIZE = 12 BLOCK_SIZE = CONTENT_SIZE + IV_SIZE def encrypt_block(data, key, key2): iv = os...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/crypto/matrix/matrix.py
ctfs/TPCTF/2023/crypto/matrix/matrix.py
import numpy as np matrices=[[[16, 55, 40], [0, -39, -40], [0, 55, 56]], [[13, 41, 29], [3, -25, -29], [-3, 41, 45]], [[7, 13, 7], [9, 3, -7], [-9, 13, 23]], [[1, -15, -15], [15, 31, 15], [-15, -15, 1]], [[217, 728, 512], [39, -472, -512], [-39, 728, 768]], [[9341, 41833, 32493], [21635, 96663, 75027], [-29315, -13096...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/crypto/sort_teaser/sort-teaser.py
ctfs/TPCTF/2023/crypto/sort_teaser/sort-teaser.py
import re from Crypto.Util.number import bytes_to_long import random letters=set(bytes(range(65,91)).decode()) class Command: def __init__(self, target_var, op, l, r=0): self.target_var = target_var self.op = op self.l = l if l in letters else int(l) self.r = r if r in letters else ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/crypto/nanoOTP/nanoOTP.py
ctfs/TPCTF/2023/crypto/nanoOTP/nanoOTP.py
import os import random import secrets import tempfile from pathlib import Path from secret import flag TEMP_DIR = Path(tempfile.mkdtemp()) import string from hashlib import sha256 def proof_of_work(): s = ''.join([secrets.choice(string.digits + string.ascii_letters) for _ in range(20)]) pr...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/crypto/blurred_memory/blurred_memory.py
ctfs/TPCTF/2023/crypto/blurred_memory/blurred_memory.py
from secret import flag assert flag[:6] == 'TPCTF{' and flag[-1] == '}' flag = flag[6:-1] assert len(set(flag)) == len(flag) xs = [] for i, c in enumerate(flag): xs += [ord(c)] * (i + 1) p = 257 print('output =', [sum(pow(x, k, p) for x in xs) % p for k in range(1, len(xs) + 1)])
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/crypto/sort_level_1/sort.py
ctfs/TPCTF/2023/crypto/sort_level_1/sort.py
import re from Crypto.Util.number import bytes_to_long import random letters=set(bytes(range(65,91)).decode()) class Command: def __init__(self, target_var, op, l, r=0): self.target_var = target_var self.op = op self.l = l if l in letters else int(l) self.r = r if r in letters else ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/crypto/sort_level_2/sort.py
ctfs/TPCTF/2023/crypto/sort_level_2/sort.py
import re from Crypto.Util.number import bytes_to_long import random letters=set(bytes(range(65,91)).decode()) class Command: def __init__(self, target_var, op, l, r=0): self.target_var = target_var self.op = op self.l = l if l in letters else int(l) self.r = r if r in letters else ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/ezsqli/manage.py
ctfs/TPCTF/2023/web/ezsqli/manage.py
#!/usr/bin/env python """Django's command-line utility for administrative tasks.""" import os import sys def main(): """Run administrative tasks.""" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ezsqli.settings') try: from django.core.management import execute_from_command_line except Impor...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/ezsqli/ezsqli/asgi.py
ctfs/TPCTF/2023/web/ezsqli/ezsqli/asgi.py
""" ASGI config for ezsqli project. It exposes the ASGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ """ import os from django.core.asgi import get_asgi_application os.environ.setdefault('DJANGO_SETTIN...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/ezsqli/ezsqli/settings.py
ctfs/TPCTF/2023/web/ezsqli/ezsqli/settings.py
""" Django settings for ezsqli project. Generated by 'django-admin startproject' using Django 4.2.7. For more information on this file, see https://docs.djangoproject.com/en/4.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.2/ref/settings/ """ from pathlib ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/ezsqli/ezsqli/__init__.py
ctfs/TPCTF/2023/web/ezsqli/ezsqli/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/ezsqli/ezsqli/wsgi.py
ctfs/TPCTF/2023/web/ezsqli/ezsqli/wsgi.py
""" WSGI config for ezsqli project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTIN...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/ezsqli/ezsqli/urls.py
ctfs/TPCTF/2023/web/ezsqli/ezsqli/urls.py
""" URL configuration for ezsqli project. The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/4.2/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home'...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/ezsqli/blog/views.py
ctfs/TPCTF/2023/web/ezsqli/blog/views.py
from django.shortcuts import render from django.db import connection # Create your views here. from django.http import HttpResponse,HttpRequest from .models import AdminUser,Blog,QueryHelper def index(request:HttpRequest): return HttpResponse('Welcome to TPCTF') def debug(request:HttpRequest): if request.met...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/ezsqli/blog/admin.py
ctfs/TPCTF/2023/web/ezsqli/blog/admin.py
from django.contrib import admin # Register your models here. from .models import AdminUser,Blog admin.site.register(AdminUser) admin.site.register(Blog)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/ezsqli/blog/models.py
ctfs/TPCTF/2023/web/ezsqli/blog/models.py
from django.db import models from django.db import connection class AdminUser(models.Model): username = models.CharField(max_length=20) password = models.CharField(max_length=20) class Blog(models.Model): id = models.IntegerField(primary_key=True) title = models.CharField(max_length=20) content = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/ezsqli/blog/__init__.py
ctfs/TPCTF/2023/web/ezsqli/blog/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/ezsqli/blog/tests.py
ctfs/TPCTF/2023/web/ezsqli/blog/tests.py
from django.test import TestCase # Create your tests here.
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/ezsqli/blog/apps.py
ctfs/TPCTF/2023/web/ezsqli/blog/apps.py
from django.apps import AppConfig class BlogConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'blog'
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/ezsqli/blog/migrations/0001_initial.py
ctfs/TPCTF/2023/web/ezsqli/blog/migrations/0001_initial.py
# Generated by Django 4.2.7 on 2023-11-15 16:25 from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='AdminUser', fields=[ ('id', models.BigAutoF...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/ezsqli/blog/migrations/__init__.py
ctfs/TPCTF/2023/web/ezsqli/blog/migrations/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/xssbot/bot.py
ctfs/TPCTF/2023/web/xssbot/bot.py
# Copyright 2022-2023 USTC-Hackergame # Copyright 2021 PKU-GeekGame # # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, this list of conditions and...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TPCTF/2023/web/xssbot_but_no_Internet/bot.py
ctfs/TPCTF/2023/web/xssbot_but_no_Internet/bot.py
# Copyright 2022-2023 USTC-Hackergame # Copyright 2021 PKU-GeekGame # # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, this list of conditions and...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WACON/2023/Quals/misc/ScavengerHunt/prob.py
ctfs/WACON/2023/Quals/misc/ScavengerHunt/prob.py
#!/usr/bin/env python3 import secret import pyseccomp import sys print("Find the treasure!") data = input() f = pyseccomp.SyscallFilter(defaction=pyseccomp.KILL) f.add_rule(pyseccomp.ALLOW, 'rt_sigaction') f.add_rule(pyseccomp.ALLOW, 'munmap') f.add_rule(pyseccomp.ALLOW, 'exit_group') f.add_rule(pyseccomp.ALLOW, 'ex...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WACON/2023/Quals/misc/ScavengerHunt/secret.py
ctfs/WACON/2023/Quals/misc/ScavengerHunt/secret.py
__builtins__ = {} some_unknown_and_very_long_identifier_name = "WACON2023{[REDACTED]}"
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WACON/2023/Quals/rev/Adult_Artist/flag.py
ctfs/WACON/2023/Quals/rev/Adult_Artist/flag.py
import sys import hashlib if len(sys.argv) != 2: print("python3 flag.py <input>") exit() print("WACON2023{" + hashlib.sha256(sys.argv[1].encode()).hexdigest() + "}")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WACON/2023/Quals/crypto/Cry/challenge.py
ctfs/WACON/2023/Quals/crypto/Cry/challenge.py
from Crypto.Util.number import bytes_to_long, getStrongPrime, isPrime SIZE = 512 e = 65537 with open("flag.txt", "rb") as f: m = bytes_to_long(f.read()) def encrypt(m): while True: p = getStrongPrime(SIZE) if p % 4 != 3: continue q = p**2 + 1 assert q % 2 == 0 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WACON/2023/Quals/crypto/White_arts_hard/RandomFunction.py
ctfs/WACON/2023/Quals/crypto/White_arts_hard/RandomFunction.py
import os class RandomFunction(): def __init__(self, n): self.domain_cache = {} self.range_cache = {} self.n = n # n "bytes" # Inverse query is not allowed def query(self, q): x = q if x not in self.domain_cache: self.domain_cache[x] = os.urandom(sel...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WACON/2023/Quals/crypto/White_arts_hard/RandomPermutation.py
ctfs/WACON/2023/Quals/crypto/White_arts_hard/RandomPermutation.py
import os class RandomPermutation(): def __init__(self, n): self.domain_cache = {} self.range_cache = {} self.n = n # n "bytes" def query(self, q, inverse = False): if not inverse: x = q if x in self.domain_cache: return self.domain_c...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WACON/2023/Quals/crypto/White_arts_hard/prob.py
ctfs/WACON/2023/Quals/crypto/White_arts_hard/prob.py
import math import os from Generator import Generator1, Generator2, Generator3, Generator4, Generator5 query_left = 266 def guess_mode(G, query_num): for _ in range(query_num): q = bytes.fromhex(input("q? > ")) inverse = input("inverse(y/n)? > ") == 'y' assert len(q) == G.input_size ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WACON/2023/Quals/crypto/White_arts_hard/Generator.py
ctfs/WACON/2023/Quals/crypto/White_arts_hard/Generator.py
import os from RandomFunction import RandomFunction from RandomPermutation import RandomPermutation def xor(a : bytes, b : bytes): return bytes([u ^ v for u,v in zip(a,b)]) class Generator1: def __init__(self): self.mode = os.urandom(1)[0] & 1 self.n = 8 self.input_size = 2 * self.n ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WACON/2023/Quals/crypto/Push_It_To_The_Limit/challenge.py
ctfs/WACON/2023/Quals/crypto/Push_It_To_The_Limit/challenge.py
from Crypto.Util.number import bytes_to_long, getStrongPrime with open("flag.txt", "rb") as f: m = bytes_to_long(f.read()) SIZE = 1024 p = getStrongPrime(SIZE) q = getStrongPrime(SIZE) n = p * q e = 0x10001 c = pow(m, e, n) p_msb = p - p % (2 ** (SIZE // 2)) print(f"{n = }") print(f"{c = }") print(f"{p_msb = }"...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WACON/2023/Quals/crypto/White_arts_easy/RandomFunction.py
ctfs/WACON/2023/Quals/crypto/White_arts_easy/RandomFunction.py
import os class RandomFunction(): def __init__(self, n): self.domain_cache = {} self.range_cache = {} self.n = n # n "bytes" # Inverse query is not allowed def query(self, q): x = q if x not in self.domain_cache: self.domain_cache[x] = os.urandom(sel...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WACON/2023/Quals/crypto/White_arts_easy/RandomPermutation.py
ctfs/WACON/2023/Quals/crypto/White_arts_easy/RandomPermutation.py
import os class RandomPermutation(): def __init__(self, n): self.domain_cache = {} self.range_cache = {} self.n = n # n "bytes" def query(self, q, inverse = False): if not inverse: x = q if x in self.domain_cache: return self.domain_c...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WACON/2023/Quals/crypto/White_arts_easy/prob.py
ctfs/WACON/2023/Quals/crypto/White_arts_easy/prob.py
import math import os from Generator import Generator1, Generator2, Generator3, Generator4, Generator5 query_left = 266 def guess_mode(G, query_num): for _ in range(query_num): q = bytes.fromhex(input("q? > ")) inverse = input("inverse(y/n)? > ") == 'y' assert len(q) == G.input_size ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WACON/2023/Quals/crypto/White_arts_easy/Generator.py
ctfs/WACON/2023/Quals/crypto/White_arts_easy/Generator.py
import os from RandomFunction import RandomFunction from RandomPermutation import RandomPermutation def xor(a : bytes, b : bytes): return bytes([u ^ v for u,v in zip(a,b)]) class Generator1: def __init__(self): self.mode = os.urandom(1)[0] & 1 self.n = 8 self.input_size = 2 * self.n ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false