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/TeamItaly/2023/web/Borraccia/challenge/Borraccia/_types.py
ctfs/TeamItaly/2023/web/Borraccia/challenge/Borraccia/_types.py
import re from rich.logging import RichHandler from rich._null_file import NullFile from rich.traceback import Traceback class ObjDict: def __init__(self, d={}): self.__dict__['_data'] = d # Avoiding Recursion errors on __getitem__ def __getattr__(self, key): if key in self._data: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TeamItaly/2023/web/Borraccia/challenge/Borraccia/const.py
ctfs/TeamItaly/2023/web/Borraccia/challenge/Borraccia/const.py
import os import sys CURRENT_DIR = os.path.dirname(os.path.abspath(sys.modules['__main__'].__name__)) PUBLIC_DIR = os.path.join(CURRENT_DIR, "public") STATIC_DIR = os.path.join(PUBLIC_DIR, "static") ERROR_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "errors")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TeamItaly/2023/web/Borraccia/challenge/Borraccia/utils.py
ctfs/TeamItaly/2023/web/Borraccia/challenge/Borraccia/utils.py
import os import re import typing from . import _types from functools import lru_cache from .const import STATIC_DIR, ERROR_DIR @lru_cache def normalize_header(s: str) -> str: return s.lower().replace('-', '_') @lru_cache def normalize_header_value(s: str) -> str: return re.sub(r"[%\"\.\n\'\!:\(\)]", "", s) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TeamItaly/2023/web/Borraccia/challenge/Borraccia/__init__.py
ctfs/TeamItaly/2023/web/Borraccia/challenge/Borraccia/__init__.py
from .server import * from .const import *
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TeamItaly/2023/web/Borraccia/challenge/Borraccia/server.py
ctfs/TeamItaly/2023/web/Borraccia/challenge/Borraccia/server.py
import os import re import sys import time import typing import socket import logging import traceback import multiprocessing from . import utils from .const import * from jinja2 import Template from rich import print as rich_print from urllib.parse import parse_qs, unquote from ._types import ObjDict, TruncatedStri...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Nexus/2024/misc/Escape/chall.py
ctfs/Nexus/2024/misc/Escape/chall.py
#!/usr/bin/python3 import signal from functools import wraps supers3cr3t = 'NexusCTF{REDACTED}' attempt_limit = 3 timeout_seconds = 5 def timeout_handler(signum, frame): print("\nTimeout reached. Exiting...") exit(0) def limit_attempts(func): @wraps(func) def wrapper(*args, **kwargs): for _ ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Nexus/2024/crypto/RAS/chall.py
ctfs/Nexus/2024/crypto/RAS/chall.py
from Crypto.Util.number import getPrime, inverse, bytes_to_long, long_to_bytes from string import ascii_letters, digits from random import choice wisdom = "".join(choice(ascii_letters + digits) for _ in range(16)) passion = getPrime(128) ambition = getPrime(128) desire = passion * ambition willpower = 65537 fate = inv...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DamCTF/2021/rev/seed/seed.py
ctfs/DamCTF/2021/rev/seed/seed.py
#!/usr/bin/env python3 import sys import time import random import hashlib def seed(): return round(time.time()) def hash(text): return hashlib.sha256(str(text).encode()).hexdigest() def main(): while True: s = seed() random.seed(s, version=2) x = random.random() flag = h...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DamCTF/2021/crypto/time-ai/chal.py
ctfs/DamCTF/2021/crypto/time-ai/chal.py
#!/usr/bin/env sage from sage.all import * from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_number_field from Crypto.Cipher import AES # The description of CrownRNG is too unclear, and the system random number # generator is bound to be more secure anyway. from Crypto.Random import random as cry...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DamCTF/2021/crypto/hav3-i-b33n-pwn3d/common.py
ctfs/DamCTF/2021/crypto/hav3-i-b33n-pwn3d/common.py
#!/usr/bin/env sage from sage.all import * from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_number_field from Crypto.Hash import MD5, SHA256 from Crypto.Random import random as crypt_random curve25519_p = 2**255 - 19 F = GF(curve25519_p) R = F['x'] x = R.gen() curve25519 = EllipticCurve(F, [0,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DamCTF/2021/crypto/hav3-i-b33n-pwn3d/psi_receiver.py
ctfs/DamCTF/2021/crypto/hav3-i-b33n-pwn3d/psi_receiver.py
#!/usr/bin/env sage from common import * from Crypto.Random import random import json import threading import socket with open("passwords", 'r') as f: passwords = f.read().strip().split('\n') class Server: CHUNK = 64 def __init__(self, host='0.0.0.0', port=31337): print(f"Binding to {host}:{por...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DamCTF/2021/crypto/hav3-i-b33n-pwn3d/psi_sender.py
ctfs/DamCTF/2021/crypto/hav3-i-b33n-pwn3d/psi_sender.py
#!/usr/bin/env sage from common import * import json import socket import sys IP = "hav3-i-b33n-pwn3d.damctf.xyz" PORT = 30944 CHUNK = 64 def send(c, msg): c.sendall((msg + '\n').encode()) def recv(c): message = b'' while len(message) < 4098: part = c.recv(CHUNK) if b'\n' in part: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DamCTF/2024/crypto/aedes/aedes.py
ctfs/DamCTF/2024/crypto/aedes/aedes.py
#!/usr/local/bin/python3 from functools import reduce, partial import operator import secrets from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes def xor(*bs): return bytes(reduce(operator.xor, bb) for bb in zip(*bs, strict=True)) def expand_k(k): sched = [] for i in range(7): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DamCTF/2024/crypto/fundamental_revenge/fundamental-revenge.py
ctfs/DamCTF/2024/crypto/fundamental_revenge/fundamental-revenge.py
#!/usr/local/bin/python3 from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes import secrets import sys p = 168344944319507532329116333970287616503 def F(k, x): f = Cipher(algorithms.AES(k), modes.ECB()).encryptor() return f.update(x) + f.finalize() def poly_eval(coeffs, x): re...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DamCTF/2024/crypto/fundamental/fundamental.py
ctfs/DamCTF/2024/crypto/fundamental/fundamental.py
#!/usr/local/bin/python3 import secrets import sys p = 129887472129814551050345803501316649949 def poly_eval(coeffs, x): res = 0 for c in coeffs: res = (c + x * res) % p return res def pad(m): padlen = 16 - (len(m) % 16) padding = bytes([padlen] * padlen) return m + padding def t...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesNoida/2021/crypto/Damn_Boi/damn_boi.py
ctfs/BSidesNoida/2021/crypto/Damn_Boi/damn_boi.py
#!/usr/bin/env python3 from Crypto.Util.number import * from random import shuffle from math import lcm, prod from topsecrets import FLAG, FLAG_parts from gmpy2 import next_prime BITS = 512 FLAGINT = bytes_to_long(FLAG.encode()) assert FLAGINT == prod(FLAG_parts) def pm(n): r = 1 a = 2 for i in range(n)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesNoida/2021/crypto/baby_crypto/babycrypto.py
ctfs/BSidesNoida/2021/crypto/baby_crypto/babycrypto.py
from functools import reduce from operator import mul from secrets import token_bytes from sys import exit from Crypto.Util.number import bytes_to_long, getPrime, long_to_bytes def main(): a = getPrime(512) b = reduce(mul, [getPrime(64) for _ in range(12)]) flag = open("flag.txt", 'rb').read() flag_int = bytes_t...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesNoida/2021/crypto/MACAW/MACAW.py
ctfs/BSidesNoida/2021/crypto/MACAW/MACAW.py
#!/usr/bin/env python3 from topsecrets import iv, key, secret_msg, secret_tag, FLAG from Crypto.Cipher import AES iv = bytes.fromhex(iv) menu = """ /===== MENU =====\\ | | | [M] MAC Gen | | [A] AUTH | | | \================/ """ def MAC(data): assert len(data) % 16 == 0,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesNoida/2021/crypto/Kotf_returns/kotf_returns.py
ctfs/BSidesNoida/2021/crypto/Kotf_returns/kotf_returns.py
from hashlib import sha1 from random import * from sys import exit from os import urandom from Crypto.PublicKey import DSA from Crypto.Util.number import * rot = randint(2, 2**160 - 1) chop = getPrime(159) def message_hash(x): return bytes_to_long(sha1(x).digest()) def nonce(s, padding, i, q): return (pow(messag...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesNoida/2021/crypto/prng/prng.py
ctfs/BSidesNoida/2021/crypto/prng/prng.py
from decimal import Decimal, getcontext from Crypto.Util.number import bytes_to_long, getRandomNBitInteger def is_valid_privkey(n): if n < 0: return False c = n * 4 // 3 d = c.bit_length() a = d >> 1 if d & 1: x = 1 << a y = (x + (n >> a)) >> 1 else: x = (3 << a) >> 2 y = (x + (c >> a)) >> 1 if x !=...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesNoida/2021/crypto/Xoro/xoro.py
ctfs/BSidesNoida/2021/crypto/Xoro/xoro.py
#!/usr/bin/env python3 import os FLAG = open('flag.txt','rb').read() def xor(a, b): return bytes([i^j for i,j in zip(a,b)]) def pad(text, size): return text*(size//len(text)) + text[:size%len(text)] def encrypt(data, key): keystream = pad(key, len(data)) encrypted = xor(keystream, data) return e...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesNoida/2021/crypto/low_power_crypto/low_power_crypto.py
ctfs/BSidesNoida/2021/crypto/low_power_crypto/low_power_crypto.py
from Crypto.Util.number import getRandomNBitInteger, isPrime # extended gcd def egcd(a, b): old_x, new_x = 1, 0 old_y, new_y = 0, 1 while a != 0: q, a, b = b // a, b % a, a new_x, old_x = old_x, new_x - q * old_x new_y, old_y = old_y, new_y - q * old_y return b, new_x, new_y # multiplicative modular inver...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesNoida/2021/crypto/Macaw_Revenge/macaw_revenge.py
ctfs/BSidesNoida/2021/crypto/Macaw_Revenge/macaw_revenge.py
#!/usr/bin/env python3 from Crypto.Cipher import AES import os with open('flag.txt') as f: FLAG = f.read() menu = """ /===== MENU =====\\ | | | [M] MAC Gen | | [A] AUTH | | | \================/ """ def MAC(data, check=False): assert len(data) % 16 == 0, "Invalid In...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2021/Quals/crypto/Sign_it/app.py
ctfs/Securinets/2021/Quals/crypto/Sign_it/app.py
from Crypto.Util.number import inverse from Crypto.Random import random from fastecdsa.curve import Curve from fastecdsa.point import Point import hashlib import signal class Server(): def __init__(self, curve, G): self.G = G self.order = curve.q self.d = random.randrange(1 , self.order - 1) self.P = (self.d ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2021/Quals/crypto/Shilaformi/app.py
ctfs/Securinets/2021/Quals/crypto/Shilaformi/app.py
import signal from secret import flag from Crypto.Random import random from Crypto.Util.number import getPrime #Odds and evens (hand game) #https://en.wikipedia.org/wiki/Odds_and_evens_(hand_game) def pad(choice, n): return 2*random.randint(1, n//2 - 1) + choice def send(choice, n): choice = pad(choice, n) return...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2021/Quals/crypto/Special/app.py
ctfs/Securinets/2021/Quals/crypto/Special/app.py
from Crypto.Util.number import isPrime, bytes_to_long from secret import flag import random def get(r): while True: a = random.getrandbits(512) p = a**2 + r if isPrime(p) : return p m = bytes_to_long(flag) e = 65537 p, q = get(1337), get(1187) n = p*q c = pow(m, e, n) print ("Modulus : {}".format(n)) print...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2021/Quals/crypto/MiTM/app.py
ctfs/Securinets/2021/Quals/crypto/MiTM/app.py
from Crypto.Util.number import long_to_bytes from Crypto.Util.Padding import pad from Crypto.Cipher import AES from secret import flag import hashlib, random, os import signal class DHx(): def __init__(self): self.g = 2 self.p = 0xf18d09115c60ea0e71137b1b35810d0c774f98faae5abcfa98d2e2924715278da4f2738fc5e3d077546...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2021/Quals/crypto/MiTM_Revenge/app.py
ctfs/Securinets/2021/Quals/crypto/MiTM_Revenge/app.py
from Crypto.Util.number import long_to_bytes from Crypto.Util.Padding import pad from Crypto.Cipher import AES from secret import flag import hashlib, random, os import signal class DHx(): def __init__(self): self.g = 2 self.p = 0xf18d09115c60ea0e71137b1b35810d0c774f98faae5abcfa98d2e2924715278da4f2738fc5e3d077546...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2021/Quals/web/Mixed/api/config.py
ctfs/Securinets/2021/Quals/web/Mixed/api/config.py
key='None'
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2021/Quals/web/Mixed/api/app.py
ctfs/Securinets/2021/Quals/web/Mixed/api/app.py
from flask import Flask, render_template, request import random import sqlite3 as sql import binascii import json import base64 from Crypto.Cipher import AES import config def my_decrypt(data, passphrase): try: unpad = lambda s : s[:-s[-1]] key = binascii.unhexlify(passphrase) encrypted = js...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2021/Quals/web/Warmup/utils.py
ctfs/Securinets/2021/Quals/web/Warmup/utils.py
import urllib import sys import urlparse import os import time import types import shutil from string import joinfields, split, lower from xml.dom import minidom domimpl = minidom.getDOMImplementation() BUFFER_SIZE = 128 * 1000 class Resource(object): # XXX this class is ugly def __init__(self, fp, file_size...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2021/Quals/web/Warmup/app.py
ctfs/Securinets/2021/Quals/web/Warmup/app.py
from itsdangerous import Signer, base64_encode, base64_decode from flask import Flask, request, render_template, make_response, g, Response from flask.views import MethodView import urlparse import shutil import utils import os import mimetypes app = Flask(__name__.split('.')[0]) app.config.from_object(__name__) BUF...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2023/Quals/crypto/PolyLCG/PolyLCG.py
ctfs/Securinets/2023/Quals/crypto/PolyLCG/PolyLCG.py
from random import randint xcoeff=[2220881165502059873403292638352563283672047788097000474246472547036149880673794935190953317495413822516051735501183996484673938426874803787946897055911986,37808680712351602153671997709526569727095109831465032116928692968362545196207687373560818368371023296266609624683335620501214279...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2023/Quals/crypto/Farfour_Post_Quantom/Farfour_post_quantom.py
ctfs/Securinets/2023/Quals/crypto/Farfour_Post_Quantom/Farfour_post_quantom.py
from Crypto.Cipher import AES from Crypto.Util.Padding import pad import hashlib from os import urandom from random import SystemRandom from sympy import GF from sympy.polys.matrices import DomainMatrix import json from hashlib import md5 random=SystemRandom() shuffle=random.shuffle randint=random.randint randrange=r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2023/Quals/crypto/TTsign/TTSign.py
ctfs/Securinets/2023/Quals/crypto/TTsign/TTSign.py
#!/usr/bin/env python3.10 from Crypto.Util.number import long_to_bytes, bytes_to_long, inverse from Crypto.Util import Counter from Crypto.Util.Padding import pad, unpad from Crypto.PublicKey import RSA from Crypto.Cipher import AES import os, sys, hashlib from random import randint import json from APTX import Serve...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2023/Quals/crypto/TTSign2/TTSign.py
ctfs/Securinets/2023/Quals/crypto/TTSign2/TTSign.py
#!/usr/bin/env python3.10 from Crypto.Util.number import long_to_bytes, bytes_to_long, inverse from Crypto.Util import Counter from Crypto.Util.Padding import pad, unpad from Crypto.PublicKey import RSA from Crypto.Cipher import AES import os, sys, hashlib from random import randint import json from APTX import Serve...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2023/Quals/crypto/DigestiveV2/DigestiveV2.py
ctfs/Securinets/2023/Quals/crypto/DigestiveV2/DigestiveV2.py
from fastecdsa.curve import P192 from fastecdsa.point import Point from secrets import randbelow,flag,banner,menu from Crypto.Util.number import bytes_to_long,inverse from string import ascii_uppercase import json #P192 Order O=6277101735386680763835789423176059013767194773182842284081 d=randbelow(O) G=Point(0x188da80e...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2023/Quals/web/Giancardi_Bank/accountant/job.py
ctfs/Securinets/2023/Quals/web/Giancardi_Bank/accountant/job.py
#!/usr/bin/env python3 import datetime import os import requests import signal from yaml import * signal.alarm(20) def verify_records(s): return "[+] I'm done, let me go home\n"+s pw = os.environ["ACCOUNTANT_PASSWORD"] auth_data = {"username": "MisterX", "password": pw} print("[+] Let me get into my office...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2023/Quals/web/mark4archive/backend/analyze.py
ctfs/Securinets/2023/Quals/web/mark4archive/backend/analyze.py
import fnmatch import hashlib import hmac import pickle import random import os import re import shutil import zipfile from flask import Blueprint, request import requests from template import DUMMY_CodeQL_BODY, DUMMY_CodeQL_HEADER, BODY_CONTENT, SNIPPET from config.config import SECRET TMP_SECRET=SECRET if os.path.ex...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2023/Quals/web/mark4archive/backend/report.py
ctfs/Securinets/2023/Quals/web/mark4archive/backend/report.py
import hmac import pickle from flask import Blueprint, Response, render_template, request import requests import re import os import random import string from analyze import TMP_SECRET SECRET=TMP_SECRET report_bp = Blueprint('report', __name__) def check_input(data): msg = "success" hash_re = re.compile( ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2023/Quals/web/mark4archive/backend/api.py
ctfs/Securinets/2023/Quals/web/mark4archive/backend/api.py
from flask import Blueprint, request, Response from reportlab.lib import colors from reportlab.lib.pagesizes import letter, landscape from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from io import BytesIO api_bp = Blueprint('api'...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2023/Quals/web/mark4archive/backend/template.py
ctfs/Securinets/2023/Quals/web/mark4archive/backend/template.py
DUMMY_CodeQL_BODY= """{Id}. {Title} File: {File} Line: {Line} Code Snippet: ```{Snippet}``` """ DUMMY_CodeQL_HEADER = """Dummy CodeQL Analysis Report ====================== Repository: {repo} Branch: {branch} Language: "python" Results: """ SNIPPET = { "Python":"""python num = input("Enter a n...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2023/Quals/web/mark4archive/backend/app.py
ctfs/Securinets/2023/Quals/web/mark4archive/backend/app.py
import json import time import os from flask import Flask, render_template from analyze import analyze_bp from report import report_bp from api import api_bp from flask_sock import Sock app = Flask(__name__) app.register_blueprint(analyze_bp) app.register_blueprint(report_bp) app.register_blueprint(api_bp) sock = Soc...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2023/Quals/web/mark4archive/backend/config/config.py
ctfs/Securinets/2023/Quals/web/mark4archive/backend/config/config.py
SECRET = bytes("secret", "utf-8")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2023/Quals/web/0_CSP/app.py
ctfs/Securinets/2023/Quals/web/0_CSP/app.py
import os import re from flask import Flask, request, jsonify, escape import random import string import requests app = Flask(__name__) url = os.environ.get("URL_BOT") user_tokens = {} headers = { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'POST, GET, OPTIONS', 'Access-Control-Al...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2025/Quals/misc/Easy_Jail/give.py
ctfs/Securinets/2025/Quals/misc/Easy_Jail/give.py
import random import string seed = random.randint(0, 2**20) shift_rng = random.Random(seed) class ProtectedFlag: def __init__(self, value): self._value = value def __str__(self): return "variable protected, sryy" def __repr__(self): return "variable protected, sryy" def __ge...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2025/Quals/crypto/Fl1pper_Zer0/chall.py
ctfs/Securinets/2025/Quals/crypto/Fl1pper_Zer0/chall.py
from Crypto.Util.number import long_to_bytes, bytes_to_long, inverse from Crypto.Cipher import AES from Crypto.Util.Padding import pad from fastecdsa.curve import P256 as EC from fastecdsa.point import Point import os, random, hashlib, json from secret import FLAG class SignService: def __init__(self): se...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2025/Quals/crypto/XTaSy/chall.py
ctfs/Securinets/2025/Quals/crypto/XTaSy/chall.py
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes import os, json from secret import FLAG class AES_XTS: def __init__(self): self.key = os.urandom(64) self.tweak = os.urandom(16) def encrypt(self, plaintext): encryptor = Cipher(algorithms.AES(self.key), modes...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2025/Quals/crypto/Exclusive/chall.py
ctfs/Securinets/2025/Quals/crypto/Exclusive/chall.py
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes import os, signal from secret import FLAG signal.alarm(30) class AES_XTS: def __init__(self): self.key = os.urandom(64) self.tweak = os.urandom(16) def encrypt(self, plaintext): encryptor = Cipher(algorithms....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2022/Quals/crypto/aes-2/aes-2.py
ctfs/Securinets/2022/Quals/crypto/aes-2/aes-2.py
from Crypto.Cipher import AES from Crypto.Util.Padding import pad import os, sys, hashlib, random FLAG = b"Securinets{REDACTED}" key, iv1, iv2 = [os.urandom(16) for _ in range(3)] def xor(a, b): return bytes(i ^ j for i, j in zip(a, b)) def get_token(msg, iv1, iv2): if len(msg) % 16 != 0: msg = pad(msg, 16) ae...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2022/Quals/crypto/escrime/escrime.py
ctfs/Securinets/2022/Quals/crypto/escrime/escrime.py
from Crypto.Util.number import getStrongPrime, getPrime, isPrime, bytes_to_long FLAG = b"Securinets{REDACTED}" def genPrime(prime): while True: a = getPrime(256) p = 2*prime*a + 1 if isPrime(p): break while True: b = getPrime(256) q = 2*prime*b + 1 i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2022/Quals/web/NarutoKeeper/app/form.py
ctfs/Securinets/2022/Quals/web/NarutoKeeper/app/form.py
from flask_wtf import Form, RecaptchaField from wtforms import StringField, validators,PasswordField,SubmitField class ReportForm(Form): url = StringField('Url To Visit', [validators.DataRequired(), validators.Length(max=255)],render_kw={"placeholder": "http://URL/"}) recaptcha = RecaptchaField() class LoginForm(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Securinets/2022/Quals/web/NarutoKeeper/app/app.py
ctfs/Securinets/2022/Quals/web/NarutoKeeper/app/app.py
from flask import Flask,request,render_template,session,redirect from form import ReportForm,LoginForm,RegisterForm import os,pymysql,time import requests,secrets,random,string from flask_wtf.csrf import CSRFProtect app= Flask(__name__) app.config["SECRET_KEY"]=os.urandom(15).hex() app.config['RECAPTCHA_USE_SSL']= Fal...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BxMCTF/2023/pwn/Banking_Issues/main.py
ctfs/BxMCTF/2023/pwn/Banking_Issues/main.py
#!/usr/local/bin/python import os balances = [10, 20, 50, 16, 29, 52, 100000] PERMS_ADMIN = { "MAX_INDEX": len(balances) - 1 } PERMS_AGENT = { "MAX_INDEX": len(balances) - 2 } def main(): perms = PERMS_AGENT wallet = 0 idx = int(input("Which account would you like to withdraw from? ")) if i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BxMCTF/2023/pwn/The_Revenge_of_Checkpass_1/main.py
ctfs/BxMCTF/2023/pwn/The_Revenge_of_Checkpass_1/main.py
#!/usr/local/bin/python # -*- coding: utf-8 -*- def main(): password = "the password can contain non-ascii charactérs :)" inp = input("Enter a Python list: ") lis = eval(inp, {'__builtins__': None}, None) if type(lis) != list: print("That's not a list") return for i in lis: if not isinstance(i, i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BxMCTF/2023/rev/MCV5U/Rev3.py
ctfs/BxMCTF/2023/rev/MCV5U/Rev3.py
import math import hashlib import sys SIZE = int(3e5) VERIFY_KEY = "46e1b8845b40bc9d977b8932580ae44c" def getSequence(A, B, n, m): ans = [0] * (n + m - 1) for x in range(n): for y in range(m): ans[x + y] += A[x] * B[y] return ans A = [0] * SIZE B = [0] * SIZE document1 = open("D...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BxMCTF/2023/web/Username_Decorator/src/app.py
ctfs/BxMCTF/2023/web/Username_Decorator/src/app.py
from flask import Flask, render_template_string, request import re app = Flask(__name__) app.config['FLAG_LOCATION'] = 'os.getenv("FLAG")' def validate_username(username): return bool(re.fullmatch("[a-zA-Z0-9._\[\]\(\)\-=,]{2,}", username)) @app.route('/', methods=['GET', 'POST']) def index(): prefix = '' ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BxMCTF/2023/web/Username_Decorator/src/wsgi.py
ctfs/BxMCTF/2023/web/Username_Decorator/src/wsgi.py
from app import app
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BxMCTF/2023/web/Repository_Security/manage.py
ctfs/BxMCTF/2023/web/Repository_Security/manage.py
import json import os from functools import wraps import click from flask import Flask, jsonify, render_template from flask_simplelogin import Message, SimpleLogin, login_required from werkzeug.security import check_password_hash, generate_password_hash # [ -- Utils -- ] def validate_login(user): db_users = js...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BxMCTF/2023/web/Repository_Security/settings.py
ctfs/BxMCTF/2023/web/Repository_Security/settings.py
import os SECRET_KEY = "secret-here" SIMPLELOGIN_BLUEPRINT = os.getenv("SIMPLELOGIN_BLUEPRINT") SIMPLELOGIN_LOGIN_URL = os.getenv("SIMPLELOGIN_LOGIN_URL") SIMPLELOGIN_LOGOUT_URL = os.getenv("SIMPLELOGIN_LOGOUT_URL") SIMPLELOGIN_HOME_URL = os.getenv("SIMPLELOGIN_HOME_URL")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BxMCTF/2023/web/Repository_Security/app.py
ctfs/BxMCTF/2023/web/Repository_Security/app.py
from flask import Flask, jsonify, render_template from flask.views import MethodView from flask_simplelogin import SimpleLogin, get_username, login_required my_users = { "chuck": {"password": "norris", "roles": ["admin"]}, "lee": {"password": "douglas", "roles": []}, "mary": {"password": "jane", "roles": [...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BxMCTF/2023/web/Repository_Security/wsgi.py
ctfs/BxMCTF/2023/web/Repository_Security/wsgi.py
from app import app
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BxMCTF/2023/web/Repository_Security/flask_simplelogin/__init__.py
ctfs/BxMCTF/2023/web/Repository_Security/flask_simplelogin/__init__.py
import logging import os from functools import wraps from uuid import uuid4 from urllib.parse import urlparse, urljoin from warnings import warn from flask import ( abort, Blueprint, current_app, flash, redirect, render_template, request, session, url_for, ) from flask_wtf import Fl...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Nowruz/2025/misc/ecal/jail.py
ctfs/Nowruz/2025/misc/ecal/jail.py
#!/usr/bin/env python import importlib blacklist = [ "os", "posix", "subprocess", "shutil", "pickle", "marshal", "csv", "pdb", "tty", "pty" ] def secure_importer(name, globals=None, locals=None, fromlist=(), level=0): if name in blacklist: raise ImportError("module '%s' is restricted." % name) return importli...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Nowruz/2025/pwn/gogogo/run.py
ctfs/Nowruz/2025/pwn/gogogo/run.py
#!/usr/bin/env python3 import tempfile import pathlib import os os.chdir(pathlib.Path(__file__).parent.resolve()) with tempfile.NamedTemporaryFile() as tmp: print('Send the file: (ended with "\\n-- EOF --\\n"):') s = input() while(s != '-- EOF --'): tmp.write((s+'\n').encode()) s = input() tmp.flush() os.sys...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Nowruz/2025/crypto/seal_the_deal/server.py
ctfs/Nowruz/2025/crypto/seal_the_deal/server.py
from math import gcd from Crypto.Util.number import getPrime, inverse from random import randint import secrets import time with open("flag.txt") as f: flag = f.readline() class Paillier: def __init__(self, bits): self.bits = bits self.pub, self.priv = self.keygen() def lcm(self, a, b): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Nowruz/2025/crypto/superguesser_v2/chal.py
ctfs/Nowruz/2025/crypto/superguesser_v2/chal.py
#!/usr/local/bin/python import os import random from Crypto.Cipher import AES from Crypto.Util.Padding import pad MAX_ATTEMPTS = 10 def encrypt_flag(flag, iv): key = random.getrandbits(128).to_bytes(16, 'big') cipher = AES.new(key, AES.MODE_CBC, iv*2) encrypted = cipher.encrypt(pad(flag.encode(), AES.blo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Nowruz/2025/crypto/Robin_s_Mystery/Robin_Mystery.py
ctfs/Nowruz/2025/crypto/Robin_s_Mystery/Robin_Mystery.py
import random from Crypto.PublicKey import RSA from Crypto.Util.number import * def nextPrime(prim): if isPrime(prim): return prim else: return nextPrime(prim+1) p = getPrime(512) q = nextPrime(p+1) while p%4 != 3 or q%4 !=3: p = getPrime(512) q = nextPrime(p+1) n = p*q m = bytes_to_l...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Nowruz/2025/crypto/EZ_RSA/EZ_RSA.py
ctfs/Nowruz/2025/crypto/EZ_RSA/EZ_RSA.py
from Crypto.Util.number import getPrime import os flag = os.getenv("FLAG", "FMCTF{F4K3_FL49}") m = int(flag.encode().hex(), 16) p = getPrime(512) q = getPrime(512) n = p*q e = 65537 c = pow(m, e, n) hint = p+q print(f"{hint = }") print(f"{n = }") print(f"{c = }") # hint = 17469292153344571442220879753705314094982...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Nowruz/2025/crypto/EZ_XOR/EZ_XOR.py
ctfs/Nowruz/2025/crypto/EZ_XOR/EZ_XOR.py
from pwn import * FLAG = os.environ.get("FLAG", "FMCTF{F4K3_FL49}").encode() key = os.urandom(7) encryptedFlag = xor(FLAG, key).hex() print(f"encryptedFlag = {encryptedFlag}") # encryptedFlag = a850d725cb56b0de4fcb40de72a4df56a72ec06cafa75ecb41f51c95
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Nowruz/2025/crypto/superguesser/chal.py
ctfs/Nowruz/2025/crypto/superguesser/chal.py
#!/usr/local/bin/python import random import time from Crypto.Cipher import AES from Crypto.Util.Padding import pad MAX_ATTEMPTS = 1000 def encrypt_flag(flag): key = random.getrandbits(128).to_bytes(16, 'big') iv = random.getrandbits(128).to_bytes(16, 'big') cipher = AES.new(key, AES.MODE_CBC, iv) en...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WeCTF/2021/Gallery/main.py
ctfs/WeCTF/2021/Gallery/main.py
import os import time import uuid from flask import Flask, request, make_response, render_template, redirect from google.cloud import storage from peewee import * db = SqliteDatabase("core.db") class User(Model): # mapping from user token to their background pic url id = AutoField() token = CharField() ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WeCTF/2021/CSP1/app.py
ctfs/WeCTF/2021/CSP1/app.py
import urllib.parse import uuid from flask import Flask, render_template, request, redirect, make_response from bs4 import BeautifulSoup as bs from peewee import * app = Flask(__name__) db = SqliteDatabase("core.db") class Post(Model): id = AutoField() token = CharField() content = TextField() cl...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WeCTF/2021/Cache/manage.py
ctfs/WeCTF/2021/Cache/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', 'cache.settings') try: from django.core.management import execute_from_command_line except Import...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WeCTF/2021/Cache/cache/asgi.py
ctfs/WeCTF/2021/Cache/cache/asgi.py
""" ASGI config for cache 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/3.2/howto/deployment/asgi/ """ import os from django.core.asgi import get_asgi_application os.environ.setdefault('DJANGO_SETTING...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WeCTF/2021/Cache/cache/settings.py
ctfs/WeCTF/2021/Cache/cache/settings.py
from pathlib import Path BASE_DIR = Path(__file__).resolve().parent.parent SECRET_KEY = 'django-insecure-p*sk-&$*0qb^j3@_b07a38kzus7d^&)-elk6rmoh1&__6yv^bf' DEBUG = True ALLOWED_HOSTS = ["*"] INSTALLED_APPS = [] MIDDLEWARE = [ 'cache.cache_middleware.SimpleMiddleware', ] ROOT_URLCONF = 'cache.urls' TEMPLATES = [] W...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WeCTF/2021/Cache/cache/__init__.py
ctfs/WeCTF/2021/Cache/cache/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WeCTF/2021/Cache/cache/cache_middleware.py
ctfs/WeCTF/2021/Cache/cache/cache_middleware.py
import urllib.parse from django.http import HttpResponse, HttpRequest import time CACHE = {} # PATH => (Response, EXPIRE) class SimpleMiddleware: def __init__(self, get_response): self.get_response = get_response def __call__(self, request: HttpRequest): path = urllib.parse.urlparse(reques...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WeCTF/2021/Cache/cache/wsgi.py
ctfs/WeCTF/2021/Cache/cache/wsgi.py
""" WSGI config for cache 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/3.2/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTING...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WeCTF/2021/Cache/cache/urls.py
ctfs/WeCTF/2021/Cache/cache/urls.py
import os from django.urls import re_path from django.http import HttpResponse, HttpRequest FLAG = os.getenv("FLAG") ADMIN_TOKEN = os.getenv("ADMIN_TOKEN") def flag(request: HttpRequest): token = request.COOKIES.get("token") print(token, ADMIN_TOKEN) if not token or token != ADMIN_TOKEN: return...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WeCTF/2021/Phish/main.py
ctfs/WeCTF/2021/Phish/main.py
import os from flask import Flask, render_template, request from peewee import * app = Flask(__name__) db = SqliteDatabase("core.db") class User(Model): id = AutoField() password = CharField() username = CharField(unique=True) class Meta: database = db @db.connection_context() def initia...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WeCTF/2022/StatusPage/main.py
ctfs/WeCTF/2022/StatusPage/main.py
import os import time import uuid from datetime import datetime from flask import Flask, render_template, jsonify, request import psutil from influxdb import InfluxDBClient from multiprocessing import Process DB_NAME = "network" def network_stats(): return psutil.net_io_counters()._asdict() def get_conn(): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/USC/2024/crypto/Its_Not_Called_Data_Loss_Prevention/handout.py
ctfs/USC/2024/crypto/Its_Not_Called_Data_Loss_Prevention/handout.py
from Crypto.Util.number import * p = 725822732075844095238364162055038734568406722448616689020689624280223586686442137170334102200948582137859091580820844096977818335257346426505761800027278640941788537395908884457537121962685677385821117042932732017210066487070089132424121969894871678519686183036597426481533528839171...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/USC/2024/crypto/unpopcorn/encoder.py
ctfs/USC/2024/crypto/unpopcorn/encoder.py
m = 57983 p = int(open("p.txt").read().strip()) def pop(s): return map(lambda x: ord(x)^42, s) def butter(s): return map(lambda x: x*p%m, s) def churn(s): l = list(map(lambda x: (x << 3), s)) return " ".join(map(lambda x: "{:x}".format(x).upper(), l[16:] + l[:16])) flag = open("flag.txt").read().str...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ICHSA/2021/crypto/Crime_Cloud/source.py
ctfs/ICHSA/2021/crypto/Crime_Cloud/source.py
import base64 import os import zlib def rand(n): return os.urandom(n) def xor(a,b): return bytes(x^y for x,y in zip(a,b)) def enc_otp(pt): return xor(pt, rand(len(pt))) def process(req): pt = zlib.compress(b"ICHSA_CTF{fake_flag_to_annoy_you_pay_us_ten_thousand_BTC}" + rand(32) + req) return enc...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ICHSA/2021/crypto/Poodle2/poodle2.py
ctfs/ICHSA/2021/crypto/Poodle2/poodle2.py
from binascii import hexlify, unhexlify from Crypto.Cipher import AES from Crypto.Random import get_random_bytes from Crypto.Util.Padding import pad, unpad import sys, traceback def encrypt(msg, key): iv = get_random_bytes(AES.block_size) cipher = AES.new(key, AES.MODE_CBC, iv) return iv + cipher.encrypt(p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ICHSA/2021/crypto/Baby_Homework/best_crypto_service.py
ctfs/ICHSA/2021/crypto/Baby_Homework/best_crypto_service.py
#!/usr/local/bin/python2 from Crypto.Cipher.AES import AESCipher import os, random, binascii from sys import argv import string import sys def padding(data): pad_size = 16 - (len(data) % 16) data = data + "".join([random.choice(string.printable) for _ in range(pad_size)]) return data def encrypt(data): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ICHSA/2021/crypto/Poodle1/poodle1.py
ctfs/ICHSA/2021/crypto/Poodle1/poodle1.py
from binascii import hexlify, unhexlify from Crypto.Cipher import AES from Crypto.Random import get_random_bytes from Crypto.Util.Padding import pad, unpad import sys, traceback def encrypt(msg, key): iv = get_random_bytes(AES.block_size) cipher = AES.new(key, AES.MODE_CBC, iv) return iv + cipher.encrypt(p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Tasteless/2021/crypto/crybaby/crybaby.py
ctfs/Tasteless/2021/crypto/crybaby/crybaby.py
#!/usr/bin/env python3 import os import sys # pip install cryptography from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from cryptography.hazmat.primitives.ciphers.aead import AESGCM key = os.urandom(16) def from_user(msg): decryptor = Cipher(algorithms.AES(key), modes.CTR(nonce)).enc...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Tasteless/2020/papple/adjust_image.py
ctfs/Tasteless/2020/papple/adjust_image.py
import os import mmap DEFAULT_FLAG = 'tstlss{XXXXXXXXXXXXXXXXXXXXXXXXXXXXX}' DEFAULT_IP = '133.133.133.133' ip = os.getenv('IP') flag = os.getenv('FLAG') if ip is None: print("Please specify an ip via the IP environment variable.") exit(-1) if len(ip) > len(DEFAULT_IP): print("Please specify an ip wit...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Tasteless/2020/movcode/chall.py
ctfs/Tasteless/2020/movcode/chall.py
#!/usr/bin/env python3 import re import sys import subprocess from time import sleep from shutil import rmtree from tempfile import TemporaryDirectory COMPILE_CMD = ['gcc', '-c', 'movcode.s'] LINK_CMD = ['ld', '-melf_x86_64', '-z', 'noexecstack', 'movcode.o'] RUN_CMD = ['setarch', 'x86_64', '-R', './a.out'] TEMPLAT...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LedgerDonjon/2021/rev/braincool/client.py
ctfs/LedgerDonjon/2021/rev/braincool/client.py
import requests CHALLENGE_URL = "http://braincool.donjon-ctf.io:3200/apdu" def get_public_key(): req = requests.post(CHALLENGE_URL, data=bytes.fromhex("e005000000")) response = req.content if response[-2:] != b"\x90\x00": return None return response[:-2] public_key = get_public_key() assert...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LedgerDonjon/2021/rev/puzzle/client.py
ctfs/LedgerDonjon/2021/rev/puzzle/client.py
import numpy as np import requests from binascii import hexlify url = "http://puzzle.donjon-ctf.io:7000" def send(dat): data = hexlify(bytes(dat, 'utf8')).decode() cmd = {'cmd' : 'send', 'data': data } x = requests.post(url, json = cmd) return x.json() if __name__ == "__main__": print(send("0\n1\...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LedgerDonjon/2021/crypto/stellar-radiation-1/challenge/server.py
ctfs/LedgerDonjon/2021/crypto/stellar-radiation-1/challenge/server.py
#!/usr/bin/env python import os from aiohttp import web from stellar_sdk import ( Keypair, Account, TransactionBuilder, Asset, Network, TransactionEnvelope, ) from stellar_sdk.exceptions import BadSignatureError app = web.Application() routes = web.RouteTableDef() STELLAR_SECRET = os.environ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LedgerDonjon/2021/crypto/magic-otp/app-otp/demo.py
ctfs/LedgerDonjon/2021/crypto/magic-otp/app-otp/demo.py
#!/usr/bin/env python3 """ Demo script that shows a setup of an OTP server with 2 OTP clients. The seed of the OTP server is known by the administrator. """ import base64 import bip32utils import mnemonic import os import struct import sys import time from cryptography.hazmat.backends import default_backend from cr...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LedgerDonjon/2021/crypto/magic-otp/challenge/app.py
ctfs/LedgerDonjon/2021/crypto/magic-otp/challenge/app.py
#!/usr/bin/env python3 import base64 import hashlib import hmac import json import os import struct import sys import time from flask import Flask, jsonify, request, send_from_directory, stream_with_context, Response from flask_limiter import Limiter from flask_limiter.util import get_remote_address import device ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LedgerDonjon/2021/crypto/fine--fine-/challenge/client.py
ctfs/LedgerDonjon/2021/crypto/fine--fine-/challenge/client.py
import numpy as np import requests from binascii import hexlify url = 'http://fine-fine.donjon-ctf.io:6000' def send_getpubkey(data): cmd = {'cmd' : 'getpubkey', 'data': data } x = requests.post(url, json = cmd) if x.headers["content-type"] == "application/octet-stream": trace = np.frombuffer(x.co...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LedgerDonjon/2021/crypto/stellar-radiation-2/challenge/server.py
ctfs/LedgerDonjon/2021/crypto/stellar-radiation-2/challenge/server.py
#!/usr/bin/env python import os import string from aiohttp import web from stellar_sdk import ( Keypair, Account, TransactionBuilder, Asset, Network, TransactionEnvelope, ) from stellar_sdk.exceptions import BadSignatureError app = web.Application() routes = web.RouteTableDef() STELLAR_SECRE...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LedgerDonjon/2021/crypto/virtual-public-network/placeholder/app.py
ctfs/LedgerDonjon/2021/crypto/virtual-public-network/placeholder/app.py
#!/usr/bin/env python3 from flask import Flask import os app = Flask(__name__) #insert your challenge here, only accessible through the vpn ! @app.route("/", methods=['GET']) def index(): return "Hello World, the flag is %s" % os.environ.get("FLAG") if __name__ == "__main__": app.run(host="0.0.0.0", port=8...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LedgerDonjon/2020/ghostbuster/ghostbuster/network/ssh-isolation.py
ctfs/LedgerDonjon/2020/ghostbuster/ghostbuster/network/ssh-isolation.py
#!/usr/bin/python3 -EIs """ Give a different UID to each SSH connection. Not meant to be secure, just prevent different users from messing with each other (there is nothing to see here.) """ import logging import os import re import shutil import sys MIN_UID = 3000 MAX_UID = 3100 WORKDIR = "/tmp/ghostbuster" def d...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false