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/MapleCTF/2023/misc/Maple_Island/server.py
ctfs/MapleCTF/2023/misc/Maple_Island/server.py
import os import time import random from secrets import SECRET_FLAG_TEXT, create_a_perfect_world CONTESTANTS_PER_SIDE = 20 def generate_contestants(): ones = [] zeroes = [] oprefs = [] zprefs = [] while len(ones) < CONTESTANTS_PER_SIDE or len(zeroes) < CONTESTANTS_PER_SIDE: contestant = os...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/misc/cjail/jail.py
ctfs/MapleCTF/2023/misc/cjail/jail.py
import os, re lines = input("input c: ") while True: line = input() lines += "\n" lines += line if line == "": break if re.search(r'[{][^}]', lines) or re.search(r'[^{][}]', lines): quit() # disallow function declarations elif re.search(r';', lines): quit() # disallow function calls elif re.se...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/misc/A_Quantum_Symphony/server.py
ctfs/MapleCTF/2023/misc/A_Quantum_Symphony/server.py
#!/usr/bin/env python3 from qiskit import QuantumCircuit import qiskit.quantum_info as qi from base64 import b64decode from secret import CHORD_PROGRESSION, FLAG, LORE QUBITS = 4 # No flat notes because they're just enharmonic to the sharps NOTE_MAP = { '0000': 'C', '0001': 'C#', '0010': 'D', '0011':...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/misc/AaaS/server.py
ctfs/MapleCTF/2023/misc/AaaS/server.py
import socketserver, string def check_safe(line): return all(c in (string.ascii_letters + string.digits + string.whitespace + '+=#').encode() for c in line) class AaaSHandler(socketserver.BaseRequestHandler): def handle(self): conn = self.request try: buf, env = bytearray(), {} ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/misc/Coinflip/server.py
ctfs/MapleCTF/2023/misc/Coinflip/server.py
from random import Random from secret import FLAG import signal class Coin: def __init__(self, coin_id): self.random = Random(coin_id) self.flips_left = 0 self.buffer = None def flip(self): if self.flips_left == 0: self.buffer = self.random.getrandbits(32) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/pwn/db/dist/web.py
ctfs/MapleCTF/2023/pwn/db/dist/web.py
import functools import bottle from bottle import abort, request, response, route, run, template, view from db import Db db = Db('film.db') @route('/') @view('index.html') def index(): offset = int(request.query.skip or 0) term = request.query.term or '' films = db.execute( b"select tconst, titl...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/pwn/db/dist/db.py
ctfs/MapleCTF/2023/pwn/db/dist/db.py
import sys from struct import pack, unpack from subprocess import PIPE, Popen from threading import Thread from collections import defaultdict DB_TIMEOUT = 5.0 class DbException(Exception): def __init__(self, msg): super().__init__(msg) class Db: def __init__(self, db_file): self.db_file = db...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/rev/mostly_harmless/src/output.py
ctfs/MapleCTF/2023/rev/mostly_harmless/src/output.py
from typing import TypeVar, Generic T = TypeVar("T", contravariant=True) class Z: ... class N(Generic[T]): ... class ML(Generic[T]): ... class MR(Generic[T]): ... class L_a(Generic[T]): ... class L_b(Generic[T]): ... class L_c(Generic[T]): ... class L_d(Generic[T]): ... class L_e(Generic[T]): ... class L_f(Generic[T]):...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
true
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/rev/mostly_harmless/src/app.py
ctfs/MapleCTF/2023/rev/mostly_harmless/src/app.py
import subprocess flag = list(input("input flag: ")) flag = flag[6:-1] flag = list(flag) def convertify(flag): INPUT = "" LENGTH = "" for c in flag: INPUT = "[L_" + c + "[N" + INPUT LENGTH += "]]" return "_: E[E[Z]] = QRW_s29[L___TAPE_END__[N" + INPUT + "[MR[N[L___TAPE_END__[N[E[E[Z]]]...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/crypto/Merkle/server.py
ctfs/MapleCTF/2023/crypto/Merkle/server.py
from secret import flag import hashlib import random import os import ast DIGEST_SIZE = 256 HEIGHT = 6 def hash(m): return hashlib.sha256(m).digest() class Node: def __init__(self, left, right, parent=None): self.left = left self.right = right self.parent = parent self.hash =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/crypto/RNG/server.py
ctfs/MapleCTF/2023/crypto/RNG/server.py
from Crypto.Util.number import getPrime from secret import flag import random class RNG: def __init__(self, s, a): self.s = s self.a = a def next(self): self.s = (self.s * self.a) % (2 ** 128) return self.s >> 96 if __name__ == "__main__": rng1 = RNG(getPrime(128), getPri...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/crypto/Fraudulent/client.py
ctfs/MapleCTF/2023/crypto/Fraudulent/client.py
from Crypto.Util.number import getPrime, long_to_bytes, bytes_to_long from random import randint from hashlib import sha256 p = 81561774084914804116542793383590610809004606518687125749737444881352531178029 g = 2 q = p - 1 x = 1 # Your private key X = pow(g, x, p) def hash(values): h = sha256() f...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/crypto/Fraudulent/server.py
ctfs/MapleCTF/2023/crypto/Fraudulent/server.py
from Crypto.Util.number import getPrime, long_to_bytes, bytes_to_long from secret import flag from random import randint from hashlib import sha256 import ast def hash(values): h = sha256() for v in values: h.update(long_to_bytes(v)) return bytes_to_long(h.digest()) def encrypt(m): assert 0 <...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/crypto/Pen_and_Paper/source.py
ctfs/MapleCTF/2023/crypto/Pen_and_Paper/source.py
import string import random ALPHABET = string.ascii_uppercase def generate_key(): return [random.randint(0, 26) for _ in range(13)] def generate_keystream(key, length): keystream = [] while len(keystream) < length: keystream.extend(key) key = key[1:] + key[:1] return keystream def...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/crypto/Handshake/server.py
ctfs/MapleCTF/2023/crypto/Handshake/server.py
from abc import abstractmethod from secret import flag from Crypto.Cipher import DES from Crypto.Util.Padding import pad import random import os import string import hashlib def bxor(a, b): return bytes([i ^ j for i, j in zip(a, b)]) def expand_key(key, n): if len(key) >= n: return key[:n] out ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/app/configuration.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/app/configuration.py
import os PORT = os.environ.get('PORT', 9080) GRAPHQL_ENDPOINT = "http://jjk_db:9090" ADMIN_NAME = os.environ.get('ADMIN_NAME', 'via') ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', 'via') QUERY = ''' { getCharacters { edges { node { name, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/app/app.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/app/app.py
from flask import Flask, request, render_template, redirect, session, send_from_directory from functools import wraps import redis from werkzeug.utils import secure_filename import requests import urllib.parse from configuration import * app = Flask(__name__, static_folder='static/', static_url_path='/') app.secret_k...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/db/configuration.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/db/configuration.py
import os PORT = os.environ.get("port", 9090)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/db/schema.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/db/schema.py
from typedefs import CharactersTypeDef, CharactersFilter, AddCharacterFields from models import CharactersModel from database import db import graphene from graphene import relay from graphene_sqlalchemy_filter import FilterableConnectionField class Query(graphene.ObjectType): node = relay.Node.Field() get_ch...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/db/models.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/db/models.py
from database import db class CharactersModel(db.Model): __tablename__ = "characters" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String) occupation = db.Column(db.String) cursed_technique = db.Column(db.String) img_file = db.Column(db.String) notes = db.Column(db.Stri...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/db/typedefs.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/db/typedefs.py
import graphene from graphene import relay from graphene_sqlalchemy import SQLAlchemyObjectType from graphene_sqlalchemy_filter import FilterSet from models import CharactersModel class CharactersFilter(FilterSet): class Meta: model = CharactersModel fields = { 'name': [...], ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/db/database.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/db/database.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/MapleCTF/2023/web/JUJUTSU_KAISEN_2/db/app.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN_2/db/app.py
from flask import Flask from flask_graphql import GraphQLView as View from schema import schema from database import db from configuration import PORT app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///jjk_db.sqlite3' app.add_url_rule("/", view_func=View.as_view("graphql", graphiql=False, schem...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/app/configuration.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/app/configuration.py
import os PORT = os.environ.get('PORT', 9080) GRAPHQL_ENDPOINT = "http://jjk_db:9090" ADMIN_NAME = os.environ.get('ADMIN_NAME', 'via') ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', 'via') QUERY = ''' { getCharacters { edges { node { name, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/app/app.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/app/app.py
from flask import Flask, request, render_template, redirect, session, send_from_directory from functools import wraps import redis from werkzeug.utils import secure_filename import requests import urllib.parse from configuration import * app = Flask(__name__, static_folder='static/', static_url_path='/') app.secret_k...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/db/configuration.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/db/configuration.py
import os PORT = os.environ.get("port", 9090)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/db/schema.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/db/schema.py
from typedefs import CharactersTypeDef, CharactersFilter, AddCharacterFields from models import CharactersModel from database import db import graphene from graphene import relay from graphene_sqlalchemy_filter import FilterableConnectionField class Query(graphene.ObjectType): node = relay.Node.Field() get_ch...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/db/models.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/db/models.py
from database import db class CharactersModel(db.Model): __tablename__ = "characters" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String) occupation = db.Column(db.String) cursed_technique = db.Column(db.String) img_file = db.Column(db.String) notes = db.Column(db.Stri...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/db/typedefs.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/db/typedefs.py
import graphene from graphene import relay from graphene_sqlalchemy import SQLAlchemyObjectType from graphene_sqlalchemy_filter import FilterSet from models import CharactersModel class CharactersFilter(FilterSet): class Meta: model = CharactersModel fields = { 'name': [...], ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/db/database.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/db/database.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/MapleCTF/2023/web/JUJUTSU_KAISEN/db/app.py
ctfs/MapleCTF/2023/web/JUJUTSU_KAISEN/db/app.py
from flask import Flask from flask_graphql import GraphQLView as View from schema import schema from database import db from configuration import PORT app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///jjk_db.sqlite3' app.add_url_rule("/", view_func=View.as_view("graphql", graphiql=False, schem...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2023/web/Data_Explorer/src/server.py
ctfs/MapleCTF/2023/web/Data_Explorer/src/server.py
import codecs import csv import os import sqlite3 import time import threading import traceback import uuid from collections import deque from dataclasses import dataclass from io import TextIOWrapper from typing import Any from flask import Flask, flash, redirect, render_template, request, url_for 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/MapleCTF/2022/pwn/EBCSIC/chal.py
ctfs/MapleCTF/2022/pwn/EBCSIC/chal.py
#!/usr/bin/env python3 import string import ctypes import os import sys import subprocess ok_chars = string.ascii_uppercase + string.digits elf_header = bytes.fromhex("7F454C4601010100000000000000000002000300010000000080040834000000000000000000000034002000020028000000000001000000001000000080040800800408001000000000010...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2022/crypto/jwt/jwt.py
ctfs/MapleCTF/2022/crypto/jwt/jwt.py
from Crypto.Util.number import bytes_to_long as bl, inverse from fastecdsa.curve import secp256k1 from base64 import urlsafe_b64decode, urlsafe_b64encode from hashlib import sha256 from json import loads, dumps from secret import private def b64decode(msg: str) -> bytes: if len(msg) % 4 != 0: msg += "=" *...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2022/crypto/jwt/models.py
ctfs/MapleCTF/2022/crypto/jwt/models.py
from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String, nullable=False) password = db.Column(db.String, nullable=False) def __repr__(self): return f"<User id={self.id} username={self.username...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2022/crypto/jwt/app.py
ctfs/MapleCTF/2022/crypto/jwt/app.py
from flask import Flask, request, render_template, flash, url_for, redirect, g from flask_cors import CORS from models import User, db from secret import flag from jwt import jwt import os def create_app(): app = Flask(__name__) CORS(app) app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////tmp/jwt.db" ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2022/crypto/brsaby/script.py
ctfs/MapleCTF/2022/crypto/brsaby/script.py
from Crypto.Util.number import getPrime, bytes_to_long from secret import FLAG msg = bytes_to_long(FLAG) p = getPrime(512) q = getPrime(512) N = p*q e = 0x10001 enc = pow(msg, e, N) hint = p**4 - q**3 print(f"{N = }") print(f"{e = }") print(f"{enc = }") print(f"{hint = }") ''' N = 13404949375254041877306553014307612...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2022/crypto/Spiral/main.py
ctfs/MapleCTF/2022/crypto/Spiral/main.py
from spiral import Spiral from secret import flag from os import urandom menu = """Options: 1. Get encrypted flag 2. Encrypt message""" key = urandom(16) cipher = Spiral(key, rounds=4) def main(): print(menu) while True: try: option = int(input(">>> ")) if option == 1: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2022/crypto/Spiral/utils.py
ctfs/MapleCTF/2022/crypto/Spiral/utils.py
# rotate a 4x4 matrix clockwise def spiralRight(matrix): right = [] for j in range(4): for i in range(3, -1, -1): right.append(matrix[i][j]) return bytes2matrix(right) # rotate a 4x4 matrix counterclockwise def spiralLeft(matrix): left = [] for j in range(3, -1, -1): fo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2022/crypto/Spiral/spiral.py
ctfs/MapleCTF/2022/crypto/Spiral/spiral.py
from utils import * class Spiral: def __init__(self, key, rounds=4): self.rounds = rounds self.keys = [bytes2matrix(key)] self.BLOCK_SIZE = 16 for i in range(rounds): self.keys.append(spiralLeft(self.keys[-1])) def encrypt(self, plaintext): if len(plaintex...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2022/crypto/qotp-real/server.py
ctfs/MapleCTF/2022/crypto/qotp-real/server.py
from random import uniform from math import sin, cos, tan, pi from signal import alarm from secret import FLAG EPS = 1e-9 class Qstate: def __init__(self, x: float, y: float): assert(abs(x * x + y * y - 1.0) < EPS) self.x = x self.y = y def __mul__(self, other): return self.x ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2022/crypto/e000p/script.py
ctfs/MapleCTF/2022/crypto/e000p/script.py
from secret import FLAG # Implementation of Edwards Curve41417 # x ** 2 + y ** 2 = 1 + 3617 * x ** 2 * y ** 2 # Formulas from http://hyperelliptic.org/EFD/g1p/auto-edwards.html P = 2 ** 414 - 17 d = 3617 def on_curve(p): x, y = p return (x * x + y * y) % P == (1 + d * x * x * y * y) % P def inv(x): ret...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2022/crypto/Spiral-baby/main.py
ctfs/MapleCTF/2022/crypto/Spiral-baby/main.py
from spiral import Spiral from secret import flag from os import urandom menu = """Options: 1. Get encrypted flag 2. Encrypt message""" key = urandom(16) cipher = Spiral(key, rounds=1) def main(): print(menu) while True: try: option = int(input(">>> ")) if option == 1: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2022/crypto/Spiral-baby/utils.py
ctfs/MapleCTF/2022/crypto/Spiral-baby/utils.py
# rotate a 4x4 matrix clockwise def spiralRight(matrix): right = [] for j in range(4): for i in range(3, -1, -1): right.append(matrix[i][j]) return bytes2matrix(right) # rotate a 4x4 matrix counterclockwise def spiralLeft(matrix): left = [] for j in range(3, -1, -1): fo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2022/crypto/Spiral-baby/spiral.py
ctfs/MapleCTF/2022/crypto/Spiral-baby/spiral.py
from utils import * class Spiral: def __init__(self, key, rounds=4): self.rounds = rounds self.keys = [bytes2matrix(key)] self.BLOCK_SIZE = 16 for i in range(rounds): self.keys.append(spiralLeft(self.keys[-1])) def encrypt(self, plaintext): if len(plaintex...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MapleCTF/2022/web/pickle-factory/hosted/app.py
ctfs/MapleCTF/2022/web/pickle-factory/hosted/app.py
import random import json import pickle from http.server import BaseHTTPRequestHandler, HTTPServer from urllib.parse import urlparse, unquote_plus from jinja2 import Environment pickles = {} env = Environment() class PickleFactoryHandler(BaseHTTPRequestHandler): def do_GET(self): parsed = urlparse(self...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2021/crypto/JAM/main.py
ctfs/TFC/2021/crypto/JAM/main.py
#!/usr/bin/env python3 import random import re import string import sys from secret import secret, flag import hashlib def print_trade_help(): print("----=== Trade ===----") print("1. Flag - 6 COIN(S)") print("2. Random String - 1 COIN(S)") print("3. Nothing - 1 COIN(S)") print("-----------------...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2021/crypto/KH5YHLZVJP/main.py
ctfs/TFC/2021/crypto/KH5YHLZVJP/main.py
import base64 import random from pwn import xor from secret import flag with open("c.out", "w") as f: for _ in range(4): x = random.getrandbits(4096) f.write(str(x) + "\n") x = random.getrandbits(4096) x = xor(flag, str(x)[:512]) secret = base64.b64encode(x).decode("utf-8") f.write(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/misc/MY_FIRST_CALCULATOR/main.py
ctfs/TFC/2023/misc/MY_FIRST_CALCULATOR/main.py
import sys print("This is a calculator") inp = input("Formula: ") sys.stdin.close() blacklist = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ." if any(x in inp for x in blacklist): print("Nice try") exit() fns = { "pow": pow } print(eval(inp, fns, fns))
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/misc/MY_THIRD_CALCULATOR/third.py
ctfs/TFC/2023/misc/MY_THIRD_CALCULATOR/third.py
import sys print("This is a safe calculator") inp = input("Formula: ") sys.stdin.close() blacklist = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ." if any(x in inp for x in blacklist): print("Nice try") exit() fns = { "__builtins__": {"setattr": setattr, "__import__": __import__, "chr": chr} ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/crypto/FERMENTATION/server.py
ctfs/TFC/2023/crypto/FERMENTATION/server.py
#!/usr/bin/env python3 import pickle from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad import os KEY = os.urandom(16) IV = os.urandom(16) FLAG = 'redacted' header = input("Header: ") name = input("Name: ") is_admin = False data = header.encode() + pickle.dumps((name, is_admin)) encrypted = AE...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/crypto/CYPHEREHPYC/cypherehpyc.py
ctfs/TFC/2023/crypto/CYPHEREHPYC/cypherehpyc.py
from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad KEY = b"redacted" * 2 FLAG = "redacted" initial_cipher = bytes.fromhex(input("Initial HEX: ").strip()) cipher = AES.new(KEY, AES.MODE_ECB).encrypt(pad(initial_cipher, 16)) print(cipher.hex()) cipher = AES.new(KEY, AES.MODE_ECB).encrypt(pad(cip...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/BABY_DUCKY_NOTES_REVENGE/src/routes.py
ctfs/TFC/2023/web/BABY_DUCKY_NOTES_REVENGE/src/routes.py
from flask import Blueprint, render_template, session, request, jsonify, abort from database.database import db_login, db_register, db_create_post, db_get_user_posts, db_get_all_users_posts, db_delete_posts, db_delete_all_posts import re, threading, datetime from functools import wraps from bot import bot USERNAME_REG...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/BABY_DUCKY_NOTES_REVENGE/src/bot.py
ctfs/TFC/2023/web/BABY_DUCKY_NOTES_REVENGE/src/bot.py
from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By import time, os def bot(username): options = Options() options.add_argument('--no-sandbox') options.add_argument('headless') options.add_argument('ignore-certificate-errors')...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/BABY_DUCKY_NOTES_REVENGE/src/app.py
ctfs/TFC/2023/web/BABY_DUCKY_NOTES_REVENGE/src/app.py
from flask import Flask, jsonify from routes import web, api import database.database as db import os, datetime app = Flask(__name__) app.secret_key = os.urandom(30).hex() app.config['LOG_DIR'] = './static/logs/' db.db_init() app.register_blueprint(web, url_prefix='/') app.register_blueprint(api, url_prefix='/api')...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/BABY_DUCKY_NOTES_REVENGE/src/database/database.py
ctfs/TFC/2023/web/BABY_DUCKY_NOTES_REVENGE/src/database/database.py
import sqlite3, os def query(con, query, args=(), one=False): c = con.cursor() c.execute(query, args) rv = [dict((c.description[idx][0], value) for idx, value in enumerate(row) if value != None) for row in c.fetchall()] return (rv[0] if rv else None) if one else rv def db_init(): con = sql...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/COOKIE_STORE/challenge/main.py
ctfs/TFC/2023/web/COOKIE_STORE/challenge/main.py
import os import sqlite3 import json from flask import Flask, render_template, request, redirect, url_for, session from bot import bot SECRET_KEY = os.urandom(32).hex() app = Flask(__name__) app.config['SECRET_KEY'] = SECRET_KEY @app.route('/', methods=('GET',)) def index(): return redirect(url_for('form_builde...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/COOKIE_STORE/challenge/bot.py
ctfs/TFC/2023/web/COOKIE_STORE/challenge/bot.py
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options import time import urllib.parse FLAG = "TFCCTF{fake_flag}" def bot(fields): chrome_options = Options() chrome_options.add_argument('headless') chrome_options.add_argument('no-s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/DUCKY_NOTES_PART_3/src/routes.py
ctfs/TFC/2023/web/DUCKY_NOTES_PART_3/src/routes.py
from flask import Blueprint, render_template, session, request, jsonify, abort from database.database import db_login, db_register, db_create_post, db_get_user_posts, db_get_all_users_posts, db_delete_posts, db_delete_all_posts import re, threading, datetime from functools import wraps from bot import bot USERNAME_REG...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/DUCKY_NOTES_PART_3/src/bot.py
ctfs/TFC/2023/web/DUCKY_NOTES_PART_3/src/bot.py
from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By import time, os def bot(username): options = Options() options.add_argument('--no-sandbox') options.add_argument('headless') options.add_argument('ignore-certificate-errors')...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/DUCKY_NOTES_PART_3/src/app.py
ctfs/TFC/2023/web/DUCKY_NOTES_PART_3/src/app.py
from flask import Flask, jsonify from routes import web, api import database.database as db import os, datetime app = Flask(__name__) app.secret_key = os.urandom(30).hex() app.config['LOG_DIR'] = './static/logs/' db.db_init() app.register_blueprint(web, url_prefix='/') app.register_blueprint(api, url_prefix='/api')...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/DUCKY_NOTES_PART_3/src/database/database.py
ctfs/TFC/2023/web/DUCKY_NOTES_PART_3/src/database/database.py
import sqlite3, os def query(con, query, args=(), one=False): c = con.cursor() c.execute(query, args) rv = [dict((c.description[idx][0], value) for idx, value in enumerate(row) if value != None) for row in c.fetchall()] return (rv[0] if rv else None) if one else rv def db_init(): con = sql...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/BABY_DUCKY_NOTES/src/routes.py
ctfs/TFC/2023/web/BABY_DUCKY_NOTES/src/routes.py
from flask import Blueprint, render_template, session, request, jsonify, abort from database.database import db_login, db_register, db_create_post, db_get_user_posts, db_get_all_users_posts, db_delete_posts, db_delete_all_posts import re, threading, datetime from functools import wraps from bot import bot USERNAME_REG...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/BABY_DUCKY_NOTES/src/bot.py
ctfs/TFC/2023/web/BABY_DUCKY_NOTES/src/bot.py
from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By import time, os def bot(username): options = Options() options.add_argument('--no-sandbox') options.add_argument('headless') options.add_argument('ignore-certificate-errors')...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/BABY_DUCKY_NOTES/src/app.py
ctfs/TFC/2023/web/BABY_DUCKY_NOTES/src/app.py
from flask import Flask, jsonify from routes import web, api import database.database as db import os, datetime app = Flask(__name__) app.secret_key = os.urandom(30).hex() app.config['LOG_DIR'] = './static/logs/' db.db_init() app.register_blueprint(web, url_prefix='/') app.register_blueprint(api, url_prefix='/api')...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/BABY_DUCKY_NOTES/src/database/database.py
ctfs/TFC/2023/web/BABY_DUCKY_NOTES/src/database/database.py
import sqlite3, os def query(con, query, args=(), one=False): c = con.cursor() c.execute(query, args) rv = [dict((c.description[idx][0], value) for idx, value in enumerate(row) if value != None) for row in c.fetchall()] return (rv[0] if rv else None) if one else rv def db_init(): con = sql...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/DUCKY_NOTES_ENDGAME/src/routes.py
ctfs/TFC/2023/web/DUCKY_NOTES_ENDGAME/src/routes.py
from flask import Blueprint, render_template, session, request, jsonify, abort from database.database import db_login, db_register, db_create_post, db_get_user_posts, db_get_all_users_posts, db_delete_posts, db_delete_all_posts import re, threading, datetime from functools import wraps from bot import bot USERNAME_REG...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/DUCKY_NOTES_ENDGAME/src/bot.py
ctfs/TFC/2023/web/DUCKY_NOTES_ENDGAME/src/bot.py
from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By import time, os def bot(username): options = Options() options.add_argument('--no-sandbox') options.add_argument('headless') options.add_argument('ignore-certificate-errors')...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/DUCKY_NOTES_ENDGAME/src/app.py
ctfs/TFC/2023/web/DUCKY_NOTES_ENDGAME/src/app.py
from flask import Flask, jsonify from routes import web, api import database.database as db import os, datetime app = Flask(__name__) app.secret_key = os.urandom(30).hex() app.config['LOG_DIR'] = './static/logs/' db.db_init() app.register_blueprint(web, url_prefix='/') app.register_blueprint(api, url_prefix='/api')...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2023/web/DUCKY_NOTES_ENDGAME/src/database/database.py
ctfs/TFC/2023/web/DUCKY_NOTES_ENDGAME/src/database/database.py
import sqlite3, os def query(con, query, args=(), one=False): c = con.cursor() c.execute(query, args) rv = [dict((c.description[idx][0], value) for idx, value in enumerate(row) if value != None) for row in c.fetchall()] return (rv[0] if rv else None) if one else rv def db_init(): con = sql...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2022/crypto/ADMIN_PANEL_BUT_HARDER_AND_FIXED/main.py
ctfs/TFC/2022/crypto/ADMIN_PANEL_BUT_HARDER_AND_FIXED/main.py
import os import random from Crypto.Cipher import AES KEY = os.urandom(16) PASSWORD = os.urandom(16) FLAG = os.getenv('FLAG') menu = """======================== 1. Access Flag 2. Change Password ========================""" def xor(bytes_first, bytes_second): d = b'' for i in range(len(bytes_second)): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2022/crypto/TRAIN_TO_PADDINGTON/main.py
ctfs/TFC/2022/crypto/TRAIN_TO_PADDINGTON/main.py
import os BLOCK_SIZE = 16 FLAG = b'|||REDACTED|||' def pad_pt(pt): amount_padding = 16 if (16 - len(pt) % 16) == 0 else 16 - len(pt) % 16 return pt + (b'\x3f' * amount_padding) pt = pad_pt(FLAG) key = os.urandom(BLOCK_SIZE) ct = b'' j = 0 for i in range(len(pt)): ct += (key[j] ^ pt[i]).to_bytes(1, 'b...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2022/crypto/ADMIN_PANEL/main.py
ctfs/TFC/2022/crypto/ADMIN_PANEL/main.py
import os import random from Crypto.Cipher import AES KEY = os.urandom(16) PASSWORD = os.urandom(16) FLAG = os.getenv('FLAG') menu = """======================== 1. Access Flag 2. Change Password ========================""" def xor(byte, bytes_second): d = b'' for i in range(len(bytes_second)): d +=...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TFC/2022/crypto/ADMIN_PANEL_BUT_HARDER/main.py
ctfs/TFC/2022/crypto/ADMIN_PANEL_BUT_HARDER/main.py
import os import random from Crypto.Cipher import AES KEY = os.urandom(16) PASSWORD = os.urandom(16) FLAG = os.getenv('FLAG') menu = """======================== 1. Access Flag 2. Change Password ========================""" def xor(bytes_first, bytes_second): d = b'' for i in range(len(bytes_second)): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SCTF/2021/pwn/Christmas_Song/server.py
ctfs/SCTF/2021/pwn/Christmas_Song/server.py
#! /usr/bin/python3 import os import subprocess import sys import uuid def socket_print(string): print("=====", string, flush=True) def get_user_input(): socket_print("Enter partial source for edge compute app (EOF to finish):") user_input = [] while True: try: line = input() ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SCTF/2021/pwn/Christmas_Bash/server.py
ctfs/SCTF/2021/pwn/Christmas_Bash/server.py
#! /usr/bin/python3 import os import subprocess import sys import uuid import urllib.request def socket_print(string): print("=====", string, flush=True) def get_user_input(filename): socket_print("please input your flag url: ") url = input() urllib.request.urlretrieve(url,filename) socket_print(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SCTF/2021/crypto/ciruit_map/gen_key.py
ctfs/SCTF/2021/crypto/ciruit_map/gen_key.py
import json from block_cipher import decrypt from random import randrange from yao_circuit import GarbledGate as Ggate flag = b'****************' circuit_filename = "circuit_map.json" with open(circuit_filename) as json_file: circuit = json.load(json_file) def init_keys(circuit): keys = {} gates ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SCTF/2021/crypto/ciruit_map/task.py
ctfs/SCTF/2021/crypto/ciruit_map/task.py
import hashlib from icecream import * from private_data import keys,flag from Crypto.Util.number import * def xor(A, B): return bytes(a ^ b for a, b in zip(A, B)) the_chaos=b'' for i in keys: tmp = sum(keys[i]) the_chaos += bytes(long_to_bytes(tmp)) mask = hashlib.md5(the_chaos).digest() print(xor(mask,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SCTF/2021/crypto/ciruit_map/public_data.py
ctfs/SCTF/2021/crypto/ciruit_map/public_data.py
G_Table = { 5: [(13303835, 2123830), (2801785, 11303723), (13499998, 248615), (13892520, 7462011)], 6: [(3244202, 918053), (3277177, 6281266), (1016382, 7097624), (10016472, 13600867)], 7: [(5944875, 3442862), ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SCTF/2021/crypto/ciruit_map/block_cipher.py
ctfs/SCTF/2021/crypto/ciruit_map/block_cipher.py
SBoxes = [[15, 1, 7, 0, 9, 6, 2, 14, 11, 8, 5, 3, 12, 13, 4, 10], [3, 7, 8, 9, 11, 0, 15, 13, 4, 1, 10, 2, 14, 6, 12, 5], [4, 12, 9, 8, 5, 13, 11, 7, 6, 3, 10, 14, 15, 1, 2, 0], [2, 4, 10, 5, 7, 13, 1, 15, 0, 11, 3, 12, 14, 9, 8, 6], [3, 8, 0, 2, 13, 14, 5, 11, 9, 1, 7, 12, 4, 6, 10, 15], [14, 12, 7, 0, 11, 4, 13, 15, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SCTF/2021/crypto/ciruit_map/yao_circuit.py
ctfs/SCTF/2021/crypto/ciruit_map/yao_circuit.py
from random import shuffle, randrange from block_cipher import encrypt, decrypt def garble_label(key0, key1, key2): """ key0, key1 = two input labels key2 = output label """ gl = encrypt(key2, key0, key1) validation = encrypt(0, key0, key1) return (gl, validation) def GarbledGate( gate,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SCTF/2021/crypto/ChristmasZone/util.py
ctfs/SCTF/2021/crypto/ChristmasZone/util.py
from Crypto.Util.number import * class Complex: baseRe = 1 baseIm = 0 p= getPrime(512) q= getPrime(512) n = p*q def __init__(self, re=0, im=0): self.re = re self.im = im def Christmas_gift(self): mistletoe = getPrime(400) phi = (Comp...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SCTF/2021/crypto/cubic/task.py
ctfs/SCTF/2021/crypto/cubic/task.py
#! /usr/bin/python3 from FLAG import flag from Crypto.Util.number import * import random def genPrime(): while True: a = random.getrandbits(512) b = random.getrandbits(512) if b % 3 == 0: continue p = a ** 2 + 3 * b ** 2 if p.bit_length() == 1024 and p % 3 == 1...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ToH/2025/rev/pickle_funny/pickle_morty.py
ctfs/ToH/2025/rev/pickle_funny/pickle_morty.py
import pickle
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
true
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CRHC/2025/crypto/easy_Padding_Oracle/server.py
ctfs/CRHC/2025/crypto/easy_Padding_Oracle/server.py
import socket from Crypto.Cipher import AES from Crypto.Util.Padding import unpad import binascii HOST = "0.0.0.0" PORT = 9999 key = b'????????????????' BLOCK_SIZE = 16 def handle_client(conn): conn.sendall(b"Welcome to Padding Oracle service!\nSend ciphertext hex and press enter.\n") while True: try:...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CRHC/2025/crypto/brrrrr_is_math/enc_public.py
ctfs/CRHC/2025/crypto/brrrrr_is_math/enc_public.py
import math import json def enc(msg, a=0????, b=0????, M=0????): p = [ord(c) for c in msg] max_p = max(p) if p else 0 prod = a * b s = 0??????? if prod < 2 * max_p: s = math.ceil(math.sqrt((2 * max_p) / prod)) a_eff = a * s b_eff = b * s l = [int(round((2 * x / (a_eff * b_eff))...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CRHC/2025/crypto/RSASRSASR/enc.py
ctfs/CRHC/2025/crypto/RSASRSASR/enc.py
import random from math import prod from Crypto.Util.number import getPrime, bytes_to_long def generate_prime_from_byte(byte_val): assert 0 <= byte_val <= 255 r = random.Random() r.seed(byte_val) return getPrime(512, randfunc=r.randbytes) def main(): FLAG = open("flag.txt", "rb").read().strip() ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CRHC/2025/crypto/Lattice/enc.py
ctfs/CRHC/2025/crypto/Lattice/enc.py
from Crypto.Util.number import getPrime from Crypto.Cipher import AES from ecdsa.curves import SECP256k1 from ecdsa.ellipticcurve import Point from hashlib import sha256 from secrets import randbelow C = SECP256k1 G = C.generator n = C.order def sign(d, Q, h, k): R = k * G r = R.x() e = int.from_bytes(sha...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BraekerCTF/2024/misc/Microservices/microservices.py
ctfs/BraekerCTF/2024/misc/Microservices/microservices.py
from scapy.all import * load_layer("http") from Crypto.Util.number import bytes_to_long, long_to_bytes import random def dropTheFlag(flag): # Flag falls into bits pieces = bytes_to_long(flag.encode()) pieces = bin(pieces) pieces = pieces[2:] pieces = [int(x) for x in pieces] # Bits get scatt...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BraekerCTF/2024/crypto/Flag_based_key_expansion/key_expansion.py
ctfs/BraekerCTF/2024/crypto/Flag_based_key_expansion/key_expansion.py
#!/usr/bin/python3 ## ## Flag-based key expansion ## ## import hashlib from argon2 import PasswordHasher # Init MD5 m = hashlib.md5() # Get flag words flag_data = open('flag.txt','r').read()[len('brck{'):-1] flag_words = flag_data.split('_') # Start with strong 256 char key init_key = "aabacadaeafa0a1a2a3a4a5a6a7a...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BraekerCTF/2024/crypto/Block_construction/block_construction.py
ctfs/BraekerCTF/2024/crypto/Block_construction/block_construction.py
import binascii from Crypto.Cipher import AES from os import urandom from string import printable import random from time import time flag = "brck{not_a_flag}" key = urandom(32) def encrypt(raw): cipher = AES.new(key, AES.MODE_ECB) return binascii.hexlify(cipher.encrypt(raw.encode())) # Generate random bytes ran...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BraekerCTF/2024/web/Empty_execution/empty_execution.py
ctfs/BraekerCTF/2024/web/Empty_execution/empty_execution.py
from flask import Flask, jsonify, request import os app = Flask(__name__) # Run commands from leaderbot @app.route('/run_command', methods=['POST']) def run_command(): # Get command data = request.get_json() if 'command' in data: command = str(data['command']) # Length check if ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BraekerCTF/2024/web/Stuffy/app/app.py
ctfs/BraekerCTF/2024/web/Stuffy/app/app.py
## Stuffy, a social media platform for sharing thoughts ### import sqlite3 import urllib3 import string import uuid from flask import Flask, render_template, request, make_response from random import choice # init app app = Flask(__name__) # read flag flag = open('flag.txt','r').read() # load username prefixes ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CCCamp/2023/misc/d3c0d3r/main.py
ctfs/CCCamp/2023/misc/d3c0d3r/main.py
#!/usr/bin/env python3 import os import subprocess import base64 def main(): print("This challenge is derived from a real world example, no joke") print("Anyway: Encode and exploit this") try: inp = input("Give input plox: ") inp = inp.upper() decoded = base64.b64decode(inp).lowe...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CCCamp/2023/misc/Navity/chal.py
ctfs/CCCamp/2023/misc/Navity/chal.py
import threading from avatar2 import * from avatar2.peripherals.avatar_peripheral import AvatarPeripheral import signal import sys import time firmware = abspath("/firmware.bin") class IOPeripheral(AvatarPeripheral): def hw_read(self, offset, size): if offset == 4: if self.char != None: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CCCamp/2023/rev/Ikea/main.py
ctfs/CCCamp/2023/rev/Ikea/main.py
from sys import setrecursionlimit from inst import * setrecursionlimit(100000) @Ribba @Billy(16) @Expedit @Klippan @Billy(0) @Billy(1) @Billy(15) @Malm @Billy(185) @Billy(198) @Billy(214) @Billy(67) @Billy(52) @Billy(212) @Billy(83) @Billy(22) @Billy(93) @Billy(13) @Billy(225) @Billy(85) @Billy(197) @Billy(225) @Bill...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CCCamp/2023/game/Maze/src/server/server/server_runner.py
ctfs/CCCamp/2023/game/Maze/src/server/server/server_runner.py
from __future__ import annotations import struct import time import traceback from asyncio import ( Queue, StreamReader, StreamWriter, as_completed, create_task, sleep, start_server, ) from copy import deepcopy from datetime import datetime, timedelta from threading import Event from typing...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CCCamp/2023/game/Maze/src/server/server/models.py
ctfs/CCCamp/2023/game/Maze/src/server/server/models.py
from dataclasses import dataclass, field from datetime import datetime, timedelta from typing import Any from shared.gen.messages.v1 import Coords, MapChunk, SessionType @dataclass class Position: coords: Coords time: datetime @dataclass class Session: type: SessionType = field(default=SessionType.SESS...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CCCamp/2023/game/Maze/src/server/server/main.py
ctfs/CCCamp/2023/game/Maze/src/server/server/main.py
import argparse import logging import os import sys import tempfile from asyncio import get_event_loop from concurrent.futures import ProcessPoolExecutor from datetime import datetime from threading import Event from typing import cast import dill from rpyc.core import SlaveService from rpyc.utils.server import Thread...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CCCamp/2023/game/Maze/src/server/server/__init__.py
ctfs/CCCamp/2023/game/Maze/src/server/server/__init__.py
from concurrent.futures import ProcessPoolExecutor from pathlib import Path from server.game.state import Game from server.server_runner import Server game_state: Game global_server: Server executor: ProcessPoolExecutor PATH = Path(__file__).parent
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false