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/PlaidCTF/2021/crypto/leaky_block_cipher/leaky_block_cipher.py
ctfs/PlaidCTF/2021/crypto/leaky_block_cipher/leaky_block_cipher.py
import flag import hashcash import secrets from Crypto.Cipher import AES def gf128(a, b): a = int.from_bytes(a, byteorder="big") b = int.from_bytes(b, byteorder="big") R = 128 P = sum(1 << x for x in [R, 7, 2, 1, 0]) r = 0 for i in range(R): if a & (1 << i): r ^= b << i ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2021/crypto/Fake_Medallion/carnival.py
ctfs/PlaidCTF/2021/crypto/Fake_Medallion/carnival.py
from bank import Bank import random from os import urandom FLAG = "PCTF{REDACTED}" # Game of Razzle class RazzleGame: def __init__(self): self.welcome_message = ( "Welcome to our custom game of razzle! It takes one " "medallion for each game. You roll 8 dies and take the " ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2021/crypto/Fake_Medallion/bank.py
ctfs/PlaidCTF/2021/crypto/Fake_Medallion/bank.py
import numpy as np import random from os import urandom from Crypto.Util.number import long_to_bytes, bytes_to_long from Crypto.Cipher import AES from qiskit import ( QuantumCircuit, QuantumRegister, ClassicalRegister, Aer, assemble ) from qiskit.quantum_info.operators import Operator class Ban...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2021/crypto/Fake_Medallion/hashcash.py
ctfs/PlaidCTF/2021/crypto/Fake_Medallion/hashcash.py
#!/usr/bin/env python3 """Implement Hashcash version 1 protocol in Python +-------------------------------------------------------+ | Written by David Mertz; released to the Public Domain | +-------------------------------------------------------+ Very hackily modified Double spend database not implemented in this mod...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2021/crypto/Fake_Medallion/server.py
ctfs/PlaidCTF/2021/crypto/Fake_Medallion/server.py
#!/usr/bin/env python3 import hashcash import json import os import socket import threading from carnival import Carnival HOST = '0.0.0.0' PORT = 15213 def to_json(dat): return json.dumps(dat).encode() + b'\n' class Server(object): def __init__(self, host, port): self.host = host self.port =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2021/web/Carmen_Sandiego/instance/server-sensor/sensor/server.py
ctfs/PlaidCTF/2021/web/Carmen_Sandiego/instance/server-sensor/sensor/server.py
from socketserver import ThreadingTCPServer, UnixStreamServer, BaseRequestHandler, StreamRequestHandler, ThreadingMixIn import re from threading import Lock, Thread import time import os from queue import Queue SENSOR_REGEX = r"([a-z]{1,512}): ([0-9a-zA-Z.+=-]+)" connection_lock = Lock() class ThreadingUnixStreamSer...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2021/web/Carmen_Sandiego/instance/server-camera/sensor/server.py
ctfs/PlaidCTF/2021/web/Carmen_Sandiego/instance/server-camera/sensor/server.py
from socketserver import ThreadingTCPServer, UnixStreamServer, BaseRequestHandler, StreamRequestHandler, ThreadingMixIn import re from threading import Lock, Thread import time import os from queue import Queue KEY_REGEX = r"([a-z]{1,512})" connection_lock = Lock() class ThreadingUnixStreamServer(ThreadingMixIn, Uni...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2021/web/Pearl_U-Stor/app/forms.py
ctfs/PlaidCTF/2021/web/Pearl_U-Stor/app/forms.py
from flask_wtf import FlaskForm from flask_wtf.file import FileAllowed, FileRequired from wtforms import SubmitField, FileField from wtforms.validators import InputRequired from markupsafe import Markup from flask_wtf.recaptcha import RecaptchaField class AppFileForm(FlaskForm): myfile = FileField("File", validat...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2021/web/Pearl_U-Stor/app/app.py
ctfs/PlaidCTF/2021/web/Pearl_U-Stor/app/app.py
from flask import Flask, render_template, url_for, request, send_from_directory, send_file, make_response, abort, redirect from forms import AppFileForm import os from io import BytesIO from werkzeug.utils import secure_filename from subprocess import Popen import uuid import sys from paste.translogger import TransLogg...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2021/web/Carmen_Sandiego_Season2/instance/server-sensor/sensor/server.py
ctfs/PlaidCTF/2021/web/Carmen_Sandiego_Season2/instance/server-sensor/sensor/server.py
from socketserver import ThreadingTCPServer, UnixStreamServer, BaseRequestHandler, StreamRequestHandler, ThreadingMixIn import re from threading import Lock, Thread import time import os from queue import Queue SENSOR_REGEX = r"([a-z]{1,512}): ([0-9a-zA-Z.+=-]+)" connection_lock = Lock() class ThreadingUnixStreamSer...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2021/web/Carmen_Sandiego_Season2/instance/server-camera/sensor/server.py
ctfs/PlaidCTF/2021/web/Carmen_Sandiego_Season2/instance/server-camera/sensor/server.py
from socketserver import ThreadingTCPServer, UnixStreamServer, BaseRequestHandler, StreamRequestHandler, ThreadingMixIn import re from threading import Lock, Thread import time import os from queue import Queue KEY_REGEX = r"([a-z]{1,512})" connection_lock = Lock() class ThreadingUnixStreamServer(ThreadingMixIn, Uni...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2018/shop/unique_seq_generator.py
ctfs/PlaidCTF/2018/shop/unique_seq_generator.py
#!/usr/bin/python def de_bruijn(alphabet, n): a = [0] * len(alphabet) * n sequence = [] def db(t, p): if t > n: if n % p == 0: sequence.extend(a[1:p + 1]) else: a[t] = a[t - p] db(t + 1, p) for j in range(a[t - p] + 1, len(alp...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2024/DHCPPP/dhcppp.c31987bce7265cdacd3329769acada11b26f8d57cc6a9676e3a6dda3b5c90200.py
ctfs/PlaidCTF/2024/DHCPPP/dhcppp.c31987bce7265cdacd3329769acada11b26f8d57cc6a9676e3a6dda3b5c90200.py
import time, zlib import secrets import hashlib import requests from Crypto.Cipher import ChaCha20_Poly1305 import dns.resolver CHACHA_KEY = secrets.token_bytes(32) TIMEOUT = 1e-1 def encrypt_msg(msg, nonce): # In case our RNG nonce is repeated, we also hash # the message in. This means the worst-case scenari...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2023/crypto/bivalves/bivalves.py
ctfs/PlaidCTF/2023/crypto/bivalves/bivalves.py
from bitstream import BitStream from bitstring import BitArray import os KEY = BitArray(os.urandom(10)).bin IV = BitArray(os.urandom(10)).bin print(IV) state = BitArray(bin=(KEY + '0101000001010' + IV + '0'*4)) output_stream = BitStream() def step(out=True): if out: output_stream.write(state[65] ^ state...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2023/crypto/fastrology/server.py
ctfs/PlaidCTF/2023/crypto/fastrology/server.py
import sys import string import random import hashlib import time import subprocess FLAGS = [ '<real new moon flag is on the server>', '<real waxing crescent flag is on the server>', '<real waxing gibbous flag is on the server>', '<real full moon flag is on the server>' ] NUM_TRIALS = 50 PHASES = ['new...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/mode.py
ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/mode.py
from enum import Enum class Mode(Enum): Authentication = 1 DiskKey = 2 TitleKey = 3 Data = 4
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/table.py
ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/table.py
table = [1, 88, 132, 233, 162, 39, 185, 237, 238, 159, 164, 76, 59, 144, 97, 94, 214, 196, 213, 221, 65, 116, 49, 222, 224, 63, 51, 118, 157, 106, 53, 45, 191, 58, 253, 71, 148, 254, 131, 40, 43, 57, 13, 128, 178, 30, 46, 226, 183, 67, 243, 44, 6, 192, 172, 29, 32, 210, 82, 170, 142, 19, 231, 127, 161, 146, 168, 195, 1...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/keys.py
ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/keys.py
import os authentication_key = bytes.fromhex(os.environ["CSS_AUTHENTICATION_KEY"]) assert len(authentication_key) == 8 player_key_id = int(os.environ["CSS_PLAYER_KEY_ID"]) player_key_data = bytes.fromhex(os.environ["CSS_PLAYER_KEY_DATA"]) assert 0 <= player_key_id <= 255 assert len(player_key_data) == 8 player_key = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/__main__.py
ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/__main__.py
import asyncio from sys import stdin, stdout from .io_manager import IOManager, ReaderWriter from .player import Player async def main(): player = Player("../disks/a.disk") host_to_player = IOManager("host -> player", color = "\x1b[31m") player_to_host = IOManager("player -> host", color = "\x1b[34m") player_t...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/cipher.py
ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/cipher.py
from .lfsr import LFSR from .mode import Mode def _should_invert_1(mode: Mode) -> bool: return mode in (Mode.Authentication, Mode.Data) def _should_invert_2(mode: Mode) -> bool: return mode in (Mode.DiskKey, Mode.Data) class Cipher: mode: Mode carry: int lfsr_1: LFSR lfsr_2: LFSR def __init__(self, key_byte...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/make_disk.py
ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/make_disk.py
from itertools import count, cycle from secrets import token_bytes from sys import argv from .cipher import Cipher from .mangle import mangle from .mode import Mode sector_size = 8192 assert len(argv) == 4, "usage: make_disk.py <output-file> <input-file> <disk-keys-file>" with open(argv[1], "wb") as f: disk_key = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/lfsr.py
ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/lfsr.py
class LFSR: size: int seed: int state: int taps: list[int] def __init__(self, size: int, seed: int, taps: int): self.size = size self.seed = seed self.state = seed assert taps < 2 ** size self.taps = [] for i in range(size): tap = taps & (1 << i) if tap > 0: self.taps.append(tap) assert s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/__init__.py
ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/io_manager.py
ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/io_manager.py
from asyncio.queues import Queue from os import getenv from sys import stdout from typing import Optional from hexdump import hexdump class IOManager: name: str color: str closed: bool queue: Queue[Optional[bytes]] buffer: bytes def __init__(self, name: str, color: Optional[str] = None): self.name = name ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/player.py
ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/player.py
import asyncio from secrets import token_bytes from .cipher import Cipher from .io_manager import ReaderWriter from .keys import authentication_key from .keys import player_key as player_key_data from .mangle import mangle, unmangle from .mode import Mode class Player: disk: str def __init__(self, disk: str): s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/mangle.py
ctfs/PlaidCTF/2023/crypto/the-other-css/css/css/mangle.py
from .table import reverse_table, table def mangle(key_bytes: bytes, value_bytes: bytes) -> bytes: key = list(key_bytes) value = list(value_bytes) value = mix(key, value) value = shift(value) value = mix(key, value) value = shift(value) value = mix(key, value) value = tabulate(value) value = shift(value) v...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2022/crypto/choreography/pow.py
ctfs/PlaidCTF/2022/crypto/choreography/pow.py
import sys import string import random import hashlib # proof of work prefix = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(10)) print("Give me a string starting with {} of length {} so its sha256sum ends in ffffff.".format(prefix, len(prefix)+8)) l = input().strip() if len(l) != len(pref...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2022/crypto/choreography/cipher.py
ctfs/PlaidCTF/2022/crypto/choreography/cipher.py
#!/usr/bin/env python3 import signal import os ROUNDS = 2**22 + 2 QUERIES = 500 sbox = [109, 86, 136, 240, 199, 237, 30, 94, 134, 162, 49, 78, 111, 172, 214, 117, 90, 226, 171, 105, 248, 216, 48, 196, 130, 203, 179, 223, 12, 123, 228, 96, 225, 113, 168, 5, 208, 124, 146, 184, 206, 77, 72, 155, 191, 83, 142, 197, 144...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2022/crypto/pressure/server.py
ctfs/PlaidCTF/2022/crypto/pressure/server.py
from nacl.bindings.crypto_scalarmult import ( crypto_scalarmult_ed25519_noclamp, crypto_scalarmult_ed25519_base_noclamp, ) from nacl.bindings.crypto_core import ( crypto_core_ed25519_scalar_mul, crypto_core_ed25519_scalar_reduce, crypto_core_ed25519_is_valid_point, crypto_core_ed25519_NONREDUCEDSCALARBYTES,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2020/pwn/ipppc/hashcash.py
ctfs/PlaidCTF/2020/pwn/ipppc/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/PlaidCTF/2020/pwn/ipppc/server.py
ctfs/PlaidCTF/2020/pwn/ipppc/server.py
#!/usr/bin/env python2 from hashcash import check import os import signal import SocketServer import threading magic = os.urandom(8).encode("hex") class threadedserver(SocketServer.ThreadingMixIn, SocketServer.TCPServer): pass class incoming(SocketServer.BaseRequestHandler): def recvline(self): line...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2020/pwn/mojo/server.py
ctfs/PlaidCTF/2020/pwn/mojo/server.py
#!/usr/bin/env python3 -u import hashlib import os import random import string import sys import subprocess import tempfile MAX_SIZE = 100 * 1024 print("Proof of work is required.") prefix = "".join([random.choice(string.digits + string.ascii_letters) for i in range(10)]) resource = prefix + "mojo" bits = 28 cash = i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2020/crypto/sidhe/pow.py
ctfs/PlaidCTF/2020/crypto/sidhe/pow.py
import sys import string import random import hashlib # proof of work prefix = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(10)) print("Give me a string starting with {} of length {} so its sha256sum ends in fffffff.".format(prefix, len(prefix)+8)) l = input().strip() if len(l) != len(pre...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2020/crypto/dyrpto/generate_problem.py
ctfs/PlaidCTF/2020/crypto/dyrpto/generate_problem.py
from cryptography.hazmat.backends.openssl import backend as openssl_backend from cryptography.hazmat.primitives.asymmetric.rsa import generate_private_key import json from message_pb2 import Message privkey = generate_private_key(3, 4096, openssl_backend) pubkey = privkey.public_key() pubkey_numbers = pubkey.public_n...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PlaidCTF/2020/crypto/dyrpto/message_pb2.py
ctfs/PlaidCTF/2020/crypto/dyrpto/message_pb2.py
# -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: message.proto import sys _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf imp...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2024/misc/Source_Code_Recovery/chal.py
ctfs/UofTCTF/2024/misc/Source_Code_Recovery/chal.py
import os import uuid import zlib import subprocess try: from flag import FLAG except: FLAG = "test{FLAG}" BANNED_LIST = ['#', '_', '?', ':'] MAX_LEN = 20000 N = 25 rows = [] row = input("C Code:") while row: rows.append(row) row = input() code = "\n".join(rows) + "\n" if len(code) > MAX_LEN: qu...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2024/jail/Zero/chal.py
ctfs/UofTCTF/2024/jail/Zero/chal.py
def check(code): # no letters alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" # no numbers numbers = "0123456789" # no underscores underscore = "__" return not any((c in alphabet) or (c in numbers) or (underscore in code) for c in code) def safe_eval(code): if (ch...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2024/crypto/repeat/gen.py
ctfs/UofTCTF/2024/crypto/repeat/gen.py
import os import secrets flag = "REDACATED" xor_key = secrets.token_bytes(8) def xor(message, key): return bytes([message[i] ^ key[i % len(key)] for i in range(len(message))]) encrypted_flag = xor(flag.encode(), xor_key).hex() with open("flag.enc", "w") as f: f.write("Flag: "+encrypted_flag)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2024/crypto/Pianoman/music_cipher.py
ctfs/UofTCTF/2024/crypto/Pianoman/music_cipher.py
# no secrets for you! flag = ... # Prime numbers p = 15197453706132395782238607390838508541955902635116468542609747926689029101014752169162322201330765471143519591753891043349946159280814093099555488139713585667665000865770222189068155638254134115433361902699500434661495474151647091698400779744784820098284432568374864...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2024/crypto/Export_Grade_Cipher/chal.py
ctfs/UofTCTF/2024/crypto/Export_Grade_Cipher/chal.py
import ast import threading from exportcipher import * try: from flag import FLAG except: FLAG = "test{FLAG}" MAX_COUNT = 100 TIMEOUT = 120 # seconds def input_bytes(display_msg): m = input(display_msg) try: m = ast.literal_eval(m) except: # might not be valid str or bytes literal ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2024/crypto/Export_Grade_Cipher/exportcipher.py
ctfs/UofTCTF/2024/crypto/Export_Grade_Cipher/exportcipher.py
import os class LFSR: def __init__(self, seed, taps, size): assert seed != 0 assert (seed >> size) == 0 assert len(taps) > 0 and (size - 1) in taps self.state = seed self.taps = taps self.mask = (1 << size) - 1 def _shift(self): feedback = 0 for ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2024/web/No_Code/app.py
ctfs/UofTCTF/2024/web/No_Code/app.py
from flask import Flask, request, jsonify import re app = Flask(__name__) @app.route('/execute', methods=['POST']) def execute_code(): code = request.form.get('code', '') if re.match(".*[\x20-\x7E]+.*", code): return jsonify({"output": "jk lmao no code"}), 403 result = "" try: result =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/misc/model-assembly-line/chal.py
ctfs/UofTCTF/2025/misc/model-assembly-line/chal.py
import ast class CodeValidator: FUNCTION_NAME = "YOUR_MODEL" UNSAFE_TYPES = ( ast.Import, ast.ImportFrom, ast.Attribute, ast.Try, ast.TryStar, ast.Assert, ast.Global, ast.Nonlocal, ast.Delete, ast.Call, ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef, ast.Lambda ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/misc/math-test/chall.py
ctfs/UofTCTF/2025/misc/math-test/chall.py
import random from flag import FLAG def genRandMath(): eqn = f'{random.randint(-1000, 1000)}' eqn = f"{eqn} {random.choice(['+', '*', '-', '//'])} {random.randint(-1000, 1000)}" while random.randint(0, 3) != 1: eqn = f"{eqn} {random.choice(['+', '*', '-', '//'])} {random.randint(-1000, 1000)}" ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/misc/simple-signing/chall.py
ctfs/UofTCTF/2025/misc/simple-signing/chall.py
from Crypto.Util.number import getPrime from secrets import FLAG ADMIN = b'adminTokenPlsNoSteal' def sign(n: int, d: int, m: bytes): if m == ADMIN: print("no no") exit(0) h = hash(tuple(m)) return pow(h, d, n) def verify(n: int, e: int, m: bytes, s: int): h = hash(tuple(m)) r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/rev/py-flagchecker/chall.py
ctfs/UofTCTF/2025/rev/py-flagchecker/chall.py
def main(): import marshal, inspect c=b'\x87\xfcA@\xc7\xc4\xea\xf5\xa6\x87\x84\x02\xd6\x9e\x85\x93\xdeM\xa9\xe7\'\xf1\xaf\xe7\xc5\xde:\xff\xff\x95\x9a\xce\x05v\xd21\xce~\xa5\xb6\x19KI\xafd\xf2\xb5D\x1d\xa9:<7\x97<\xc8\xfd\x02\x9fK\x9a\x14\xb3\xc8\xb82\x90\x1a7\x140j\xffw\xe6\xb1s\xcd|s\xfd\x99\xf4b\xe1Z\x9e\x86...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/jail/dont-sandbox-python-2/chal.py
ctfs/UofTCTF/2025/jail/dont-sandbox-python-2/chal.py
from asteval import Interpreter def read_input(end_marker: str = "$$END$$") -> str: """ Read input code until the end marker is encountered. Args: end_marker: String that signals the end of input Returns: Concatenated input code as a string """ print("Enter your co...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/jail/dont-sandbox-python/chal.py
ctfs/UofTCTF/2025/jail/dont-sandbox-python/chal.py
from asteval import Interpreter def read_input(end_marker: str = "$$END$$") -> str: """ Read input code until the end marker is encountered. Args: end_marker: String that signals the end of input Returns: Concatenated input code as a string """ print("Enter your co...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/jail/dont-sandbox-python-3/chal.py
ctfs/UofTCTF/2025/jail/dont-sandbox-python-3/chal.py
from asteval import Interpreter def read_input(end_marker: str = "$$END$$") -> str: """ Read input code until the end marker is encountered. Args: end_marker: String that signals the end of input Returns: Concatenated input code as a string """ print("Enter your co...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/crypto/shuffler/shuffler.py
ctfs/UofTCTF/2025/crypto/shuffler/shuffler.py
#! /usr/local/bin/python3 from fractions import Fraction from Crypto.Cipher import AES from Crypto.Util.number import long_to_bytes from hashlib import sha256 def Bake(x,y): if y <= 1 / 2: x, y = x / 2, 2 * y elif y >= 1 / 2: x, y = 1 - x / 2, 2 - 2 * y return x,y class PRNG: def __ini...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/crypto/causation/causation.py
ctfs/UofTCTF/2025/crypto/causation/causation.py
import secrets MASK = (1<<64)-1 def rotl(x, k): return ((x<<k)&MASK)|(x>>(64-k)) class PRNG(): def __init__(self, state): self.p = 0 assert not all(i==0 for i in state) assert len(state)==16 assert all(i<(1<<64) for i in state) self.state = state def next(self): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/crypto/enchanted-oracle/generate-key.py
ctfs/UofTCTF/2025/crypto/enchanted-oracle/generate-key.py
from Crypto.Random import get_random_bytes key = get_random_bytes(16) with open('/app/key', 'wb') as f: f.write(key)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/crypto/enchanted-oracle/aes-cbc.py
ctfs/UofTCTF/2025/crypto/enchanted-oracle/aes-cbc.py
from base64 import b64encode, b64decode from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad print("Welcome to the AES-CBC oracle!") key = open("key", "rb").read() while True: print("Do you want to encrypt the flag or decrypt a message?") print("1. Encrypt the flag") print("2. Decrypt a...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/web/timeless/src/run.py
ctfs/UofTCTF/2025/web/timeless/src/run.py
from app import create_app app = create_app() if __name__ == "__main__": app.run(host="0.0.0.0", port=5000)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/web/timeless/src/config.py
ctfs/UofTCTF/2025/web/timeless/src/config.py
from datetime import datetime import os import random import uuid class Config: JSON_SORT_KEYS = False START_TIME = datetime.now() random.seed(int(START_TIME.timestamp())) SECRET_KEY = str(uuid.uuid1(clock_seq=random.getrandbits(14))) SESSION_USE_SIGNER = True TEMPLATES_AUTO_RELOAD = False S...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/web/timeless/src/app/models.py
ctfs/UofTCTF/2025/web/timeless/src/app/models.py
import uuid from . 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(120), nullable=False) profile_photo = db.Column(db.String(120), nullable=True) posts = db.relationship('Blo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/web/timeless/src/app/helpers.py
ctfs/UofTCTF/2025/web/timeless/src/app/helpers.py
import os import hashlib from datetime import datetime ALLOWED_EXTENSIONS = {'png', 'jpeg', 'jpg'} def allowed_username(username): return ".." not in username def allowed_file(filename): return not ("." in filename and (filename.rsplit('.', 1)[1].lower() not in ALLOWED_EXTENSIONS or ".." in filename)) def gen...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/web/timeless/src/app/__init__.py
ctfs/UofTCTF/2025/web/timeless/src/app/__init__.py
from flask import Flask, g from flask_sqlalchemy import SQLAlchemy from flask_session import Session import os db = SQLAlchemy() def create_app(): app = Flask(__name__, static_folder='/app/app/static') app.config.from_object("config.Config") os.makedirs(os.path.dirname(app.config['SQLALCHEMY_DATABASE_URI'...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/web/timeless/src/app/routes.py
ctfs/UofTCTF/2025/web/timeless/src/app/routes.py
import os from uuid import uuid4 from datetime import datetime from functools import wraps from flask import ( render_template, request, redirect, url_for, session, flash, send_file, current_app as app, jsonify, g, abort ) from .models import User, BlogPost from .helpers import ( allowed_username, allowed_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/web/code-db/src/code_samples/machine_learning_model.py
ctfs/UofTCTF/2025/web/code-db/src/code_samples/machine_learning_model.py
import numpy as np from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import accuracy_score # Load dataset iris = load_iris() X = iris.data y = iris.target # Split X_train, X_test, y_train, y_test = train...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/web/code-db/src/code_samples/data_pipeline.py
ctfs/UofTCTF/2025/web/code-db/src/code_samples/data_pipeline.py
import pandas as pd import numpy as np def clean_data(df): df = df.dropna() df['date'] = pd.to_datetime(df['date']) return df def transform_data(df): df['month'] = df['date'].dt.month df['year'] = df['date'].dt.year return df def load_data(df, filename): df.to_csv(filename, index=False) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/web/code-db/src/code_samples/hello_world.py
ctfs/UofTCTF/2025/web/code-db/src/code_samples/hello_world.py
print("Hello world!")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/web/code-db/src/code_samples/calculator.py
ctfs/UofTCTF/2025/web/code-db/src/code_samples/calculator.py
import operator def calculate(expression): ops = { '+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv } stack = [] for token in expression.split(): if token in ops: b = stack.pop() a = stack.pop() re...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/web/my-second-app/src/guest_list.py
ctfs/UofTCTF/2025/web/my-second-app/src/guest_list.py
from flask import Flask, request, render_template, render_template_string, flash, redirect, url_for import hashlib import os import random app = Flask(__name__) app.secret_key = os.urandom(24) SECRET_KEY = os.urandom(random.randint(16, 64)) MALICIOUS_SUBSTRINGS = [ '#','%', '!', '=', '+', '-', '/', '&', '^', '<', ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UofTCTF/2025/web/prepared-1/app.py
ctfs/UofTCTF/2025/web/prepared-1/app.py
import re from flask import Flask, render_template, request, redirect, url_for, flash import mysql.connector import os import setuptools app = Flask(__name__) app.secret_key = os.urandom(24) DB_HOST = os.getenv('MYSQL_HOST', 'localhost') DB_USER = os.getenv('MYSQL_USER', 'root') DB_PASSWORD = os.getenv('MYSQL_PASSWOR...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ArabSecurityCyberWargames/2023/Quals/crypto/Perfect_Encryption/challenge.py
ctfs/ArabSecurityCyberWargames/2023/Quals/crypto/Perfect_Encryption/challenge.py
from Crypto.Util.number import bytes_to_long, getStrongPrime from random import getrandbits FLAG = bytes_to_long(b"ASCWG{XXXX}") p = getStrongPrime(512) a, b, c = getrandbits(256), getrandbits(256), getrandbits(256) x = getrandbits(512) y = FLAG*x % p f1 = (a*x*y + b*x - c*y + a*b) % p f2 = (a*x*y - a*b*x + c*y - a...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Wargames.MY/2024/crypto/Hohoho_3_continue/server.py
ctfs/Wargames.MY/2024/crypto/Hohoho_3_continue/server.py
#!/usr/bin/env python3 import hashlib from Crypto.Util.number import * m = getRandomNBitInteger(128) class User: def __init__(self, name, token): self.name = name self.mac = token def verifyToken(self): data = self.name.encode(errors="surrogateescape") crc = (1 << 128) - 1 for b in data: crc ^= b f...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Wargames.MY/2024/crypto/lwe/main.py
ctfs/Wargames.MY/2024/crypto/lwe/main.py
import os import random import numpy as np import signal def _handle_timeout(signum, frame): raise TimeoutError('function timeout') timeout = 180 signal.signal(signal.SIGALRM, _handle_timeout) signal.alarm(timeout) FLAG = 'wgmy{fake_flag}' def change_support(support): while (t := random.randint(0, n - 1)) i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Wargames.MY/2024/crypto/Hohoho_3/server.py
ctfs/Wargames.MY/2024/crypto/Hohoho_3/server.py
#!/usr/bin/env python3 import hashlib from Crypto.Util.number import * m = getRandomNBitInteger(128) class User: def __init__(self, name, token): self.name = name self.mac = token def verifyToken(self): data = self.name.encode(errors="surrogateescape") crc = (1 << 128) - 1 for b in data: crc ^= b f...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Wargames.MY/2024/crypto/RickS_Algorithm/server.py
ctfs/Wargames.MY/2024/crypto/RickS_Algorithm/server.py
from Crypto.Util.number import * import os from secret import revealFlag flag = bytes_to_long(b"wgmy{REDACTED}") p = getStrongPrime(1024) q = getStrongPrime(1024) e = 0x557 n = p*q phi = (p-1)*(q-1) d = inverse(e,phi) while True: print("Choose an option below") print("=======================") print("1. Encrypt a ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Wargames.MY/2024/crypto/RickS_Algorithm_2/server.py
ctfs/Wargames.MY/2024/crypto/RickS_Algorithm_2/server.py
from Crypto.Util.number import * import os from secret import revealFlag flag = bytes_to_long(b"wgmy{REDACTED}") p = getStrongPrime(1024) q = getStrongPrime(1024) e = 0x557 n = p*q phi = (p-1)*(q-1) d = inverse(e,phi) while True: print("Choose an option below") print("=======================") print("1. Encrypt a ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2021/crypto/lwsr/lwsr.py
ctfs/Hack.lu/2021/crypto/lwsr/lwsr.py
#!/usr/bin/env sage from os import urandom from sage.crypto.lwe import Regev import sys flag = b"flag{this_may_look_like_a_real_flag_but_its_not}" def lfsr(state): # x^384 + x^8 + x^7 + x^6 + x^4 + x^3 + x^2 + x + 1 mask = (1 << 384) - (1 << 377) + 1 newbit = bin(state & mask).count('1') & 1 return ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2021/crypto/whatthehecc/server.py
ctfs/Hack.lu/2021/crypto/whatthehecc/server.py
#!/usr/bin/env python3 import sys import shlex import subprocess from Cryptodome.PublicKey import ECC from Cryptodome.Hash import SHA3_256 from Cryptodome.Math.Numbers import Integer import time # util def run_cmd(cmd): try: args = shlex.split(cmd) return subprocess.check_output(args).decode('utf...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2021/web/SeekingExploits/mybb-server/install.py
ctfs/Hack.lu/2021/web/SeekingExploits/mybb-server/install.py
#!/usr/bin/python3 import requests import sys import os import time import random import string import pymysql from urllib.parse import urlencode hostname = os.environ["HOSTNAME"] flag = os.environ["FLAG"] headers = { 'Host': hostname } # poll installer script while True: time.sleep(1) try: resp...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2018/babyphp/exploit.py
ctfs/Hack.lu/2018/babyphp/exploit.py
#!/usr/bin/env python2 import requests import urllib import base64 # flag{7c217708c5293a3264bb136ef1fadd6e} params = { # we can provide a data: url to file_get_contents 'msg': 'data://text/plain;base64,{}'.format(base64.b64encode('Hello Challenge!')), 'key1': 1337, # the dollar sing is NOT actually ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/misc/soulsplitter/app.py
ctfs/Hack.lu/2023/misc/soulsplitter/app.py
#!/usr/bin/env python3 import base64 import io import os import qrcode import random import secrets import zlib FLAG = os.getenv('FLAG', 'flag{fake_flag}') SOULS = int(os.getenv('SOULS', '20')) SHARDS = int(os.getenv('SHARDS', '17')) BLOCK_FULL = chr(9608) BLOCK_UPPER = chr(9600) BLOCK_LOWER = chr(9604) BLOCK_EMPTY...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/misc/Safest_Eval/server/src/server.py
ctfs/Hack.lu/2023/misc/Safest_Eval/server/src/server.py
import subprocess import os, stat from flask import Flask, request, render_template app = Flask(__name__) @app.route("/") def index(): return render_template("index.html") @app.post("/challenge") def palindrome_challenge(): user_code = request.json["code"] cmd = ["timeout", "-s", "KILL", os.environ.get(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/misc/Safest_Eval/server/src/palindrome_challenge.py
ctfs/Hack.lu/2023/misc/Safest_Eval/server/src/palindrome_challenge.py
from types import CodeType, FunctionType from opcode import opname, opmap import dis import sys BAD_ATTRS = ["func_globals", "f_globals", "f_locals", "f_builtins", "gi_code", "co_code", "gi_frame"] BAD_OPCODES = {opmap[opname] for opname in ['STORE_ATTR', 'DELETE_ATTR', 'STORE_GLOBAL', 'DELETE_GLOBAL',...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/crypto/Lucky_Numbers/lucky_number.py
ctfs/Hack.lu/2023/crypto/Lucky_Numbers/lucky_number.py
#!/usr/bin/env python #hacklu23 Baby Crypyo Challenge import math import random from Crypto.Cipher import AES from Crypto.Random import get_random_bytes import base64 import os def add(e): return e+(length-len(e)%length)*chr(length-len(e)%length) def remove(e): re...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/crypto/Spooky_Safebox/cryptod.py
ctfs/Hack.lu/2023/crypto/Spooky_Safebox/cryptod.py
import ecdsa, ecdsa.ecdsa from cryptography.hazmat.primitives.kdf.kbkdf import ( CounterLocation, KBKDFHMAC, Mode ) from cryptography.hazmat.primitives import hashes import secrets from Crypto.Cipher import ChaCha20_Poly1305 def get_order(): return ecdsa.NIST256p.generator.order() def encrypt_sym(input_bytes: bytes...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/crypto/Spooky_Safebox/proofofwork.py
ctfs/Hack.lu/2023/crypto/Spooky_Safebox/proofofwork.py
import os import hashlib import random DEFAULT_DIFFICULTY = int(os.environ.get('DEFAULT_DIFFICULTY', 6)) DEFAULT_INPUT_LENGTH = int(os.environ.get('DEFAULT_INPUT_LENGTH', 13)) check = lambda s, challenge, prefix: hashlib.sha256((challenge + s).encode('utf-8')).hexdigest()[:len(prefix)] == prefix def solve_pow(chall...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/crypto/Spooky_Safebox/app.py
ctfs/Hack.lu/2023/crypto/Spooky_Safebox/app.py
#!/usr/bin/env python3 import secrets import os, sys, hmac import cryptod from proofofwork import challenge_proof_of_work FLAG = os.environ.get("FLAG", "flag{FAKE_FLAG}") if "flag" in os.environ.get("FLAG","") else "flag{FAKE_FLAG}" def main(): print("Welcome to the Spooky Safebox!") if not challenge_proo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/crypto/Doctored_Dobbertin/oracle.py
ctfs/Hack.lu/2023/crypto/Doctored_Dobbertin/oracle.py
import os, sys class TAES_Oracle: rounds = 10 keysize = 10 s_box = ( 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/crypto/Doctored_Dobbertin/app.py
ctfs/Hack.lu/2023/crypto/Doctored_Dobbertin/app.py
#!/usr/bin/env python3 import secrets import os, sys from oracle import TAES_Oracle FLAG = os.getenv('FLAG') FLAG = FLAG if "flag" in FLAG else "flag{fake_flag}" FLAG += " " * (16 - len(FLAG)) assert len(FLAG) == 16 def encrypt_challenge(oracle: TAES_Oracle, challenge: bytes, tweak: str): return oracle.encrypt(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/web/StylePen/bot/bot-master/src/worker.py
ctfs/Hack.lu/2023/web/StylePen/bot/bot-master/src/worker.py
import json import subprocess from queue import Queue from threading import Thread, current_thread import log import config bot_queue = Queue() POISON_PILL = 'POISON_PILL' workers = [] def start_worker(i): t = Thread(name='worker-{}'.format(i), target=worker_main, args=[i]) t.start() workers.append(t) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/web/StylePen/bot/bot-master/src/log.py
ctfs/Hack.lu/2023/web/StylePen/bot/bot-master/src/log.py
def log(tag, *msg): print(tag, *msg)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/web/StylePen/bot/bot-master/src/config.py
ctfs/Hack.lu/2023/web/StylePen/bot/bot-master/src/config.py
import json from time import sleep from threading import Thread from log import log from worker import workers, start_worker, kill_one_worker config = {} old_config = {} config_load = None config_loader = None running = True def init_config(config_file): global config_loader load_config(config_file) con...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/web/StylePen/bot/bot-master/src/app.py
ctfs/Hack.lu/2023/web/StylePen/bot/bot-master/src/app.py
#!/usr/bin/env python from curses.ascii import SI import os, stat import sys import re import datetime from urllib.parse import urlparse, urlunparse from flask import Flask, request, render_template, jsonify import log import config import worker PORT = int(os.getenv('PORT', '5000')) BIND_ADDR = os.getenv('BIND_ADDR...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/web/Based_Encoding/based91.py
ctfs/Hack.lu/2023/web/Based_Encoding/based91.py
# Base91 encode/decode for Python 2 and Python 3 # # Copyright (c) 2012 Adrien Beraud # Copyright (c) 2015 Guillaume Jacquenot # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributio...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2023/web/Based_Encoding/app.py
ctfs/Hack.lu/2023/web/Based_Encoding/app.py
from flask import Flask, redirect, request, session, render_template, flash import os import sqlite3 import secrets import based91 import time import re import subprocess app = Flask(__name__) base_url = os.getenv("BASE_URL", "http://localhost:5000") FLAG = os.getenv("FLAG", "flag{testflag}") admin_password = secr...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2025/misc/CODEBULLAR/codebullar.py
ctfs/Hack.lu/2025/misc/CODEBULLAR/codebullar.py
import os import random from PIL import Image köttbullar_dir = './assets/köttbullar' hotdogs_dir = './assets/hotdogs' output_dir = './encoded' os.makedirs(output_dir, exist_ok=True) köttbullar_files = [os.path.join(köttbullar_dir, f) for f in os.listdir(köttbullar_dir)] hotdogs_files = [os.path.join(hotdogs_dir, f) f...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2025/crypto/FLUXKAMANUAL/server.py
ctfs/Hack.lu/2025/crypto/FLUXKAMANUAL/server.py
#!/usr/bin/env nix-shell #!nix-shell -i python -p python3Packages.pycryptodome import os import re import secrets from Crypto.Cipher import AES from Crypto.Hash import SHA3_256 from Crypto.Random import get_random_bytes from Crypto.Util.Padding import pad FLAG = os.environ.get("FLAG", "flag{FLUXKEA_USER_MANUAL}") MAS...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/pwn/ordersystem/plugin.py
ctfs/Hack.lu/2022/pwn/ordersystem/plugin.py
''' This file handles plugins. They can be added to a server instance and allow for modified behavior such as advanced sorting, server info, remote access and much more. Due to performance reasons and size constraints, plugins are pure python bytecode. co_onsts will be pre set by the plugin handler and supply the plugi...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/pwn/ordersystem/disk.py
ctfs/Hack.lu/2022/pwn/ordersystem/disk.py
''' This file provides functions for dumping from memory to disk, useful for persistence. ''' from os import path ROOT = path.normpath(path.join(path.abspath(__file__),'..')) def _store(fname,content): full = path.join(ROOT,fname) open(full,'w').write(content.hex()) def store_disk(entries): for k,v ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/pwn/ordersystem/main.py
ctfs/Hack.lu/2022/pwn/ordersystem/main.py
''' entry point. This file manages orders received by clients and executes the requested commands. For this demo the commands store,dump and plugin are implemented, though this version ships without any plugins. ''' import socket from threading import Thread import traceback from disk import store_disk from plugin imp...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/pwn/riot_at_the_coffeebar/docker/coffe.py
ctfs/Hack.lu/2022/pwn/riot_at_the_coffeebar/docker/coffe.py
#!/usr/bin/python3 import io import os import sys flag = os.environb.get(b"FLAG") if not flag: flag = b"flag{fake_flag}" def readline(fd): buf = [] while True: c = os.read(fd, 1) if c == b"\n": break buf.append(c) return b"".join(buf) # use virtual serial line for...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/crypto/linearstarter/otp.py
ctfs/Hack.lu/2022/crypto/linearstarter/otp.py
from os import urandom import binascii import time flag = r'flag{fake_flag}' ######### Public m = int(binascii.hexlify(urandom(16)), 16) ######### Secret a = int(binascii.hexlify(urandom(4)), 16) % m b = int(binascii.hexlify(urandom(4)), 16) % m ######### Encrypt otp = [] otp.append(int(time.time()) % m) for _ in ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/crypto/recipevault/vault.py
ctfs/Hack.lu/2022/crypto/recipevault/vault.py
#!/usr/bin/env python3 import numpy as np import socket from threading import Thread import binascii import os some_table = np.zeros(256, dtype=int) def byteof(d, i): return (d >> (i * 8)) & 0xff def mystery(x): y = np.zeros(4, dtype=int) y[0] = some_table[byteof(x[0], 0) ^ some_table[byteof(x[2], 0)]...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/crypto/FaultyIngredient/fluxtagram_leak1.py
ctfs/Hack.lu/2022/crypto/FaultyIngredient/fluxtagram_leak1.py
from os import urandom ############################################################################ # AES ENCRYPTION but something is faulty here ############################################################################ # CONSTANTS sbox = ( 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/crypto/FaultyIngredient/fluxtagram_leak0.py
ctfs/Hack.lu/2022/crypto/FaultyIngredient/fluxtagram_leak0.py
import json import os from Crypto.Cipher import AES import fluxtagram_leak1 ############################################################################ pt = [] ct = [] ft = [] enc_flag = [] NUMBER_OF_PAIRS = 25 KEY = os.urandom(16) FLAG = b'flag{secret_duh}' ###########################################################...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false