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/redpwn/2021/crypto/Keeper_of_the_Flag/kotf.py
ctfs/redpwn/2021/crypto/Keeper_of_the_Flag/kotf.py
#!/usr/local/bin/python3 from Crypto.Util.number import * from Crypto.PublicKey import DSA from random import * from hashlib import sha1 rot = randint(2, 2 ** 160 - 1) chop = getPrime(159) def H(s): x = bytes_to_long(sha1(s).digest()) return pow(x, rot, chop) L, N = 1024, 160 dsakey = DSA.generate(1024) p ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2021/crypto/retrosign/server.py
ctfs/redpwn/2021/crypto/retrosign/server.py
#!/usr/local/bin/python from Crypto.Util.number import getPrime, bytes_to_long from Crypto.Hash import SHA256 from binascii import unhexlify from secrets import randbelow with open('flag.txt','r') as f: flag = f.read().strip() def sha256(val): h = SHA256.new() h.update(val) return h.digest() def exe...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2021/web/cool/app.py
ctfs/redpwn/2021/web/cool/app.py
from flask import ( Flask, request, render_template_string, session, redirect, send_file ) from random import SystemRandom import sqlite3 import os app = Flask(__name__) app.secret_key = os.getenv('FLASK_KEY') rand = SystemRandom() allowed_characters = set( 'abcdefghijklmnopqrstuvwxyzABCD...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2021/web/pastebin-3/app/app.py
ctfs/redpwn/2021/web/pastebin-3/app/app.py
import os import secrets import sqlite3 from flask import ( Flask, flash, redirect, render_template, request, session ) app = Flask(__name__) app.secret_key = os.getenv('FLASK_KEY') def execute(query, params=()): con = sqlite3.connect('../db/db.sqlite3') cur = con.cursor() cur.exe...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2021/web/pastebin-3/sandbox/app.py
ctfs/redpwn/2021/web/pastebin-3/sandbox/app.py
import sqlite3 from flask import ( Flask, render_template_string, request, ) app = Flask(__name__) def execute(query, params=()): con = sqlite3.connect('../db/db.sqlite3') cur = con.cursor() cur.execute(query, params) con.commit() return cur.fetchall() def get_paste(paste_id): r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/rev/drive/run.py
ctfs/redpwn/2022/rev/drive/run.py
#!/usr/local/bin/python import subprocess from binascii import unhexlify i = input() p = subprocess.run(["./drive"], input=unhexlify(i), capture_output=True) print(p.stdout.decode())
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/rev/slices/slices.py
ctfs/redpwn/2022/rev/slices/slices.py
flag = input('Enter flag: ') def fail(): print('Wrong!') exit(-1) if len(flag) != 32: fail() if flag[:5] != 'hope{': fail() if flag[-1] != '}': fail() if flag[5::3] != 'i0_tnl3a0': fail() if flag[4::4] != '{0p0lsl': fail() if flag[3::5] != 'e0y_3l': fail() if flag[6::3] != '_vph_is_t': fail() if flag[7::3] ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/rev/dumb/check.py
ctfs/redpwn/2022/rev/dumb/check.py
import json import subprocess flag = input('Flag: ').encode('ascii') assert len(flag) == 32 inp = { "flag": list(bytes(flag)) } open('tmp_input.json', 'w').write(json.dumps(inp)) rcode = subprocess.run('snarkjs wc ./parts/main.wasm tmp_input.json tmp_witness.wtns', shell=True) if rcode.returncode == 1: pri...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/rev/dumb/proof.py
ctfs/redpwn/2022/rev/dumb/proof.py
import json import subprocess print('I know the flag:') pub = json.load(open('parts/public.json', 'r')) print('Public: ', pub) if pub == ["1"]: print('good :)') else: print('bad :(') subprocess.run('snarkjs plonk verify parts/verification_key.json parts/public.json parts/proof.json', shell=True)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/crypto/replacement/encrypt.py
ctfs/redpwn/2022/crypto/replacement/encrypt.py
import random with open('text.txt') as f: plaintext = f.read() with open('flag.txt') as f: plaintext += '\n' + f.read() characters = set(plaintext) - {'\n'} shuffled = list(characters) random.shuffle(shuffled) replacement = dict(zip(characters, shuffled)) ciphertext = ''.join(replacement.get(c, c) for c i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/crypto/obp/encrypt.py
ctfs/redpwn/2022/crypto/obp/encrypt.py
import random with open('flag.txt', 'rb') as f: plaintext = f.read() key = random.randrange(256) ciphertext = [key ^ byte for byte in plaintext] with open('output.txt', 'w') as f: f.write(bytes(ciphertext).hex())
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/crypto/streamlined/streamlined.py
ctfs/redpwn/2022/crypto/streamlined/streamlined.py
import random with open("aooo.txt", "r") as f: plaintext = f.read() assert len(plaintext) == 14332 with open("flag.txt", "r") as f: flag = f.read() assert len(flag) == 52 and flag.startswith("hope{") and flag.endswith("}") plaintext = plaintext + flag plaintext = plaintext.encode() N = 8 * len(plainte...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/crypto/small-fortune/script.py
ctfs/redpwn/2022/crypto/small-fortune/script.py
from Crypto.Util.number import * from gmpy2 import legendre flag = bytes_to_long(open("flag.txt", "rb").read()) p, q = getPrime(256), getPrime(256) n = p * q x = getRandomRange(0, n) while legendre(x, p) != -1 or legendre(x, q) != -1: x = getRandomRange(0, n) def gm_encrypt(msg, n, x): y = getRandomRange(0,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/crypto/reverse-rsa/reverse-rsa.py
ctfs/redpwn/2022/crypto/reverse-rsa/reverse-rsa.py
#!/usr/local/bin/python import re from Crypto.Util.number import isPrime, GCD flag_regex = rb"hope{[a-zA-Z0-9_\-]+}" with open("ciphertext.txt", "r") as f: c = int(f.read(), 10) print(f"Welcome to reverse RSA! The encrypted flag is {c}. Please provide the private key.") p = int(input("p: "), 10) q = int(input("q...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/crypto/pem/generate.py
ctfs/redpwn/2022/crypto/pem/generate.py
from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_OAEP with open('flag.txt','rb') as f: flag = f.read() key = RSA.generate(2048) cipher_rsa = PKCS1_OAEP.new(key) enc = cipher_rsa.encrypt(flag) with open('privatekey.pem','wb') as f: f.write(key.export_key('PEM')) with open("encrypted.bin", "wb") as ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/crypto/DESpicable-you/encrypt.py
ctfs/redpwn/2022/crypto/DESpicable-you/encrypt.py
from os import urandom def encipher(a,b): c = '' for i, j in zip(a,b): c+=chr(ord(i)^ord(j)) return c def rekey(key): k = "" for i,c in enumerate(key): if i == len(key)-1: k += c k += chr(ord(c)^ord(key[0])) else: k += c k += ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/crypto/kfb/server.py
ctfs/redpwn/2022/crypto/kfb/server.py
#!/usr/local/bin/python -u from Crypto.Cipher import AES from Crypto.Random import get_random_bytes from Crypto.Util.Padding import pad from Crypto.Util.strxor import strxor from more_itertools import ichunked BLOCK = AES.block_size FLAG = open('flag.txt', 'rb').read().strip() def encrypt_block(k, pt): cipher = AE...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/web/oeps/server.py
ctfs/redpwn/2022/web/oeps/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/redpwn/2022/web/oeps/app.py
ctfs/redpwn/2022/web/oeps/app.py
import os import random import sqlite3 from server import Server # database stuff connection = sqlite3.connect(':memory:') def init(): connection.execute(''' create table approved ( id integer primary key autoincrement, sentence text ); ''') connection.execute('''...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/web/secure-page/server.py
ctfs/redpwn/2022/web/secure-page/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/redpwn/2022/web/secure-page/app.py
ctfs/redpwn/2022/web/secure-page/app.py
import os from server import Server server = Server() @server.get('/') async def root(request): admin = request.cookies.get('admin', '') headers = {} if admin == '': headers['set-cookie'] = 'admin=false' if admin == 'true': return (200, ''' <title>Secure Page</title> ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/web/flag-viewer/server.py
ctfs/redpwn/2022/web/flag-viewer/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/redpwn/2022/web/flag-viewer/app.py
ctfs/redpwn/2022/web/flag-viewer/app.py
import os import random from server import Server server = Server() @server.get('/') async def root(request): return (200, ''' <title>Flag Viewer</title> <link rel="stylesheet" href="/style.css" /> <div class="container"> <h1>The Flag Viewer</h1> <form action="/fla...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/web/reverser/app.py
ctfs/redpwn/2022/web/reverser/app.py
from flask import Flask, render_template_string, request app = Flask(__name__) @app.get('/') def index(): result = ''' <link rel="stylesheet" href="style.css" /> <div class="container"> <h1>Text Reverser</h1> Reverse any text... now as a web service! <form meth...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/web/your-space/app/model.py
ctfs/redpwn/2022/web/your-space/app/model.py
from datetime import datetime from sqlalchemy.ext.hybrid import hybrid_property from werkzeug.security import check_password_hash, generate_password_hash from . import db, login class User(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(32), unique=True, nullable=False...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/web/your-space/app/form.py
ctfs/redpwn/2022/web/your-space/app/form.py
from flask_wtf import FlaskForm from wtforms import ( PasswordField, StringField, SubmitField, TextAreaField, ValidationError, ) from wtforms.validators import InputRequired, Length from .model import User def validate_username(_form, field): if User.query.filter_by(username=field.data).count...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/web/your-space/app/config.py
ctfs/redpwn/2022/web/your-space/app/config.py
import os class Config: SQLALCHEMY_DATABASE_URI = "sqlite:///db.sqlite" SQLALCHEMY_TRACK_MODIFICATIONS = False CACHE_TYPE = "RedisCache" WTF_CSRF_ENABLED = False class ProdConfig(Config): DEBUG = False SECRET_KEY = os.environ.get("SECRET_KEY") CACHE_REDIS_URL = "redis://redis:6379/0" c...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/web/your-space/app/__init__.py
ctfs/redpwn/2022/web/your-space/app/__init__.py
from pathlib import Path from flask import Flask from flask_caching import Cache from flask_login import LoginManager from flask_sqlalchemy import SQLAlchemy from .notify import start_notifier cache = Cache() db = SQLAlchemy() login = LoginManager() login.login_view = "auth.login" login.login_message = "not logged i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/web/your-space/app/notify.py
ctfs/redpwn/2022/web/your-space/app/notify.py
import json from io import StringIO from multiprocessing import Process, Queue import pycurl queue = Queue() def notify_single(url, body): c = pycurl.Curl() c.setopt(pycurl.URL, url) c.setopt( pycurl.HTTPHEADER, [ "Accept: application/json", "Content-Type: applicat...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/web/your-space/app/routes/main.py
ctfs/redpwn/2022/web/your-space/app/routes/main.py
from flask import Blueprint, flash, render_template from flask_login import current_user, login_required from .. import db from ..form import WebhookForm from ..model import Space main = Blueprint("main", __name__) @main.route("/") def home(): spaces = Space.query.all() return render_template("home.html", s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/web/your-space/app/routes/__init__.py
ctfs/redpwn/2022/web/your-space/app/routes/__init__.py
from .auth import auth from .main import main from .space import space __all__ = ["auth", "main", "space"]
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/web/your-space/app/routes/auth.py
ctfs/redpwn/2022/web/your-space/app/routes/auth.py
from flask import Blueprint, flash, redirect, render_template, request, url_for from flask_login import current_user, login_user, logout_user from .. import db from ..form import LoginForm, RegisterForm from ..model import User auth = Blueprint("auth", __name__) @auth.route("/login", methods=["GET", "POST"]) def lo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2022/web/your-space/app/routes/space.py
ctfs/redpwn/2022/web/your-space/app/routes/space.py
from flask import Blueprint, abort, flash, redirect, render_template, url_for from flask_login import current_user, login_required from .. import cache, db from ..form import PostForm, SpaceForm from ..model import Post, Space, Subscription from ..notify import notify space = Blueprint("space", __name__) def get_su...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2020/four-function-heap/starter.py
ctfs/redpwn/2020/four-function-heap/starter.py
from pwn import * e = ELF("./four-function-heap") libc = ELF("./libc.so.6") p = process(e.path) def alloc(idx, size, data="AAAA"): p.sendline("1") p.sendlineafter(":", str(idx)) p.sendlineafter(":", str(size)) p.sendlineafter(":", data) p.recvuntil(":") def free(idx): p.sendline("2") p.sendlineafter(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PBjar/2021/crypto/ReallynotSecureAlgorithm/script.py
ctfs/PBjar/2021/crypto/ReallynotSecureAlgorithm/script.py
from Crypto.Util.number import * with open('flag.txt','rb') as f: flag = f.read().strip() e=65537 p=getPrime(128) q=getPrime(128) n=p*q m=bytes_to_long(flag) ct=pow(m,e,n) print (p) print (q) print (e) print (ct)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PBjar/2021/crypto/Not_Baby/script.py
ctfs/PBjar/2021/crypto/Not_Baby/script.py
from Crypto.Util.number import * with open('flag.txt','rb') as g: flag = g.read().strip() with open('nums.txt','r') as f: s=f.read().strip().split() a=int(s[0]) b=int(s[1]) c=int(s[2]) e=65537 n=a**3+b**3-34*c**3 m=bytes_to_long(flag) ct=pow(m,e,n) print ("n: ",n) print ("e: ",e) print ("ct: ",ct)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PBjar/2021/crypto/Iloveyou3000/script.py
ctfs/PBjar/2021/crypto/Iloveyou3000/script.py
import random from Crypto.Util.number import * def newflag(oldflag): s=list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPWRSTUVWXYYZ") for i in range(random.randint(1,10)): oldflag=random.choice(s)+oldflag for i in range(random.randint(1,10)): oldflag=oldflag+random.choice(s) return oldflag with open('flag.txt'...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PBjar/2021/crypto/not_baby_fixed/script.py
ctfs/PBjar/2021/crypto/not_baby_fixed/script.py
from Crypto.Util.number import * with open('flag.txt','rb') as g: flag = g.read().strip() with open('nums.txt','r') as f: s=f.read().strip().split() a=int(s[0]) b=int(s[1]) c=int(s[2]) e=65537 n=a**3+b**3-34*c**3 m=bytes_to_long(flag) ct=pow(m,e,n) print ('n:',n) print ('e:',e) print ('ct:',ct)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PBjar/2021/crypto/leftovers/script.py
ctfs/PBjar/2021/crypto/leftovers/script.py
from random import * def gen(): mod=randint(10**9,10**10) while (mod%2==0): mod=randint(10**9,10**10) return mod mod=gen() small=mod while True: for i in range(2,int((mod+5)**(1/2))): if mod%i==0: small=i break if small!=mod: mod*=small break mod=gen() lst=[] for i in range(sm...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PBjar/2021/crypto/knapsack/knapsack.py
ctfs/PBjar/2021/crypto/knapsack/knapsack.py
from Crypto.Util.number import getPrime from sympy import nextprime from random import randint flag = open('./flag.txt', 'rb').read().strip() flagbits = bin(int.from_bytes(flag, 'big'))[2:] n, r = len(flagbits), getPrime(8) w = [randint(1, 69)] for i in range(1, n): w.append(randint(sum(w[:i]) + 1, w[-1] * r)) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PBjar/2021/crypto/MRSA/script.py
ctfs/PBjar/2021/crypto/MRSA/script.py
from Crypto.Util.number import * with open('flag.txt','rb') as f: flag = f.read().strip() e=65537 p=getPrime(256) q=getPrime(128) n=p*q m=bytes_to_long(flag) ct=pow(m,e,n) print ('n:',n) print ('e:',e) print ('ct:',ct) def enc(msg): print (p%msg) try: br="#" print (br*70) print ("Now here's the...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PBjar/2021/crypto/MRSA2/script.py
ctfs/PBjar/2021/crypto/MRSA2/script.py
from Crypto.Util.number import * with open('flag.txt','rb') as f: flag = f.read().strip() e=65537 p=getPrime(256) q=getPrime(256) n=p*q phi=(p-1)*(q-1) m=bytes_to_long(flag) d=pow(e,-1,phi) ct=pow(m,e,n) print ('n:',n) print ('e:',e) print ('ct:',ct) def enc(msg): print (d%msg) try: br="#" print (b...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AirOverflow/2024/misc/Ba_Sing_Se/ba-sing-se.py
ctfs/AirOverflow/2024/misc/Ba_Sing_Se/ba-sing-se.py
#!/usr/local/bin/python """ Purely aesthetics. """ colors = { "[BLACK]" : "\033[0;30m", "[RED]" : "\033[0;31m", "[GREEN]" : "\033[0;32m", "[BROWN]" : "\033[0;33m", "[BLUE]" : "\033[0;34m", "[PURPLE]" : "\033[0;35m", "[CYAN]" : "\033[0;36m", "[LIGHT_GRAY]" : "\033[0;37m", "[DARK_GRAY]" : "\033[1;30m", "[LIGHT...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AirOverflow/2024/crypto/Impurity/impurity.py
ctfs/AirOverflow/2024/crypto/Impurity/impurity.py
#!/usr/local/bin python3 from Crypto.Util.number import bytes_to_long, getPrime, long_to_bytes def get_key(): p = getPrime(512) q = getPrime(512) n = p * q e = 0x10001 phi = (p - 1) * (q - 1) return (e, n, phi) def encrypt(m, e, n): return pow(m, e, n) def encrypt_flag(flag, e, n): r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2023/misc/wow/src/main.py
ctfs/pingCTF/2023/misc/wow/src/main.py
import random import os FLAG = os.getenv("FLAG", "ping{FAKE}") random.seed(random.randint(0, 10_000_000)) opponent_balance = 10_000_000 user_balance = 50 round_num = 1 def print_balance(): print(f"{user_balance=}") print(f"{opponent_balance=}") def spacer(): print("-" * 64) def roll(n: int): re...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2023/misc/you_spin_me_round/src/main.py
ctfs/pingCTF/2023/misc/you_spin_me_round/src/main.py
import random import time from flag import FLAG from messages import hello, m_task1, m_task2, m_task3, m_correct, m_incorrect TIME_LIMIT_SEC = 10 def task1(n): x = random.randint(100, 10000) y = random.randint(1, 100) solution = x // y m_task1(x, solution, n) answer = int(input('Enter what should be under "?" ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2023/misc/you_spin_me_round/src/messages.py
ctfs/pingCTF/2023/misc/you_spin_me_round/src/messages.py
def beep(n: int): return (('BEEP ' * n).strip()) def boop(n: int): return (('BOOP ' * n).strip()) def m_correct(): print(''' CORRECT ''') def m_incorrect(wrong_solution, correct_solution, opt=None): print(f''' INCORRECT YOUR SOLUTION:\t{wrong_solution} CORRECT:\t\t{correct_solutio...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2023/misc/you_spin_me_round/src/flag.py
ctfs/pingCTF/2023/misc/you_spin_me_round/src/flag.py
import os FLAG = os.environ.get("FLAG", "flag{FAKE}")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2023/rev/python_rev_for_freaks/python_freak.py
ctfs/pingCTF/2023/rev/python_rev_for_freaks/python_freak.py
from base64 import b64decode exec(b64decode('ZXhlYyhiNjRkZWNvZGUoJ2FXMXdiM0owSUhONWN3cGxlR1ZqS0dJMk5HUmxZMjlrWlNnbldsaG9iRmw1YUdsT2FsSnJXbGRPZGxwSFZXOUtNazE2WWtod1RXSnJOWE5hUldoTFlrWnJlbFp1YkdwTmJYZ3lXVzB4TkdOSFNsaGlSRUpNVWtWV00xUlZVa0prTURGRVlUQjBZVmRIYUhOWFdHeHZZVlUxY1ZWdGRHRldNRFV5VjJ0a1ZtSXdiM2hqUm14b1VqTm9ZVnBXWkc...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2023/crypto/easy_rsa/main.py
ctfs/pingCTF/2023/crypto/easy_rsa/main.py
from Crypto.Util.number import getPrime from Crypto.Util.number import bytes_to_long p = getPrime(2048) q = getPrime(2048) n = p * q e = 65537 d = pow(e, -1, (p-1)*(q-1)) flag = open("flag.txt","rb").read() print(f"q & p = {q & p}") print(f"q & (p << 1) = {q & (p << 1)}") print(f"n = {n}") print(f"ct = {pow(bytes_to_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2023/crypto/shrek/src/shrek.py
ctfs/pingCTF/2023/crypto/shrek/src/shrek.py
import random class Shrek: def __init__(self): file = open("shrek.txt") self.parts = list(file.read().split()) alphabet = "" for part in self.parts: for letter in part: if not letter in alphabet: alphabet += letter self.alphab...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2023/crypto/shrek/src/main.py
ctfs/pingCTF/2023/crypto/shrek/src/main.py
import os from shrek import Shrek shrek = Shrek() FLAG = os.environ.get("FLAG", "ping{FAKE}") for i in range(10): plainText = shrek.generatePlainText() print(f'Ciphertext: {shrek.encrypt(plainText)}') guess = input('Can you guess plaintext?: ') if guess == plainText: print(f'Congratulations, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2023/crypto/lame_lame_loser/main.py
ctfs/pingCTF/2023/crypto/lame_lame_loser/main.py
from hashlib import sha256 from math import gcd from Crypto.Cipher import AES from Crypto.Util.Padding import pad from secret import FLAG, x, y, a, b out = open('out.txt', 'w') assert FLAG.startswith('ping{') assert FLAG.endswith('}') assert x*a + y*b == 0 assert a > 0 assert b > 0 assert x.bit_length() >= 1023 assert...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2023/web/double_secret/src/db.py
ctfs/pingCTF/2023/web/double_secret/src/db.py
import mysql.connector db = mysql.connector.connect( host="db", user="root", password="password", db="chall" )
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2023/web/double_secret/src/setup_db.py
ctfs/pingCTF/2023/web/double_secret/src/setup_db.py
import mysql.connector from secrets import token_hex import os secret = token_hex(12) mydb = mysql.connector.connect( host="db", user="root", password="password", ) mycursor = mydb.cursor() mycursor.execute("CREATE DATABASE chall") mycursor.execute("USE chall") mycursor.execute("CREATE TABLE secret (secret...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2023/web/double_secret/src/secret.py
ctfs/pingCTF/2023/web/double_secret/src/secret.py
import os from db import db cursor = db.cursor() cursor.execute("SELECT secret from secret") firstSecret = cursor.fetchone()[0] secondSecret = os.getenv('SECRET', 'TEST_SECRET') secret = secondSecret + firstSecret flag = os.getenv('FLAG', 'ping{FAKE}')
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2023/web/double_secret/src/app.py
ctfs/pingCTF/2023/web/double_secret/src/app.py
from flask import Flask, session, render_template, request, redirect, make_response from secret import secret, flag, firstSecret, secondSecret from db import db import os from hashlib import sha1 from flask_httpauth import HTTPBasicAuth app = Flask(__name__) ## INSTANCER CODE auth = HTTPBasicAuth() @auth.get_pass...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2025/pwn/tick_tock/secure_server.py
ctfs/pingCTF/2025/pwn/tick_tock/secure_server.py
from flask import Flask, request import subprocess as sp app = Flask(__name__) @app.route('/check', methods=['get']) def check(): flag = request.args.get('flag') if not flag: return "No flag given" # if not flag.isalnum() or "{" in flag or "}" in flag: for c in flag: if not c.isalnum() ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2025/pwn/tick_tock/gunicorn_config.py
ctfs/pingCTF/2025/pwn/tick_tock/gunicorn_config.py
import os workers = 8 threads = 4 bind ="0.0.0.0:8080" forwarded_allow_ips = "*" secure_scheme_headers = { "X-Forwarded-Proto": "https" }
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2022/pwn/storage_room/storage_room/_import.py
ctfs/pingCTF/2022/pwn/storage_room/storage_room/_import.py
from flask import Flask, request, redirect, session, render_template, g import re import secrets import sqlite3 import pickle import pickletools from db import db, append_buffer, get_buffer, is_printable, clear_buffer, register, login, set_buffer, is_using_special_buffer from messages import * from base64 import b64enc...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2022/pwn/storage_room/storage_room/db.py
ctfs/pingCTF/2022/pwn/storage_room/storage_room/db.py
import string from _import import g, sqlite3, pickle, pickletools import messages from app import app MAX_BUFFER_SIZE = 0xffff def db(): db = getattr(g, '_database', None) if db is None: db = g._database = sqlite3.connect('/tmp/db2.sqlite3') db.row_factory = sqlite3.Row return db def process_buffer(current_buf...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2022/pwn/storage_room/storage_room/messages.py
ctfs/pingCTF/2022/pwn/storage_room/storage_room/messages.py
class messages: bad_charactes = "Please respect the regex ^[a-z0-9]+$ case insensitive in any fields, as we don't trust noone here." bad_password = "Bad password" registered = "You have been registered as :u" logged = "You were logged in as :u" not_logged = "You are not logged in!" logged_out = "You are logged ou...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2022/pwn/storage_room/storage_room/PrivateBufferClass.py
ctfs/pingCTF/2022/pwn/storage_room/storage_room/PrivateBufferClass.py
class PrivateBufferClass: def __init__(self, size): self.__buffer = [None] * size self.__bufferSize = size self.__bufferIndex = 0 def add(self, data): if type(data) == str or type(data) == bytes: for i in range(len(data)): self.__buffer[self.__bufferIndex] = data[i] self.__bufferIndex += 1 if ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2022/pwn/storage_room/storage_room/app.py
ctfs/pingCTF/2022/pwn/storage_room/storage_room/app.py
from _import import * app = Flask(__name__) app.secret_key = secrets.token_hex(0o77) # Chain and buffer @app.get('/files') def files(): if 'username' in session: return render_template('files.html', logged_in=True) else: return render_template('index.html', message=messages.not_logged, logged_in=False) @app.po...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2022/rev/crypto/app.py
ctfs/pingCTF/2022/rev/crypto/app.py
from binascii import hexlify printable = [chr(i) for i in range(0, 0xff)] FLAG = open("flag.txt").readline().strip() class Flawless: rounds = [] def __init__(self, *rs): self.alphabet = printable self.rounds[:0] = rs[0] self.l = len(rs[0]) def move(self): for i in range(len(self.alphabet)): self.alph...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/pingCTF/2022/crypto/dialog/app.py
ctfs/pingCTF/2022/crypto/dialog/app.py
import base64 FLAG = open("flag.txt").readline().strip() class DialogEncryption: def __init__(self, key): self.key = key def encrypt(self, message): encoded = "" for i in range(len(message)): key_c = self.key[i % len(self.key)][::-1] encoded_c = chr((ord(message[i]) + ord(key_c)) % 256) encoded += e...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2024/misc/miku_ai/checker.py
ctfs/vsCTF/2024/misc/miku_ai/checker.py
''' Miku AI is designed to support both high-quality audio and stunning visualizations. To test its stability, you will be prompted with a random string and asked to upload an MP3. Server has several checks to ensure that the AI is working as expected. ''' import io import os import random import time import matplotli...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2023/misc/not_a_last_minute_pyjail/server.py
ctfs/vsCTF/2023/misc/not_a_last_minute_pyjail/server.py
#!/usr/local/bin/python # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2023/misc/OtterSec_Is_Cat/server.py
ctfs/vsCTF/2023/misc/OtterSec_Is_Cat/server.py
""" Model is trained by modifying https://github.com/elbow-jason/keras-examples/blob/master/mnist_cnn.py. This challenge is using [Cifar10](https://www.cs.toronto.edu/~kriz/cifar.html) dataset. """ print("System is starting...Might take a while :)") import os os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3" # disable tenso...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2023/misc/Babyfunge/chall.py
ctfs/vsCTF/2023/misc/Babyfunge/chall.py
from interpreter import befunge """ Befunge grid: [Line 1 input here] [Line 2 input here] [Line 3 input here] @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ vsctf{??????????????????????????????} """ unneeded_commands = "pg&~" # idk why anyone would need these FLAG = "vsctf{??????????????????????????????}" # real flag will ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2023/misc/Babyfunge/interpreter.py
ctfs/vsCTF/2023/misc/Babyfunge/interpreter.py
""" CREDIT: https://github.com/java-abhinav07/Befunge93_Interpreter """ import random class Stack: def __init__(self): self.items = [] def is_empty(self): return self.items == [] def push(self, data): self.items.append(data) def pop(self): if not self.is_empty(): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2023/crypto/Inexpensive/chall2.py
ctfs/vsCTF/2023/crypto/Inexpensive/chall2.py
from sage.all import * from flag import flag from Crypto.Util.Padding import pad from Crypto.Cipher import AES from random import SystemRandom random = SystemRandom() # Secp256k1 p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f a = 0 b = 7 E = EllipticCurve(GF(p), [a, b]) G = E.gens()[0] order = E...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2023/crypto/Inexpensive/flag.py
ctfs/vsCTF/2023/crypto/Inexpensive/flag.py
flag='FAKEFLAG'
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2023/crypto/Redundancy/chall1.py
ctfs/vsCTF/2023/crypto/Redundancy/chall1.py
from flag import flag from Crypto.Util.number import getPrime as gP e1, e2 = 5*2, 5*3 assert len(flag) < 16 flag = "Wow good job the flag is (omg hype hype): vsctf{"+flag+"}" p = gP(1024) q = gP(1024) n = p * q m = int.from_bytes(flag.encode(), 'big') c1 = pow(m, e1, n) c2 = pow(m, e2, n) print(f"n = {n}") 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/vsCTF/2023/crypto/Redundancy/flag.py
ctfs/vsCTF/2023/crypto/Redundancy/flag.py
flag='FAKEFLAG'
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2023/crypto/Share++/server.py
ctfs/vsCTF/2023/crypto/Share++/server.py
#!/usr/bin/env python3 from Crypto.Util.number import isPrime, getRandomRange, bytes_to_long from typing import List import os, signal class SecretSharing: def __init__(self, p: int, n: int, secret: int): self.p = p self.n = n self.poly = [secret] + [getRandomRange(0, self.p + 1) for _ in ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2022/crypto/Recovery/PassChecker2000.py
ctfs/vsCTF/2022/crypto/Recovery/PassChecker2000.py
# I coded this so that I wouldn't have to use a database! from random import randint from base64 import b64encode def validate(password: str) -> bool: if len(password) != 49: return False key = ['vs'.join(str(randint(7, 9)) for _ in range(ord(i))) + 'vs' for i in password[::-2]] gate = [118, 140,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2022/crypto/SecureGradingSystem/system.py
ctfs/vsCTF/2022/crypto/SecureGradingSystem/system.py
import string import sys import ecdsa import hashlib import random from time import time from base64 import b64encode from Crypto.Util.number import bytes_to_long, long_to_bytes, getPrime, size from secret import FLAG, get_report_content ''' Grading system documentation (for internal use ONLY) 1. The school's grader...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2022/crypto/ArtFinal/enhancer.py
ctfs/vsCTF/2022/crypto/ArtFinal/enhancer.py
# Teacher, please give me an A import random from PIL import Image boring = Image.open('Art_Final_2022.png', 'r').convert('RGBA') boring_pix = boring.load() spicy = Image.new('RGBA', boring.size) spicy_pix = spicy.load() # Add SPICE for i in range(boring.size[0] * boring.size[1]): x = i % boring.size[0] y =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2022/crypto/BabyRSA/chall.py
ctfs/vsCTF/2022/crypto/BabyRSA/chall.py
from Crypto.PublicKey import RSA from Crypto.Util.number import * from secret import e with open("flag.txt",'r') as f: flag = f.read().strip() p = getPrime(128) q = getPrime(128) while p % e != 1: p = getPrime(128) while q % e != 1: q = getPrime(128) n = p * q m = bytes_to_long(flag.encode()) c = pow(m,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2022/crypto/StrongestRSA/chall.py
ctfs/vsCTF/2022/crypto/StrongestRSA/chall.py
from Crypto.Util.number import getStrongPrime, bytes_to_long from sympy import prevprime, factorial from math import gcd import random from secret import FLAG e = 0x10001 def getStrongestPrime(nbits): while True: p = getStrongPrime(nbits) delta = random.randint(0x1337, 0x1337 + 0x1337) pp...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vsCTF/2022/crypto/NISTFinalistRevisited/ascon.py
ctfs/vsCTF/2022/crypto/NISTFinalistRevisited/ascon.py
#!/usr/bin/env python3 """ Implementation of Ascon hash function http://ascon.iaik.tugraz.at/ Round-Reduced Ascon-Hash adapted from https://github.com/meichlseder/pyascon/blob/master/ascon.py """ import json FLAG = "vsctf{REDACTED}" def ascon_xof(message): a = 2 b = 2 rate = 8 # bytes hashlength = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/rev/lambda_lambda/chall.py
ctfs/angstromCTF/2021/rev/lambda_lambda/chall.py
print((lambda LAMBDa: lambda LAMbDA: lambda LAMBda: lambda LAMbda: (lambda Lambda: ((lambda LAMBDA: Lambda(lambda LAMbda: LAMBDA(LAMBDA)(LAMbda)))(lambda LAMBDA: Lambda(lambda LAMbda: LAMBDA(LAMBDA)(LAMbda)))))(lambda Lambda: lambda lAMBDA: lambda lamBDA: (lambda lAmbda: lambda lAMbda: (lAMBDA if not lAmbda else Lambda...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/crypto/Relatively_Simple_Algorithm/rsa.py
ctfs/angstromCTF/2021/crypto/Relatively_Simple_Algorithm/rsa.py
from Crypto.Util.number import getStrongPrime f = [REDACTED] m = int.from_bytes(f,'big') p = getStrongPrime(512) q = getStrongPrime(512) n = p*q e = 65537 d = pow(e,-1,(p-1)*(q-1)) c = pow(m,e,n) print("n =",n) print("p =",p) print("q =",q) print("e =",e) print("c =",c)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/crypto/Im_so_Random/chall.py
ctfs/angstromCTF/2021/crypto/Im_so_Random/chall.py
import time import random import os class Generator(): DIGITS = 8 def __init__(self, seed): self.seed = seed assert(len(str(self.seed)) == self.DIGITS) def getNum(self): self.seed = int(str(self.seed**2).rjust(self.DIGITS*2, "0")[self.DIGITS//2:self.DIGITS + self.DIGITS//2]) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/crypto/Substitution/chall.py
ctfs/angstromCTF/2021/crypto/Substitution/chall.py
#!/usr/bin/python from functools import reduce with open("flag", "r") as f: key = [ord(x) for x in f.read().strip()] def substitute(value): return (reduce(lambda x, y: x*value+y, key))%691 print("Enter a number and it will be returned with our super secret synthetic substitution technique") while True: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/crypto/Keysar_v2/chall.py
ctfs/angstromCTF/2021/crypto/Keysar_v2/chall.py
import string with open("key.txt", "r") as f: shift = int(f.readline()) key = f.readline() with open("flag.txt", "r") as f: flag = f.read() stdalph = string.ascii_lowercase rkey = "" for i in key: if i not in rkey: rkey += i for i in stdalph: if i not in rkey: rkey += i rkey = r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/crypto/Cache_Money/cachemoney.py
ctfs/angstromCTF/2021/crypto/Cache_Money/cachemoney.py
import itertools from time import perf_counter_ns as timer from time import monotonic_ns as timestamp class Rijndael: sbox = bytes.fromhex( "637c777bf26b6fc53001672bfed7ab76ca82c97dfa5947f0add4a2af9ca472c0b7fd9326363ff7cc34a5e5f171d8311504c723c31896059a071280e2eb27b27509832c1a1b6e5aa0523bd6b329e32f8453d10...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/crypto/Home_Rolled_Crypto/chall.py
ctfs/angstromCTF/2021/crypto/Home_Rolled_Crypto/chall.py
#!/usr/bin/python import binascii from random import choice class Cipher: BLOCK_SIZE = 16 ROUNDS = 3 def __init__(self, key): assert(len(key) == self.BLOCK_SIZE*self.ROUNDS) self.key = key def __block_encrypt(self, block): enc = int.from_bytes(block, "big") for i in ran...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/crypto/Follow_the_Currents/source.py
ctfs/angstromCTF/2021/crypto/Follow_the_Currents/source.py
import os import zlib def keystream(): key = os.urandom(2) index = 0 while 1: index+=1 if index >= len(key): key += zlib.crc32(key).to_bytes(4,'big') yield key[index] ciphertext = [] with open("plain","rb") as f: plain = f.read() assert b"actf{" in plain k = keystream() for i in plain: ciphertext.appe...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/crypto/Oracle_of_Blair/server.py
ctfs/angstromCTF/2021/crypto/Oracle_of_Blair/server.py
from Crypto.Cipher import AES from Crypto.Util.Padding import pad import os key = os.urandom(32) flag = open("flag","rb").read() while 1: try: i = bytes.fromhex(input("give input: ")) if not i: break except: break iv = os.urandom(16) inp = i.replace(b"{}", flag) if len(inp) % 16: inp = pad(inp, 16) p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/crypto/Circle_of_Trust/gen.py
ctfs/angstromCTF/2021/crypto/Circle_of_Trust/gen.py
import random import secrets import math from decimal import Decimal, getcontext from Crypto.Cipher import AES BOUND = 2 ** 128 MULT = 10 ** 10 getcontext().prec = 50 def nums(a): b = Decimal(random.randint(-a * MULT, a * MULT)) / MULT c = (a ** 2 - b ** 2).sqrt() if random.randrange(2): c *= -1 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/web/Ekans/db.py
ctfs/angstromCTF/2021/web/Ekans/db.py
import pickle import base64 import io import os POKEMON = {id: (os.environ.get('FLAG', 'flag{TEST}') if id == 1337 else 'EKANS') for id in range(2000)} USERS = {'guest': 'guest', 'PokeMaster3000': os.environ.get('ADMIN_PASSWORD', '<secret>')} ADMINS = ['PokeMaster3000'] class User: admin = False def __init__(self,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/web/Ekans/ekans.py
ctfs/angstromCTF/2021/web/Ekans/ekans.py
from flask import Flask, request, redirect, make_response import importlib import pickle import base64 app = Flask(__name__) header = """<title>POKEDEX</title> <style> * { font-family: sans-serif } ul { padding: 0; display: flex; flex-wrap: wrap; list-style: none; justify-content: center; } li { height: 5em; w...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/web/Spoofy/app.py
ctfs/angstromCTF/2021/web/Spoofy/app.py
from flask import Flask, Response, request import os from typing import List FLAG: str = os.environ.get("FLAG") or "flag{fake_flag}" with open(__file__, "r") as f: SOURCE: str = f.read() app: Flask = Flask(__name__) def text_response(body: str, status: int = 200, **kwargs) -> Response: return Response(body,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/web/Reaction.py/server.py
ctfs/angstromCTF/2021/web/Reaction.py/server.py
from flask import escape, session, request, Flask, redirect from collections import Counter import uuid import string from functools import wraps from threading import Lock import subprocess import json import requests # exceptions bad results good OK = 1 ERR = 2 SAFECHARS = set(string.ascii_letters + string.digits +...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2021/web/Jar/jar.py
ctfs/angstromCTF/2021/web/Jar/jar.py
from flask import Flask, send_file, request, make_response, redirect import random import os app = Flask(__name__) import pickle import base64 flag = os.environ.get('FLAG', 'actf{FAKE_FLAG}') @app.route('/pickle.jpg') def bg(): return send_file('pickle.jpg') @app.route('/') def jar(): contents = request.cookies....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2018/crypto/Very_ez_cipher/feistel.py
ctfs/angstromCTF/2018/crypto/Very_ez_cipher/feistel.py
#!/usr/bin/python3 #key = 0xXXXXXXXXXXXXX size = len(bin(key)[2:]) def F(left, right, key): newR = (((right^key)>>3) + (((right^key)&7)<<(size//2-3))) ^ 0x3ffffff return (right, left^newR) def encrypt(block, key): key0 = key>>size//2 key1 = key & int('1'*(size//2),2) L = block>>size//2 R = blo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2018/crypto/Randomized_Cipher/great_cipher.py
ctfs/angstromCTF/2018/crypto/Randomized_Cipher/great_cipher.py
#!/usr/bin/python3 #key = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" import random def genPBox(): output = list(range(32)) while output == list(range(32)): random.shuffle(output) return output def genSBox(): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/angstromCTF/2018/crypto/ofb/encrypt.py
ctfs/angstromCTF/2018/crypto/ofb/encrypt.py
import struct def lcg(m, a, c, x): return (a*x + c) % m m = pow(2, 32) with open('lcg') as f: a = int(f.readline()) c = int(f.readline()) x = int(f.readline()) d = open('flag.png').read() d += '\x00' * (-len(d) % 4) d = [d[i:i+4] for i in range(0, len(d), 4)] e = '' for i in range(len(d)): e += struct.pack('>...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false