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/WRECKCTF/2022/crypto/lsfr/lsfr.py | ctfs/WRECKCTF/2022/crypto/lsfr/lsfr.py | #!/usr/local/bin/python
import random
from pylfsr import LFSR
with open ("flag.txt", "r") as f:
flag = f.read()
def enc(plaintext):
r = random.getrandbits(32)
state = [int(i) for i in list(bin(r)[2:].zfill(32))]
plaintext = list([int(j) for j in ''.join(format(ord(i), 'b').zfill(8) for i in plaintext... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WRECKCTF/2022/crypto/prime/prime.py | ctfs/WRECKCTF/2022/crypto/prime/prime.py | #!/usr/local/bin/python
import random
import math
with open ("flag.txt", "r") as f:
flag = f.read()
n = int(input(">> "))
n_len = n.bit_length()
if n_len<1020 or n_len>1028:
print("no.")
quit()
for i in range(2,1000):
if n%i==0:
print("no.")
quit()
if all([pow(random.randrange(1,n), n-1... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WRECKCTF/2022/crypto/token/challenge.py | ctfs/WRECKCTF/2022/crypto/token/challenge.py | #!/usr/local/bin/python
import os
import random
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
KEY = ''.join(random.choice('0123456789abcdef') for _ in range(32)).encode()
def encrypt(name):
cipher = AES.new(KEY, AES.MODE_ECB)
return cipher.encrypt(pad(name.encode(), AES.block_size)... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WRECKCTF/2022/crypto/mtp/server.py | ctfs/WRECKCTF/2022/crypto/mtp/server.py | #!/usr/local/bin/python -u
import os
import random
LETTERS = set('abcdefghijklmnopqrstuvwxyz')
def encrypt(plaintext, key):
return ''.join(
chr(permutation[ord(letter) - ord('a')] + ord('a'))
if letter in LETTERS
else letter
for letter, permutation in zip(plaintext, key)
)
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WRECKCTF/2022/crypto/spin/encrypt.py | ctfs/WRECKCTF/2022/crypto/spin/encrypt.py | with open('flag.txt', 'r') as file:
plaintext = file.read().strip()
def spin(c, key):
return chr((ord(c) - ord('a') - key) % 26 + ord('a'))
ciphertext = ''.join(
spin(c, 43) if 'a' <= c <= 'z' else c
for c in plaintext
)
with open('ciphertext.txt', 'w+') as file:
file.write(ciphertext)
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WRECKCTF/2022/crypto/rsa/rsa.py | ctfs/WRECKCTF/2022/crypto/rsa/rsa.py | #!/usr/local/bin/python
from Crypto.Util.number import *
p = getPrime(1024)
q = getPrime(1024)
n = p * q
e = 65537
flag = open('flag.txt', 'rb').read()
d = inverse(e, (p-1)*(q-1))
pandaman = b"PANDAMAN! I LOVE PANDAMAN! PANDAMAN MY BELOVED! PANDAMAN IS MY FAVORITE PERSON IN THE WHOLE WORLD! PANDAMAN!!!!"
def enc(m):... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WRECKCTF/2022/web/password-1/server.py | ctfs/WRECKCTF/2022/web/password-1/server.py | from aiohttp import web
class Server:
def __init__(self):
self.app = web.Application()
def get(self, path, c_type='text/html'):
def handle(handler):
decorated_handler = self._handle_factory(handler, c_type)
self.app.add_routes([web.get(path, decorated_handler)])
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WRECKCTF/2022/web/password-1/app.py | ctfs/WRECKCTF/2022/web/password-1/app.py | import os
from server import Server
FLAG = os.environ.get('FLAG', 'flag missing!')
server = Server()
@server.get('/')
async def root(request):
del request
return (200, '''
<link rel="stylesheet" href="/style.css" />
<div class="container">
<form class="content">
<... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WRECKCTF/2022/web/blog/flaskr/blog.py | ctfs/WRECKCTF/2022/web/blog/flaskr/blog.py | from flask import (
Blueprint, flash, g, redirect, render_template, render_template_string, request, url_for
)
from werkzeug.exceptions import abort
from flaskr.auth import login_required
from flaskr.db import get_db
bp = Blueprint('blog', __name__)
@bp.route('/')
@login_required
def index():
db = get_db()
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WRECKCTF/2022/web/blog/flaskr/db.py | ctfs/WRECKCTF/2022/web/blog/flaskr/db.py | import sqlite3
from werkzeug.security import generate_password_hash
db = sqlite3.connect(
'data/db.sqlite3',
detect_types=sqlite3.PARSE_DECLTYPES,
isolation_level=None,
)
db.row_factory = sqlite3.Row
def get_db():
return db
SCHEMA = '''
PRAGMA journal_mode=WAL;
CREATE TABLE IF NOT EXISTS user (
i... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WRECKCTF/2022/web/blog/flaskr/__init__.py | ctfs/WRECKCTF/2022/web/blog/flaskr/__init__.py | import os
from flask import Flask, abort
app = Flask(__name__, instance_relative_config=True)
app.config.from_mapping(
SECRET_KEY=open("flaskr/protected/burdellsecrets.txt").read(),
)
# ensure the instance folder exists
try:
os.makedirs(app.instance_path)
except OSError:
pass
from . import db
db.init_db... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WRECKCTF/2022/web/blog/flaskr/auth.py | ctfs/WRECKCTF/2022/web/blog/flaskr/auth.py | import functools
from flask import (
Blueprint, flash, g, redirect, render_template, request, session, url_for
)
from werkzeug.security import check_password_hash, generate_password_hash
from flaskr.db import get_db
bp = Blueprint('auth', __name__, url_prefix='/auth')
@bp.before_app_request
def load_logged_in_... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2024/rev/Magnum_Opus/magnum_opus.py | ctfs/SekaiCTF/2024/rev/Magnum_Opus/magnum_opus.py | # uses python 3.11.9
import pickle
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | true |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2024/crypto/Some_Trick/sometrick.py | ctfs/SekaiCTF/2024/crypto/Some_Trick/sometrick.py | import random
from secrets import randbelow, randbits
from flag import FLAG
CIPHER_SUITE = randbelow(2**256)
print(f"oPUN_SASS_SASS_l version 4.0.{CIPHER_SUITE}")
random.seed(CIPHER_SUITE)
GSIZE = 8209
GNUM = 79
LIM = GSIZE**GNUM
def gen(n):
p, i = [0] * n, 0
for j in random.sample(range(1, n), n - 1):
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2024/crypto/Squares_vs._Cubes/chall.py | ctfs/SekaiCTF/2024/crypto/Squares_vs._Cubes/chall.py | from Crypto.Util.number import bytes_to_long, getPrime
from secrets import token_bytes, randbelow
from flag import FLAG
padded_flag = bytes_to_long(FLAG + token_bytes(128 - len(FLAG)))
p, q, r = getPrime(512), getPrime(512), getPrime(512)
N = e = p * q * r
phi = (p - 1) * (q - 1) * (r - 1)
d = pow(e, -1, phi)
# Genn... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2024/web/Funny_lfr/app.py | ctfs/SekaiCTF/2024/web/Funny_lfr/app.py | from starlette.applications import Starlette
from starlette.routing import Route
from starlette.responses import FileResponse
async def download(request):
return FileResponse(request.query_params.get("file"))
app = Starlette(routes=[Route("/", endpoint=download)])
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/misc/Just_Another_Pickle_Jail/my_pickle.py | ctfs/SekaiCTF/2023/misc/Just_Another_Pickle_Jail/my_pickle.py | """Create portable serialized representations of Python objects.
See module copyreg for a mechanism for registering custom picklers.
See module pickletools source for extensive comments.
Classes:
Pickler
Unpickler
Functions:
dump(object, file)
dumps(object) -> string
load(file) -> object
lo... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | true |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/misc/Just_Another_Pickle_Jail/chall.py | ctfs/SekaiCTF/2023/misc/Just_Another_Pickle_Jail/chall.py | #!/usr/bin/python3
# Heavily based on AZ's you shall not call (ictf 2023), because that was a great chall
import __main__
# Security measure -- don't let people get io module
from io import BytesIO
from my_pickle import _Unpickler as Unpickler
class mgk:
class nested:
pass
mgk.nested.__import__ = __i... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/misc/Blockchain_Play_for_Free/solve.py | ctfs/SekaiCTF/2023/misc/Blockchain_Play_for_Free/solve.py | # sample solve script to interface with the server
import pwn
# feel free to change this
account_metas = [
("program", "-r"), # read only
("data account", "-w"), # writable
("user", "sw"), # signer + writable
("user data", "sw"),
("system program", "-r"),
]
instruction_data = b"placeholder"
p = p... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/crypto/cryptoGRAPHy_3/server.py | ctfs/SekaiCTF/2023/crypto/cryptoGRAPHy_3/server.py | from itertools import product, chain
from multiprocessing import Pool
from lib import GES
import networkx as nx
import random
import time
from SECRET import flag, generate_tree, decrypt
NODE_COUNT = 60
SECURITY_PARAMETER = 128
MENU = '''============ MENU ============
1. Graph Information
2. Query Responses
3. Challen... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/crypto/Noisier_CRC/chall.py | ctfs/SekaiCTF/2023/crypto/Noisier_CRC/chall.py | import secrets
from Crypto.Util.number import *
from Crypto.Cipher import AES
from hashlib import sha256
from flag import FLAG
isIrreducible = [True for i in range(1 << 17)]
def init():
for f in range(2, 1 << 17):
if isIrreducible[f]:
ls = [0] # store all multiples of polynomial `f`
cur_term = f
while cu... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/crypto/cryptoGRAPHy_1/utils.py | ctfs/SekaiCTF/2023/crypto/cryptoGRAPHy_1/utils.py | from typing import *
import multiprocessing.pool as mpp
import networkx as nx
from Crypto.Hash import HMAC, SHA256
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
'''
Utility functions
'''
def istarmap(self, func, iterable, chunksize):
'''
starmap equivalent using imap.
Feel free t... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/crypto/cryptoGRAPHy_1/DES.py | ctfs/SekaiCTF/2023/crypto/cryptoGRAPHy_1/DES.py | from __future__ import annotations
from typing import *
from Crypto.Random import get_random_bytes
from itertools import product
from multiprocessing import Pool
import utils
class DESClass:
'''
Implementation of dictionary encryption scheme
'''
def __init__(self, encrypted_db: dict[bytes, bytes] = {})... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/crypto/cryptoGRAPHy_1/GES.py | ctfs/SekaiCTF/2023/crypto/cryptoGRAPHy_1/GES.py | from __future__ import annotations
from typing import *
from multiprocessing import Pool
from itertools import product
from Crypto.Random import get_random_bytes
import networkx as nx
import gc
import DES
import utils
DES = DES.DESClass({})
class GESClass:
'''
Implementation of graph encryption scheme
''... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/crypto/cryptoGRAPHy_1/server.py | ctfs/SekaiCTF/2023/crypto/cryptoGRAPHy_1/server.py | from lib import GES, utils
import networkx as nx
import random
from SECRET import flag, decrypt
NODE_COUNT = 130
EDGE_COUNT = 260
SECURITY_PARAMETER = 16
def gen_random_graph(node_count: int, edge_count: int) -> nx.Graph:
nodes = [i for i in range(1, node_count + 1)]
edges = []
while len(edges) < edge_c... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/crypto/Diffecientwo/diffecientwo.py | ctfs/SekaiCTF/2023/crypto/Diffecientwo/diffecientwo.py | import math
import mmh3
class BloomFilter:
def __init__(self, m, k, hash_func=mmh3.hash):
self.__m = m
self.__k = k
self.__i = 0
self.__digests = set()
self.hash = hash_func
def security(self):
false_positive = pow(
1 - pow(math.e, -self.__k * self.... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/crypto/Noisy_CRC/chall.py | ctfs/SekaiCTF/2023/crypto/Noisy_CRC/chall.py | import secrets
from Crypto.Util.number import *
from Crypto.Cipher import AES
from hashlib import sha256
from flag import FLAG
def getCRC16(msg, gen_poly):
assert (1 << 16) <= gen_poly < (1 << 17) # check if deg = 16
msglen = msg.bit_length()
msg <<= 16
for i in range(msglen - 1, -1, -1):
if (msg >> (i + 16))... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/crypto/cryptoGRAPHy_2/server.py | ctfs/SekaiCTF/2023/crypto/cryptoGRAPHy_2/server.py | from lib import GES, utils
import networkx as nx
import random
from SECRET import flag, get_SDSP_node_degrees
'''
get_SDSP_node_degrees(G, dest) returns the node degrees in the single-destination shortest path (SDSP) tree, sorted in ascending order.
For example, if G has 5 nodes with edges (1,2),(1,3),(2,3),(2,5),(4,... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/crypto/RandSubWare/chall.py | ctfs/SekaiCTF/2023/crypto/RandSubWare/chall.py | from math import log2
import random
import secrets
import signal
def gen_pbox(s, n):
"""
Generate a balanced permutation box for an SPN
:param s: Integer, number of bits per S-box.
:param n: Integer, number of S-boxes.
:return: List of integers, representing the generated P-box.
"""
retur... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/web/Chunky/blog/src/app.py | ctfs/SekaiCTF/2023/web/Chunky/blog/src/app.py | from flask import (
Flask,
render_template,
request,
session,
redirect,
make_response,
)
import os
import blog_posts.blog_posts as blog_posts
import users.users as users
from admin.admin import admin_bp
app = Flask(__name__)
app.secret_key = os.getenv("SECRET_KEY")
app.register_blueprint(admin... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/web/Chunky/blog/src/blog_posts/blog_posts.py | ctfs/SekaiCTF/2023/web/Chunky/blog/src/blog_posts/blog_posts.py | import os
import uuid
import sqlite3
db = os.getenv("DB")
def init_table():
conn = sqlite3.connect(db)
cursor = conn.cursor()
cursor.execute(
"""
CREATE TABLE IF NOT EXISTS blog_posts (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
content TEXT NOT NULL,
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/web/Chunky/blog/src/admin/admin.py | ctfs/SekaiCTF/2023/web/Chunky/blog/src/admin/admin.py | from flask import Blueprint, request, session
import os
import jwt
import requests
admin_bp = Blueprint("admin", __name__, url_prefix="/admin")
jwks_url_template = os.getenv("JWKS_URL_TEMPLATE")
valid_algo = "RS256"
def get_public_key_url(user_id):
return jwks_url_template.format(user_id=user_id)
def get_publ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2023/web/Chunky/blog/src/users/users.py | ctfs/SekaiCTF/2023/web/Chunky/blog/src/users/users.py | import sqlite3
import hashlib
import uuid
import os
db = os.getenv("DB")
def init_table():
conn = sqlite3.connect(db)
cursor = conn.cursor()
cursor.execute(
"""
CREATE TABLE IF NOT EXISTS users (
id TEXT PRIMARY KEY,
username TEXT NOT NULL,
password TEX... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2025/misc/Literal_Eval/chall.py | ctfs/SekaiCTF/2025/misc/Literal_Eval/chall.py | from Crypto.Util.number import bytes_to_long
from hashlib import shake_128
from ast import literal_eval
from secrets import token_bytes
from math import floor, ceil, log2
import os
FLAG = os.getenv("FLAG", "SEKAI{}")
m = 256
w = 21
n = 128
l1 = ceil(m / log2(w))
l2 = floor(log2(l1*(w-1)) / log2(w)) + 1
l = l1 + l2
cl... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2025/crypto/SSSS/chall.py | ctfs/SekaiCTF/2025/crypto/SSSS/chall.py | import random, os
p = 2 ** 256 - 189
FLAG = os.getenv("FLAG", "SEKAI{}")
def challenge(secret):
t = int(input())
assert 20 <= t <= 50, "Number of parties not in range"
f = gen(t, secret)
for i in range(t):
x = int(input())
assert 0 < x < p, "Bad input"
print(poly_eval(f, x))
if int(input()) == secret:
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2025/crypto/I_Dream_of_Genni/idog.py | ctfs/SekaiCTF/2025/crypto/I_Dream_of_Genni/idog.py | from hashlib import sha256
from Crypto.Cipher import AES
x = int(input('Enter an 8-digit multiplicand: '))
y = int(input('Enter a 7-digit multiplier: '))
assert 1e6 <= y < 1e7 <= x < 1e8, "Incorrect lengths"
assert x * y != 3_81_40_42_24_40_28_42, "Insufficient ntr-opy"
def dream_multiply(x, y):
x, y = str(x), st... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2025/crypto/APES/chall.py | ctfs/SekaiCTF/2025/crypto/APES/chall.py | import os
FLAG = os.getenv("FLAG", "SEKAI{TESTFLAG}")
def play():
plainperm = bytes.fromhex(input('Plainperm: '))
assert sorted(plainperm) == list(range(256)), "Invalid permutation"
key = os.urandom(64)
def f(i):
for k in key[:-1]:
i = plainperm[i ^ k]
return i ^ key[-1]
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2025/crypto/unfairy_ring/chall.py | ctfs/SekaiCTF/2025/crypto/unfairy_ring/chall.py | from functools import reduce
from uov import uov_1p_pkc as uov # https://github.com/mjosaarinen/uov-py/blob/main/uov.py
import os
FLAG = os.getenv("FLAG", "SEKAI{TESTFLAG}")
def xor(a, b):
assert len(a) == len(b), "XOR inputs must be of the same length"
return bytes(x ^ y for x, y in zip(a, b))
names = ['Miku... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2025/crypto/unfairy_ring/uov.py | ctfs/SekaiCTF/2025/crypto/unfairy_ring/uov.py | # uov.py
# 2024-04-24 Markku-Juhani O. Saarinen <mjos@iki.fi>. See LICENSE
# === Implementation of UOV 1.0 ===
from Crypto.Cipher import AES
from Crypto.Hash import SHAKE256
import os
class UOV:
# initialize
def __init__(self, gf=256, n=112, m=44, pkc=False, skc=False, name='',
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2025/crypto/unfairy_ring++/chall.py | ctfs/SekaiCTF/2025/crypto/unfairy_ring++/chall.py | from functools import reduce
from uov import uov_1p_pkc as uov # https://github.com/mjosaarinen/uov-py/blob/main/uov.py
import os
FLAG = os.getenv("FLAG", "SEKAI{TESTFLAG}")
def xor(a, b):
assert len(a) == len(b), "XOR inputs must be of the same length"
return bytes(x ^ y for x, y in zip(a, b))
names = ['Miku... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2025/crypto/unfairy_ring++/uov.py | ctfs/SekaiCTF/2025/crypto/unfairy_ring++/uov.py | # uov.py
# 2024-04-24 Markku-Juhani O. Saarinen <mjos@iki.fi>. See LICENSE
# === Implementation of UOV 1.0 ===
from Crypto.Cipher import AES
from Crypto.Hash import SHAKE256
import os
class UOV:
# initialize
def __init__(self, gf=256, n=112, m=44, pkc=False, skc=False, name='',
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2025/crypto/Law_And_Order/chall.py | ctfs/SekaiCTF/2025/crypto/Law_And_Order/chall.py | from py_ecc.secp256k1 import P, G as G_lib, N
from py_ecc.secp256k1.secp256k1 import multiply, add
import random
import os
from hashlib import sha256
import sys
CONTEXT = os.urandom(69)
NUM_PARTIES = 9
THRESHOLD = (2 * NUM_PARTIES) // 3 + 1
NUM_SIGNS = 100
FLAG = os.environ.get("FLAG", "FLAG{I_AM_A_NINCOMPOOP}")
# IO... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2022/crypto/EZmaze/chall.py | ctfs/SekaiCTF/2022/crypto/EZmaze/chall.py | #!/usr/bin/env python3
import os
import random
from Crypto.Util.number import *
from flag import flag
directions = "LRUD"
SOLUTION_LEN = 64
def toPath(x: int):
s = bin(x)[2:]
if len(s) % 2 == 1:
s = "0" + s
path = ""
for i in range(0, len(s), 2):
path += directions[int(s[i:i+2], 2)]
return path
def toInt(... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2022/crypto/TimeCapsule/chall.py | ctfs/SekaiCTF/2022/crypto/TimeCapsule/chall.py | import time
import os
import random
from SECRET import flag
def encrypt_stage_one(message, key):
u = [s for s in sorted(zip(key, range(len(key))))]
res = ''
for i in u:
for j in range(i[1], len(message), len(key)):
res += message[j]
return res
def encrypt_stage_two(message):
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2022/crypto/SecureImageEncryption/server-player.py | ctfs/SekaiCTF/2022/crypto/SecureImageEncryption/server-player.py | from io import BytesIO
from PIL import Image
from flask import Flask, request, render_template
import base64
app = Flask(__name__, template_folder="")
app.config['MAX_CONTENT_LENGTH'] = 2 * 1000 * 1000
FLAG_PATH = "flag.png"
flag_img = Image.open(FLAG_PATH)
def encrypt_img(img: Image) -> Image:
# Permutation-only... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2022/crypto/FaILProof/source.py | ctfs/SekaiCTF/2022/crypto/FaILProof/source.py | import hashlib
from os import urandom
from flag import FLAG
def gen_pubkey(secret: bytes, hasher=hashlib.sha512) -> list:
def hash(m): return hasher(m).digest()
state = hash(secret)
pubkey = []
for _ in range(len(hash(b'0')) * 4):
pubkey.append(int.from_bytes(state, 'big'))
state = has... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SekaiCTF/2022/crypto/Diffecient/diffecient.py | ctfs/SekaiCTF/2022/crypto/Diffecient/diffecient.py | import math
import random
import re
import mmh3
def randbytes(n): return bytes ([random.randint(0,255) for i in range(n)])
class BloomFilter:
def __init__(self, m, k, hash_func=mmh3.hash):
self.__m = m
self.__k = k
self.__i = 0
self.__digests = set()
self.hash = hash_func
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AlpacaHack/2025/crypto/Equivalent_Privacy_Wired/server.py | ctfs/AlpacaHack/2025/crypto/Equivalent_Privacy_Wired/server.py | import os
import signal
from Crypto.Cipher import ARC4
import string
import random
signal.alarm(300)
FLAG = os.environ.get("FLAG", "Alpaca{*** FAKEFLAG ***}")
chars = string.digits + string.ascii_lowercase + string.ascii_uppercase
master_key = "".join(random.choice(chars) for _ in range(16)).encode()
for _ in range(... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MetaCTF/2021/rev/I_Hate_Python/python.py | ctfs/MetaCTF/2021/rev/I_Hate_Python/python.py | import random
def do_thing(a, b):
return ((a << 1) & b) ^ ((a << 1) | b)
x = input("What's the password? ")
if len(x) != 25:
print("WRONG!!!!!")
else:
random.seed(997)
k = [random.randint(0, 256) for _ in range(len(x))]
a = { b: do_thing(ord(c), d) for (b, c), d in zip(enumerate(x), k) }
b = l... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MetaCTF/2021/crypto/hide_and_seek_the_flag/client.py | ctfs/MetaCTF/2021/crypto/hide_and_seek_the_flag/client.py | import socket, sys, select, gmpy2
def establish_communication(ip, port):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((ip, port))
keys = []
while True:
active = select.select([s, sys.stdin], [], [])[0]
if s in active:
buf = s... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MetaCTF/2021/crypto/hide_and_seek_the_flag/server.py | ctfs/MetaCTF/2021/crypto/hide_and_seek_the_flag/server.py | import gmpy2
import random
import socket
import select
sockets = []
def get_rsa_info():
p = gmpy2.next_prime(random.getrandbits(1024))
q = gmpy2.next_prime(random.getrandbits(1024))
e = 65537
d = gmpy2.invert(e, (p - 1) * (q - 1))
return (e, int(p), int(q))
def establish_communication(port):
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MetaCTF/2025/crypto/ShaNOISEmir/ShaNOISEmir.py | ctfs/MetaCTF/2025/crypto/ShaNOISEmir/ShaNOISEmir.py | #!/usr/bin/env python3
from os import urandom
from Crypto.Util.number import getPrime as gp
from random import getrandbits, shuffle
random_int = lambda size: int(urandom(size).hex(), 16)
secret = b'FLAG'
secret = int(secret.hex(),16)
class shamir:
def __init__(self, p, coeffs):
self.p = p
self.... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MetaCTF/2020/steg_as_a_service/steg/www/server.py | ctfs/MetaCTF/2020/steg_as_a_service/steg/www/server.py | #!/usr/bin/env python3
from flask import Flask, render_template, request
import subprocess
import uuid
import os
from os import path
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = './uploads/'
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024
@app.route('/')
def upload_file():
return render_template('./upl... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TSCCTF/2025/crypto/Random_Strangeeeeee_Algorithm/server.py | ctfs/TSCCTF/2025/crypto/Random_Strangeeeeee_Algorithm/server.py | import os
import random
import sys
from Crypto.Util.number import getRandomNBitInteger, bytes_to_long
from gmpy2 import is_prime
from secret import FLAG
def get_prime(nbits: int):
if nbits < 2:
raise ValueError("'nbits' must be larger than 1.")
while True:
num = getRandomNBitInteger(nbits... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TSCCTF/2025/crypto/Very_Simple_Login/server.py | ctfs/TSCCTF/2025/crypto/Very_Simple_Login/server.py | import base64
import hashlib
import json
import os
import re
import sys
import time
from secret import FLAG
def xor(message0: bytes, message1: bytes) -> bytes:
return bytes(byte0 & byte1 for byte0, byte1 in zip(message0, message1))
def sha256(message: bytes) -> bytes:
return hashlib.sha256(message).digest()... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TSCCTF/2025/crypto/AES_Encryption_Oracle/chal.py | ctfs/TSCCTF/2025/crypto/AES_Encryption_Oracle/chal.py | #!/usr/bin/env python3
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.backends import default_backend
import os
def aes_cbc_encrypt(msg: bytes, key: bytes) -> bytes:
"""
Encrypts a message using AES in CBC... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TSCCTF/2025/web/E4sy_SQLi/main.py | ctfs/TSCCTF/2025/web/E4sy_SQLi/main.py | from flask import Flask, render_template, request, redirect, url_for, session, flash, jsonify
import mysql.connector
import os, time
from werkzeug.security import generate_password_hash, check_password_hash
from functools import wraps
from flask_wtf.csrf import CSRFProtect
from flag_generate import create_discount_code... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/RVCExIITBxYCF/2024/crypto/Art_of_Predictability/chall.py | ctfs/RVCExIITBxYCF/2024/crypto/Art_of_Predictability/chall.py | from Crypto.Util.number import bytes_to_long, isPrime
from secrets import randbelow
from sympy import nextprime
s = 696969
p = bytes_to_long(REDACTED)
c = 0
while not isPrime(p):
p+=1
c+=1
assert isPrime(p)
a = randbelow(p)
b = randbelow(p)
def mathemagic(seed):
return (a * seed + b) % p
print("c = ",... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FullWeakEngineer/2025/rev/A/main.py | ctfs/FullWeakEngineer/2025/rev/A/main.py | class _A(type):
def __xor__(AA, AAA):
return AA(AAA)
def __invert__(AA):
return globals()
def __mod__(AA, AAA):
return __import__("base64").b64decode(['QXJpdGhtZXRpY0Vycm9y', 'QXNzZXJ0aW9uRXJyb3I=', 'QXR0cmlidXRlRXJyb3I=', 'QmFzZUV4Y2VwdGlvbg==', 'QmFzZUV4Y2VwdGlvbkdyb3Vw', 'QmxvY2tp... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FullWeakEngineer/2025/rev/reeeeeee/reeeeeee.py | ctfs/FullWeakEngineer/2025/rev/reeeeeee/reeeeeee.py | from _sre import compile
from sys import version_info
assert version_info[0] == 3 and version_info[1] >= 11
flag = input("Enter flag > ")
print("YNeos!!"[not compile("dummy",0,[14, 4, 0, 0, 0, 4, 40, 0, 6, 0, 16, 102, 16, 119, 16, 101, 16, 99, 16, 116, 16, 102, 16, 123, 24, 16, 48, 48, 13, 11, 9, 0, 2214526978, 22817... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2024/misc/Mutual_TLS/serv.py | ctfs/WorldWide/2024/misc/Mutual_TLS/serv.py | import ssl
from OpenSSL import crypto
from flask import Flask, request
from werkzeug.serving import WSGIRequestHandler, make_server
app = Flask(__name__)
def extract_subject_from_cert(ssl_socket):
try:
for cert in ssl_socket.get_unverified_chain():
cert = cert
cert = crypto.load_certi... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2024/crypto/Simpler_RSA/chal.py | ctfs/WorldWide/2024/crypto/Simpler_RSA/chal.py | from secret import flag
from Crypto.Util.number import bytes_to_long, getPrime
flag = bytes_to_long(flag)
p = getPrime(2048)
q = getPrime(2048)
c = pow(flag, p, q) # i believe this is the fancy rsa encryption?
print(f'{p=}')
print(f'{q=}')
print(f'{c=}')
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2024/crypto/Subathon/chall.py | ctfs/WorldWide/2024/crypto/Subathon/chall.py | from notaes import notAES
from os import urandom
from time import time
# ugh standard flag shenanigans yada yada
key = urandom(16)
cipher = notAES(key)
from secret import flag
flag_enc = cipher.encrypt(flag.encode())
print(f'{flag_enc = }')
# time for the subathon!
st = time()
TIME_LEFT = 30
while time() - st < TI... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2024/crypto/Subathon/notaes.py | ctfs/WorldWide/2024/crypto/Subathon/notaes.py | #!/usr/bin/env python3
# https://github.com/boppreh/aes/blob/master/aes.py, definitely unaltered
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, 0... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2024/crypto/Rolypoly/chall.py | ctfs/WorldWide/2024/crypto/Rolypoly/chall.py | from sage.all import GF, PolynomialRing, ZZ, save
from hashlib import sha256
from Crypto.Cipher import AES
n = 1201
q = 467424413
K = GF(q)
PR = PolynomialRing(K, names=('t',)); (t,) = PR._first_ngens(1)
R = PR.quotient(PR.ideal([t**n-1 ]))
PR2 = PolynomialRing(R,2 , names=('x', 'y',)); (x, y,) = PR2._first_ngens(2)
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2024/crypto/Amineo/chall.py | ctfs/WorldWide/2024/crypto/Amineo/chall.py | from secrets import randbits
from hashlib import sha256
import os
flag = os.getenv("flag", "wwf{<REDACTED>}").encode()
assert len(flag) == 32
p = 0xffffffffffffffffffffffffffffff53
Nr = 4
bSEED = b"AMINEO"
A = int.from_bytes(sha256(b"A" + bSEED).digest(), "big") % p
B = int.from_bytes(sha256(b"B" + bSEED).digest(), ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2024/crypto/epsilonDH/chall.py | ctfs/WorldWide/2024/crypto/epsilonDH/chall.py | from Crypto.Util.number import getStrongPrime, getRandomNBitInteger, bytes_to_long
import os
p = getStrongPrime(1024)
flag = os.getenv("flag", "wwf{<REDACTED>}").encode()
class Epsilon:
def __init__(self, a, b):
self.a, self.b = a, b
def __add__(self, other):
if type(other) == int: other ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2024/crypto/Modnar/chall.py | ctfs/WorldWide/2024/crypto/Modnar/chall.py | import random
import time
from secret import flag
def get_random_array(x):
y = list(range(1,x))
random.Random().shuffle(y)
return y
my_seed = bytes(get_random_array(42))
random.seed(my_seed)
my_random_val = random.getrandbits(9999)
print(f"my seed: {my_seed.hex()}")
start = time.time()
ur_seed = bytes.f... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2024/crypto/Modnar/random.py | ctfs/WorldWide/2024/crypto/Modnar/random.py | """Random variable generators.
bytes
-----
uniform bytes (values between 0 and 255)
integers
--------
uniform within range
sequences
---------
pick random element
pick random sample
pick weighted random sample
generate random p... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2024/crypto/Just_Lattice/chal.py | ctfs/WorldWide/2024/crypto/Just_Lattice/chal.py | import numpy as np
from secret import flag
def gen(q, n, N, sigma):
t = np.random.randint(0, high=q//2, size=n)
s = np.concatenate([np.ones(1, dtype=np.int32), t])
A = np.random.randint(0, high=q//2, size=(N, n))
e = np.round(np.random.randn(N) * sigma ** 2).astype(np.int32) % q
b = ((np.dot(A, t)... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2024/crypto/Twister/deploy.py | ctfs/WorldWide/2024/crypto/Twister/deploy.py | from dataclasses import dataclass
from cmath import exp
import secrets
import time
import os
FLAG = os.getenv("FLAG") or "test{flag_for_local_testing}"
@dataclass
class Wave:
a: int
b: int
def eval(self, x):
theta = x / self.a + self.b
return ((exp(1j * theta) - exp(-1j * theta)) / 2j).r... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2025/blockchain/Solidity_Jail_2/JailTalker.py | ctfs/WorldWide/2025/blockchain/Solidity_Jail_2/JailTalker.py | #!/usr/local/bin/python
import signal
from solcx import compile_standard
import os
from web3 import Web3
import string
import re
import requests
import sys
contr_add = os.environ.get("CONTRACT_ADDDR")
rpc_url = os.environ.get("RPC_URL")
print("Enter the body of main() (end with three blank lines):")
lines = []
empty_... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2025/blockchain/Solidity_Jail_1/jailTalk.py | ctfs/WorldWide/2025/blockchain/Solidity_Jail_1/jailTalk.py | #!/usr/local/bin/python
import signal
from solcx import compile_standard
import os
from web3 import Web3
import string
import requests
from urllib.parse import urlparse
contr_add = os.environ.get("CONTRACT_ADDDR")
rpc_url = os.environ.get("RPC_URL")
try:
parsed = urlparse(rpc_url)
resp = requests.get(f"{parse... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2025/misc/Non_Functional_Calculator_2/jail.py | ctfs/WorldWide/2025/misc/Non_Functional_Calculator_2/jail.py | #!/usr/local/bin/python
values = {}
whitelist_chars = set("abcdefghijklmnopqrstuvwxyz0123456789.,()")
blacklist_words = {
"exe",
"import",
"eval",
"os",
"sys",
"run",
"sub",
"class",
"process",
"cat",
"repr",
"base",
"echo",
"open",
"file",
"sh",
"ite... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2025/misc/Non_Functional_Calculator/jail.py | ctfs/WorldWide/2025/misc/Non_Functional_Calculator/jail.py | #!/usr/local/bin/python
values = {}
whitelist_chars = set("abcdefghijklmnopqrstuvwxyz0123456789.,()")
blacklist_words = {
"exe",
"import",
"eval",
"os",
"sys",
"run",
"sub",
"class",
"process",
"cat",
"repr",
"base",
"echo",
"open",
"file",
"sh",
"ite... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2025/misc/Ouroboros/chall.py | ctfs/WorldWide/2025/misc/Ouroboros/chall.py | import os
import random
import string
import sys
import tempfile
import hashlib
import subprocess
import shutil
BASE = os.path.join(tempfile.gettempdir(), 'sandbox')
sys.stdout.write('''\x1b[31;1m
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⣀⣀⣀⣄⣀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⡶⢿⣟⡛⣿⢉⣿⠛⢿⣯⡈⠙⣿⣦⡀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⡾⠻⣧⣬⣿⣿⣿⣿⣿⡟⠉⣠⣾⣿⠿⠿⠿⢿⣿⣦⠀⠀⠀
⠀⠀⠀⠀⣠⣾⡋⣻⣾⣿⣿⣿⠿⠟⠛⠛⠛⠀⢻⣿⡇⢀⣴⡶⡄⠈⠛⠀... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2025/misc/bf_jail/chall.py | ctfs/WorldWide/2025/misc/bf_jail/chall.py | #!/usr/bin/env python3
import sys
def bf(code):
output = ""
s = []
matches = {}
tape = [0] * 1000000
for i, j in enumerate(code):
if j == "[":
s.append(i)
if j == "]":
m = s.pop()
matches[m] = i
matches[i] = m
cp = 0
p = 0
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2025/crypto/Cheops/server.py | ctfs/WorldWide/2025/crypto/Cheops/server.py | from hashlib import shake_256
import os
from typing import Callable
def xor(a, b):
assert len(a) == len(b)
return bytes([x ^ y for x, y in zip(a, b)])
def rotr(a, n):
a = int.from_bytes(a, "big")
a = ((a >> n) | (a << (32 - n))) & 0xFFFFFFFF
a = a.to_bytes(4, "big")
return a
ROTATION_SCHEDUL... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2025/crypto/Layered_Signatures/chall.py | ctfs/WorldWide/2025/crypto/Layered_Signatures/chall.py | # /usr/bin/env python
import sys
from Crypto.Util.number import (
getPrime,
getRandomInteger,
isPrime,
bytes_to_long,
long_to_bytes,
)
from hashlib import sha256
from flag import flag
nbits = 1024
# openssl prime -generate -bits 1024 -safe
p = 1571774580279477384646085877185051708725575373113360223... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2025/crypto/IsogenyMaze2/chall.py | ctfs/WorldWide/2025/crypto/IsogenyMaze2/chall.py | from sage.all import EllipticCurve, GF
from sage.all_cmdline import x
flag = "wwf{?????????????????????????????????????????????????????}"
p = 2**51 * 3**37 - 1
F = GF(p**2 , modulus=x**2 +1 , names=('i',)); (i,) = F._first_ngens(1)
def H(num, seed=0):
j_prev = F(0)
j = F(seed)
while num:
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2025/crypto/LFSR_Hamster/chall.py | ctfs/WorldWide/2025/crypto/LFSR_Hamster/chall.py | from flag import flag
import os
assert flag[:4] == b"wwf{" and flag[-1:] == b"}"
class LFSRHamster:
def __init__(self, key):
self.state = [int(eb) for b in key for eb in bin(b)[2:].zfill(8)]
self.taps = [0, 1, 2, 7]
self.filter = [85, 45, 76, 54, 45, 35, 39, 37, 117, 13, 112, 64, 75, 117, ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2025/crypto/FaultyCurve/chall.py | ctfs/WorldWide/2025/crypto/FaultyCurve/chall.py | def add(P, Q, a, p):
if P is None:
return Q
if Q is None:
return P
x1, y1 = P
x2, y2 = Q
if x1 == x2 and (y1 != y2 or y1 == 0):
return None
if x1 == x2:
m = (3 * x1 * x1 + a) * pow(2 * y1, -1, p) % p
else:
m = (y2 - y1) * pow(x2 - x1, -1, p) % p
x3... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2025/beginner/Evil_Snek/jail.py | ctfs/WorldWide/2025/beginner/Evil_Snek/jail.py | #!/usr/bin/python3
def blacklist(cmd):
if cmd.isascii() == False:
return True
bad_cmds = ['"',
"'",
"print",
"_",
".",
"import",
"os",
"lambda",
"system",
"("... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WorldWide/2025/beginner/Shuffle/chall.py | ctfs/WorldWide/2025/beginner/Shuffle/chall.py | from hashlib import sha256
import os
from random import shuffle
class Cipher:
def __init__(self):
self.state = [i for i in range(10000)]
shuffle(self.state)
def key(self):
shuffled = []
for i in range(5000):
shuffled.append(self.state[i])
shuffled.ap... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2021/crypto/FNES_3/fnes3.py | ctfs/BCACTF/2021/crypto/FNES_3/fnes3.py | #!/usr/bin/env python3
import random
import math
import time
import binascii
p = 2**135 + 2**75 + 1
a = 313370
b = 12409401451673702436179381616844751057480 # discriminant is zero
g = (313379, 9762458732130899649993884045943131856797, False)
def negp(P):
x,y,z = P
return (-x,y,z)
def dubp(P):
x,y,z = P
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2021/crypto/FNES_2.5/app.py | ctfs/BCACTF/2021/crypto/FNES_2.5/app.py | from flask import Flask, render_template, request, redirect, make_response
from json import loads, dumps
import secrets
import random
import math
import time
import binascii
import sys
from Crypto.Cipher import AES
from Crypto.Hash import SHA
from Crypto.Util.Padding import pad, unpad
sys.tracebacklimit = 0
app = Fl... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2021/crypto/FNES_2/fnes2.py | ctfs/BCACTF/2021/crypto/FNES_2/fnes2.py | #!/usr/bin/env python3
import random
import math
import time
import binascii
import secrets
from Crypto.Cipher import AES
from Crypto.Hash import SHA
from Crypto.Util.Padding import pad, unpad
with open("flag.txt", "r") as f:
flag = f.read().strip().encode("ascii")
with open("key.txt", "r") as f:
key = int(... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2021/crypto/FNES_1/fnes1.py | ctfs/BCACTF/2021/crypto/FNES_1/fnes1.py | #!/usr/bin/env python3
import random
import math
import time
import binascii
from Crypto.Cipher import ARC4
from Crypto.Hash import SHA
with open("flag.txt", "r") as f:
flag = f.read().strip().encode("ascii")
with open("key.txt", "r") as f:
key = int(f.read().strip())
target_query = "Open sesame... Flag ple... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2021/crypto/Rainbow_Passage/rp.py | ctfs/BCACTF/2021/crypto/Rainbow_Passage/rp.py | #!/usr/bin/env python3
import math
import binascii
from Crypto.Util.Padding import pad, unpad
print("""
Welcome to the official communication encryption system for rainbow bridges.
Input the encryption password given to you by your sponsor diety to encode messages,
and use the decryption password given to you to deco... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2024/misc/MathJail/pycalculator.py | ctfs/BCACTF/2024/misc/MathJail/pycalculator.py | print("Welcome to your friendly python calculator!")
equation = input("Enter your equation below and I will give you the answer:\n")
while equation!="e":
answer = eval(equation, {"__builtins__":{}},{})
print(f"Here is your answer: {answer}")
equation = input("Enter your next equation below (type 'e' to exit... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2024/misc/JailBreak_2/main.py | ctfs/BCACTF/2024/misc/JailBreak_2/main.py | def sanitize(letter):
print("Checking for contraband...")
return any([i in letter.lower() for i in BANNED_CHARS])
def end():
print("Contraband letters found!\nMessages Deleted!")
exit()
BANNED_CHARS = "gdvxfiyundmnet/\\'~`@#$%^&.{}0123456789"
flag = open('flag.txt').read().strip()
print("Welcome to t... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2024/misc/JailBreak_Revenge/main.py | ctfs/BCACTF/2024/misc/JailBreak_Revenge/main.py | def sanitize(letter):
print("Checking for contraband...")
return any([(i in letter.lower()) for i in BANNED_CHARS]) or any([ord(l)>120 for l in letter])
def end():
print("Contraband letters found!\nMessages Deleted!")
exit()
BANNED_CHARS = "gdvxfiyundmpnetkb/\\'\"~`!@#$%^&*.{},:;=0123456789#-_|? \t\n\... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2024/misc/JailBreak_1/deploy.py | ctfs/BCACTF/2024/misc/JailBreak_1/deploy.py | def sanitize(letter):
print("Checking for contraband...")
return any([i in letter.lower() for i in BANNED_CHARS])
BANNED_CHARS = "gdvxftundmnt'~`@#$%^&*-/.{}"
flag = open('flag.txt').read().strip()
print("Welcome to the prison's mail center")
msg = input("Please enter your message: ")
if sanitize(msg):
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2024/misc/reload_decode/main.py | ctfs/BCACTF/2024/misc/reload_decode/main.py | from flask import Flask, render_template
import random
app = Flask(__name__)
@app.route('/')
def index(): #Gets the main page
return render_template('index.html')
@app.route('/flag')
def getFlag():
#Get flag from flag.txt
with open("flag.txt") as f:
flag = bytearray(f.read().encode())
flag_st... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2024/crypto/RSAEncrypter/rsa_encrypter.py | ctfs/BCACTF/2024/crypto/RSAEncrypter/rsa_encrypter.py | from Crypto.Util.number import getPrime, bytes_to_long, long_to_bytes
message = open("./flag.txt").read().encode('utf-8')
def encode():
n = getPrime(512)*getPrime(512)
ciphertext = pow(bytes_to_long(message), 3, n)
return (ciphertext, n)
print("Return format: (ciphertext, modulus)")
print(encode())
s... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2024/crypto/Superstitious_2/superstitious-2.py | ctfs/BCACTF/2024/crypto/Superstitious_2/superstitious-2.py | from Crypto.Util.number import *
def myGetPrime():
while True:
x = getRandomNBitInteger(1024) & ((1 << 1024) - 1)//3
if isPrime(x):
return x
p = myGetPrime()
q = myGetPrime()
n = p * q
e = 65537
message = open('flag.txt', 'rb')
m = bytes_to_long(message.read())
c = pow(m, e, n)
open("sup... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2024/crypto/Talk_to_Echo/echo.py | ctfs/BCACTF/2024/crypto/Talk_to_Echo/echo.py | from random import randint
from time import sleep
from Crypto.Hash import SHA256
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
a = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc
b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b
n = 0xffffffff00000001000000000... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2024/crypto/Encryptor_Shop/server.py | ctfs/BCACTF/2024/crypto/Encryptor_Shop/server.py | from Crypto.Util.number import *
p = getPrime(1024)
q = getPrime(1024)
r = getPrime(1024)
n = p * q
phi = (p - 1) * (q - 1)
e = 65537
d = pow(e, -1, phi)
print("Welcome to the enc-shop!")
print("What can I encrypt for you today?")
for _ in range(3):
message = input("Enter text to encrypt: ")
m = bytes_to_lo... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2024/crypto/rad_be_damned/message.py | ctfs/BCACTF/2024/crypto/rad_be_damned/message.py | import random
def find_leftmost_set_bit(plaintext):
pos = 0
while plaintext > 0:
plaintext = plaintext >> 1
pos += 1
return pos
def encrypt(plaintext: str):
enc_plaintext = ""
for letter in plaintext:
cp = int("10011", 2)
cp_length = cp.bit_length()
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BCACTF/2024/crypto/Cha_Cha_Slide/server.py | ctfs/BCACTF/2024/crypto/Cha_Cha_Slide/server.py | from Crypto.Cipher import ChaCha20
from os import urandom
key = urandom(32)
nonce = urandom(12)
secret_msg = urandom(16).hex()
def encrypt_msg(plaintext):
cipher = ChaCha20.new(key=key, nonce=nonce)
return cipher.encrypt(plaintext.encode()).hex()
print('Secret message:')
print(encrypt_msg(secret_msg))
pri... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.