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/HITCON/2023/Quals/crypto/Random_Shuffling_Algorithm/chall.py
ctfs/HITCON/2023/Quals/crypto/Random_Shuffling_Algorithm/chall.py
from Crypto.Util.number import * from functools import reduce from random import SystemRandom import os random = SystemRandom() def xor(a, b): return bytes([x ^ y for x, y in zip(a, b)]) with open("flag.txt", "rb") as f: flag = f.read().strip() n_size = 1024 msgs = [os.urandom(n_size // 8 - 1) 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/HITCON/2023/Quals/crypto/Careless_Padding/chal.py
ctfs/HITCON/2023/Quals/crypto/Careless_Padding/chal.py
#!/usr/local/bin/python import random import os from secret import flag from Crypto.Cipher import AES from Crypto.Random import get_random_bytes import json N = 16 # 0 -> 0, 1~N -> 1, (N+1)~(2N) -> 2 ... def count_blocks(length): block_count = (length-1) // N + 1 return block_count def find_repeat_tail(messa...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HITCON/2023/Quals/crypto/Careless_Padding/secret.py
ctfs/HITCON/2023/Quals/crypto/Careless_Padding/secret.py
import os flag = "hitcon{tmperory_flag_for_testing}"
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HITCON/2023/Quals/crypto/Collision/server.py
ctfs/HITCON/2023/Quals/crypto/Collision/server.py
#!/usr/bin/env python3 import os import signal if __name__ == "__main__": salt = os.urandom(8) print("salt:", salt.hex()) while True: m1 = bytes.fromhex(input("m1: ")) m2 = bytes.fromhex(input("m2: ")) if m1 == m2: continue h1 = hash(salt + m1) h2 = hash(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HITCON/2023/Quals/crypto/Share/server.py
ctfs/HITCON/2023/Quals/crypto/Share/server.py
#!/usr/bin/env python3 from Crypto.Util.number import isPrime, getRandomRange, bytes_to_long from typing import List import os, signal class SecretSharing: def __init__(self, p: int, n: int, secret: int): self.p = p self.n = n self.poly = [secret] + [getRandomRange(0, self.p - 1) for _ in ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HITCON/2023/Quals/crypto/Echo/server.py
ctfs/HITCON/2023/Quals/crypto/Echo/server.py
#!/usr/bin/env python3 from Crypto.Util.number import * from shlex import quote import subprocess, sys, signal class RSA: def __init__(self, size): self.p = getPrime(size // 2) self.q = getPrime(size // 2) self.n = self.p * self.q self.e = getPrime(size // 2) self.d = pow(s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HITCON/2023/Quals/crypto/EZRSA/server.py
ctfs/HITCON/2023/Quals/crypto/EZRSA/server.py
#!/usr/bin/env python3 from Crypto.Util.number import isPrime, getPrime, getRandomNBitInteger, getRandomRange import gmpy2, os # some generic elliptic curve stuff because sage is too heavy :( # there is no intended vulnerability in part, please ignore it class Curve: def __init__(self, p, a, b): self.p =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HITCON/2023/Quals/web/AMF/server.py
ctfs/HITCON/2023/Quals/web/AMF/server.py
from pyamf.remoting.gateway.wsgi import WSGIGateway import secrets ADMIN_USER = secrets.token_urlsafe(16) ADMIN_PASS = secrets.token_urlsafe(16) class FileManagerService: def read(self, filename): with open(filename, "rb") as f: return f.read() def list(self, path="/"): import os...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HITCON/2022/pwn/EaaS/share/eaas.py
ctfs/HITCON/2022/pwn/EaaS/share/eaas.py
import fitz import base64 import tempfile import os import json inputtext = input("Give me a text: ")[:1024] uspassword = input("Choose a user password for your document: ") owpassword = input("Choose a owner password for your document: ") options_inp = input("Options for Document.save(): ") allow_options = [ "ga...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HITCON/2022/pwn/sandbox/service/chal.py
ctfs/HITCON/2022/pwn/sandbox/service/chal.py
#!/usr/bin/python3 -u import atexit import os import random import signal import string import subprocess import sys import tempfile # Edit these variables for your own testing purpose WWW_DIR = os.getenv("WWW") WEB_HOST = os.getenv("HOST_IP") WEB_PORT = os.getenv("PORT") DOCKER_IMG_NAME = "hitcon2022_sandbox" MAX_I...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HITCON/2022/pwn/sandbox/service/hashcash.py
ctfs/HITCON/2022/pwn/sandbox/service/hashcash.py
#!/usr/bin/env python2.3 """Implement Hashcash version 1 protocol in Python +-------------------------------------------------------+ | Written by David Mertz; released to the Public Domain | +-------------------------------------------------------+ Double spend database not implemented in this module, but stub for ca...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HITCON/2022/crypto/secret/prob.py
ctfs/HITCON/2022/crypto/secret/prob.py
import random, os from Crypto.Util.number import getPrime, bytes_to_long p = getPrime(1024) q = getPrime(1024) n = p * q flag = open('flag','rb').read() pad_length = 256 - len(flag) m = bytes_to_long(os.urandom(pad_length) + flag) assert(m < n) es = [random.randint(1, 2**512) for _ in range(64)] cs = [pow(m, p + e, n...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HITCON/2022/crypto/babysss/chall.py
ctfs/HITCON/2022/crypto/babysss/chall.py
from random import SystemRandom from Crypto.Cipher import AES from hashlib import sha256 from secret import flag rand = SystemRandom() def polyeval(poly, x): return sum([a * x**i for i, a in enumerate(poly)]) DEGREE = 128 SHARES_FOR_YOU = 8 # I am really stingy :) poly = [rand.getrandbits(64) for _ in range(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HITCON/2022/crypto/superprime/chall.py
ctfs/HITCON/2022/crypto/superprime/chall.py
from Crypto.Util.number import getPrime, isPrime, bytes_to_long def getSuperPrime(nbits): while True: p = getPrime(nbits) pp = bytes_to_long(str(p).encode()) if isPrime(pp): return p, pp p1, q1 = getSuperPrime(512) p2, q2 = getSuperPrime(512) p3, q3 = getSuperPrime(512) p4, q...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HITCON/2022/web/s0undcl0ud/app/app.py
ctfs/HITCON/2022/web/s0undcl0ud/app/app.py
from flask import Flask, request, redirect, send_from_directory, g, session, render_template import sqlite3 import os import re import secrets from operator import attrgetter from werkzeug.security import safe_join import mimetypes import magic import pickle import pickletools from flask.sessions import SecureCookieS...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/HITCON/2020/revenge_of_pwn/exploit.py
ctfs/HITCON/2020/revenge_of_pwn/exploit.py
#!/usr/bin/env python3 from pwn import * import os host, port = '127.0.0.1', 1337 context.arch = 'amd64' context.timeout = 2 log.info('Version of pwntools: ' + pwnlib.__version__) r = remote(host, port) r.recvuntil('stack address @ 0x') stk = int(r.recvline(), 16) log.info('stk @ ' + hex(stk)) l = listen(31337) s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesSF/2023/web/prototype2/db.py
ctfs/BSidesSF/2023/web/prototype2/db.py
import sqlite3 import argparse import os import json import uuid def create_connection(db_file): conn = None try: conn = sqlite3.connect(db_file) except Error as e: print(e) return conn def create_db(conn): createRegistrationTable="""CREATE TABLE IF NOT EXISTS registrationRequests(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesSF/2023/web/prototype2/server.py
ctfs/BSidesSF/2023/web/prototype2/server.py
from db import create_connection, insertRegistration, create_db, getRequests, validateSession, validateUser from flask import Flask, request, send_file, render_template, make_response, redirect, url_for, abort from marshmallow import Schema, fields from flask_cors import CORS import json, hashlib app = Flask(__name__)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesSF/2023/web/prototype/db.py
ctfs/BSidesSF/2023/web/prototype/db.py
import sqlite3 import argparse import os import json import uuid def create_connection(db_file): conn = None try: conn = sqlite3.connect(db_file) except Error as e: print(e) return conn def create_db(conn): createRegistrationTable="""CREATE TABLE IF NOT EXISTS registrationRequests(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BSidesSF/2023/web/prototype/server.py
ctfs/BSidesSF/2023/web/prototype/server.py
from db import create_connection, insertRegistration, create_db, getRequests, validateSession, validateUser from flask import Flask, request, send_file, render_template, make_response, redirect, url_for, abort from marshmallow import Schema, fields from flask_cors import CORS import json, hashlib app = Flask(__name__)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2021/Quals/crypto/Obscurity-fixed/chall.py
ctfs/m0leCon/2021/Quals/crypto/Obscurity-fixed/chall.py
import random from functools import reduce from secret import flag def xor(a, b): return bytes(x^y for x,y in zip(a,b)) class LFSR(object): def __init__(self, s, p): self.s = s self.p = p def clock(self): out = self.s[0] self.s = self.s[1:]+[self.s[0]^self.s[(self.p)[0]]^s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2021/Quals/crypto/babysign/server.py
ctfs/m0leCon/2021/Quals/crypto/babysign/server.py
from secret import flag from Crypto.Util.number import bytes_to_long, getStrongPrime, inverse from hashlib import sha256 import os def prepare(m): if len(m)>64: m = m[:64] elif len(m)<64: l = 64-len(m) m = m + os.urandom(l) assert len(m) == 64 return (m[:32],m[32:]) def sign(m,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2021/Quals/crypto/Obscurity/server.py
ctfs/m0leCon/2021/Quals/crypto/Obscurity/server.py
import random from functools import reduce import sys from math import log2 from secret import flag def xor(a, b): return bytes(x^y for x,y in zip(a,b)) class LFSR(object): def __init__(self, s, p): self.s = s self.p = p def clock(self): out = self.s[0] self.s = self.s[1:]...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2021/Quals/crypto/Giant_log/chall.py
ctfs/m0leCon/2021/Quals/crypto/Giant_log/chall.py
import random from secret import flag, fast_exp import signal p = 0x83f39daf527c6cf6360999dc47c4f0944ca1a67858a11bd915ee337f8897f36eff98355d7c35c2accdf4555b03a9552b4bf400915320ccd0ba60b0cb7fcad723 g = 0x15a5f7dec38869e064dd933e23c64f785492854fbe8a6e919d991472ec68edf035eef8c15660d1f059ca1600ee99c7f91a760817d7a3619a3e93...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2021/Quals/web/Waffle/waf.py
ctfs/m0leCon/2021/Quals/web/Waffle/waf.py
from flask import Flask, Response, request, jsonify from urllib.parse import unquote import requests import json import os app = Flask(__name__) appHost = 'http://'+os.environ['APP_HOSTNAME']+':10000/' @app.route('/', defaults={'path': ''}, methods=['GET']) @app.route('/<path:path>', methods=['GET']) def catch_all...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2026/Beginner/crypto/OG_Game_2/snake2.py
ctfs/m0leCon/2026/Beginner/crypto/OG_Game_2/snake2.py
from flask import Flask, render_template, jsonify, request import json import secrets import random from datetime import datetime from Crypto.Cipher import AES from Crypto.Random import get_random_bytes import os app = Flask(__name__) # Game configuration GRID_SIZE = 20 # 20x20 grid SNAKE_SLEEP_SCORE = 100 # Snake ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2026/Beginner/crypto/Hidden_In_Plain_Sight/hidden_in_plain_sight.py
ctfs/m0leCon/2026/Beginner/crypto/Hidden_In_Plain_Sight/hidden_in_plain_sight.py
from fastapi import FastAPI from pydantic import BaseModel from fastapi.middleware.cors import CORSMiddleware from fastapi import Request from fastapi.responses import JSONResponse from random import Random from starlette.middleware.sessions import SessionMiddleware import os from fastapi.staticfiles import StaticFiles...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2026/Beginner/crypto/Sloppy_Admin/sloppy-admin.py
ctfs/m0leCon/2026/Beginner/crypto/Sloppy_Admin/sloppy-admin.py
#!/usr/local/bin/env python3 from os import getenv from Crypto.PublicKey import RSA from Crypto.Util.number import bytes_to_long, long_to_bytes import string import random DB_LIMIT = 100 def generate_password(length: int) -> str: characters = string.printable.strip() return ''.join(random.choice(characters) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2026/Beginner/crypto/NO_birthday_s.r.l/no_birthday.py
ctfs/m0leCon/2026/Beginner/crypto/NO_birthday_s.r.l/no_birthday.py
#! /usr/bin/env python3 import os import hashlib from functools import reduce from secret import * assert FLAG is not None assert FLAG.startswith("ptm{") assert FLAG.endswith("}") db = {(1, 'admin', 1002319200)} banner = """ =========================================================== = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2026/Beginner/crypto/Magic_OTP/magic-OTP.py
ctfs/m0leCon/2026/Beginner/crypto/Magic_OTP/magic-OTP.py
import os from secret import KEY assert len(KEY) == 2 assert KEY[1] == 64 def crypt(n): m = (1<<KEY[1])-1 iv = os.urandom(KEY[1]//8) x = int.from_bytes(iv, 'big') & m y = bytearray() for _ in range(n): b = 0 for i in range(8): b += (x&1) if i!=7: b <<= 1 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2024/Quals/crypto/ECSign/server.py
ctfs/m0leCon/2024/Quals/crypto/ECSign/server.py
from Crypto.PublicKey.ECC import EccPoint from Crypto.Random import random import hashlib import json import os FLAG = os.environ.get("FLAG", "ptm{test}") p = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff Gx = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 Gy = 0x4fe342e2fe1a7...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2024/Quals/crypto/Talor/chall.py
ctfs/m0leCon/2024/Quals/crypto/Talor/chall.py
#!/usr/bin/env python3 from random import SystemRandom import os random = SystemRandom() p = 241 SB = [31, 32, 57, 9, 31, 144, 126, 114, 1, 38, 231, 220, 122, 169, 105, 29, 33, 81, 129, 4, 6, 64, 97, 134, 193, 160, 150, 145, 114, 133, 23, 193, 73, 162, 220, 111, 164, 88, 56, 102, 0, 107, 37, 227, 129, 17, 143, 134, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2024/Quals/crypto/Quadratic_Leak/QuadraticLeak.py
ctfs/m0leCon/2024/Quals/crypto/Quadratic_Leak/QuadraticLeak.py
from Crypto.PublicKey import RSA from Crypto.Util.number import long_to_bytes, bytes_to_long flag = b'ptm{REDACTED}' flag = bytes_to_long(flag) key = RSA.generate(2048) n = key.n e = key.e p, q = key.p, key.q leak = (p**2 + q**2 - p - q)%key.n ciph = pow(flag, key.e, key.n) ciph = long_to_bytes(ciph) print(f'{n = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2024/Quals/crypto/Yet_Another_OT/server.py
ctfs/m0leCon/2024/Quals/crypto/Yet_Another_OT/server.py
import random from hashlib import sha256 import json import os from Crypto.Cipher import AES from Crypto.Util.Padding import pad random = random.SystemRandom() def jacobi(a, n): if n <= 0: raise ValueError("'n' must be a positive integer.") if n % 2 == 0: raise ValueError("'n' must be odd.") ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2023/Quals/pwn/NoRegVM/template.py
ctfs/m0leCon/2023/Quals/pwn/NoRegVM/template.py
#!/usr/bin/env python3 from pwn import * r = remote("remote-addr", 3333) # send files before interacting code_file = open("challenge.vm", "rb") r.send(code_file.read()+b'ENDOFTHEFILE') code_file.close() memory_file = open("strings.vm", "rb") r.send(memory_file.read()+b'ENDOFTHEFILE') memory_file.close() r.recvuntil(b...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2023/Quals/crypto/Collisions/server.py
ctfs/m0leCon/2023/Quals/crypto/Collisions/server.py
from math import log, ceil import os from Crypto.Util.number import bytes_to_long, long_to_bytes from secret import flag blen = 16 nrounds = 128 sbox = [171, 87, 67, 54, 63, 28, 53, 182, 176, 135, 130, 106, 133, 137, 108, 181, 228, 236, 198, 15, 27, 168, 190, 172, 61, 43, 224, 174, 175, 208, 183, 162, 18, 5, 96, 214, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/api.py
ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/api.py
import base64 import json import os import traceback import zlib import simple_websocket from flask_login import current_user, login_required from models import Order, Product, User from server import JSONEncoder, db from flask import Blueprint, request api = Blueprint("api", __name__) ok_msg = json.dumps({"ok": Tr...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/server.py
ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/server.py
import json import os import secrets from datetime import timedelta from decimal import Decimal from flask_login import LoginManager from flask_sqlalchemy import SQLAlchemy from flask_sslify import SSLify from flask_talisman import Talisman from flask_talisman.talisman import ONE_YEAR_IN_SECS from flask_wtf.csrf impor...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/website.py
ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/website.py
import base64 import json import string import traceback import zlib from time import time from flask_login import current_user, login_required from models import Order, Product from server import db from flask import Blueprint, redirect, render_template, url_for website = Blueprint("website", __name__) @website.r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/auth.py
ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/auth.py
from flask_login import current_user, login_required, login_user, logout_user from flask_wtf import FlaskForm from flask_wtf.csrf import generate_csrf from models import User from server import app, db, login_manager from sqlalchemy.orm import Session from werkzeug.datastructures import ImmutableMultiDict from wtforms ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/models/user.py
ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/models/user.py
from argon2 import PasswordHasher from argon2.exceptions import VerifyMismatchError from flask_login import UserMixin from server import db from sqlalchemy.orm.attributes import flag_modified hasher = PasswordHasher() class User(UserMixin, db.Model): __tablename__ = "user" id = db.Column(db.Integer, primary_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/models/order.py
ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/models/order.py
from server import db class Order(db.Model): __tablename__ = "order" id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False) product_id = db.Column(db.Integer, db.ForeignKey( "product.id"), nullable=False) product_quantity = db...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/models/__init__.py
ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/models/__init__.py
from server import db from .order import Order from .product import Product from .user import User
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/models/product.py
ctfs/m0leCon/2023/Quals/web/goldinospizza/flask/models/product.py
from server import db class Product(db.Model): __tablename__ = "product" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Unicode, nullable=False) price = db.Column(db.Numeric, nullable=False) description = db.Column(db.Unicode, nullable=True) image = db.Column(db.Unicode, null...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2025/Quals/crypto/Guess_Me/guess_me.py
ctfs/m0leCon/2025/Quals/crypto/Guess_Me/guess_me.py
#!/usr/bin/env python3 from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad from hashlib import sha256 from hmac import compare_digest from random import shuffle import os flag = os.environ.get("FLAG", "ptm{REDACTED}") BLOCK_SIZE = 16 NUM_BITS = BLOCK_SIZE * 8 SBOX = (0xC, 0x5, 0x6, 0xB, 0x9, 0x0...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2025/Quals/crypto/GrownFeistel/grown_feistel.py
ctfs/m0leCon/2025/Quals/crypto/GrownFeistel/grown_feistel.py
#!/usr/bin/env python3 import os flag = os.environ.get("FLAG", "ptm{REDACTED}") ROUNDS = 9 GF16_POLY = 0x13 SBOX = [ 0xC, 0x5, 0x6, 0xB, 0x9, 0x0, 0xA, 0xD, 0x3, 0xE, 0xF, 0x8, 0x4, 0x7, 0x1, 0x2, ] PERM = [ [0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1], [0x0, 0x1, 0x2...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2025/Quals/crypto/One_More_Bit/fhe_server.py
ctfs/m0leCon/2025/Quals/crypto/One_More_Bit/fhe_server.py
from __future__ import annotations import json import sys from typing import Any, Callable, Dict, List import os from ind_cpa_d_bitwise_game import ( AddCircuit, BitwiseCKKSIndCpaDGame, HomomorphicCKKSFunction, MultiplyCircuit, SquareCircuit, ) flag = os.environ.get("FLAG", "ptm{REDACTED}") CIRC...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2025/Quals/crypto/One_More_Bit/ind_cpa_d_bitwise_game.py
ctfs/m0leCon/2025/Quals/crypto/One_More_Bit/ind_cpa_d_bitwise_game.py
from __future__ import annotations import secrets from dataclasses import dataclass from typing import List, Protocol, Tuple from openfhe import ( CCParamsCKKSRNS, Ciphertext, CryptoContext, GenCryptoContext, PKESchemeFeature, Plaintext, ) DEBUG_GAME = False def float_to_bits(value: float, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2025/Quals/crypto/Talor_2.0/talor_2.py
ctfs/m0leCon/2025/Quals/crypto/Talor_2.0/talor_2.py
#!/usr/bin/env python3 from random import SystemRandom import os random = SystemRandom() # Data from 2025 Teaser, just for reference :) ########### # p = 241 # SB = [31, 32, 57, 9, 31, 144, 126, 114, 1, 38, 231, 220, 122, 169, 105, 29, 33, 81, 129, 4, 6, 64, 97, 134, 193, 160, 150, 145, 114, 133, 23, 193, 73, 162, 2...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2025/Beginner/misc/pickle_soup/server.py
ctfs/m0leCon/2025/Beginner/misc/pickle_soup/server.py
"""Pickle soup server.""" from base64 import b64decode import binascii from collections import Counter import pickle from pickle import UnpicklingError BANNER: str = '\n'.join(( ' ( ', ' ) ) ', ' ._ o _ | | _ ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2025/Beginner/pwn/Hypwn/app.py
ctfs/m0leCon/2025/Beginner/pwn/Hypwn/app.py
from flask import Flask, session, redirect, url_for, render_template, request, jsonify, abort import uuid import subprocess import random import os app = Flask(__name__) app.secret_key = os.environ.get("SECRET_KEY", os.urandom(24)) app.template_folder = "templates" app.static_url_path = "/static" app.static_folder = "...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2025/Beginner/crypto/SmallAuth/server.py
ctfs/m0leCon/2025/Beginner/crypto/SmallAuth/server.py
from secret import flag, password import signal from Crypto.Util.number import ( bytes_to_long, long_to_bytes, getRandomRange, ) from hashlib import sha256 import os p = 52707161169656985026896896711307812191424026820271954380351676860318657214001304961973826040023259789779178238710388883730851183545004224...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2025/Beginner/crypto/XORed_picture/chall.py
ctfs/m0leCon/2025/Beginner/crypto/XORed_picture/chall.py
from pwn import xor from os import urandom key = urandom(16) fin = open("flag.png", "rb") fout = open("flag_enc.png", "wb") pt = fin.read() ct = xor(pt, key) fout.write(ct) fin.close() fout.close()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2025/Beginner/crypto/datadestroyer9000/chall.py
ctfs/m0leCon/2025/Beginner/crypto/datadestroyer9000/chall.py
import os from random import shuffle FLAG = os.getenv("SECRET", "This is some veeeeeeeeeeeeeeeeeeeeeeeeery looooooooooooooooooong sample text :D ptm{fakeflag}").encode() CHUNK_SIZE = 128 BLOCK_SIZE = 32 def gen_otp(): #generate otp for a chunk of data, 128 bytes key = os.urandom(CHUNK_SIZE) return key d...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2025/Beginner/crypto/Small_RSA/chall.py
ctfs/m0leCon/2025/Beginner/crypto/Small_RSA/chall.py
from Crypto.Util.number import getStrongPrime from os import getenv BITS = 512 def gen_key(): p = getStrongPrime(BITS) q = getStrongPrime(BITS) n = p*q e = 65537 return (p, q, e) def safe_encrypt(key, msg): p, q, e = key n = p*q pt = int(msg, 16) if pt > p: return b'Error...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/crypto/moo/server.py
ctfs/m0leCon/2022/Quals/crypto/moo/server.py
from Crypto.Util.number import bytes_to_long import random from secret import flag from functools import reduce from random import randint from gmpy2 import is_prime, next_prime, gcd, lcm def gen_prime(): while True: cnt = 0 p = 1 fs = [] while cnt<4: e, x = randint(1,3)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/crypto/classic/chall.py
ctfs/m0leCon/2022/Quals/crypto/classic/chall.py
from secret import flag import random def xor(s1, s2): res = "" for a, b in zip(s1, s2): res += str(int(a)^int(b)) return res class Classic(object): def __init__(self, rotors): self.rotors = rotors random.shuffle(self.rotors) self.perms = self.gen_permutations() de...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/crypto/magic_generator/server.py
ctfs/m0leCon/2022/Quals/crypto/magic_generator/server.py
import random import os assert "FLAG" in os.environ flag = os.environ["FLAG"] def xor(arr): res = 0 for a in arr: res ^= a return res class MyGenerator: def __init__(self, nbits, l): self.l = l self.t = [0, 1, 2, 3, 9, 14] self.u = [random.randint(0, 1) for _ in rang...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/crypto/fancynotes/app/db.py
ctfs/m0leCon/2022/Quals/crypto/fancynotes/app/db.py
from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/crypto/fancynotes/app/models.py
ctfs/m0leCon/2022/Quals/crypto/fancynotes/app/models.py
from .db import db class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True, nullable=False) password = db.Column(db.String(256), nullable=False) locale = db.Column(db.String(3), nullable=False) def __repr__(self): return '<User %r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/crypto/fancynotes/app/validators.py
ctfs/m0leCon/2022/Quals/crypto/fancynotes/app/validators.py
import re def validate_registration(form_data): if not form_data['username'] or not form_data['password']: return 'missing parameter' if not re.match(r'^[a-zA-Z0-9-_$]+$', form_data['username']): return 'do you have special characters in your name??' if len(form_data['username']) > 30: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/crypto/fancynotes/app/utils.py
ctfs/m0leCon/2022/Quals/crypto/fancynotes/app/utils.py
from flask import request import uuid import base64 import hashlib import string import os import random from .models import * SECRET_KEY = os.environ.get("SECRET_KEY") FLAG = os.environ.get("FLAG") def random_string(n): return ''.join(random.choices(string.printable, k=n)) def init_db(db): username = "ad...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/crypto/fancynotes/app/__init__.py
ctfs/m0leCon/2022/Quals/crypto/fancynotes/app/__init__.py
import os from time import sleep from flask import Flask from .db import db from .routes import init_routes from .models import * from .utils import init_db def create_app(test_config=None): app = Flask(__name__, instance_relative_config=True) app.config.from_mapping( SECRET_KEY='dev', SQLALCH...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/crypto/fancynotes/app/routes.py
ctfs/m0leCon/2022/Quals/crypto/fancynotes/app/routes.py
import hashlib import os import uuid from flask import render_template, request, redirect, make_response, send_file from .validators import validate_registration, validate_login, validate_note from .models import * from .utils import generate_cookie, get_user, save_picture from .db import db def init_routes(app): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/web/fancynotes/app/db.py
ctfs/m0leCon/2022/Quals/web/fancynotes/app/db.py
from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/web/fancynotes/app/models.py
ctfs/m0leCon/2022/Quals/web/fancynotes/app/models.py
from .db import db class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True, nullable=False) password = db.Column(db.String(256), nullable=False) locale = db.Column(db.String(3), nullable=False) def __repr__(self): return '<User %r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/web/fancynotes/app/validators.py
ctfs/m0leCon/2022/Quals/web/fancynotes/app/validators.py
import re def validate_registration(form_data): if not form_data['username'] or not form_data['password']: return 'missing parameter' if not re.match(r'^[a-zA-Z0-9-_$]+$', form_data['username']): return 'do you have special characters in your name??' if len(form_data['username']) > 30: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/web/fancynotes/app/utils.py
ctfs/m0leCon/2022/Quals/web/fancynotes/app/utils.py
from flask import request import uuid import base64 import hashlib import string import os import random from .models import * SECRET_KEY = os.environ.get("SECRET_KEY") FLAG = os.environ.get("FLAG") def random_string(n): return ''.join(random.choices(string.printable, k=n)) def init_db(db): username = "ad...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/web/fancynotes/app/__init__.py
ctfs/m0leCon/2022/Quals/web/fancynotes/app/__init__.py
import os from time import sleep from flask import Flask from .db import db from .routes import init_routes from .models import * from .utils import init_db def create_app(test_config=None): app = Flask(__name__, instance_relative_config=True) app.config.from_mapping( SECRET_KEY='dev', SQLALCH...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/web/fancynotes/app/routes.py
ctfs/m0leCon/2022/Quals/web/fancynotes/app/routes.py
import hashlib import os import uuid from flask import render_template, request, redirect, make_response, send_file from .validators import validate_registration, validate_login, validate_note from .models import * from .utils import generate_cookie, get_user, save_picture from .db import db def init_routes(app): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/web/dumbforum/main.py
ctfs/m0leCon/2022/Quals/web/dumbforum/main.py
from app import app, db from app.models import User, Post if __name__ == "__main__": from waitress import serve serve(app, host="0.0.0.0", port=8080)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/web/dumbforum/config.py
ctfs/m0leCon/2022/Quals/web/dumbforum/config.py
import os basedir = os.path.abspath(os.path.dirname(__file__)) class Config(object): SECRET_KEY = os.environ.get("SECRET_KEY") or os.urandom(32) SQLALCHEMY_DATABASE_URI = os.environ.get( "DATABASE_URL" ) or "sqlite:///" + os.path.join(basedir, "db", "app.db") SQLALCHEMY_TRACK_MODIFICATIONS = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/web/dumbforum/app/models.py
ctfs/m0leCon/2022/Quals/web/dumbforum/app/models.py
from datetime import datetime from flask_sqlalchemy import SQLAlchemy from werkzeug.security import generate_password_hash, check_password_hash from flask_login import UserMixin from hashlib import md5 from app import db, login_manager class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=Tru...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/web/dumbforum/app/errors.py
ctfs/m0leCon/2022/Quals/web/dumbforum/app/errors.py
from flask import render_template from app import app, db @app.errorhandler(404) def not_found_error(error): return render_template('404.html'), 404 @app.errorhandler(500) def internal_error(error): db.session.rollback() return render_template('500.html'), 500 @app.errorhandler(409) def not_found_error(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/web/dumbforum/app/__init__.py
ctfs/m0leCon/2022/Quals/web/dumbforum/app/__init__.py
from flask import Flask from flask_bootstrap import Bootstrap from config import Config from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from flask_login import LoginManager app = Flask(__name__, template_folder="templates") Bootstrap(app) app.config.from_object(Config) db = SQLAlchemy(app) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/web/dumbforum/app/routes.py
ctfs/m0leCon/2022/Quals/web/dumbforum/app/routes.py
from flask import render_template, render_template_string, flash, redirect, url_for, abort from app import db, app from flask_login import current_user, login_user from app.models import User from flask_login import login_required from flask import request from werkzeug.urls import url_parse, url_decode import calendar...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Quals/web/dumbforum/app/forms.py
ctfs/m0leCon/2022/Quals/web/dumbforum/app/forms.py
from flask_wtf import FlaskForm from wtforms import StringField, PasswordField, BooleanField, SubmitField from wtforms.validators import ValidationError, DataRequired, Email, EqualTo from .models import User from wtforms import StringField, TextAreaField, SubmitField from wtforms.validators import DataRequired, Length ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Beginner/rev/scramble/chall.py
ctfs/m0leCon/2022/Beginner/rev/scramble/chall.py
from flag import flag from random import randint assert(len(flag) <= 50) shift = randint(1, len(set(flag)) - 1) def encrypt(data): charsf = {} for c in data: if c not in charsf.keys(): charsf[c] = 1 else: charsf[c] += 1 chars = list(charsf.keys()) chars.sort(re...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Beginner/crypto/Transfers_notes/service.py
ctfs/m0leCon/2022/Beginner/crypto/Transfers_notes/service.py
import interface import utils def validate(username: str, new=False): valid = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' if len(username) == 0: print("Cancelling operation...") return True elif not (3 <= len(username) <= 64): print("Invalid username: length mus...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Beginner/crypto/Transfers_notes/interface.py
ctfs/m0leCon/2022/Beginner/crypto/Transfers_notes/interface.py
header=""" |---------------------------| | Welcome in Transfer-notes | |---------------------------| """ main_menu = """ Available operations: 1) List users 2) List transactions 3) Login 4) Register 5) List transactions by user 6) Exit """ user_menu = """Available operations: 1) List users 2) List transactions 3) Lis...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Beginner/crypto/Transfers_notes/utils.py
ctfs/m0leCon/2022/Beginner/crypto/Transfers_notes/utils.py
import hashlib import random import json import time import os Users = dict() Ids = dict() Path = './data/' def padding(s: str, n: int): if len(s) % n == 0: s += ' ' while len(s) % n != 0: s += random.choice('abcdefghijklnoqrsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') return s 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/m0leCon/2022/Beginner/crypto/SSA/challenge.py
ctfs/m0leCon/2022/Beginner/crypto/SSA/challenge.py
# The following imports are from the pycryptodome library from Crypto.Util.number import getPrime from Crypto.Util.Padding import pad from Crypto.Cipher import AES from secret import message import random import os if __name__ == '__main__': print('Welcome to the Secret Service Agency, the most secret agency in t...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Beginner/crypto/Magic_not_crypto/challenge.py
ctfs/m0leCon/2022/Beginner/crypto/Magic_not_crypto/challenge.py
# The following imports are from the pycryptodome library from Crypto.Util.number import bytes_to_long, long_to_bytes, getPrime import hashlib import base64 import random import os def RSA(x: bytes) -> bytes: e = 65537 random.seed(bytes_to_long(x[:4])) p = getPrime(1024, randfunc=random.randbytes) q =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Beginner/crypto/Determination_is_key/challenge.py
ctfs/m0leCon/2022/Beginner/crypto/Determination_is_key/challenge.py
# The following imports are from the pycryptodome library from Crypto.Util.number import isPrime, bytes_to_long from functools import reduce import random import os flag = os.getenv('FLAG', 'ptm{fake_flag}') def getPrime() -> int: # Magic function to get 256 bits or more prime while True: p = random...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/m0leCon/2022/Beginner/web/FloppyBird/app.py
ctfs/m0leCon/2022/Beginner/web/FloppyBird/app.py
from flask import Flask, request, send_file, jsonify from flask_limiter.util import get_remote_address from flask_limiter import Limiter import sqlite3 import os db = sqlite3.connect('db.sqlite3', check_same_thread=False) db.execute('CREATE TABLE IF NOT EXISTS scores (token TEXT, score INTEGER)') app = Flask( __na...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2023/sandbox/unicomp/sandbox.py
ctfs/CakeCTF/2023/sandbox/unicomp/sandbox.py
#!/usr/local/bin/python import ctypes from unicorn import * from unicorn.x86_const import * libc = ctypes.CDLL(None) LOAD_ADDR, CODE_SIZE = 0x555555554000, 0x10000 STACK_ADDR, STACK_SIZE = 0x7ffffffdd000, 0x22000 def emu_syscall(mu, _user_data): ret = libc.syscall( mu.reg_read(UC_X86_REG_RAX), m...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2023/sandbox/cranelift/run.py
ctfs/CakeCTF/2023/sandbox/cranelift/run.py
#!/usr/local/bin/python import subprocess import tempfile if __name__ == '__main__': print("Enter your code (End with '__EOF__\\n')") code = '' while True: line = input() if line == '__EOF__': break code += line + "\n" with tempfile.NamedTemporaryFile('w') as f: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2023/crypto/Iron_Door/server.py
ctfs/CakeCTF/2023/crypto/Iron_Door/server.py
from Crypto.Util.number import getPrime, isPrime, getRandomRange, inverse, long_to_bytes from hashlib import sha256 import os import secrets import signal def h1(s: bytes) -> int: return int(sha256(s).hexdigest()[:40], 16) def h2(s: bytes) -> int: return int(sha256(s).hexdigest()[:50], 16) # curl https://2t...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2023/crypto/simple_signature/server.py
ctfs/CakeCTF/2023/crypto/simple_signature/server.py
import os import sys from hashlib import sha512 from Crypto.Util.number import getRandomRange, getStrongPrime, inverse, GCD import signal flag = os.environ.get("FLAG", "neko{cat_does_not_eat_cake}") p = getStrongPrime(512) g = 2 def keygen(): while True: x = getRandomRange(2, p-1) y = getRandom...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2023/crypto/ding_dong_ting_ping/server.py
ctfs/CakeCTF/2023/crypto/ding_dong_ting_ping/server.py
import os from base64 import b64decode, b64encode from hashlib import md5 from datetime import datetime from Crypto.Cipher import AES FLAG = os.environ.get("FLAG", "neko{cat_does_not_eat_cake}") PREFIX = os.environ.get("PREFIX", "cake").encode() KEY = os.urandom(16) IV = os.urandom(16) aes = AES.new(KEY, AES.MODE_ECB...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2023/web/TOWFL/service/app.py
ctfs/CakeCTF/2023/web/TOWFL/service/app.py
#!/usr/bin/env python3 import flask import json import lorem import os import random import redis REDIS_HOST = os.getenv("REDIS_HOST", "redis") REDIS_PORT = int(os.getenv("REDIS_PORT", "6379")) app = flask.Flask(__name__) app.secret_key = os.urandom(16) @app.route("/") def index(): return flask.render_template("...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2023/web/AdBlog/service/app.py
ctfs/CakeCTF/2023/web/AdBlog/service/app.py
import base64 import flask import json import os import re import redis REDIS_HOST = os.getenv("REDIS_HOST", "redis") REDIS_PORT = int(os.getenv("REDIS_PORT", "6379")) app = flask.Flask(__name__) @app.route('/', methods=['GET', 'POST']) def index(): if flask.request.method == 'GET': return flask.render_t...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2023/web/AdBlog/report/app.py
ctfs/CakeCTF/2023/web/AdBlog/report/app.py
import flask import json import os import re import redis import requests REDIS_HOST = os.getenv("REDIS_HOST", "redis") REDIS_PORT = int(os.getenv("REDIS_HOST", "6379")) RECAPTCHA_KEY = os.getenv("RECAPTCHA_KEY", None) app = flask.Flask(__name__) def db(): if getattr(flask.g, '_redis', None) is None: fla...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2023/web/Country_DB/init_db.py
ctfs/CakeCTF/2023/web/Country_DB/init_db.py
import sqlite3 import os FLAG = os.getenv("FLAG", "FakeCTF{*** REDACTED ***}") conn = sqlite3.connect("database.db") conn.execute("""CREATE TABLE country ( code TEXT NOT NULL, name TEXT NOT NULL );""") conn.execute("""CREATE TABLE flag ( flag TEXT NOT NULL );""") conn.execute(f"INSERT INTO flag VALUES (?)", (FL...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2023/web/Country_DB/app.py
ctfs/CakeCTF/2023/web/Country_DB/app.py
#!/usr/bin/env python3 import flask import sqlite3 app = flask.Flask(__name__) def db_search(code): with sqlite3.connect('database.db') as conn: cur = conn.cursor() cur.execute(f"SELECT name FROM country WHERE code=UPPER('{code}')") found = cur.fetchone() return None if found is None e...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2023/web/OpenBio_2/service/app.py
ctfs/CakeCTF/2023/web/OpenBio_2/service/app.py
import bleach import flask import json import os import re import redis REDIS_HOST = os.getenv("REDIS_HOST", "redis") REDIS_PORT = int(os.getenv("REDIS_PORT", "6379")) app = flask.Flask(__name__) @app.route('/', methods=['GET', 'POST']) def index(): if flask.request.method == 'GET': return flask.render_t...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2023/web/OpenBio_2/report/app.py
ctfs/CakeCTF/2023/web/OpenBio_2/report/app.py
import flask import json import os import re import redis import requests REDIS_HOST = os.getenv("REDIS_HOST", "redis") REDIS_PORT = int(os.getenv("REDIS_HOST", "6379")) RECAPTCHA_KEY = os.getenv("RECAPTCHA_KEY", None) app = flask.Flask(__name__) def db(): if getattr(flask.g, '_redis', None) is None: fla...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2022/crypto/rock_door/server.py
ctfs/CakeCTF/2022/crypto/rock_door/server.py
from Crypto.Util.number import getPrime, isPrime, getRandomRange, inverse, long_to_bytes from hashlib import sha256 import os import secrets def h(s: bytes) -> int: return int(sha256(s).hexdigest(), 16) q = 139595134938137125662213161156181357366667733392586047467709957620975239424132898952897224429799258317678...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2022/crypto/brand_new_crypto/task.py
ctfs/CakeCTF/2022/crypto/brand_new_crypto/task.py
from Crypto.Util.number import getPrime, getRandomRange, inverse, GCD import os flag = os.getenv("FLAG", "FakeCTF{sushi_no_ue_nimo_sunshine}").encode() def keygen(): p = getPrime(512) q = getPrime(512) n = p * q phi = (p-1)*(q-1) while True: a = getRandomRange(0, phi) b = phi + ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CakeCTF/2022/crypto/frozen_cake/task.py
ctfs/CakeCTF/2022/crypto/frozen_cake/task.py
from Crypto.Util.number import getPrime import os flag = os.getenv("FLAG", "FakeCTF{warmup_a_frozen_cake}") m = int(flag.encode().hex(), 16) p = getPrime(512) q = getPrime(512) n = p*q print("n =", n) print("a =", pow(m, p, n)) print("b =", pow(m, q, n)) print("c =", pow(m, n, n))
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false