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/BSidesTLV/2022/crypto/SEV/lib/session.py
ctfs/BSidesTLV/2022/crypto/SEV/lib/session.py
import enum import hashlib import hmac from typing import NamedTuple def KMAC(key, size, prefix, content): return hashlib.shake_256(key + size.to_bytes(4, byteorder='little') + prefix + content).digest(size) class RoleLabel(enum.Enum): I2R = b'I2R' R2I = b'R2I' class Role(enum.Enum): Initiator = (R...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2022/crypto/SEV/lib/io.py
ctfs/BSidesTLV/2022/crypto/SEV/lib/io.py
from typing import Protocol, runtime_checkable from .data import JoinData, SplitData @runtime_checkable class IOBase(Protocol): def writeLine(self, line : bytes) -> None: ... def readLine(self) -> bytes: ... class IO: def __init__(self, base : IOBase) -> None: self.base = base def readLi...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2022/crypto/SEV/lib/data.py
ctfs/BSidesTLV/2022/crypto/SEV/lib/data.py
from base64 import b64encode, b64decode def JoinData(*data : bytes): return b'|'.join(b64encode(d) for d in data) def SplitData(data : bytes): return tuple(b64decode(x) for x in data.split(b'|'))
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2022/crypto/HighExpectations/challenge.py
ctfs/BSidesTLV/2022/crypto/HighExpectations/challenge.py
import secrets import flag START_NUM_OF_PEOPLE = 60 PERFECT_SHOW = 2000 MAX_NUM_GAMES = 3000 RIGHT_GUESS = 60 WRONG_GUESS = 1 NUM_OF_SUITS = 4 NUM_OF_VALUES = 13 WELCOME_TEXT = """ You are a mentalist and now it's your show! It's your chance to make the impossible possible! Currently there are {} people in the show. ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2022/crypto/MediumExpectations/challenge.py
ctfs/BSidesTLV/2022/crypto/MediumExpectations/challenge.py
import random import hashlib import flag START_NUM_OF_PEOPLE = 60 PERFECT_SHOW = 2000 MAX_NUM_GAMES = 3000 RIGHT_GUESS = 60 WRONG_GUESS = 1 NUM_OF_SUITS = 4 NUM_OF_VALUES = 13 WELCOME_TEXT = """ You are a mentalist and now it's your show! It's your chance to make the impossible possible! Currently there are {} people...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2022/web/RollTheImpossible/challenge.py
ctfs/BSidesTLV/2022/web/RollTheImpossible/challenge.py
from flask import session import flag import random CTX_FIELDS = ["question", "num"] NUM_DIGITS = 10 FISH_IN_SEA = 3500000000000 # thanks wikipedia QUESTIONS_LIST = {"roll a negative number": lambda num: int(num) < 0, "roll a number that is divisable by 10": lambda num: int(num) % 10 == 0, "roll a num...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2022/web/RollTheImpossible/flask_server.py
ctfs/BSidesTLV/2022/web/RollTheImpossible/flask_server.py
import os import challenge from flask import Flask, session, render_template app = Flask(__name__) app.secret_key = os.getenv("SECRET_KEY", os.urandom(32)) @app.route("/") def init(): challenge.init() return render_template("index.html") @app.route("/step", methods=["POST"]) def step(): return challenge....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2022/web/RollTheImpossible/flag.py
ctfs/BSidesTLV/2022/web/RollTheImpossible/flag.py
FLAG = "BSidesTLV2022{1_wi11_n3ver_submi7_a_dummy_fl4g_ag4in}"
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2022/web/Smuggler/python-microservice/server.py
ctfs/BSidesTLV/2022/web/Smuggler/python-microservice/server.py
import os from flask import Flask, request from werkzeug.serving import WSGIRequestHandler app = Flask(__name__) @app.route('/') def run_cmd(): if 'cmd' in request.args: os.system(request.args['cmd']) return 'OK' @app.route('/', methods=['POST']) def echo_request(): return request.get_data() ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2024/Quals/rev/Nerfed/r.py
ctfs/LakeCTF/2024/Quals/rev/Nerfed/r.py
class R: def __init__(s)->None: s.__r=[0 for _ in range(11)] def s(s,r,v): s.__r[r]=v def g(s,r): return s.__r[r] def gh(s): return s.__r # Created by pyminifier (https://github.com/liftoff/pyminifier)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2024/Quals/rev/Nerfed/f.py
ctfs/LakeCTF/2024/Quals/rev/Nerfed/f.py
class F: def __init__(s)->None: s.__flag=0 def x(s,bit): s.__flag= s.__flag^(1<<bit) def s(s,bit,value=1): if value!=s.gf(bit): s.x(bit) def c(s,bit): s.__flag=s.__flag&~(1<<bit) def gf(s,bit): return 1 if s.__flag&(1<<bit)else 0 def gh(s): return hash(s.__flag) def gn(s): return s.__flag # Crea...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2024/Quals/rev/Nerfed/main.py
ctfs/LakeCTF/2024/Quals/rev/Nerfed/main.py
#!/usr/bin/env python3 import random import PIL.Image import numpy as np from PIL import Image import pickle import secrets from m import M from r import R from t import T from f import F def fin(): fl.c(0) exit("congrats, you can get flag") def fl_s(): fl.s(1,tb.c_c[rs.g(0),rs.g(1)]) fl.s(13,tb.r_c[rs.g(0),rs.g(1)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2024/Quals/rev/Nerfed/m.py
ctfs/LakeCTF/2024/Quals/rev/Nerfed/m.py
#!/usr/bin/env python3 import numpy as np class M: def __init__(s)->None: s.__m=np.load("flag.npz")["flag"] def gh(s): x_m=np.zeros(s.__m.shape[1],dtype=np.int8) for i in range(s.__m.shape[0]): x_m=x_m^s.__m[i] x_m.flags.writeable=False return x_m def s(s): mask=s.gh()*np.ones(s.__m.shape,dtype=np.int...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2024/Quals/rev/Nerfed/t.py
ctfs/LakeCTF/2024/Quals/rev/Nerfed/t.py
#!/usr/bin/env python3 import numpy as np class T: npz=np.load("tz.npz") c_c=npz["compute_check"] c_c.flags.writeable=False c_h=npz["compute_hash"] c_h.flags.writeable=False f_c=npz["flag_check"] f_c.flags.writeable=False f_h=npz["flag_hash"] f_h.flags.writeable=False r_c=npz["reg_check"] r_c.flags.writeable...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2024/Quals/rev/silent_lake/chal.py
ctfs/LakeCTF/2024/Quals/rev/silent_lake/chal.py
#!/usr/bin/env python3 import subprocess import tempfile import os def pns(s: str) -> None: print(s) pns("Give me the correct source code.") source = "" for line in iter(input, "EOF"): source += line + "\n" with tempfile.TemporaryDirectory() as tmpdirname: with open(os.path.join(tmpdirname, "main.c"), "...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2024/Quals/crypto/wild_signatures/server.py
ctfs/LakeCTF/2024/Quals/crypto/wild_signatures/server.py
#!/usr/bin/env python3 import os from Crypto.PublicKey import ECC from Crypto.Signature import eddsa flag = os.environ.get("FLAG", "EPFL{test_flag}") msgs = [ b"I, gallileo, command you to give me the flag", b"Really, give me the flag", b"can I haz flagg", b"flag plz" ] leos_key = ECC.generate(curve...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2024/Quals/crypto/cert/cert.py
ctfs/LakeCTF/2024/Quals/crypto/cert/cert.py
from binascii import hexlify, unhexlify from Crypto.Util.number import bytes_to_long, long_to_bytes from precomputed import message, signature, N, e from flag import flag if __name__ == "__main__": print(message + hexlify(long_to_bytes(signature)).decode()) cert = input(" > ") try: s = 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/LakeCTF/2024/Quals/crypto/cert/precomputed.py
ctfs/LakeCTF/2024/Quals/crypto/cert/precomputed.py
from Crypto.Util.number import bytes_to_long message = "Sign \"admin\" for flag. Cheers, " m = 147375778215096992303698953296971440676323238260974337233541805023476001824 N = 128134160623834514804190012838497659744559662971015449992742073261127899204627514400519744946918210411041809618188694716954631963628028483173612...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2024/Quals/crypto/hsb_2.2/challenge.py
ctfs/LakeCTF/2024/Quals/crypto/hsb_2.2/challenge.py
# Thanks to _MH_ for the code from Crypto.PublicKey import RSA from inspect import signature from secrets import choice import os RSA_LEN = 256 TYPE_USER = b"\x01" TYPE_INTERNAL = b"\x02" SECRET = os.getenv("flag", "EPFL{not_the_flag}").encode() def b2i(b: bytes) -> int: return int.from_bytes(b, "big") def i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2024/Quals/crypto/circuits/challenge.py
ctfs/LakeCTF/2024/Quals/crypto/circuits/challenge.py
from Crypto.Random import random import os B = 12 def and_gate(a, b): return a & b def or_gate(a, b): return a | b def xor_gate(a, b): return a ^ b def not_gate(a, x): return ~a & 1 def rand_circuit(size: int, input_size: int, output_size): circ_gates = [or_gate, not_gate, xor_gate, and_gate] a...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2023/Quals/pwn/trustMEE/exploit_template.py
ctfs/LakeCTF/2023/Quals/pwn/trustMEE/exploit_template.py
from pwn import * import hashlib import re import base64 def upload(r, bytes, outfile_path): r.sendline(f"touch {outfile_path}.b64".encode()) b64_data = base64.b64encode(bytes) for i in range(0, len(b64_data), 256): chunk = b64_data[i:i + 256] r.sendline(f'echo -n {chunk.decode()} >> {outf...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2023/Quals/crypto/KeySharer/chal.py
ctfs/LakeCTF/2023/Quals/crypto/KeySharer/chal.py
#!/usr/bin/env -S python3 -u import os from Crypto.Util.number import isPrime, bytes_to_long from Crypto.Random.random import randrange class Point: def __init__(self,x,y,curve, isInfinity = False): self.x = x % curve.p self.y = y % curve.p self.curve = curve self.isInfinity = isInfinity def __add__(self,othe...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2023/Quals/crypto/Vigenere_CBC/vigenere.py
ctfs/LakeCTF/2023/Quals/crypto/Vigenere_CBC/vigenere.py
import secrets SHIFT = 65 MOD = 26 BLOCKLENGTH = 20 def add(block1,block2): assert(len(block1)<= len(block2)) assert(len(block2)<= BLOCKLENGTH) b1upper = block1.upper() b2upper = block2.upper() b1 = [ ord(b1upper[i])-SHIFT for i in range(len(block1))] b2 = [ ord(b2upper[i])-SHIFT for i in rang...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2023/Quals/crypto/Choices/choices.py
ctfs/LakeCTF/2023/Quals/crypto/Choices/choices.py
import random, string flag = ''.join(random.SystemRandom().sample(string.ascii_letters, 32)) print(f"EPFL{{{flag}}}") open("output.txt", "w").write(''.join(random.choices(flag, k=10000)))
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2023/Quals/web/Cyber_Library/serve.py
ctfs/LakeCTF/2023/Quals/web/Cyber_Library/serve.py
from web import create_app if __name__ == '__main__': app = create_app() app.run(host='0.0.0.0', port=8080, debug=False)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2023/Quals/web/Cyber_Library/web/user.py
ctfs/LakeCTF/2023/Quals/web/Cyber_Library/web/user.py
from flask_login import UserMixin class User(UserMixin): def __init__(self, id): self.id = id
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2023/Quals/web/Cyber_Library/web/main.py
ctfs/LakeCTF/2023/Quals/web/Cyber_Library/web/main.py
from flask import Blueprint, abort, current_app from flask import flash, render_template, redirect, url_for, request from flask_cors import cross_origin from flask_login import login_user, current_user import os import time import validators from . import admin_token, sock, limiter, q, User from .bot import visit ORIG...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2023/Quals/web/Cyber_Library/web/__init__.py
ctfs/LakeCTF/2023/Quals/web/Cyber_Library/web/__init__.py
from flask import Flask, render_template from flask_cors import CORS from flask_limiter import Limiter from flask_limiter.util import get_remote_address from flask_login import LoginManager, UserMixin from flask_sock import Sock from redis import Redis from rq import Queue from werkzeug.exceptions import HTTPException ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2023/Quals/web/Cyber_Library/web/bot.py
ctfs/LakeCTF/2023/Quals/web/Cyber_Library/web/bot.py
from playwright.sync_api import sync_playwright from time import sleep import sys def visit(url, admin_token): print("Visiting", url, file=sys.stderr) with sync_playwright() as p: # Launch a headless browser with custom Firefox preferences browser = p.firefox.launch( headless=True,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2025/Quals/pwn/stackception_2/chall.py
ctfs/LakeCTF/2025/Quals/pwn/stackception_2/chall.py
#!/usr/bin/env -S python3 -u import os import subprocess as sp from textwrap import dedent def main(): msg = dedent( """ Enter assembly code Note: replace spaces with underscores, newlines with '|', e.g., main: push 5 call main becomes 'main:|push...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2025/Quals/pwn/stackception_1/chall.py
ctfs/LakeCTF/2025/Quals/pwn/stackception_1/chall.py
#!/usr/bin/env -S python3 -u import os import subprocess as sp from textwrap import dedent def main(): msg = dedent( """ Enter assembly code Note: replace spaces with underscores, newlines with '|', e.g., main: push 5 call main becomes 'main:|push...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2025/Quals/crypto/Guess_Flag/Guessflag.py
ctfs/LakeCTF/2025/Quals/crypto/Guess_Flag/Guessflag.py
#!/usr/bin/env -S python3 -u flag = "00000000000000000000000000000000" print("Don't even think to guess the flag by brute force, it is 32 digits long!") user_input = input() if not user_input.isdigit(): print("Flag only contains digits!") exit() index = 0 for char in user_input: if char != flag[ind...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2025/Quals/crypto/The_Phantom_Menace/chall.py
ctfs/LakeCTF/2025/Quals/crypto/The_Phantom_Menace/chall.py
import numpy as np import json try: from flag import flag except: flag = "redacted_this_is_just_so_that_it_works_and_you_can_test_locally." m_b = np.array([int(c) for char in flag for c in format(ord(char), '08b')]) # Parameters q = 3329 n = 512 k = 4 f = np.array([1] + [0]*(n-1) + [1]) assert len(m_b)==n ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2025/Quals/crypto/Attack_of_the_Clones/chall.py
ctfs/LakeCTF/2025/Quals/crypto/Attack_of_the_Clones/chall.py
import numpy as np import json try: from flag import flag except: flag = "redacted_this_is_just_so_that_it_works_and_you_can_test_locally." m_b = np.array([int(c) for char in flag for c in format(ord(char), '08b')]) # Parameters q = 3329 n = 512 k = 4 f = np.array([1] + [0]*(n-1) + [1]) assert len(m_b)==n ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2025/Quals/crypto/Quantum_vernam/chall.py
ctfs/LakeCTF/2025/Quals/crypto/Quantum_vernam/chall.py
#!/usr/bin/env -S python3 -u import os import numpy as np from math import sqrt # no need quantum libraries here, only linear algebra. from scipy.stats import unitary_group def string_to_bits(s): bits = [] for byte in s: for i in range(8): bits.append((byte >> (7 - i)) & 1) return b...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2025/Quals/crypto/Ez_Part/chall.py
ctfs/LakeCTF/2025/Quals/crypto/Ez_Part/chall.py
#!/usr/bin/env python3 import string from flask import Flask, request, jsonify import hashlib import random import os from Crypto.Util.number import getPrime, isPrime, bytes_to_long from default_vals import masks app = Flask(__name__) BITS = 1535 def gen_p(BITS): while True: q = getPrime(BITS - 150) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2025/Quals/crypto/Revenge_of_the_Sith/chall.py
ctfs/LakeCTF/2025/Quals/crypto/Revenge_of_the_Sith/chall.py
import numpy as np import json # message try: from flag import flag except: flag = "redacted_this_is_just_so_that_it_works_and_you_can_test_locally." m_process = [int(c) for char in flag for c in format(ord(char), '08b')] # Parameters q = 251 n = 16 k = 2 f = np.array([1] + [0]*(n-1) + [1]) m_b = np.array([...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2022/Quals/blockchain/QuinEVM/quinevm.py
ctfs/LakeCTF/2022/Quals/blockchain/QuinEVM/quinevm.py
#!/usr/bin/env -S python3 -u LOCAL = False # Set this to true if you want to test with a local hardhat node, for instance ############################# import os.path, hashlib, hmac BASE_PATH = os.path.abspath(os.path.dirname(__file__)) if LOCAL: from web3.auto import w3 as web3 else: from web3 import Web3,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2022/Quals/blockchain/Immutable/immutable.py
ctfs/LakeCTF/2022/Quals/blockchain/Immutable/immutable.py
#!/usr/bin/env -S python3 -u LOCAL = False # Set this to true if you want to test with a local hardhat node, for instance ############################# import os.path, hashlib, hmac BASE_PATH = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(BASE_PATH, "key")) as f: KEY = bytes.fromhex(f.read(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2022/Quals/crypto/ps2-enjoyer/sign.py
ctfs/LakeCTF/2022/Quals/crypto/ps2-enjoyer/sign.py
#!/bin/python3 import hashlib from math import gcd import random def generate_inv_elem(n): while True: k = random.randint(1, n) if gcd(k, n) == 1: return k with open("flag", "rb") as f: flag = f.read() assert len(flag) == 32 flag = random.randbytes(128 - 32) + flag x = int.from_bytes(flag, 'big...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2022/Quals/crypto/quremo/quremo.py
ctfs/LakeCTF/2022/Quals/crypto/quremo/quremo.py
#!/usr/bin/env python3 from Crypto.Util.number import * import sys from secret import privkey, flag def encrypt(m, pubkey): g, n = pubkey c = pow(g, m, n ** 2) return c def main(): border = "|" pr(border*72) pr(border, " Welcome to Quremo battle, try our ultra secure encryption oracle! ", border) pr(border, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2022/Quals/crypto/LeakyFileVault/filevault.py
ctfs/LakeCTF/2022/Quals/crypto/LeakyFileVault/filevault.py
#!/usr/local/bin/python3 from hashlib import blake2s from rich.table import Table from rich.console import Console from rich.prompt import Prompt from binascii import unhexlify import pathlib BLOCK_SIZE = 8 def pad(data, block_size): if len(data) % block_size == 0: return data else: return da...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2022/Quals/crypto/chaindle/chaindle.py
ctfs/LakeCTF/2022/Quals/crypto/chaindle/chaindle.py
#!/usr/local/bin/python from Crypto.Cipher import AES from Crypto.Util.Padding import pad from Crypto.Random import get_random_bytes from Crypto.Random.random import shuffle from enum import Enum from hashlib import sha256 import json import string class Color(Enum): BLACK = "⬛" YELLOW = "🟨" GREEN = "�...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2022/Quals/web/Clob-Mate/src/models.py
ctfs/LakeCTF/2022/Quals/web/Clob-Mate/src/models.py
from . import db class Order(db.Model): order_id = db.Column(db.Text(), primary_key=True) email = db.Column(db.Text()) username = db.Column(db.Text()) quantity = db.Column(db.Text()) address = db.Column(db.Text()) article = db.Column(db.Text()) status = db.Column(db.Text())
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2022/Quals/web/Clob-Mate/src/main.py
ctfs/LakeCTF/2022/Quals/web/Clob-Mate/src/main.py
from flask import Blueprint, abort, escape from flask import flash, render_template, redirect, url_for, request import os from . import db, limiter, q from .models import Order from .bot import visit import codecs import ipaddress main = Blueprint('main', __name__) @main.route('/') def index(): return render_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2022/Quals/web/Clob-Mate/src/__init__.py
ctfs/LakeCTF/2022/Quals/web/Clob-Mate/src/__init__.py
from flask import Flask, render_template from flask_limiter import Limiter from flask_limiter.util import get_remote_address from flask_sqlalchemy import SQLAlchemy from redis import Redis from rq import Queue from werkzeug.exceptions import HTTPException import os db = SQLAlchemy() limiter = Limiter(key_func=get_remo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2022/Quals/web/Clob-Mate/src/bot.py
ctfs/LakeCTF/2022/Quals/web/Clob-Mate/src/bot.py
from pyppeteer import launch import asyncio async def visit(order_id): url = f'http://web:8080/orders/{order_id}/preview' print("Visiting", url) browser = await launch({'args': ['--no-sandbox', '--disable-setuid-sandbox']}) page = await browser.newPage() await page.goto(url) await asyncio.slee...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2022/Quals/web/People/src/models.py
ctfs/LakeCTF/2022/Quals/web/People/src/models.py
from . import db from flask_login import UserMixin class User(UserMixin, db.Model): id = db.Column(db.String(16), primary_key=True) email = db.Column(db.String(100), unique=True) password = db.Column(db.String(100)) fullname = db.Column(db.Text()) title = db.Column(db.Text()) lab = db.Column(d...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2022/Quals/web/People/src/main.py
ctfs/LakeCTF/2022/Quals/web/People/src/main.py
from flask import Blueprint, abort from flask import flash, render_template, redirect, url_for, request from flask_login import login_user, logout_user, login_required, current_user from werkzeug.security import generate_password_hash, check_password_hash import os import secrets from . import db, admin_token, limiter,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2022/Quals/web/People/src/__init__.py
ctfs/LakeCTF/2022/Quals/web/People/src/__init__.py
from flask import Flask, render_template from flask_limiter import Limiter from flask_limiter.util import get_remote_address from flask_login import LoginManager from flask_sqlalchemy import SQLAlchemy from flask_talisman import Talisman from redis import Redis from rq import Queue from werkzeug.exceptions import HTTPE...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LakeCTF/2022/Quals/web/People/src/bot.py
ctfs/LakeCTF/2022/Quals/web/People/src/bot.py
from pyppeteer import launch import asyncio async def visit(user_id, admin_token): url = f'http://web:8080/profile/{user_id}' print("Visiting", url) browser = await launch({'args': ['--no-sandbox', '--disable-setuid-sandbox']}) page = await browser.newPage() await page.setCookie({'name': 'admin_to...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberHeroines/2023/pwn/Ada_Lovelace/punchcard.py
ctfs/CyberHeroines/2023/pwn/Ada_Lovelace/punchcard.py
#!/usr/bin/env python3 import sys import unittest def parse_punch_card(card): row_values = "0123456789abcdef" lines = card.strip().split('\n') punched_rows = [line for line in lines if 'o' in line] result = "" col_starts = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60] for col ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberHeroines/2023/crypto/Katherine_Johnson/service.py
ctfs/CyberHeroines/2023/crypto/Katherine_Johnson/service.py
#!/usr/bin/env python3 import string import random import time import math import signal import sys from functools import partial NUM_TO_SEND = 300 SEND_TIME = 15 GRACE_TIME = 120 FLAG = "./flag.txt" # For better functionality when paired with socat print_flush = partial(print, flush=True) # Signal handler for prog...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberHeroines/2023/crypto/Shannon_Kent/solve.py
ctfs/CyberHeroines/2023/crypto/Shannon_Kent/solve.py
from binascii import unhexlify from gzip import decompress from struct import pack from datetime import datetime from zipfile import ZipFile from io import BytesIO from pwn import xor print('start here')
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberHeroines/2023/web/Shafrira_Goldwasser/app.py
ctfs/CyberHeroines/2023/web/Shafrira_Goldwasser/app.py
from flask import Flask, render_template, request import sqlite3 import subprocess app = Flask(__name__) # Database connection #DATABASE = "database.db" def query_database(name): query = 'sqlite3 database.db "SELECT biography FROM cyberheroines WHERE name=\'' + str(name) +'\'\"' result = subprocess.check_out...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UACTF/2022/rev/pain/final.py
ctfs/UACTF/2022/rev/pain/final.py
list(__builtins__.__dict__.items())[[list(__builtins__.__dict__.items())[[__builtins__.__dict__['__tropmi__'[::-1]]('bilhsah'[::-1]).md5(gl.encode()).hexdigest() for gl in list(__builtins__.__dict__)].index(list(set([__builtins__.__dict__['__tropmi__'[::-1]]('bilhsah'[::-1]).md5(gl.encode()).hexdigest() for gl in list(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
true
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UACTF/2022/crypto/Non-textualTroubles/xor.py
ctfs/UACTF/2022/crypto/Non-textualTroubles/xor.py
from random import seed, randrange seed(True, version=2) with open("plaintext.txt", "r") as read, open("ciphertext.txt", "w") as write: plaintext = read.read() for char in plaintext: A = ord(char) B = randrange(256) ciphertext = chr(A ^ B) write.write(ciphertext)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TokyoWesterns/2018/EscapeMe/pow.py
ctfs/TokyoWesterns/2018/EscapeMe/pow.py
#!/usr/bin/env python2.7 # # Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TokyoWesterns/2020/vi-deteriorated/run.py
ctfs/TokyoWesterns/2020/vi-deteriorated/run.py
#!/usr/bin/python3 import pty pty.spawn("./vid")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WxMCTF/2024/rev/Recursive_Combinatorics/rev4_5s33Foa.py
ctfs/WxMCTF/2024/rev/Recursive_Combinatorics/rev4_5s33Foa.py
from hashlib import sha512 def acid(s): return sha512(s.encode('utf-8')).hexdigest() def ___(n, k): a = 0 for _ in range(1, k+1): j = 0 while(n>=(1<<j)): a += n&(1<<j) j += 1 return a def rock(a, n): if n == 0: return 1 return a*rock(___(a, a),n...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WxMCTF/2024/rev/Binary_Conspicuous_Digits/encrypt.py
ctfs/WxMCTF/2024/rev/Binary_Conspicuous_Digits/encrypt.py
#!/usr/bin/env python3 flag = 'wxmctf{REDACTED}' encoded = '' for c in flag: encoded += ''.join(map( lambda x: format(int(x), 'b').zfill(4), str(ord(c)).zfill(3) )) with open('output.txt', 'w') as output: output.write(encoded)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WxMCTF/2024/crypto/3_5_business_days/chal_Z0ks27x.py
ctfs/WxMCTF/2024/crypto/3_5_business_days/chal_Z0ks27x.py
import os from Crypto.Util.number import * ks = [bytes_to_long(os.urandom(16)) for i in range(11)] s = [250, 116, 131, 104, 181, 251, 127, 32, 155, 191, 125, 31, 214, 151, 67, 50, 36, 123, 141, 47, 12, 112, 249, 133, 207, 139, 161, 119, 231, 120, 136, 68, 162, 158, 110, 217, 247, 183, 176, 111, 146, 215, 159, 212...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WxMCTF/2024/crypto/Espionagey_Crafty_Clues/jumbler_QWGaWww.py
ctfs/WxMCTF/2024/crypto/Espionagey_Crafty_Clues/jumbler_QWGaWww.py
import random gen = [XXXXXXXX] # Past generator points x1 = [] # First half of the x-coords x2 = [] # Second half of the x-coords y1 = [] # First half of the y-coords y2 = [] # Second half of the y-coords for i in gen: x = str(i[0]) y = str(i[1]) x1.append(x[0:len(x) // 2]) x2.append(x[len(x) // 2:...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WxMCTF/2024/crypto/racing/chal.py
ctfs/WxMCTF/2024/crypto/racing/chal.py
import os from Crypto.Util.number import * def rng(): m = 1<<48 a = 25214903917 b = 11 s = bytes_to_long(os.urandom(6)) while True: yield (s>>24)%6+1 s = (a*s+b)%m r = rng() cpuPlayers = [0]*6 yourPlayers = [0]*6 def printBoard(cpu, your): board = [[] for i in range(100)] ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WxMCTF/2023/rev/NaturalSelection/main_xiRTmuC.py
ctfs/WxMCTF/2023/rev/NaturalSelection/main_xiRTmuC.py
from base64 import * from os import * from sys import * exec(b64decode("aW1wb3J0IGJhc2U2NAoKYiA9IGludChpbnB1dCgiYmFzZSA/IGRlY29kZT8gIikpCgpleGVjKGdldGF0dHIoYmFzZTY0LCBmImJ7Yn1kZWNvZGUiKSgiTVY0R0tZWklNSTNESVpERk1OWFdJWkpJRUpORzRTVFdNSkpVRU1EQks0WVdZU0tITlIyR0dSWlpQRlNFR1FUMk1KRFZNM0RESUZZRzJZU0RJRTRVU1IzTU9WUlVRVlJRSk5C...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WxMCTF/2023/rev/Brainf/interpreter.py
ctfs/WxMCTF/2023/rev/Brainf/interpreter.py
import sys TAPE_SIZE = 500 def run(code): stack = [] lmatch = dict() rmatch = dict() for i in range(len(code)): if code[i] == '[': stack.append(i) elif code[i] == ']': lmatch[i] = stack[-1] rmatch[stack[-1]] = i stack.pop() tape = [0]...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WxMCTF/2023/crypto/Permutations/main_njzMd2E.py
ctfs/WxMCTF/2023/crypto/Permutations/main_njzMd2E.py
import random from Crypto.Util.number import * from Crypto.Cipher import AES from hashlib import sha256 import os N = 100000 flag = b'wxmctf{REDACTED}' f = open("out.txt", "w") def compose(a, b): r = [] for i in range(N): r.append(b[a[i]]) return r G = [x for x in range(N)] random.shuffle(G) pri...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WxMCTF/2023/crypto/maze/maze_zS72xsE.py
ctfs/WxMCTF/2023/crypto/maze/maze_zS72xsE.py
#!/usr/local/bin/python3 from random import getrandbits from hashlib import sha256 from console.utils import wait_key from console.screen import Screen class PRNG: def __init__(self, seed): self.state = seed self.mul = 25214903917 self.add = 11 self.mod = 1 << 48 def next(sel...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WxMCTF/2023/crypto/CommonRoom/chall.py
ctfs/WxMCTF/2023/crypto/CommonRoom/chall.py
from Crypto.Util.number import * from Crypto.Random.random import * p = getPrime(1024) q = getPrime(1024) n = p*q flag = bytes_to_long(open("flag.txt", "rb").read()) iv = getrandbits(1024) def genPoly(iv): ret = [] s = 0 for i in range(64, 0, -1): a = getrandbits(1024) ret.append(a) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WxMCTF/2023/crypto/LOCAL_HIDDEN_VARIABLES/author_q6CvOT9.py
ctfs/WxMCTF/2023/crypto/LOCAL_HIDDEN_VARIABLES/author_q6CvOT9.py
import base64 import RC4 flag = "CTF{CENSORED}" # CENSORED rc4 = RC4.RC4("CENSORED", 0) # CENSORED, established 40-bit key # the first number may be 8 and the last number may be 9 rc4a = RC4.RC4("CENSORED") # CENSORED, 16-bit pre-shared key last = rc4.cipher(flag, "plain", "plain") for i in range(3): last = rc4.c...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WxMCTF/2023/web/NFTs/app.py
ctfs/WxMCTF/2023/web/NFTs/app.py
from flask import Flask, request, render_template, redirect, flash, make_response from flask import send_from_directory import os app = Flask(__name__) app.secret_key = os.urandom(16) @app.route("/", methods=['GET', 'POST']) def index(): if request.method == 'POST': if 'file' not in request.files: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VishwaCTF/2023/rev/Phi-Calculator/Phi_Calculator.py
ctfs/VishwaCTF/2023/rev/Phi-Calculator/Phi_Calculator.py
#============================================================================# #============================Phi CALCULATOR===============================# #============================================================================# import hashlib from cryptography.fernet import Fernet import base64 # GLOBALS --v ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VishwaCTF/2023/crypto/0_or_1/up_down.py
ctfs/VishwaCTF/2023/crypto/0_or_1/up_down.py
#Just a simple Python program. Isn't it?? k = "1010" n = "" for i in k: if i == '0': n += '1' else: n += '0' print(n)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VishwaCTF/2023/crypto/SharingIsCaring/challenge.py
ctfs/VishwaCTF/2023/crypto/SharingIsCaring/challenge.py
from sympy import randprime from random import randrange def generate_shares(secret, k, n): prime = randprime(secret, 2*secret) coeffs = [secret] + [randrange(1, prime) for _ in range(k-1)] shares = [] for i in range(1, n+1): x = i y = sum(c * x**j for j, c in enumerate(coeffs)) % prim...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VishwaCTF/2022/rev/BetGame/sage.py
ctfs/VishwaCTF/2022/rev/BetGame/sage.py
sage_words = "ǏLJǣŻǏƟƣƷƫƣƷƛŻƷƓƛƓǏƣǗƓƯǣ" def _0000xf69(passed_strr): _0000xf42='' for _0000xf72 in passed_strr: _0000xf96 = _0000xf106(_0000xf72) _0000xf42 = _0000xf42+chr(2*(ord(_0000xf96))+1) return _0000xf42 def _0000xf106(passed_char): return chr(2*(ord(passed_ch...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VishwaCTF/2022/rev/OneWayEnigma/OneWayEnigma.py
ctfs/VishwaCTF/2022/rev/OneWayEnigma/OneWayEnigma.py
from string import ascii_uppercase, digits class rotors: saved = { 1:('{K8UMNZBGS20D3IR_5CEFYOQPX4JH1VA}96TW7L',[9]), 2:('EFXRSBQ1MC3GYW_9{47AVT8JP5ON6U20ZK}HDIL',[23]), 3:('WUXQGVJHT2YO043MK17LC9ANZBP{_S6D}I5EFR8',[7]), 4:('W0K2NBVRPJTZY1XHD9478L{QUMG6I_O3FAS5}CE',...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VishwaCTF/2022/rev/OneWayEnigma/machine.py
ctfs/VishwaCTF/2022/rev/OneWayEnigma/machine.py
from OneWayEnigma import * settings = getSettings() encryptor = Enigma(settings) print(Encrypt(input("ENTER_YOUR_SECRETS_HERE >>> "), encryptor)) # No. of rotors = 5, sequence = (5,3,1,2,4), positions = (?, ?, ?, ?, ?)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VishwaCTF/2022/rev/RunTheCat/cat.py
ctfs/VishwaCTF/2022/rev/RunTheCat/cat.py
CAT = int cAT = len CaT = print RAT = str CATCATCATCATCATCAT = RAT.isdigit def Kitty(cat): return RAT(CAT(cat)*CATCATCAT) def CAt(cat, cats): print(cat, cats) cat1 = 0 cat2 = 0 catcat = 0 cAt = "" while cat1 < cAT(cat) and cat2 < cAT(cats): if catcat%CATCATCAT == CATCATCATCATCAT//...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VishwaCTF/2022/crypto/JumbleBumble/script.py
ctfs/VishwaCTF/2022/crypto/JumbleBumble/script.py
import random from Crypto.Util.number import getPrime, bytes_to_long flags = [] with open('stuff.txt', 'rb') as f: for stuff in f.readlines(): flags.append(stuff) with open('flag.txt', 'rb') as f: flag = f.read() flags.append(flag) random.shuffle(flags) for rand in flags: p = getPrime(1024...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/JerseyCTF/2025/pwn/Play_Fairi/file.py
ctfs/JerseyCTF/2025/pwn/Play_Fairi/file.py
import random from random import randint def reverseMe(p): random.seed(3211210) arr = ['j', 'b', 'c', 'd', '2', 'f', 'g', 'h', '1', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'y', 'v', '3', '}', '{', '_'] t = [] for i in range(len(arr), 0, -1): l = randint(0, i-1) t.app...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/JerseyCTF/2025/crypto/CryptoPass_API/server.py
ctfs/JerseyCTF/2025/crypto/CryptoPass_API/server.py
#!/usr/local/bin/python from Crypto.Cipher import AES from random import seed,choices,randint from os import urandom,environ from string import ascii_letters,digits seed(urandom(16)) charset = ascii_letters+digits admin_id = "RokosBasiliskIsSuperCool" master_key = urandom(16) def crypt(data, iv, enc): if type(data)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/JerseyCTF/2022/crypto/file-zip-cracker/FileZipCracker_Challenge_Version.py
ctfs/JerseyCTF/2022/crypto/file-zip-cracker/FileZipCracker_Challenge_Version.py
import zipfile import itertools from itertools import permutations # Function for extracting zip files to test if the password works! def extractFile(zip_file, password): try: zip_file.extractall(pwd=password.encode()) return True except KeyboardInterrupt: exit(0) except Exception ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/JerseyCTF/2022/crypto/hidden-in-plain-sight/encryption.py
ctfs/JerseyCTF/2022/crypto/hidden-in-plain-sight/encryption.py
import base64 import os from base64 import b64encode from Cryptodome.Cipher import AES from Cryptodome.Util.Padding import pad key = "" # Don't worry damien. I hid the key. Don't worry about it. This encryption program is secure. with open("flag_message_key", 'rb') as NFILE: malware_code = NFILE.read() crypto...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2021/pwn/seccon_tree/env/run.py
ctfs/SECCON/2021/pwn/seccon_tree/env/run.py
#!/usr/bin/env python3.7 import sys import os import binascii import re import subprocess import signal import string import urllib.request LIBFILE = "seccon_tree.cpython-39-x86_64-linux-gnu.so" def handler(_x,_y): sys.exit(-1) signal.signal(signal.SIGALRM, handler) signal.alarm(30) def gen_filename(): ret...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2021/pwn/seccon_tree/env/template.py
ctfs/SECCON/2021/pwn/seccon_tree/env/template.py
from seccon_tree import Tree # Debug utility seccon_print = print seccon_bytes = bytes seccon_id = id seccon_range = range seccon_hex = hex seccon_bytearray = bytearray class seccon_util(object): def Print(self, *l): seccon_print(*l) def Bytes(self, o): return seccon_bytes(o) def Id(self, o...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2021/pwn/seccon_tree/src/setup.py
ctfs/SECCON/2021/pwn/seccon_tree/src/setup.py
from distutils.core import setup, Extension setup(name='seccon_tree', version='1.0', ext_modules=[Extension('seccon_tree', ['lib.c'])] )
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2021/pwn/pyast64/pyast64.py
ctfs/SECCON/2021/pwn/pyast64/pyast64.py
#!/usr/bin/env python3.9 """Compile a subset of the Python AST to x64-64 assembler. Read more about it here: http://benhoyt.com/writings/pyast64/ Released under a permissive MIT license (see LICENSE.txt). """ import ast import tempfile import subprocess import urllib.request class Assembler: """The Assembler tak...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2021/rev/pyast64/pyast64.py
ctfs/SECCON/2021/rev/pyast64/pyast64.py
#!/usr/bin/env python3.9 """Compile a subset of the Python AST to x64-64 assembler. Read more about it here: http://benhoyt.com/writings/pyast64/ Released under a permissive MIT license (see LICENSE.txt). """ import ast import tempfile import subprocess import urllib.request class Assembler: """The Assembler tak...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2021/crypto/CCC/challenge.py
ctfs/SECCON/2021/crypto/CCC/challenge.py
from Crypto.Util.number import bytes_to_long, getPrime, getRandomInteger, isPrime from secret import flag def create_prime(p_bit_len, add_bit_len, a): p = getPrime(p_bit_len) p_bit_len2 = 2*p_bit_len // 3 + add_bit_len while True: b = getRandomInteger(p_bit_len2) _p = a * p q = _p*...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2021/crypto/cerberus/problem.py
ctfs/SECCON/2021/crypto/cerberus/problem.py
import base64 from Crypto.Cipher import AES from Crypto.Random import get_random_bytes from Crypto.Util.Padding import pad, unpad from Crypto.Util.strxor import strxor from flag import flag import signal key = get_random_bytes(16) block_size = 16 # encrypt by AES-PCBC # https://en.wikipedia.org/wiki/Block_cipher_mode...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2021/crypto/oOoOoO/problem.py
ctfs/SECCON/2021/crypto/oOoOoO/problem.py
import signal from Crypto.Util.number import long_to_bytes, bytes_to_long, getPrime import random from flag import flag message = b"" for _ in range(128): message += b"o" if random.getrandbits(1) == 1 else b"O" M = getPrime(len(message) * 5) S = bytes_to_long(message) % M print("M =", M) print('S =', S) print('M...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2018/Quals/internet_of_seat/wrapper.py
ctfs/SECCON/2018/Quals/internet_of_seat/wrapper.py
#!/usr/bin/python -u import os import socket import subprocess import threading import sys from hashlib import md5 from contextlib import closing sys.stderr = open('/tmp/log', 'wb', 0) def find_free_port(): with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s: s.setsockopt(socket.SOL_SOCK...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2023/Quals/misc/readme_2023/server.py
ctfs/SECCON/2023/Quals/misc/readme_2023/server.py
import mmap import os import signal signal.alarm(60) try: f = open("./flag.txt", "r") mm = mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ) except FileNotFoundError: print("[-] Flag does not exist") exit(1) while True: path = input("path: ") if 'flag.txt' in path: print("[-] Path not al...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2023/Quals/rev/Sickle/problem.py
ctfs/SECCON/2023/Quals/rev/Sickle/problem.py
import pickle, io payload = b'\x8c\x08builtins\x8c\x07getattr\x93\x942\x8c\x08builtins\x8c\x05input\x93\x8c\x06FLAG> \x85R\x8c\x06encode\x86R)R\x940g0\n\x8c\x08builtins\x8c\x04dict\x93\x8c\x03get\x86R\x8c\x08builtins\x8c\x07globals\x93)R\x8c\x01f\x86R\x8c\x04seek\x86R\x94g0\n\x8c\x08builtins\x8c\x03int\x93\x8c\x07__a...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2023/Quals/sandbox/crabox/app.py
ctfs/SECCON/2023/Quals/sandbox/crabox/app.py
import sys import re import os import subprocess import tempfile FLAG = os.environ["FLAG"] assert re.fullmatch(r"SECCON{[_a-z0-9]+}", FLAG) os.environ.pop("FLAG") TEMPLATE = """ fn main() { {{YOUR_PROGRAM}} /* Steal me: {{FLAG}} */ } """.strip() print(""" 🦀 Compile-Time Sandbox Escape 🦀 Input your progra...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2023/Quals/crypto/plai_n_rsa/problem.py
ctfs/SECCON/2023/Quals/crypto/plai_n_rsa/problem.py
import os from Crypto.Util.number import bytes_to_long, getPrime flag = os.getenvb(b"FLAG", b"SECCON{THIS_IS_FAKE}") assert flag.startswith(b"SECCON{") m = bytes_to_long(flag) e = 0x10001 p = getPrime(1024) q = getPrime(1024) n = p * q e = 65537 phi = (p-1)*(q-1) d = pow(e, -1, phi) hint = p+q c = pow(m,e,n) print(f...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2023/Quals/crypto/CIGISICGICGICG/problem.py
ctfs/SECCON/2023/Quals/crypto/CIGISICGICGICG/problem.py
import os from functools import reduce from secrets import randbelow flag = os.getenvb(b"FLAG", b"FAKEFLAG{THIS_IS_FAKE}") p1 = 21267647932558653966460912964485513283 a1 = 6701852062049119913950006634400761786 b1 = 19775891958934432784881327048059215186 p2 = 21267647932558653966460912964485513289 a2 = 107205246498882...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2017/Quals/interpreter/interpreter.py
ctfs/SECCON/2017/Quals/interpreter/interpreter.py
import ast, sys, re, struct, tempfile, os from uuid import uuid4 if len(sys.argv) < 2: sys.argv.append('test.asm') if len(sys.argv) < 3: sys.argv.append(tempfile.mktemp(prefix='%s_' % uuid4(), dir='/tmp/relativity')) f = open(sys.argv[1], 'r') f2 = open(sys.argv[2], 'wb') # Opcode definition handler = {} def sd(sr...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2017/Quals/interpreter/server.py
ctfs/SECCON/2017/Quals/interpreter/server.py
import os import random import tempfile import re from uuid import uuid4 from flask import Flask, abort, render_template, request app = Flask(__name__) root = os.path.dirname(os.path.abspath(__file__)) upload_dir = os.path.join(root, 'upload') interpreter = os.path.join(root, 'interpreter.py') temp_dir = '/tmp/relati...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2022/Quals/pwn/lslice/bin/app.py
ctfs/SECCON/2022/Quals/pwn/lslice/bin/app.py
#!/usr/bin/env python3 import subprocess import sys import tempfile print("Input your Lua code (End with \"__EOF__\"):", flush=True) source = "" while True: line = sys.stdin.readline() if line.startswith("__EOF__"): break source += line if len(source) >= 0x2000: print("[-] Code too lo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false