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/BuckeyeCTF/2022/crypto/bonce/bonce.py
ctfs/BuckeyeCTF/2022/crypto/bonce/bonce.py
import random with open('sample.txt') as file: line = file.read() with open('flag.txt') as file: flag = file.read() samples = [line[i:i+28] for i in range(0, len(line) - 1 - 28, 28)] samples.insert(random.randint(0, len(samples) - 1), flag) i = 0 while len(samples) < 40: samples.append(samples[len(samp...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BuckeyeCTF/2022/web/Hambone/dist.py
ctfs/BuckeyeCTF/2022/web/Hambone/dist.py
def get_distances(padded_url : str, flag_path : str): distances = [] for i in range(3): # calculate hamming distance on 16 byte subgroups flag_subgroup = flag_path[i*32:i*32+32] z = int(padded_url[i*32:i*32+32], 16)^int(flag_subgroup, 16) distances.append(bin(z)....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BuckeyeCTF/2022/web/shortbread/src/app.py
ctfs/BuckeyeCTF/2022/web/shortbread/src/app.py
# file: app.py from flask import Flask, render_template, request, Response, redirect import validators from Crypto.Hash import SHAKE256 from binascii import hexlify from pymongo import MongoClient import datetime import json import os import random app = Flask(__name__) shake = SHAKE256.new(os.urandom(random.randrang...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BuckeyeCTF/2022/web/goober/internal/app.py
ctfs/BuckeyeCTF/2022/web/goober/internal/app.py
from flask import Flask, request import os from dotenv import load_dotenv load_dotenv() flag = os.getenv("FLAG") app = Flask(__name__) @app.route("/", methods=["GET"]) def index(): return "<p>Whoa! You must be someone important </p>" @app.route("/flag", methods=["GET"]) def get_flag(): print(request.remote...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesIndore/2023/crypto/My_beloved_LCGpy/My_beloved_LCG.py
ctfs/BSidesIndore/2023/crypto/My_beloved_LCGpy/My_beloved_LCG.py
from Crypto.Util.number import long_to_bytes ,getPrime from random import randint,shuffle import json from banner import banner class LCG: def __init__(self,m, seed): self.a = randint(1,m) self.b = randint(1,m) self.m = m self.state = seed self.refresh() def refresh(sel...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesIndore/2023/crypto/DiffieHellman/Diffiehellman.py
ctfs/BSidesIndore/2023/crypto/DiffieHellman/Diffiehellman.py
from Crypto.Util.number import * from secrets import randbelow flag = b'BSidesIndore{?????????????????????????????????????????}' p = getPrime(1024) a = randbelow(p) b = randbelow(p) s = randbelow(p) #private_key na = randbelow(p) nb = randbelow(p) def f(z): return (a * z + b) % p def compose_f(z , n): for...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesIndore/2023/crypto/Inverse/Inverse.py
ctfs/BSidesIndore/2023/crypto/Inverse/Inverse.py
from Crypto.Cipher import AES from Crypto.Util.Padding import pad from Crypto.Util.number import bytes_to_long,long_to_bytes from secrets import generate_random_point_mod,small_noise from os import urandom n=bytes_to_long(urandom(16)) base,mod=generate_random_point_mod() new_base=(base*n+small_noise())%mod key=long_to_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Bearcat/2024/crypto/Olivias_Oracle/server.py
ctfs/Bearcat/2024/crypto/Olivias_Oracle/server.py
#!/usr/local/bin/python import sys import math import hashlib import binascii import re from Crypto.Util.number import bytes_to_long, long_to_bytes from Crypto.PublicKey import RSA class Server(object): def __init__(self): with open("key.pem") as key: self.key = RSA.importKey(ke...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Bearcat/2025/pwn/OK_Jail/jail.py
ctfs/Bearcat/2025/pwn/OK_Jail/jail.py
#!/usr/local/bin/python3 -u import json import builtins def choose_cell(): print("Choose your cell") while True: inp = input('> ') if hasattr(builtins,inp): return inp print("I don't think that cell would hold you") def choose_inmate(ok): print("Choose your inmate") ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Bearcat/2025/rev/Say_Cheese/cheese.py
ctfs/Bearcat/2025/rev/Say_Cheese/cheese.py
import base64 def encoder(input_str, key): encoded_chars = [] for i in range(len(input_str)): key_c = key[i % len(key)] encoded_c = chr((ord(input_str[i]) + ord(key_c)) % 256) encoded_chars.append(encoded_c) encoded_str = ''.join(encoded_chars) return base64.b64encode(encoded_st...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Bearcat/2025/rev/crython/crython.py
ctfs/Bearcat/2025/rev/crython/crython.py
f = int.from_bytes(input('Enter your flag: ').encode(),'big')
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
true
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Bearcat/2025/crypto/sqRSA/sqRSA.py
ctfs/Bearcat/2025/crypto/sqRSA/sqRSA.py
from Crypto.Util.number import getPrime, bytes_to_long from Crypto.Util.Padding import pad with open('flag.txt','rb') as fil: FLAG = fil.read() e = 2 p = getPrime(512) q = getPrime(512) n = p*q print(f'{e = }') print(f'{p = }') print(f'{q = }') print(f'{n = }') m = bytes_to_long(pad(FLAG,100)) c = 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/Bearcat/2025/crypto/Times_to_Die/server.py
ctfs/Bearcat/2025/crypto/Times_to_Die/server.py
import sys import socket import random from time import time def xor(bytes1, bytes2): return bytes(a ^ b for a, b in zip(bytes1, bytes2)) def pad(plaintext, length): pad_len = length - (len(plaintext)%length) return plaintext + bytes([pad_len]*pad_len) def encrypt(plaintext): key = int(time()*2**...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/RITSEC/2021/crypto/Streams_and_Rivers/stream.py
ctfs/RITSEC/2021/crypto/Streams_and_Rivers/stream.py
import random import os import binascii import sys a = long(binascii.hexlify(os.urandom(2500)), 16) rand = random.Random(a) flag = "__RS{REDACTEDREDACTEDRED}" #only difference between this and challenge binary is the characters of the flag were replaced with the characters of redacted def transform(x): unshiftRig...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/RITSEC/2024/rev/Fun/ctf_oby_medium_1.py
ctfs/RITSEC/2024/rev/Fun/ctf_oby_medium_1.py
O0O0O0O0O00OOO0O0O000O0OO00OOOOO00OO0OOOO0O0O0OO0O00OOO0OOO000O0O = ['!', 68, '\x01E"puo', '\x1f\x07', '\x1bs', '\rd', 15, '!', '\x00Y', '\x1cT', '\x01E"puo', 'p\x10\x146`!mo', 'p\x10\x146`!mo', '\x04j', 'p\x10\x146`!mo', '\x01E"puo', '*q', '\x01E"puo', '\x01E"puo', '\x0c~', '\x1aT', '!', '\x1bI', '\x0...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
true
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/RITSEC/2024/crypto/Old_Fashioned_Crypto/encryptor.py
ctfs/RITSEC/2024/crypto/Old_Fashioned_Crypto/encryptor.py
import json from Crypto.Random import get_random_bytes from Crypto.Cipher import AES from Crypto.Util.Padding import pad from math import gcd, log2, ceil class CryptoSystem: def __init__(self, size, pub_key=None, priv_key=None): self.size = size if pub_key is None and priv_key is None: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/RITSEC/2024/crypto/Dastardly_Evil_Scientists/server.py
ctfs/RITSEC/2024/crypto/Dastardly_Evil_Scientists/server.py
from Crypto.Cipher import DES from Crypto.Util.Padding import pad from secret import KEY, FLAG BLOCK_SIZE = 64 key = bytes.fromhex(KEY) cipher = DES.new(key, DES.MODE_ECB) flag = cipher.encrypt(pad(bytes(FLAG, "utf-8"), BLOCK_SIZE)) print("Here's the flag (in hex):", flag.hex()) print("=" * 64) print("Encrypt someth...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/RITSEC/2023/rev/GuessThePassword/encoding.py
ctfs/RITSEC/2023/rev/GuessThePassword/encoding.py
import hashlib, json class Encoder(): def __init__(self, secrets_file): with open(secrets_file, "r") as file: data = json.load(file) self.hashed_key = data["key"] self.secret = data["secret"] def flag_from_pwd(self, key): # This function uses code from Vin...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/RITSEC/2023/rev/GuessThePassword/server.py
ctfs/RITSEC/2023/rev/GuessThePassword/server.py
from encoding import Encoder import socket, sys, time, threading class Server: def __init__(self, PORT, DEBUG=True): self.HOST = "" self.PORT = PORT self.DEBUG = DEBUG self.accepting_connections = False self.encoder = Encoder("supersecret.json") self.connections = {...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/RITSEC/2023/crypto/Either_or_Neither_nor/chal.py
ctfs/RITSEC/2023/crypto/Either_or_Neither_nor/chal.py
#! /usr/bin/env python flag = "XXXXXXXXXXXXXXXXXXXXX" enc_flag = [91,241,101,166,85,192,87,188,110,164,99,152,98,252,34,152,117,164,99,162,107] key = [0, 0, 0, 0] KEY_LEN = 4 # Encrypt the flag for idx, c in enumerate(flag): enc_flag = ord(c) ^ key[idx % len(key)]
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/RITSEC/2025/jail/Shrimple/shrimple.py
ctfs/RITSEC/2025/jail/Shrimple/shrimple.py
from secret import flag1, flag2, flag3, flag4, SHRIMPVALS import random SHRIMPS = { SHRIMPVALS[0]: flag1, SHRIMPVALS[1]: flag2, SHRIMPVALS[2]: flag3, SHRIMPVALS[3]: flag4, } def whitelist(shrimp: str) -> bool: if any([c not in "<([+-~*])>" for c in shrimp]) or len(shrimp) > 210: return Fal...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/RITSEC/2025/crypto/Leaky_ZKP/server.py
ctfs/RITSEC/2025/crypto/Leaky_ZKP/server.py
#!/usr/local/bin/python from os import urandom, getenv from secrets import randbelow from Crypto.Util.number import getPrime, bytes_to_long FLAG = getenv('FLAG', 'MetaCTF{test_flag}').encode() def main(): p = getPrime(512) k = 32 x = bytes_to_long(FLAG + urandom(64 - len(FLAG))) g = 3 h = pow(g, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/RITSEC/2025/crypto/A_Space_Odyssey/chall.py
ctfs/RITSEC/2025/crypto/A_Space_Odyssey/chall.py
from secret import key from hashlib import sha256 data = open("flag", "rb").read() enc = b'' with open('a_space_odyssey.txt') as f: assert key.decode().lower() in f.read().lower() assert key.decode().isalnum() HASH_ROUNDS = 1000000000 dat = key.lower() for i in range(HASH_ROUNDS): dat = sha256(dat)....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/RITSEC/2025/crypto/Mothership/server.py
ctfs/RITSEC/2025/crypto/Mothership/server.py
import base64 import os import signal from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad COORDS = open("coordinates.txt").read().strip() def encrypt(message, key, iv): cipher = AES.new(key, AES.MODE_CBC, iv) padded = pad(message.encode(), AES.block_size) ciphertext = cipher.encrypt...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/RITSEC/2022/crypto/RSAGoneWrong/server.py
ctfs/RITSEC/2022/crypto/RSAGoneWrong/server.py
from Crypto.Util import number from Crypto.Util.number import long_to_bytes, bytes_to_long def getPrime(): # Note: to reduce server workload, we actually read from a precalculated list of primes. # This doesn't meaningfully change the challenge. p = number.getPrime(285) return p def encrypt(): p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/INCOGNITO/2024/misc/Doodle_game/source.py
ctfs/INCOGNITO/2024/misc/Doodle_game/source.py
#!/usr/bin/python import time import unicodedata blacklist = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789[]{}<>/_'!" def isSafe(cmd): for i in cmd: if i in blacklist: return(0) return(1) def main(): cmd = input(">> ") normalized_cmd = unicodedata.normalize('NFKD'...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ApoorvCTF/2025/hw/Secret_Guarding_Itself/decimal_string.py
ctfs/ApoorvCTF/2025/hw/Secret_Guarding_Itself/decimal_string.py
def dec_to_string(dec): binary = str(bin(dec)).replace("b","") text = ''.join(chr(int(binary[i:i+8], 2)) for i in range(0, len(binary), 8)) return text
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ApoorvCTF/2025/crypto/Genjutsu_Labyrinth/broken.py
ctfs/ApoorvCTF/2025/crypto/Genjutsu_Labyrinth/broken.py
from sympy import primerange import random from collections import deque def generate(size): grid = [[random.randint(0, 9) for col in range(size)] for row in range(size)] grid[0][0] = 0 return grid def encrypt(n, a, b, mod=101): return (a * n + b) % mod def build_encrypted_grid(grid, a, b, mod=101): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BlueArena/2025/rev/Reverse_Eng./shadowgate_challenge.py
ctfs/BlueArena/2025/rev/Reverse_Eng./shadowgate_challenge.py
import sys import random import math import functools import operator import string import builtins as __b AlphaCompute = lambda x: x BetaProcess = lambda x, y: x + y - y for Q in range(100): exec(f'def QuantumFunc_{Q}(a): return a') GammaList = [lambda x: x for _ in range(50)] for Z in range(50): GammaList[Z...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
true
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DaVinciCTF/2023/crypto/RadioactiveRSA/chall.py
ctfs/DaVinciCTF/2023/crypto/RadioactiveRSA/chall.py
from Crypto.Util.number import getStrongPrime, inverse, GCD, bytes_to_long from Crypto.Util.Padding import pad from Crypto.Cipher import AES import random import hashlib import os FLAG = b"[REDACTED]" e = 0x10001 while True: p = getStrongPrime(2048) q = getStrongPrime(2048) phi = (p-1)*(q-1) d = inver...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DaVinciCTF/2023/crypto/DaVincisClock/chall.py
ctfs/DaVinciCTF/2023/crypto/DaVincisClock/chall.py
from Crypto.Cipher import AES from hashlib import sha256 from Crypto.Util.number import getPrime, inverse from Crypto.Util.Padding import pad, unpad import random from time import time import os from tonelli_shanks import tonelli_shanks from collections import namedtuple Point = namedtuple("Point", "x y") O = 'Origin...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DaVinciCTF/2023/crypto/InfiniteImage/chall.py
ctfs/DaVinciCTF/2023/crypto/InfiniteImage/chall.py
from PIL import Image import hashlib import random import math FLAG = b"dvCTF{[a-zA-Z0-9_]+}" LSB = "".join([format(l,'b').zfill(8) for l in FLAG]).zfill(8*3*math.ceil(len(FLAG)/3)) leonards_image = Image.open("starting_image.png") message = Image.new(leonards_image.mode, leonards_image.size) (columns, rows) = leonar...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DaVinciCTF/2023/crypto/Personalkey/decrypt.py
ctfs/DaVinciCTF/2023/crypto/Personalkey/decrypt.py
from Crypto.Util.Padding import unpad from Crypto.Cipher import AES import argparse import hashlib def decrypt_fct(private_key: int, iv: str, ciphertext: str) : derived_aes_key = hashlib.sha256(str(private_key).encode('ascii')).digest() cipher = AES.new(derived_aes_key, AES.MODE_CBC, bytes.fromhex(iv)) ret...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DaVinciCTF/2025/crypto/SCAred_Generator/challenge.py
ctfs/DaVinciCTF/2025/crypto/SCAred_Generator/challenge.py
from hidden import FLAG from Crypto.Util.number import bytes_to_long, getRandomInteger, isPrime import sympy def getPrime(b=512): v = 2 * getRandomInteger(b) + 1 # Random odd number while 1: v += 2 R = sympy.sieve.primerange(1000) for r in R: if v % r == 0: # Trial divisio...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DaVinciCTF/2025/crypto/IndestructibleVault/source.py
ctfs/DaVinciCTF/2025/crypto/IndestructibleVault/source.py
from hidden import KEY, MSG from Crypto.Cipher import AES from flask import Flask app = Flask(__name__) @app.route('/') def home(): return "Welcome to the Indestructible Vault !" @app.route('/vault/<pwd>') def encrypt(pwd): pwd = bytes.fromhex(pwd) assert len(pwd) == 16 and len(KEY) == 16 cipher = AE...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DaVinciCTF/2025/web/LouvreArchives/app.py
ctfs/DaVinciCTF/2025/web/LouvreArchives/app.py
from flask import Flask, jsonify, abort, make_response, render_template, request from os import path import jwt import datetime import random import base64 def generate_random_filename(): rdn = random.getrandbits(32) return f"{rdn}.webp" image_list = [generate_random_filename() for _ in range(650)] app = Flas...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DaVinciCTF/2022/crypto/CwyptographicOwacle/script.py
ctfs/DaVinciCTF/2022/crypto/CwyptographicOwacle/script.py
import ecdsa import random import hashlib import time from Crypto.Cipher import AES from Crypto.Util.Padding import pad from Crypto.Util.number import long_to_bytes FLAG = b'dvCTF{XXXXXXXXXXXXXXXXXXX}' def encrypt_flag(priv): key = long_to_bytes(priv) cipher = AES.new(key, AES.MODE_ECB) text = cipher.encr...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PointerOverflow/2024/crypto/Rechance_Meeting/Crypto200-2_hashfunc.py
ctfs/PointerOverflow/2024/crypto/Rechance_Meeting/Crypto200-2_hashfunc.py
import hashlib def custom_hash(input_str): sha256_hash = hashlib.sha256(input_str.encode()).hexdigest() md5_hash = hashlib.md5(input_str.encode()).hexdigest() combined_hash = sha256_hash + md5_hash hash_value1 = 0 hash_value2 = 0 hash_value3 = 0 primes = [31, 37, 41, 43, 47, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PointerOverflow/2024/crypto/Put_Down_Thy_Wrath/Crypto300-3_homomorphic_encryption.py
ctfs/PointerOverflow/2024/crypto/Put_Down_Thy_Wrath/Crypto300-3_homomorphic_encryption.py
# homomorphic_encryption.py import random import binascii class FlawedHomomorphicEncryption: def __init__(self, p, q): self.n = p * q self.p = p self.q = q self.public_key = self.n def encrypt(self, message): encrypted_message = [] for char in message: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2021/crypto/Snab_Yes_Snab/Snab.py
ctfs/COMPFEST/2021/crypto/Snab_Yes_Snab/Snab.py
from Cryptodome.Util.number import* e = 0x10001 s = pow(p + q, 2) n = p*q a = pow(s, 3, r) b = (s - q*(2*p + q))*r m_list = [findme] c_list = [] for i in range(len(m_list)): m = bytes_to_long(m_list[i]) c = pow(m*r, e, n) c_list.append(c) output = open("output.txt", "w") output.writelines([str(i) + "\n...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2021/crypto/You_AES_Me_Up/chall.py
ctfs/COMPFEST/2021/crypto/You_AES_Me_Up/chall.py
#!/usr/bin/env python3 import sys import os import random import binascii from Crypto.Cipher import AES from Crypto.Util.number import long_to_bytes, bytes_to_long from secret import FLAG IV = os.urandom(AES.block_size) KEY = os.urandom(AES.block_size) class Unbuffered(object): def __init__(self, stream): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2021/crypto/Junior_Signing_System/chall.py
ctfs/COMPFEST/2021/crypto/Junior_Signing_System/chall.py
#!/usr/bin/env python3 from collections import namedtuple from Crypto.Util.number import inverse, bytes_to_long from Crypto.Hash import SHA1 import sys import os class Unbuffered(object): def __init__(self, stream): self.stream = stream def write(self, data): self.stream.write(data) se...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2021/crypto/Secure_Channel/talk-with-alice.py
ctfs/COMPFEST/2021/crypto/Secure_Channel/talk-with-alice.py
#!/usr/bin/env python3 import sys from base64 import b64encode, b64decode from Crypto.Util.number import getPrime, bytes_to_long as bl, long_to_bytes as lb from secrets import Alice, You class Unbuffered(object): def __init__(self, stream): self.stream = stream def write(self, data): self.stre...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2021/crypto/Secure_Channel/secrets.py
ctfs/COMPFEST/2021/crypto/Secure_Channel/secrets.py
#!/usr/bin/env python3 from Crypto.Util.number import bytes_to_long as bl, long_to_bytes as lb from Crypto.Cipher import AES import os import random import string sp = list(map(ord, list(string.printable))) def pad(msg): pad_length = random.randint(20, 100) for i in range(pad_length): c = random.randi...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2021/crypto/Secure_Channel/talk-with-bob.py
ctfs/COMPFEST/2021/crypto/Secure_Channel/talk-with-bob.py
#!/usr/bin/env python3 import sys from base64 import b64encode, b64decode from Crypto.Util.number import getPrime, bytes_to_long as bl, long_to_bytes as lb from secrets import Bob, You class Unbuffered(object): def __init__(self, stream): self.stream = stream def write(self, data): self.stream...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2021/crypto/Secure_Channel/alice-bob.py
ctfs/COMPFEST/2021/crypto/Secure_Channel/alice-bob.py
#!/usr/bin/env python3 import sys from base64 import b64encode, b64decode from Crypto.Util.number import getPrime, bytes_to_long as bl, long_to_bytes as lb from secrets import Alice, Bob from chats import alice_dialogue, bob_dialogue import time class Unbuffered(object): def __init__(self, stream): self.s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2021/web/COMPFEST_Pay_v2/transaction/views.py
ctfs/COMPFEST/2021/web/COMPFEST_Pay_v2/transaction/views.py
from django.contrib import messages from django.contrib.auth.decorators import login_required from django.contrib.auth.hashers import check_password from django.core.exceptions import ValidationError from django.http import QueryDict from django.shortcuts import redirect, resolve_url from django.views.decorators.http i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2021/web/COMPFEST_IDE/views.py
ctfs/COMPFEST/2021/web/COMPFEST_IDE/views.py
from django.shortcuts import render, redirect from django.views.decorators.http import require_http_methods from .utils import CODE_DIR, BLACKLIST, run_code, get_output, generate_id @require_http_methods(['GET', 'POST']) def create_handler(req): illegal = False if req.method == 'POST': code = req.POST....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2021/web/COMPFEST_IDE/urls.py
ctfs/COMPFEST/2021/web/COMPFEST_IDE/urls.py
"""compfestide URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/3.2/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-b...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2024/misc/john_O_jail/challenge.py
ctfs/COMPFEST/2024/misc/john_O_jail/challenge.py
import inspect as [REDACTED] blocked1 = ['eval', 'exec', 'execfile', 'compile', 'open', 'file', 'input', 'import', 'getattr', 'setattr', 'delattr','attr', 'var', 'help', 'dir', 'bytearray', 'bytes', 'memoryview', '__import__', 'os', 'sys', 'subprocess', 'shutil', 'socket', 'threading', 'multiprocessing',...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2024/misc/john_O_jail/flag.py
ctfs/COMPFEST/2024/misc/john_O_jail/flag.py
def flag_peye(): try: assert(1+1==0) print("\nOh no! John has escaped with the flag: COMPFEST16{fake_flag}\n") except AssertionError: print(f"\nJohnny Johnny no escape!\n") if __name__=='__main__': flag_peye()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2024/misc/Edit_Distance_0/main.py
ctfs/COMPFEST/2024/misc/Edit_Distance_0/main.py
import logging import tempfile import subprocess from pathlib import Path def get_module_logger(mod_name: str) -> logging.Logger: logger = logging.getLogger(mod_name) handler = logging.StreamHandler() formatter = logging.Formatter("%(asctime)s [%(name)-12s] %(levelname)-8s %(message)s") handler.setFor...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2024/crypto/All_My_Apes_Are_Gone/signature_extract.py
ctfs/COMPFEST/2024/crypto/All_My_Apes_Are_Gone/signature_extract.py
import binascii from bitcoin.core import CTransaction, CMutableTransaction from bitcoin.core.script import SignatureHash, SIGHASH_ALL, CScript #pip install ecdsa #pip install def extract_msg_hash_and_sig(tx_hex): # Decode the transaction hex tx = CTransaction.deserialize(binascii.unhexlify(tx_hex)) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2024/crypto/money_gone_wallet_also_gone/chall.py
ctfs/COMPFEST/2024/crypto/money_gone_wallet_also_gone/chall.py
import hashlib import random methods = ['md5', 'sha256', 'sha3_256', 'sha3_512', 'sha3_384', 'sha1', 'sha384', 'sha3_224', 'sha512', 'sha224'] def random_encrypt(x) : method = random.choice(methods) hash_obj = hashlib.new(method) hash_obj.update(x.encode()) return hash_obj.hexdigest() def main() : ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2024/crypto/Forge_Me_if_You_can/main.py
ctfs/COMPFEST/2024/crypto/Forge_Me_if_You_can/main.py
from flask import Flask, request, jsonify from Crypto.Util.number import bytes_to_long, getPrime, inverse from hashlib import sha256, sha512, sha3_256, sha3_512, blake2b, blake2s app = Flask(__name__) algo_round = [sha256, sha3_256, sha3_512, blake2b, blake2s] magic_string = b"SkibidiSigmaRizzleDizzleMyNizzleOffTheH...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2024/crypto/Prime_Rotation/chall.py
ctfs/COMPFEST/2024/crypto/Prime_Rotation/chall.py
from sage.all import * from Crypto.Util.number import * flag = b'COMPFEST16{REDACTED}' while True: p = next_prime(randrange(10*299, 10**300)) if len(str(p)) != 300: continue q = Integer(int(str(p)[200:] + str(p)[100:200] + str(p)[:100])) if is_prime(q): if len(str(p*q)) == 600: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2024/web/SIAK_OG/captcha.py
ctfs/COMPFEST/2024/web/SIAK_OG/captcha.py
import hashlib import sys import os TOTAL_ROUNDS = 92621 def captcha(inp: str): s = inp for _ in range(TOTAL_ROUNDS): inp = hashlib.sha256(s.encode()).hexdigest() s = inp[0] for i in range(1, len(inp)): s += chr(ord(inp[i]) ^ ord(inp[i - 1]) & 0b10101010) return hash...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2023/misc/napi/snippet.py
ctfs/COMPFEST/2023/misc/napi/snippet.py
# ... del __builtins__.__import__ def main(): banned = ['eval', 'exec', 'import', 'open', 'system', 'globals', 'os', 'password', 'admin', 'pop', 'clear', 'remove'] print("--- Prisoner Limited Access System ---") user = input("Enter your username: ") if user == "john": inp = input(f"{user} >...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2023/misc/artificial_secret/main.py
ctfs/COMPFEST/2023/misc/artificial_secret/main.py
# This code is based on the following example: # https://discordpy.readthedocs.io/en/stable/quickstart.html#a-minimal-bot import discord import openai client = discord.Client() #dihide, jangan dicolong ya bang openai.api_key = "redacted" flag = "ini flag" async def get_balance(msg): resp = openai.ChatCompletion.c...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2023/rev/Read_Around/src/main.py
ctfs/COMPFEST/2023/rev/Read_Around/src/main.py
import os import asyncio from reader.server import handle_client async def run_server(): os.chdir("./files/") server = await asyncio.start_server(handle_client, "0.0.0.0", 3000) async with server: await server.serve_forever() asyncio.run(run_server())
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2023/rev/Read_Around/src/reader/core.py
ctfs/COMPFEST/2023/rev/Read_Around/src/reader/core.py
from dataclasses import dataclass @dataclass class Request: method: str path: str data: str class InvalidRequest(Exception): pass class MethodNotAllowed(Exception): pass
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2023/rev/Read_Around/src/reader/utils.py
ctfs/COMPFEST/2023/rev/Read_Around/src/reader/utils.py
import os import string import asyncio def check_filename(fname): for c in fname: if c not in string.ascii_lowercase + "." + "/": return False return True def get_content(fname: str | None) -> str: if fname: if not fname.endswith(".txt") or not check_filename(fname) or '../' in...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2023/rev/Read_Around/src/reader/routes.py
ctfs/COMPFEST/2023/rev/Read_Around/src/reader/routes.py
from jinja2 import Environment, PackageLoader, select_autoescape from reader.core import InvalidRequest, Request from reader.utils import get_content, get_filelist env = Environment(loader=PackageLoader("reader"), autoescape=select_autoescape()) template = env.get_template("index.html") async def list_files(request:...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2023/rev/Read_Around/src/reader/server.py
ctfs/COMPFEST/2023/rev/Read_Around/src/reader/server.py
import collections import asyncio import traceback from urllib.parse import unquote from reader.core import InvalidRequest, MethodNotAllowed, Request from reader.routes import list_files BUFFER_SIZE = 8196 async def parse_request(reader: asyncio.StreamReader): print("Recv req") req = (await reader.read(BUFF...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2023/rev/KatVM/run_katvm.py
ctfs/COMPFEST/2023/rev/KatVM/run_katvm.py
import base64 import tempfile import sys from pathlib import Path modules: list[tuple[str, bytes]] = [('utils', b'bw0NCgAAAABXjPFkvgMAAOMAAAAAAAAAAAAAAAAAAAAACQAAAEAAAABzzgAAAFUAZABkAWwAbQFaAQEAZABkAmwCWgJkAGQCbANaA2QAZANsBG0FWgUBAGQEZAWEAGQGZgJkB2QFhABkBmYCZAhkBYQAZAZmAmQJZAWEAGQAZgJkCmQFhABkAGYCZAtkBYQAZABmAmQMZAWEA...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2023/crypto/CryptoVault/main.py
ctfs/COMPFEST/2023/crypto/CryptoVault/main.py
from flask import Flask, jsonify, request, render_template import ecdsa import ecdsa.ellipticcurve as EC from flask_cors import CORS import binascii import ecdsa.util app = Flask(__name__) CORS(app) curve = ecdsa.SECP256k1 G = curve.generator n = G.order() x = int('ce205d44c14517ba33f3ef313e404537854d494e28fcf71615e5...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2023/crypto/Swusjask_Encryption/chall.py
ctfs/COMPFEST/2023/crypto/Swusjask_Encryption/chall.py
from Crypto.Util.number import long_to_bytes, bytes_to_long p = 1179478847235411356076287763101027881 e = 0x10001 def bytes_to_block(msg: bytes): res = [] msg_int = bytes_to_long(msg) while msg_int: res.append(msg_int % (p**2)) msg_int //= p**2 return res def block_to_bytes(blocks: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2023/crypto/knapsack/chall.py
ctfs/COMPFEST/2023/crypto/knapsack/chall.py
from collections import namedtuple import random from Crypto.Util.number import isPrime, GCD from secret import message, key_size PrivateKey = namedtuple("PrivateKey", "W q r") PublicKey = namedtuple("PublicKey", "B") def to_bits(m): _bin = lambda b: [1 if b & (1 << n) else 0 for n in range(7)] return sum([_b...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2023/crypto/choose_exponent/chall.py
ctfs/COMPFEST/2023/crypto/choose_exponent/chall.py
from Crypto.Util.number import getPrime, bytes_to_long FLAG = b"COMPFEST15{REDACTED}".ljust(256, b"\x00") class RSA: def __init__(self): self.p = getPrime(1024) self.q = getPrime(1024) self.n = self.p * self.q # you can choose your own public exponent # self.e = 65537 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2022/crypto/AnnihilatedSimilarity/chall.py
ctfs/COMPFEST/2022/crypto/AnnihilatedSimilarity/chall.py
import os from random import shuffle from math import prod from Crypto.Cipher import AES from Crypto.Util.Padding import pad from secret import FLAG class LFSR: def __init__(self, state, taps): self.state = state self.taps = [len(state) - t for t in taps] def clock(self): out = self.st...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2022/crypto/similar/chall.py
ctfs/COMPFEST/2022/crypto/similar/chall.py
from Crypto.Cipher import AES from Crypto.Util import Padding, number from secret import flag, seed import hashlib, secrets class LFSR: def __init__(self, state, taps): self.state = state self.taps = [len(state) - t for t in taps] def clock(self): out = self.state[0] self.state...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2022/crypto/33DES/chall.py
ctfs/COMPFEST/2022/crypto/33DES/chall.py
from des_lib import * from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l from flag import FLAG import os def lrot(s, n): for _ in range(n): s = s[1:] + s[0] return s def generate_keys(): key_bits = bin(b2l(KEY[0]))[2:].zfill(64) permuted_key = ''.join([key_bits[i] for i ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2022/crypto/Anti-Factorization/chall.py
ctfs/COMPFEST/2022/crypto/Anti-Factorization/chall.py
from math import log, e, pi from secrets import randbelow from secret import FLAG from gmpy2 import is_prime delta = lambda k, n : 1/(2*k+1) + \ log(2*k**3)/(2*(2*k+1)*log(n)) + \ (log(2*k+1) - log(2*pi*e) - log(4*k**3))/(4*log(n)) def getPrime(pbits, M, k=8): assert M...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2022/web/VacationGallery/chall.py
ctfs/COMPFEST/2022/web/VacationGallery/chall.py
import re from flask import Flask, render_template, request, render_template_string app = Flask(__name__) s = { "austria-1": { "url": "https://cdn.discordapp.com/attachments/803887398105776168/872209040694972416/20210803_140556.jpg", "title": "The woods and fallen log in the Austrian Alps" }, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2022/web/Searchify/backend/src/api.py
ctfs/COMPFEST/2022/web/Searchify/backend/src/api.py
from .utils import filter_items from duckduckgo_search import ddg import os import requests class BingAPI(object): subscription_key = os.getenv('BING_SEARCH_V7_SUBSCRIPTION_KEY') endpoint = 'https://api.bing.microsoft.com/v7.0/search' keywords = ['name', 'url', 'snippet'] def request(self, query, max...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2022/web/Searchify/backend/src/utils.py
ctfs/COMPFEST/2022/web/Searchify/backend/src/utils.py
def filter_items(items, keys): excluded_keys = [v for v in items.keys() if v not in keys] for key in excluded_keys: del items[key] return items def normalize(elements): results = [] for enum, element in enumerate(elements): items = dict() for key, val in element.it...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2022/web/Searchify/backend/src/__init__.py
ctfs/COMPFEST/2022/web/Searchify/backend/src/__init__.py
from .routes import app if __name__ == "__main__": app.run()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/COMPFEST/2022/web/Searchify/backend/src/routes.py
ctfs/COMPFEST/2022/web/Searchify/backend/src/routes.py
from flask import Flask from flask import jsonify from flask import request from flask_cors import CORS from flask_cors import cross_origin from .utils import normalize from .api import BingAPI from .api import DuckDuckGOAPI app = Flask(__name__) cors = CORS(app) @app.route('/search', methods=['GET']) @cross_origin...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/h4ckc0n/2025/crypto/MTH211/chall.py
ctfs/h4ckc0n/2025/crypto/MTH211/chall.py
from Crypto.Util.number import getPrime,isPrime,GCD,bytes_to_long from secrets import flag p = getPrime(256) q = getPrime(256) phi = (p-1)*(q-1) g = getPrime(256) n = p*q e = 13 p1 = getPrime(28) p2 = getPrime(28) K = p1*p2 gift =pow(K,e,n) print(f"gift={gift}") K *= g #enough padding of the key to prevent boneh d...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/h4ckc0n/2025/crypto/d4rkc0pe.com_for_sale/CRYPTO_CHAL.py
ctfs/h4ckc0n/2025/crypto/d4rkc0pe.com_for_sale/CRYPTO_CHAL.py
#!/usr/bin/env python3 import re from Crypto.Hash import SHA256 from Crypto.Util.number import bytes_to_long, long_to_bytes, getPrime from pkcs1 import emsa_pkcs1_v15 p1 = getPrime(1024) p2 = getPrime(1024) N = p1 * p2 E = 0x10001 phi = (p1-1)*(p2-1) D = pow(E,-1,N) FLAG = b"d4rk{REDACTED}c0de" MSG = 'hippity hoppi...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/h4ckc0n/2025/crypto/Easy_Inverse/inverse_fun.py
ctfs/h4ckc0n/2025/crypto/Easy_Inverse/inverse_fun.py
from Crypto.Util.number import * p = getPrime(1024) bits = 100 from secret import flag m = bytes_to_long(flag) hints = [pow(m , -1 , p) , pow(m+1 , -2 , p)] hints_leak = [(i>>bits)<<bits for i in hints] print(f"hints_leak = {hints_leak}") print(f"p = {p}")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/InternetFestival/2023/Quals/rev/Lambda_lambda_lambda/lambda.py
ctfs/InternetFestival/2023/Quals/rev/Lambda_lambda_lambda/lambda.py
#!/usr/bin/env python3.10 import sys sys.setrecursionlimit(10000000) (lambda _0: _0(37))(lambda _1: (lambda _2: _2(lambda _3: lambda _4: _3 == _4))(lambda _5: (lambda _6: _6(lambda _7: lambda _8: _7 + _8))(lambda _9: (lambda _10: _10(lambda _11: lambda _12: _11 % _12))(lambda _13: (lambda _14: _14(lambda _15: lambda ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/InternetFestival/2023/Quals/crypto/Baby_oracle/server.py
ctfs/InternetFestival/2023/Quals/crypto/Baby_oracle/server.py
#!/usr/bin/env python3 import pickle from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad import os import sys null = open(os.devnull, 'w') sys.stderr = null FLAG = os.environ.get("FLAG") key = os.urandom(16) def encrypt(message: object) -> bytes: msg = pickle.dumps(message) cipher = AE...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/InternetFestival/2023/Quals/crypto/Grown_oracle/chall.py
ctfs/InternetFestival/2023/Quals/crypto/Grown_oracle/chall.py
#!/usr/local/bin/python3 from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad import os FLAG = open("flag.txt", "r").read().strip() def encrypt(key, iv, plaintext): cipher = AES.new(key, AES.MODE_CBC, iv) ciphertext = cipher.encrypt(pad(plaintext, 16)) return ciphertext def decrypt(k...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/InternetFestival/2023/Quals/crypto/RANDOM/chall.py
ctfs/InternetFestival/2023/Quals/crypto/RANDOM/chall.py
#!/usr/local/bin/python3 import os from random import Random import signal TIMEOUT = 60 FLAG = open("flag.txt", "r").read().strip() def handle(): s1 = os.urandom(10) r1 = Random(s1) len_seed = r1.randint(100, 1200) seed = int.from_bytes(os.urandom(len_seed), 'big') r2 = Random(seed) check ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/InternetFestival/2023/Quals/web/proxed/solve_pow.py
ctfs/InternetFestival/2023/Quals/web/proxed/solve_pow.py
import random from hashlib import sha256 import sys import string if len(sys.argv) != 2: print(f'Usage: python {sys.argv[0]} <end-of-hash>') exit(1) pow = sys.argv[1] while True: x = ''.join(random.choices(string.ascii_letters, k=25)) if( sha256(x.encode()).hexdigest().endswith(pow) ): print...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/InternetFestival/2023/Quals/web/flagify_3/bank/server/db.py
ctfs/InternetFestival/2023/Quals/web/flagify_3/bank/server/db.py
import mysql.connector import utils import hashlib import os class DBException(Exception): pass class DB: hostname = os.environ.get('DBHOST', '127.0.0.1') dbname = os.environ.get('MYSQL_DATABASE', 'bank_db') username = 'root' password = os.environ.get('MYSQL_ROOT_PASSWORD', 'password') def ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/InternetFestival/2023/Quals/web/flagify_3/bank/server/utils.py
ctfs/InternetFestival/2023/Quals/web/flagify_3/bank/server/utils.py
import random import string import jwt def random_string(k=8): return ''.join(random.choices(string.ascii_letters + string.digits, k=k)) def parse_token(token, secret): data = jwt.decode(token, secret, algorithms = 'HS256') try: url = data['url'] amount = data['amount'] transacti...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/InternetFestival/2023/Quals/web/flagify_3/bank/server/app.py
ctfs/InternetFestival/2023/Quals/web/flagify_3/bank/server/app.py
from flask import Flask, request, redirect, session, jsonify from flask_login import LoginManager, login_user, current_user, login_required from db import DB, DBException import utils import os import jwt import pyotp import requests app = Flask(__name__) login_manager = LoginManager(app) app.config['SECRET_KEY'] = u...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/InternetFestival/2023/Quals/web/flagify_3/shop/server/db.py
ctfs/InternetFestival/2023/Quals/web/flagify_3/shop/server/db.py
import mysql.connector import utils import hashlib import os class DBException(Exception): pass class DB: hostname = os.environ.get('DBHOST', '127.0.0.1') dbname = os.environ.get('MYSQL_DATABASE', 'shop_db') username = 'root' password = os.environ.get('MYSQL_ROOT_PASSWORD', 'password') def ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/InternetFestival/2023/Quals/web/flagify_3/shop/server/utils.py
ctfs/InternetFestival/2023/Quals/web/flagify_3/shop/server/utils.py
import random import string import jwt def random_string(k=8): return ''.join(random.choices(string.ascii_letters + string.digits, k=k)) def parse_token(token, secret): data = jwt.decode(token, secret, algorithms = 'HS256') try: status = data['status'] transaction_id = data['transaction_i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/InternetFestival/2023/Quals/web/flagify_3/shop/server/app.py
ctfs/InternetFestival/2023/Quals/web/flagify_3/shop/server/app.py
from flask import Flask, request, url_for, session, jsonify from db import DB, DBException from functools import wraps import utils import os import jwt app = Flask(__name__) app.config['SECRET_KEY'] = utils.random_string(20) app.config['SHARED_SECRET'] = os.environ.get( 'SHARED_SECRET', 'segreto_segretissimo_muc...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TAMUctf/2023/pwn/macchiato/solver-template.py
ctfs/TAMUctf/2023/pwn/macchiato/solver-template.py
from pwn import * p = remote("tamuctf.com", 443, ssl=True, sni="macchiato") p.interactive()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TAMUctf/2023/pwn/bank/solver-template.py
ctfs/TAMUctf/2023/pwn/bank/solver-template.py
from pwn import * p = remote("tamuctf.com", 443, ssl=True, sni="bank") p.interactive()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TAMUctf/2023/pwn/contrived-shellcode/solver-template.py
ctfs/TAMUctf/2023/pwn/contrived-shellcode/solver-template.py
from pwn import * p = remote("tamuctf.com", 443, ssl=True, sni="contrived-shellcode") p.interactive()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TAMUctf/2023/pwn/pwnme/solver-template.py
ctfs/TAMUctf/2023/pwn/pwnme/solver-template.py
from pwn import * p = remote("tamuctf.com", 443, ssl=True, sni="pwnme") p.interactive()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TAMUctf/2023/pwn/sea-shells/solver-template.py
ctfs/TAMUctf/2023/pwn/sea-shells/solver-template.py
from pwn import * p = remote("tamuctf.com", 443, ssl=True, sni="sea-shells") p.interactive()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TAMUctf/2023/pwn/unlucky/solver-template.py
ctfs/TAMUctf/2023/pwn/unlucky/solver-template.py
from pwn import * p = remote("tamuctf.com", 443, ssl=True, sni="unlucky") p.interactive()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TAMUctf/2023/pwn/encryptinator/solver-template.py
ctfs/TAMUctf/2023/pwn/encryptinator/solver-template.py
from pwn import * p = remote("tamuctf.com", 443, ssl=True, sni="encryptinator") p.interactive()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TAMUctf/2023/pwn/inspector-gadget/solver-template.py
ctfs/TAMUctf/2023/pwn/inspector-gadget/solver-template.py
from pwn import * p = remote("tamuctf.com", 443, ssl=True, sni="inspector-gadget") p.interactive()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false