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/corCTF/2021/pwn/Outfoxed/app/fox.py
ctfs/corCTF/2021/pwn/Outfoxed/app/fox.py
#!/usr/bin/env python3 import os import sys import tempfile print("Enter exploit followed by EOF: ") sys.stdout.flush() buf = "" while "EOF" not in buf: buf += input() + "\n" with tempfile.TemporaryDirectory() as dir: os.chdir(dir) with open("exploit.html", 'w') as f: f.write("<script src='explo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2021/crypto/bank/server.py
ctfs/corCTF/2021/crypto/bank/server.py
import numpy as np import math, random flag = open('flag.txt').read() class Qubit: def __init__(self, vector): self.vec = vector def x(self): mat = np.array([[0, 1], [1, 0]]) self.vec = mat.dot(self.vec) def y(self): mat = np.array([[0, -1j], [1j, 0]]) self.vec = mat.dot(self.vec) def z(self): mat ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2021/crypto/babypad/server.py
ctfs/corCTF/2021/crypto/babypad/server.py
from Crypto.Cipher import AES from Crypto.Util import Counter from Crypto.Util.Padding import pad, unpad from Crypto.Util.number import bytes_to_long import os flag = open("/challenge/flag.txt").read().encode() key = os.urandom(16) def encrypt(pt): iv = os.urandom(16) ctr = Counter.new(128, initial_value=bytes_to...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2021/crypto/4096/source.py
ctfs/corCTF/2021/crypto/4096/source.py
from Crypto.Util.number import getPrime, bytes_to_long from private import flag def prod(lst): ret = 1 for num in lst: ret *= num return ret m = bytes_to_long(flag) primes = [getPrime(32) for _ in range(128)] n = prod(primes) e = 65537 print(n) print(pow(m, e, n))
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2021/crypto/mystery_stream/source.py
ctfs/corCTF/2021/crypto/mystery_stream/source.py
from random import randrange from secrets import flag, key from Crypto.Util.number import long_to_bytes def bsum(state, taps, l): ret = 0 for i in taps: ret ^= (state >> (l - i)) return ret & 1 class Gen: def __init__(self, key, slength): self.state = key self.slength = slength self.TAPS = [2, 4, 5, 7, 10...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2021/crypto/dividing_secrets/server.py
ctfs/corCTF/2021/crypto/dividing_secrets/server.py
from Crypto.Util.number import bytes_to_long, getStrongPrime from random import randrange from secret import flag LIMIT = 64 def gen(): p = getStrongPrime(512) g = randrange(1, p) return g, p def main(): g, p = gen() print("g:", str(g)) print("p:", str(p)) x = bytes_to_long(flag) enc = pow(g, x, p) print("e...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2021/crypto/babyrand/script.py
ctfs/corCTF/2021/crypto/babyrand/script.py
from random import randrange from Crypto.Util.number import getPrime, long_to_bytes from Crypto.Cipher import AES from Crypto.Util.Padding import pad from hashlib import sha256 from os import urandom flag = open("flag.txt", "rb").read() def und(): p = getPrime(512) x = randrange(p) a = p ^ x ^ randrange(2**200)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2021/crypto/LCG_k/source.py
ctfs/corCTF/2021/crypto/LCG_k/source.py
from Crypto.Util.number import bytes_to_long, inverse from hashlib import sha256 from secrets import randbelow from private import flag from fastecdsa.curve import P256 G = P256.G N = P256.q class RNG: def __init__(self, seed, A, b, p): self.seed = seed self.A = A self.b = b self.p = p def gen(self): out...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2021/crypto/leave_it_to_chance/source.py
ctfs/corCTF/2021/crypto/leave_it_to_chance/source.py
from Crypto.Util.number import getPrime from random import randrange, shuffle from private import flag class Game(): KEY_LEN = 32 def __init__(self): self.p = getPrime(256) while self.p % 4 == 3: self.p = getPrime(256) x = randrange(self.p) while pow(x, (self.p-1)//2, self.p) == 1: x = randrange(self....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2021/crypto/babyrsa/script.py
ctfs/corCTF/2021/crypto/babyrsa/script.py
from Crypto.Util.number import bytes_to_long n = 735426165606478775655440367887380252029393814251587377215443983568517874011835161632218370139295595689938440468041879777053762891080651268836035629049417486536078363582673596640410647087621544747861682046281816673713057883036243969033232162791106853991454769165851229172...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2021/crypto/fibinary/enc.py
ctfs/corCTF/2021/crypto/fibinary/enc.py
fib = [1, 1] for i in range(2, 11): fib.append(fib[i - 1] + fib[i - 2]) def c2f(c): n = ord(c) b = '' for i in range(10, -1, -1): if n >= fib[i]: n -= fib[i] b += '1' else: b += '0' return b flag = open('flag.txt', 'r').read() enc = '' for c in flag: enc += c2f(c) + ' ' with open('flag.enc', 'w') a...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2021/crypto/supercomputer/supercomputer.py
ctfs/corCTF/2021/crypto/supercomputer/supercomputer.py
from Crypto.Util.number import getPrime, long_to_bytes from pwn import * import random, binascii flag = open('flag.txt').read() def v(p, k): ans = 0 while k % p == 0: k /= p ans += 1 return ans p, q, r = getPrime(2048), getPrime(2048), getPrime(2048) print(p, q, r) n = pow(p, q) * r a1 = random.randint(0, n)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2021/web/drinkme/chall/app/app.py
ctfs/corCTF/2021/web/drinkme/chall/app/app.py
#!/usr/bin/env python3 from flask import Flask, flash, request, redirect, url_for, render_template, send_from_directory import os import hashlib app = Flask(__name__) app.secret_key = b'537472656c6c6963206973206d79206661766f72697465206d656d626572206f6620436f52' # Don't bother trying to exploit - this is just to get fla...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2024/misc/lights_out/lights_out.py
ctfs/corCTF/2024/misc/lights_out/lights_out.py
#!/usr/bin/env python import random import time import sys import os def generate_random_board(n: int) -> list[int]: """ Generate a random n x n Lights Out board. Args: n (int): The size of the board (n x n). Returns: list[int]: A list representing the board, where each element ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2024/crypto/roots/main.py
ctfs/corCTF/2024/crypto/roots/main.py
from Crypto.Util.number import getPrime, bytes_to_long from random import getrandbits from decimal import Decimal, getcontext from secret import FLAG N = 3 MSIZE = 64 PSIZE = 128 getcontext().prec = 2024 def chunk(inp: bytes, n: int) -> list[bytes]: return [inp[i:i + n] for i in range(0, len(inp), n)] def gener...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2024/crypto/two_wrongs/two_wrongs.py
ctfs/corCTF/2024/crypto/two_wrongs/two_wrongs.py
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, transpile from qiskit_aer import AerSimulator import numpy as np import random, os, binascii, sys from Crypto.Cipher import AES from flag import flag key = os.urandom(16) cipher = AES.new(key, AES.MODE_ECB) sv_sim = AerSimulator(method="statevecto...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2024/crypto/steps/main.py
ctfs/corCTF/2024/crypto/steps/main.py
from Crypto.Util.number import getPrime from random import randint from hashlib import sha512 from secret import FLAG p = getPrime(1024) Pair = tuple[int, int] def apply(x: Pair, y: Pair) -> Pair: z0 = x[0] * y[1] + x[1] * y[0] - x[0] * y[0] z1 = x[0] * y[0] + x[1] * y[1] return z0 % p, z1 % p def calcu...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2024/forensic/the_conspiracy/source.py
ctfs/corCTF/2024/forensic/the_conspiracy/source.py
import random from scapy.all import * import csv sources, destinations, messages = [], [], [] with open('chatlogs.csv', mode='r') as file: csv_reader = csv.reader(file) for row in csv_reader: sources.append(row[0]) destinations.append(row[1]) messages.append(row[2]) def encrypt(messag...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/misc/msfrogofwar2/chesslib.py
ctfs/corCTF/2023/misc/msfrogofwar2/chesslib.py
class Piece: NONE = None KING = 0 PAWN = 1 KNIGHT = 2 BISHOP = 3 ROOK = 4 QUEEN = 5 KIND_MASK = 7 WHITE = 8 BLACK = 16 COLOR_MASK = 24 def color(piece): return piece & Piece.COLOR_MASK def kind(piece): return piece & Piece.KIND_MASK def t...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/misc/msfrogofwar2/app.py
ctfs/corCTF/2023/misc/msfrogofwar2/app.py
from flask import Flask, request from flask_socketio import SocketIO, emit from stockfish import Stockfish import random import os import chesslib import movegen games = {} toxic_msges = [ "?", "rip bozo", "so bad lmfaoo", "ez", "skill issue", "mad cuz bad", "hold this L", "L + ratio ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/misc/msfrogofwar2/movegen.py
ctfs/corCTF/2023/misc/msfrogofwar2/movegen.py
from chesslib import Piece, Position, CastlingRights, CHAR_TO_PIECE, PIECE_TO_CHAR class Move: def __init__(self, start, end, **kwargs): self.start = start self.end = end self.promotion = kwargs.get("promotion", Piece.NONE) self.castle = kwargs.get("castle", None) self.en_p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/pwn/daydream/main.py
ctfs/corCTF/2023/pwn/daydream/main.py
#!/usr/bin/python3 import subprocess from threading import Timer import sys import os import tempfile import secrets import socket import functools import struct FLAG = b'corctf{test_flag!}' FILE = 'flag' ROUNDS = 16 HOST = '0.0.0.0' PORT = 5000 MAX = 1073741824 TIME = 60 def get_program_output(data): print('tes...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/crypto/fizzbuzz101/fizzbuzz101.py
ctfs/corCTF/2023/crypto/fizzbuzz101/fizzbuzz101.py
#!/usr/local/bin/python from Crypto.Util.number import * from os import urandom flag = open("flag.txt", "rb").read() flag = bytes_to_long(urandom(16) + flag + urandom(16)) p = getPrime(512) q = getPrime(512) n = p * q e = 0x10001 d = pow(e, -1, (p-1)*(q-1)) assert flag < n ct = pow(flag, e, n) print(f"{n = }") print...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/crypto/fizzbuzz100/fizzbuzz100.py
ctfs/corCTF/2023/crypto/fizzbuzz100/fizzbuzz100.py
#!/usr/local/bin/python from Crypto.Util.number import * from os import urandom flag = open("flag.txt", "rb").read() flag = bytes_to_long(urandom(16) + flag + urandom(16)) p = getPrime(512) q = getPrime(512) n = p * q e = 0x10001 d = pow(e, -1, (p-1)*(q-1)) assert flag < n ct = pow(flag, e, n) print(f"{n = }") print...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/crypto/superbox/DDT.py
ctfs/corCTF/2023/crypto/superbox/DDT.py
""" SUPERBOX (c) DDT information. DDT is formatted as `DDT[delta_in][delta_out]` For other information related to the SUPERBOX (c), contact your supervisor for access. """
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
true
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/crypto/QCG-k/qcgk.py
ctfs/corCTF/2023/crypto/QCG-k/qcgk.py
from random import randint from Crypto.Util.number import inverse, bytes_to_long from Crypto.Util.Padding import pad from Crypto.Cipher import AES from hashlib import sha256 import os class PRNG: def __init__(self, mod): self.coeffs = [randint(1,mod) for _ in range(16)] self.mod = mod self....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/crypto/cbc/cbc.py
ctfs/corCTF/2023/crypto/cbc/cbc.py
import random def random_alphastring(size): return "".join(random.choices(alphabet, k=size)) def add_key(key, block): ct_idxs = [(k_a + pt_a) % len(alphabet) for k_a, pt_a in zip([alphabet.index(k) for k in key], [alphabet.index(pt) for pt in block])] return "".join([alphabet[idx] for idx in ct_idxs]) de...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/crypto/fizzbuzz102/fizzbuzz102.py
ctfs/corCTF/2023/crypto/fizzbuzz102/fizzbuzz102.py
#!/usr/local/bin/python from Crypto.Util.number import * from os import urandom from secrets import randbits flag = open("flag.txt", "rb").read() flag = bytes_to_long(urandom(16) + flag + urandom(16)) p = getPrime(512) q = getPrime(512) n = p * q e = 0x10001 d = pow(e, -1, (p-1)*(q-1)) assert flag < n ct = pow(flag, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/web/pdf-pal/app/app.py
ctfs/corCTF/2023/web/pdf-pal/app/app.py
from flask import Flask, abort, url_for, request, redirect, send_from_directory, send_file, jsonify from urllib.parse import unquote, urlparse import hashlib import requests import os import io app = Flask(__name__) files = [] def blacklist(text, extra=()): banned = ["flag", "txt", "root", "output", "pdf-gen"] + ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/web/msfrognymize/tasks.py
ctfs/corCTF/2023/web/msfrognymize/tasks.py
import os from celery_config import celery_app from src.anonymize_faces import anonymize_faces @celery_app.task def process_image(temp_path, new_file_path, encrypted_exif): anonymize_faces(temp_path, 'data/msfrog.png', new_file_path, encrypted_exif) os.unlink(temp_path) def clear_uploads_folder(): print...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/web/msfrognymize/celery_config.py
ctfs/corCTF/2023/web/msfrognymize/celery_config.py
from celery import Celery from celery.schedules import crontab celery_app = Celery( 'tasks', broker='redis://localhost:6379/0', backend='redis://localhost:6379/1' ) celery_app.conf.update( result_expires=3600, beat_schedule={ # This is the periodic task to clear the uploads/ folder every 5...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/web/msfrognymize/app.py
ctfs/corCTF/2023/web/msfrognymize/app.py
import os import piexif import tempfile import uuid from PIL import Image, ExifTags from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes, hmac from flask import Flask, request, send_file, render_template from urllib.parse import unquote from werkzeug.utils import s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2023/web/msfrognymize/src/anonymize_faces.py
ctfs/corCTF/2023/web/msfrognymize/src/anonymize_faces.py
import cv2 import dlib import numpy as np import os from PIL import Image # No intended vuln here, just magic script_dir = os.path.dirname(os.path.realpath(__file__)) classifier_path = os.path.join(script_dir, 'haarcascade_frontalface_default.xml') predictor_path = os.path.join(script_dir, 'shape_predictor_68_face_la...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2025/misc/control/ctrl.py
ctfs/corCTF/2025/misc/control/ctrl.py
#!/usr/bin/env python3 import struct import numba import numpy as np import wasmtime import base64 import tempfile import sys from scipy.integrate import solve_ivp LOAD_RESISTANCE = 5 SOURCE_RESISTANCE = 0.01 SOURCE_VOLTAGE = 15 C1 = 47e-6 C2 = 47e-6 L = 88e-6 DT = 0.0001 N = 1000 @numba.njit def F(x, u): vC1...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2025/crypto/rules/rules.py
ctfs/corCTF/2025/crypto/rules/rules.py
#!/usr/local/bin/python3 import json import random import numpy as np FLAG = open("flag.txt").read() BANNER = """ _____ _____ ( ___ )----------------------------------------------------------( ___ ) | | ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2025/crypto/oooo/oooo.py
ctfs/corCTF/2025/crypto/oooo/oooo.py
#!/usr/local/bin/python3 import random; FLAG = open("flag.txt", "rb").read(); print("welcome to oooo") while True: print(bytes(a^b for a, b in zip(FLAG, random.sample(range(0, 256), k=len(FLAG)))).hex() if input() != "exit" else exit())
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2025/crypto/keys/encrypt.py
ctfs/corCTF/2025/crypto/keys/encrypt.py
from functools import reduce import itertools import os def xor(x, y): return bytes([a ^ b for a, b in zip(x, y)]) def stream(keys0, keys1): for keys in itertools.product(*zip(keys0, keys1)): key = reduce(xor, keys) yield key with open('flag.bmp', 'rb') as f: d = f.read() header = d[:...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2025/crypto/ssss/ssss.py
ctfs/corCTF/2025/crypto/ssss/ssss.py
#!/usr/local/bin/python3 import random p = 2**255 - 19 k = 15 SECRET = random.randrange(0, p) print("welcome to ssss") # Step 1: Generate a random, degree-(k−3) polynomial g(x) g = [random.randrange(p) for _ in range(k - 2)] # Step 2: Select a random c in Fp c = random.randrange(0, p) # Step 3: Set f(x)=g(x)x^2+Sx+c ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/pwn/nbd/serv.py
ctfs/corCTF/2022/pwn/nbd/serv.py
import socket import subprocess sock = socket.socket() sock.bind(('', 5000)) sock.listen(1) c, _ = sock.accept() c.send(b'IP: ') ip = c.recv(1024) c.send(b'Port: ') port = c.recv(1024) subprocess.run(['./nbd-client', ip.strip(), '-N', 'whatever', '-l', port.strip(), '/dev/nbd0']) c.close()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/crypto/luckyguess/luckyguess.py
ctfs/corCTF/2022/crypto/luckyguess/luckyguess.py
#!/usr/local/bin/python from random import getrandbits p = 2**521 - 1 a = getrandbits(521) b = getrandbits(521) print("a =", a) print("b =", b) try: x = int(input("enter your starting point: ")) y = int(input("alright, what's your guess? ")) except: print("?") exit(-1) r = getrandbits(20) for _ in ra...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/crypto/threetreasures/source.py
ctfs/corCTF/2022/crypto/threetreasures/source.py
from sage.all import * from Crypto.Util.number import bytes_to_long, getPrime from random import getrandbits from secret import flag, p, x, y def random_pad(n, length): return (n << (length - n.bit_length())) + getrandbits(length - n.bit_length()) flag = bytes_to_long(flag) fbits = flag.bit_length() piece_bits = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/crypto/rlfsr/rlfsr.py
ctfs/corCTF/2022/crypto/rlfsr/rlfsr.py
from secrets import randbits from random import shuffle from hashlib import sha256 from Crypto.Cipher import AES from Crypto.Util.Padding import pad class LFSR: def __init__(self, key, taps): self.key = key self.taps = taps self.state = list(map(int, list("{:0128b}".format(key)))) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/crypto/D3S/constants.py
ctfs/corCTF/2022/crypto/D3S/constants.py
import random random.seed(69) # Nothing up my sleeve... __all__ = [ "INIT_PERM", "FINAL_PERM", "KEY_PERM1", "KEY_PERM2", "SHIFTS", "EXP_PERM", "SBOX", "FEISTEL_PERM", ] INIT_PERM = tuple(random.sample(range(54), 54)) FINAL_PERM = tuple(INIT_PERM.index(i) for i in range(54)) # May ha...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/crypto/D3S/D3S.py
ctfs/corCTF/2022/crypto/D3S/D3S.py
from secret import key, flag from constants import * def pad(a: list, length: int = 54) -> list: return a + [0] * (length - len(a)) def int_to_bytes(a: int, length: int = 0, order: str = "little") -> bytes: if length < 1: length = (a.bit_length() + 7) // 8 return a.to_bytes(length, order) def bytes_to_in...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/crypto/tadpole/tadpole.py
ctfs/corCTF/2022/crypto/tadpole/tadpole.py
from Crypto.Util.number import bytes_to_long, isPrime from secrets import randbelow p = bytes_to_long(open("flag.txt", "rb").read()) assert isPrime(p) a = randbelow(p) b = randbelow(p) def f(s): return (a * s + b) % p print("a = ", a) print("b = ", b) print("f(31337) = ", f(31337)) print("f(f(31337)) = ", f(f(3...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/crypto/corrupted-curves+/corruptedcurvesplus.py
ctfs/corCTF/2022/crypto/corrupted-curves+/corruptedcurvesplus.py
#!/usr/local/bin/python from secrets import randbits from Crypto.Util.number import getPrime from random import randrange def square_root(a, p): if legendre_symbol(a, p) != 1: return 0 elif a == 0: return 0 elif p == 2: return 0 elif p % 4 == 3: return pow(a, (p + 1) // ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/crypto/corrupted-curves/corruptedcurves.py
ctfs/corCTF/2022/crypto/corrupted-curves/corruptedcurves.py
#!/usr/local/bin/python from secrets import randbits from Crypto.Util.number import getPrime def square_root(a, p): if legendre_symbol(a, p) != 1: return 0 elif a == 0: return 0 elif p == 2: return 0 elif p % 4 == 3: return pow(a, (p + 1) // 4, p) s = p - 1 e = 0...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/crypto/hidE/main.py
ctfs/corCTF/2022/crypto/hidE/main.py
#!/usr/local/bin/python import random import time import math import binascii from Crypto.Util.number import * p, q = getPrime(512), getPrime(512) n = p * q phi = (p - 1) * (q - 1) flag = open('./flag.txt').read().encode() random.seed(int(time.time())) def encrypt(msg): e = random.randint(1, n) while math.g...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/crypto/generous/generous.py
ctfs/corCTF/2022/crypto/generous/generous.py
#!/usr/local/bin/python from Crypto.Util.number import getPrime, inverse, bytes_to_long from random import randrange with open("flag.txt", "rb") as f: flag = f.read().strip() def gen_keypair(): p, q = getPrime(512), getPrime(512) n = (p**2) * q while True: g = randrange(2, n) if pow(g, p-1, p**2) != 1: bre...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/crypto/exchanged/exchanged.py
ctfs/corCTF/2022/crypto/exchanged/exchanged.py
from Crypto.Util.number import * from Crypto.Cipher import AES from Crypto.Util.Padding import pad from hashlib import sha256 from secrets import randbelow p = 142031099029600410074857132245225995042133907174773113428619183542435280521982827908693709967174895346639746117298434598064909317599742674575275028013832939859...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/crypto/leapfrog/leapfrog.py
ctfs/corCTF/2022/crypto/leapfrog/leapfrog.py
from Crypto.Util.number import long_to_bytes, getPrime from Crypto.Cipher import AES from Crypto.Util.Padding import pad from hashlib import sha256 from secrets import randbelow from random import sample p = getPrime(256) a = randbelow(p) b = randbelow(p) s = randbelow(p) def f(s): return (a * s + b) % p jumps =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/web/leetmail/bot/visit/app.py
ctfs/corCTF/2022/web/leetmail/bot/visit/app.py
import config import requests import os import json import base64 from urllib.parse import quote from playwright.sync_api import sync_playwright from flask import Flask, request app = Flask(__name__) def start(url, iid): print(url, iid) with sync_playwright() as p: browser = p.firefox.launch(executable_path='/a...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/web/sndbx/app/signer.py
ctfs/corCTF/2022/web/sndbx/app/signer.py
import datetime from cryptography import x509 from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives import hashes with open('ca/cert.pem', 'rb') as f: ca_pem = f.read() ca = x509.load_pem_x509_certificate(ca_pem) with open('ca/priv.pem', 'rb') as f: private_key = serializat...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/web/sndbx/app/setup.py
ctfs/corCTF/2022/web/sndbx/app/setup.py
from cryptography import x509 from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives.asymmetric import ec from cryptography.x509.oid import NameOID, ExtendedKeyUsageOID import datetime import os import config castle_template = """<!DOCTYPE html> <html> <head> <meta cha...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/web/sndbx/app/config.py
ctfs/corCTF/2022/web/sndbx/app/config.py
import os from datetime import timedelta SESSION_TYPE = 'filesystem' SESSION_COOKIE_SAMESITE = 'Strict' SESSION_COOKIE_DOMAIN = False PERMANENT_SESSION_LIFETIME = timedelta(hours=1) APP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) TEMPLATE_PATH = os.path.join(APP_PATH, 'templates/') MAX_CONTENT_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/web/sndbx/app/server.py
ctfs/corCTF/2022/web/sndbx/app/server.py
import manager import config from gevent import ssl from gevent.pywsgi import WSGIServer from app import app context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) context.load_cert_chain('certs/.root/cert.pem', 'certs/.root/priv.pem') def sni_callback(socket, sni, ctx): if sni is None: return if sni == config.DOMAI...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/web/sndbx/app/manager.py
ctfs/corCTF/2022/web/sndbx/app/manager.py
import os from cryptography.hazmat.primitives import serialization from glob import glob subdomains = set() with open('ca/cert.pem', 'rb') as f: ca_cert = f.read() with open('ca/priv.pem', 'rb') as f: ca_priv = f.read() def add(subdomain, public, private, content=b''): try: os.mkdir(f'certs/{subdomain}/') ex...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/web/sndbx/app/app.py
ctfs/corCTF/2022/web/sndbx/app/app.py
import secrets import config import signer import manager from flask import Flask, session, render_template, request from flask_session import Session from cryptography.hazmat.primitives import serialization from cryptography import x509 app = Flask(__name__) app.config.from_object(config) Session(app) @app.route('...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/corCTF/2022/web/sndbx/bot/visit/app.py
ctfs/corCTF/2022/web/sndbx/bot/visit/app.py
import config import requests import os import json import base64 from urllib.parse import quote from playwright.sync_api import sync_playwright from flask import Flask, request app = Flask(__name__) def start(script): print(f'{config.CASTLE_BASE}?eval={quote(script)}&flag={config.FLAG}') os.makedirs('/etc/firefo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TU/2024/rev/Custom_Image_Generator/timg.py
ctfs/TU/2024/rev/Custom_Image_Generator/timg.py
from PIL import Image import numpy as np import crc8 def main(): inp = input(""" Welcome to the TU Image Program It can convert images to TIMGs It will also display TIGMs [1] Convert Image to TIMG [2] Display TIMG """...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TU/2024/crypto/Simpler_Cipher/cipher.py
ctfs/TU/2024/crypto/Simpler_Cipher/cipher.py
import time exptables=[REDACTED] def main(): while(2>1): time.sleep(2) inp = input('''Please Select Your Mode\n [1] Encrypt a message with a custom key [2] Decrypt a message [3] Get the flag [4] Exit ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TU/2024/crypto/Kraken/kraken.py
ctfs/TU/2024/crypto/Kraken/kraken.py
import hashlib import os import time import datetime import struct import time import random import users class KrakenGuard: username = None TIMEOUT = 60 * 3 # Isn't python beautiful users = users.users help = """ ==================================HELP================================== list ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TU/2024/web/Shopping_Time/app.py
ctfs/TU/2024/web/Shopping_Time/app.py
from flask import Flask,render_template,request, redirect import sqlite3 import hashlib app = Flask(__name__) @app.route("/") def mainHandler(): return render_template("index.html") @app.route("/review") def reviewHandler(): con = sqlite3.connect("shopping.db") cur = con.cursor() item = request.args...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TU/2023/crypto/Simple_Cipher/SimpleCipher_Pub.py
ctfs/TU/2023/crypto/Simple_Cipher/SimpleCipher_Pub.py
### ### ### def main(): while(2>1): inp = input('''Please Select Your Mode\n [1] Encrypt a message with a custom key [2] Decrypt a message [3] Get the flag [4] Exit \n''') if not(inp in ('1','2','3...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TU/2023/crypto/Custom_ECB_Cipher/simple_ecb_cipher.py
ctfs/TU/2023/crypto/Custom_ECB_Cipher/simple_ecb_cipher.py
from Crypto.Util import number flag = b"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" def convert(msg): msg = msg ^ msg >> x msg = msg ^ msg << 13 & 275128763 msg = msg ^ msg << 20 & 2186268085 msg = msg ^ msg >> 14 return msg def transform(message): assert len(message) % 4 == 0 new_messag...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TU/2023/programming/CaRLsLabrinth/maze.py
ctfs/TU/2023/programming/CaRLsLabrinth/maze.py
import numpy as np # See solution for source of mdp class MDP: def __init__(self,T,R): ''' Inputs: T -- Transition function: |A| x |S| x |S'| array R -- Reward function: |A| x |S| array ''' self.nActions = T.shape[0] self.nStates = T.shape[1] self.T = T self.R = R self.discou...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TU/2022/crypto/UnmixTheFlag/flag_unmixer.py
ctfs/TU/2022/crypto/UnmixTheFlag/flag_unmixer.py
import string upperFlag = string.ascii_uppercase[:26] lowerFlag = string.ascii_lowercase[:26] MIN_LETTER = ord("a") MIN_CAPLETTER = ord("A") def mix(oneLetter,num): if(oneLetter.isupper()): word = ord(oneLetter)-MIN_CAPLETTER shift = ord(num)-MIN_CAPLETTER return upperFlag[(word + shift)%...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TU/2022/crypto/MoreEffort/more_effort.py
ctfs/TU/2022/crypto/MoreEffort/more_effort.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Nov 23 22:26:57 2022 @author: weiping """ import os import random from Crypto.Util.number import * import gmpy2 flag = b'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' class RSA(): def __init__(self): self.p = getPrime(512) self.s = 0 for i in r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0x41414141/2021/crypto/Soul-Permutation-Network/net.py
ctfs/0x41414141/2021/crypto/Soul-Permutation-Network/net.py
import os import socketserver import string import threading from time import * import time import binascii ROUNDS = 4 BLOCK_SIZE = 8 sbox = [237, 172, 175, 254, 173, 168, 187, 174, 53, 188, 165, 166, 161, 162, 131, 227, 191, 152, 63, 182, 169, 136, 171, 184, 149, 148, 183, 190, 181, 177, 163, 186, 207, 140, 143, 139...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0x41414141/2021/crypto/Delegate-wallet/wallet.py
ctfs/0x41414141/2021/crypto/Delegate-wallet/wallet.py
import os import socketserver import string import threading from time import * import time import binascii import random flag = open("flag.txt", "rb").read().strip() class prng_lcg: def __init__(self): self.n = pow(2, 607) -1 self.c = random.randint(2, self.n) self.m = random.randint(2,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0x41414141/2021/crypto/factorize/factorize.py
ctfs/0x41414141/2021/crypto/factorize/factorize.py
mport binascii import random from Crypto.Util.number import isPrime flag = open("flag.txt", "rb").read().strip() m = int(binascii.hexlify(flag), 16) def genPrimes(size): base = random.getrandbits(size // 2) << size // 2 base = base | (1 << 1023) | (1 << 1022) | 1 while True: temp = base | random.g...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0x41414141/2021/crypto/staple-AES/aes.py
ctfs/0x41414141/2021/crypto/staple-AES/aes.py
import os import socketserver import string import threading from time import * import random import time import binascii from Crypto.Cipher import AES from Crypto.Util.Padding import pad iv = b'' key = b'' flag = open("flag.txt", "rb").read().strip() class Service(socketserver.BaseRequestHandler): def handle(s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Dragon/2021/pwn/noflippidy/gen_chall.py
ctfs/Dragon/2021/pwn/noflippidy/gen_chall.py
with open("flippidy", "rb") as f: x = bytearray(f.read()) patch_off = 0x138d patch = b'\x85\xc0\x74\x02\xc9\xc3' for i, v in enumerate(patch): x[patch_off + i] = v with open("noflippidy", "wb") as f: f.write(x)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Dragon/2021/crypto/Baby_MAC/task.py
ctfs/Dragon/2021/crypto/Baby_MAC/task.py
#!/usr/bin/env python3 import os try: from Crypto.Cipher import AES except ImportError: from Cryptodome.Cipher import AES def split_by(data, cnt): return [data[i : i+cnt] for i in range(0, len(data), cnt)] def pad(data, bsize): b = bsize - len(data) % bsize return data + bytes([b] * b) def xor(a,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Dragon/2021/crypto/CRC_Recursive_Challenge/crc_hard.py
ctfs/Dragon/2021/crypto/CRC_Recursive_Challenge/crc_hard.py
#!/usr/bin/env python3 def crc128(buf, crc=0xffffffffffffffffffffffffffffffff): for val in buf: crc ^= val << 120 for _ in range(8): crc <<= 1 if crc & 2**128: crc ^= 0x14caa61b0d7fe5fa54189d46709eaba2d return crc inp = input().strip().encode() crc = crc...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Dragon/2021/crypto/CRC_Recursive_Challenge_warmup/crc.py
ctfs/Dragon/2021/crypto/CRC_Recursive_Challenge_warmup/crc.py
#!/usr/bin/env python3 def crc64(buf, crc=0xffffffffffffffff): for val in buf: crc ^= val << 56 for _ in range(8): crc <<= 1 if crc & 2**64: crc ^= 0x1ad93d23594c935a9 return crc inp = input().strip().encode() crc = crc64(inp) if inp == f'My crc64 is 0x{...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Dragon/2020/crypto/BitFlip3/task.py
ctfs/Dragon/2020/crypto/BitFlip3/task.py
#!/usr/bin/python3 from Crypto.Util.number import bytes_to_long, long_to_bytes from Crypto.Cipher import AES import hashlib import os import base64 from gmpy2 import is_prime FLAG = open("flag").read() FLAG += (16 - (len(FLAG) % 16))*" " class Rng: def __init__(self, seed): self.seed = seed self.generated...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Dragon/2020/crypto/BitFlip2/task.py
ctfs/Dragon/2020/crypto/BitFlip2/task.py
#!/usr/bin/python3 from Crypto.Util.number import bytes_to_long, long_to_bytes from Crypto.Cipher import AES import hashlib import os import base64 from gmpy2 import is_prime FLAG = open("flag").read() FLAG += (16 - (len(FLAG) % 16))*" " class Rng: def __init__(self, seed): self.seed = seed self.generated...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Dragon/2020/crypto/BitFlip1/task.py
ctfs/Dragon/2020/crypto/BitFlip1/task.py
#!/usr/bin/python3 from Crypto.Util.number import bytes_to_long, long_to_bytes from Crypto.Cipher import AES import hashlib import os import base64 from gmpy2 import is_prime FLAG = open("flag").read() FLAG += (16 - (len(FLAG) % 16))*" " class Rng: def __init__(self, seed): self.seed = seed self.generated...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Infobahn/2025/misc/speechless/chall.py
ctfs/Infobahn/2025/misc/speechless/chall.py
#!/usr/bin/python3 allowed = "ab.=-/" with open("flag.txt", 'rb') as f: flag = f.read() a = None while True: expr = input(">>> ") if not all(char in allowed for char in expr): print('you need to try harder') continue if any(f"{blocked}==" in expr or f"=={blocked}" in expr for blocke...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Infobahn/2025/rev/fish/fish.py
ctfs/Infobahn/2025/rev/fish/fish.py
#!/usr/local/bin/python3.2 """ Python interpreter for the esoteric language ><> (pronounced /ˈfɪʃ/). Usage: ./fish.py --help More information: http://esolangs.org/wiki/Fish Requires python 2.7/3.2 or higher. """ import sys import time import random from collections import defaultdict # constants NCHARS = "012345...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Infobahn/2025/jail/pyjail/chall.py
ctfs/Infobahn/2025/jail/pyjail/chall.py
import io import contextlib with open("flag.txt", 'rb') as f: FLAG = f.read() def run(code): buf = io.StringIO() try: with contextlib.redirect_stdout(buf): exec(code, {}) except Exception: return None return buf.getvalue() or None code = input("Enter your solution: ") ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Infobahn/2025/crypto/Sayaka_Stream/challenge.py
ctfs/Infobahn/2025/crypto/Sayaka_Stream/challenge.py
from Crypto.Cipher import AES from Crypto.Util.Padding import pad from hashlib import sha256 from os import getenv from random import Random, getrandbits class Sayaka_Stream: def __init__(self, seed): def make_generator(seed): rng = Random(seed) while True: x = rng.getrandbits(5) a, b, c, d, e = [x >>...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Infobahn/2025/crypto/Homura_Hash/server.py
ctfs/Infobahn/2025/crypto/Homura_Hash/server.py
from os import getenv from secrets import randbits class Homura_Hash: def __init__(self, n, key): self.n = n self.key = [] for shift, offset_0, offset_1, bit_select in key: assert 1 <= shift < n assert all(0 <= x < 2**n for x in [offset_0, offset_1, bit_select]) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Infobahn/2025/crypto/Linearity/chall.py
ctfs/Infobahn/2025/crypto/Linearity/chall.py
from random import randint from hashlib import sha256 from secret import FLAG V = [randint(0, 100) for i in range(5)] M = [[V[i] * randint(0, 100) for i in range(5)] for i in range(5)] C = [M[i // 5 % 5][i % 5] ^ ord(FLAG[i]) for i in range(len(FLAG))] print(f"{V = }") print(f"{C = }") print(sha256(FLAG.encode()).dig...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Infobahn/2025/crypto/Madoka_RSA/challenge.py
ctfs/Infobahn/2025/crypto/Madoka_RSA/challenge.py
from Crypto.Cipher import AES from Crypto.Util.number import isPrime, getPrime from Crypto.Util.Padding import pad from hashlib import sha256 from os import getenv from random import getrandbits from sage.all import CRT, GF class Madoka_RSA: @staticmethod def has_sqrt_2(p): return p % 8 == 1 or p % 8 == 7 @static...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Infobahn/2025/crypto/Mami_LES/server.py
ctfs/Infobahn/2025/crypto/Mami_LES/server.py
from Crypto.Cipher import AES from Crypto.Util.number import getPrime, getRandomRange from Crypto.Util.Padding import pad from hashlib import sha256 from os import getenv class Mami_LES: def __init__(self, block_len, pad_len, p, secret): self.block_len = block_len self.pad_len = pad_len self.p = p self.iv = l...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Infobahn/2025/crypto/Kyoko_Ring/challenge.py
ctfs/Infobahn/2025/crypto/Kyoko_Ring/challenge.py
from Crypto.Cipher import AES from Crypto.Util.number import getPrime from Crypto.Util.Padding import pad from copy import deepcopy from hashlib import sha256 from itertools import product from os import getenv from random import getrandbits, randrange class Kyoko_Ring: def __init__(self, p, q, data): for i, j in p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Infobahn/2025/crypto/Nagisa_Determinants/challenge.py
ctfs/Infobahn/2025/crypto/Nagisa_Determinants/challenge.py
from Crypto.Cipher import AES from Crypto.Util.number import getPrime from Crypto.Util.Padding import pad from hashlib import sha256 from os import getenv from random import randrange, shuffle from sage.all import GF, ZZ, matrix class Nagisa_Determinants: def __init__(self, p, key_len, output_len): self.p = p sel...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Infobahn/2025/crypto/YAOL/challenge.py
ctfs/Infobahn/2025/crypto/YAOL/challenge.py
print(pow(5, int.from_bytes(b"infobahn{redacted}") , 1630517278473550194282041875833486355623215533573046940060264097136914038603536518992736923653676649116183817847560673180565058236761676707835672941973386700920193823734995675702699)) # 120531199467721308055367297632927243037628033678875794747956044944951910611342365...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2021/web/Intellimage/index.py
ctfs/BSidesTLV/2021/web/Intellimage/index.py
import os import hashlib import tempfile from exiftool import ExifTool from flask import Flask, request, jsonify app = Flask(__name__, template_folder="views", static_folder="public", static_url_path="/") app.config["MAX_CONTENT_LENGTH"] = 100 * 1024 secret = os.getenv("SECRET") or "BSidesTLV2021{This_Is_Not_The_Flag}...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2021/web/Intellimage/tests/test_prod.py
ctfs/BSidesTLV/2021/web/Intellimage/tests/test_prod.py
import unittest import requests class TestIntellimage(unittest.TestCase): def test_view(self): with open("VEVAK.png", "rb") as f: res = requests.post( url="http://localhost.realgame.co.il:5000/view", files={ "image[]": ( ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2023/misc/compare_me/compare_me.py
ctfs/BSidesTLV/2023/misc/compare_me/compare_me.py
import os import sys from ctypes import CDLL, c_char_p, c_uint32 # memcmp_all to ensure constant time check memcmp_all = CDLL('./memcmp_all.so').memcmp_all memcmp_all.argtypes = [c_char_p, c_char_p, c_uint32] memcmp_all.restype = c_uint32 def main(): guess_me = os.urandom(16) flag = os.getenv("FLAG") pri...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2023/pwn/Zend_Master/sanity-tests.py
ctfs/BSidesTLV/2023/pwn/Zend_Master/sanity-tests.py
# empty
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2023/pwn/Zend_Master/server.py
ctfs/BSidesTLV/2023/pwn/Zend_Master/server.py
#!/usr/bin/env python3 import sys import os import secrets import subprocess LIMIT: int = 1024 def prep_ini(filepath: str) -> None: runner_path = f'{filepath}.runner' with open('./conf.ini', 'r') as f: ini_template = f.read() ini_template = ini_template.replace('<RUNNER_PATH>', f'{runner_path}...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2023/pwn/Out-of-Character/server.py
ctfs/BSidesTLV/2023/pwn/Out-of-Character/server.py
#!/usr/bin/python3 from dataclasses import dataclass from enum import Enum import pathlib import io import sys import random DB_USERS = pathlib.Path(r"/tmp/users.db") DB_SECRETS = pathlib.Path(r"/tmp/secrets.db") MAX_SECRET_LEN = 128 MAX_USERNAME_LEN = 32 class UserType(Enum): MEMBER = "m" GUEST = "g" MEM...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesTLV/2023/crypto/lost-basis/lost_basis.py
ctfs/BSidesTLV/2023/crypto/lost-basis/lost_basis.py
import os from operator import xor from functools import reduce, wraps from hashlib import sha256 from hmac import HMAC, compare_digest from json import dumps, loads def read_json(prompt): return loads(input(prompt)) def write_json(dct): print(dumps(dct)) def decode_json(data): assert type(data) is dict...
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/main.py
ctfs/BSidesTLV/2022/crypto/SEV/main.py
import enum import sys from hashlib import sha256 from ecdsa.ellipticcurve import PointJacobi from ecdsa.curves import NIST384p, NIST256p from ecdsa.ecdh import ECDH from ecdsa.keys import SigningKey, VerifyingKey from lib.session import session_context, Role from lib.io import IO from lib.pow import PoW def log(m...
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/pow.py
ctfs/BSidesTLV/2022/crypto/SEV/lib/pow.py
from hashlib import sha256 from random import choice from string import digits, ascii_letters alphabet = (digits + ascii_letters).encode() def random(len): return bytes(choice(alphabet) for _ in range(len)) class PoW(object): def __init__(self, lvl : int = 4, nonce_size : int = 16, hashFn = sha256): s...
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/__init__.py
ctfs/BSidesTLV/2022/crypto/SEV/lib/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false