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/DownUnderCTF/2023/crypto/hhhhh/hhhhh.py
ctfs/DownUnderCTF/2023/crypto/hhhhh/hhhhh.py
#!/usr/bin/env python3 from os import getenv as hhhhhhh from hashlib import md5 as hhhhh def hhhhhh(hhh): h = hhhhh() hh = bytes([0] * 16) for hhhh in hhh: h.update(bytes([hhhh])) hh = bytes([hhhhhhh ^ hhhhhhhh for hhhhhhh, hhhhhhhh in zip(hh, h.digest())]) return hh print('hhh hhh hhhh hhh hhhhh hhhh hhhh hhhhh hhhh hh hhhhhh hhhh?') h = bytes.fromhex(input('h: ')) if hhhhhh(h) == b'hhhhhhhhhhhhhhhh': print('hhhh hhhh, hhhh hh hhhh hhhh:', hhhhhhh('FLAG')) else: print('hhhhh, hhh hhhhh!')
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/complementary/complementary.py
ctfs/DownUnderCTF/2023/crypto/complementary/complementary.py
flag = open('./flag.txt', 'rb').read().strip() m1 = int.from_bytes(flag[:len(flag)//2]) m2 = int.from_bytes(flag[len(flag)//2:]) n = m1 * m2 print(n)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/apbq_rsa_ii/apbq-rsa-ii.py
ctfs/DownUnderCTF/2023/crypto/apbq_rsa_ii/apbq-rsa-ii.py
from Crypto.Util.number import getPrime, bytes_to_long from random import randint p = getPrime(1024) q = getPrime(1024) n = p * q e = 0x10001 hints = [] for _ in range(3): a, b = randint(0, 2**312), randint(0, 2**312) hints.append(a * p + b * q) FLAG = open('flag.txt', 'rb').read().strip() c = pow(bytes_to_long(FLAG), e, n) print(f'{n = }') print(f'{c = }') print(f'{hints = }')
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/encrypted_mail/crypto.py
ctfs/DownUnderCTF/2023/crypto/encrypted_mail/crypto.py
import hashlib, secrets, random from gmpy2 import powmod # faster than pow() pow = lambda a, b, c: int(powmod(a, b, c)) g = 3 p = 1467036926602756933667493250084962071646332827366282684436836892199877831990586034135575089582195051935063743076951101438328248410785708278030691147763296367303874712247063207281890660681715036187155115101762255732327814001244715367 class Authenticator: def __init__(self, pubkey): self.y = pubkey def generate_challenges(self, n=128): challenges = [] answers = [] for _ in range(n): b = round(random.random()) r = random.getrandbits(p.bit_length()) c = random.getrandbits(p.bit_length()) c1 = pow(g, r, p) if b == 0: c2 = pow(g, c, p) elif b == 1: c2 = pow(self.y, r, p) answers.append(b) challenges.append((int(c1), int(c2))) self.answers = answers return challenges def verify_answers(self, answers): return len(answers) == len(self.answers) and all(a == b for a, b in zip(answers, self.answers)) class Cipher: def __init__(self, key): self.n = 4 self.idx = self.n self.state = [(key >> (32 * i)) & 0xffffffff for i in range(self.n)] def next(self): if self.idx == self.n: for i in range(self.n): x = self.state[i] v = x >> 1 if x >> 31: v ^= 0xa9b91cc3 if x & 1: v ^= 0x38ab48ef self.state[i] = v ^ self.state[(i + 3) % self.n] self.idx = 0 v = self.state[self.idx] x0, x1, x2, x3, x4 = (v >> 31) & 1, (v >> 24) & 1, (v >> 18) & 1, (v >> 14) & 1, v & 1 y = x0 + x1 + x2 + x3 + x4 self.idx += 1 return y & 1 def next_byte(self): return int(''.join([str(self.next()) for _ in range(8)]), 2) def xor(self, A, B): return bytes([a ^ b for a, b in zip(A, B)]) def encrypt(self, message): return self.xor(message, [self.next_byte() for _ in message]) def decrypt(self, ciphertext): return self.xor(ciphertext, [self.next_byte() for _ in ciphertext]) class Encryptor: def __init__(self, public_key): self.public_key = public_key def encrypt(self, m): r = secrets.randbelow(p) c1 = pow(g, r, p) c2 = pow(self.public_key, r, p) * m % p return (c1, c2) class Decryptor: def __init__(self, private_key): self.private_key = private_key def decrypt(self, ct): assert self.private_key is not None c1, c2 = ct m = c2 * pow(c1, -self.private_key, p) % p return m class Signer: def __init__(self, private_key): self.private_key = private_key def hash(self, m): return int(hashlib.sha256(m).hexdigest(), 16) def sign(self, msg): k = secrets.randbelow(p-1) | 1 r = pow(g, k, p) s = (self.hash(msg) - self.private_key * r) * pow(k, -1, p - 1) % (p - 1) return (r, s) class Verifier: def __init__(self, public_key): self.public_key = public_key def hash(self, m): return int(hashlib.sha256(m).hexdigest(), 16) def verify(self, msg, sig): r, s = sig if not (0 < r < p and 0 < s < p - 1): return False return pow(g, self.hash(msg), p) == pow(self.public_key, r, p) * pow(r, s, p) % p class Messenger: def __init__(self, private_key): self.private_key = private_key def send(self, recipient_public_key, message): key = secrets.randbelow(2**128) key_enc = Encryptor(recipient_public_key).encrypt(key) key_enc = key_enc[0].to_bytes(96, 'big') + key_enc[1].to_bytes(96, 'big') ct = Cipher(key).encrypt(message) sig = Signer(self.private_key).sign(ct) return (key_enc + ct, sig) def receive(self, sender_public_key, ciphertext, sig): if len(ciphertext) < 192: return False key_enc, ct = ciphertext[:192], ciphertext[192:] if not Verifier(sender_public_key).verify(ct, sig): return False key_enc0, key_enc1 = int.from_bytes(key_enc[:96], 'big'), int.from_bytes(key_enc[96:192], 'big') key = Decryptor(self.private_key).decrypt((key_enc0, key_enc1)) message = Cipher(key).decrypt(ct) return message
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/encrypted_mail/bot_users.py
ctfs/DownUnderCTF/2023/crypto/encrypted_mail/bot_users.py
from crypto import g, p, Messenger from secrets import randbelow import os class Bots: def __init__(self, db): self.db = db def setup(self): self.admin_privkey = randbelow(p) self.flag_haver_privkey = randbelow(p) self.admin_pubkey = pow(g, self.admin_privkey, p) self.flag_haver_pubkey = pow(g, self.flag_haver_privkey, p) self.db.add_user('admin', self.admin_pubkey) self.db.add_user('flag_haver', self.flag_haver_pubkey) def send_welcome_message(self, target_user): target_user_pubkey = self.db.get_user_pubkey(target_user) msg_enc, sig = Messenger(self.admin_privkey).send(target_user_pubkey, f'Welcome {target_user}!'.encode()) self.db.add_message('admin', target_user, msg_enc, sig) def receive_flag_message(self, msg): sender, _, msg_enc, sig = msg sender_pubkey = self.db.get_user_pubkey(sender) msg = Messenger(self.flag_haver_privkey).receive(sender_pubkey, msg_enc, sig) if not msg or sender != 'admin': return if msg.startswith(b'Send flag to '): user = msg[13:].decode() if not self.db.user_exists(user): return user_pubkey = self.db.get_user_pubkey(user) FLAG = open(os.path.join(os.path.dirname(__file__), 'flag.txt'), 'r').read() msg_enc, sig = Messenger(self.flag_haver_privkey).send(user_pubkey, f'Here is the flag: {FLAG}'.encode()) self.db.add_message('flag_haver', user, msg_enc, sig) def perform_bot_user_actions(self): for user in self.db.users: if user not in ['flag_haver', 'admin'] and len(self.db.get_inbox(user)) == 0: self.send_welcome_message(user) for msg in self.db.get_inbox('flag_haver'): self.receive_flag_message(msg) self.db.clear_inbox('flag_haver')
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/encrypted_mail/db.py
ctfs/DownUnderCTF/2023/crypto/encrypted_mail/db.py
from collections import defaultdict from time import time class Database: def __init__(self): self.users = {} self.inboxes = defaultdict(list) self.current_user = None def add_user(self, username, pubkey): self.users[username] = pubkey def user_exists(self, username): return username in self.users def get_user_pubkey(self, username): return self.users[username] def set_current_user(self, username): self.current_user = username def get_current_user(self): return self.current_user def get_inbox(self, username): return self.inboxes[username] def clear_inbox(self, username): self.inboxes[username] = [] def add_message(self, sender, recipient, msg_enc, sig): self.inboxes[recipient].append((sender, int(time()), msg_enc, sig))
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/encrypted_mail/server.py
ctfs/DownUnderCTF/2023/crypto/encrypted_mail/server.py
#!/usr/bin/env python3 from collections import defaultdict import os, time, re from db import Database from bot_users import Bots from crypto import Authenticator, Encryptor, p def menu(): print('[R]egister') print('[L]ogin') print('[S]end message') print('[V]iew inbox') return input('> ')[0].lower() def register(db): username = input('Username: ') if db.user_exists(username): print('User already exists with that username!') return if not re.fullmatch(r'[a-zA-Z0-9]{8,16}', username): print('Invalid username!') return pubkey = int(input('Public key: ')) if not (1 < pubkey < p - 1): print('Invalid public key!') return db.add_user(username, pubkey) print('Registration successful!') def login(db): username = input('Username: ') if not db.user_exists(username): print('Unknown user!') return auth = Authenticator(db.get_user_pubkey(username)) challenges = auth.generate_challenges() print(challenges) answers = list(map(int, input('Answers: ').split())) if not auth.verify_answers(answers): print('Authentication failed!') return print('Login successful!') db.set_current_user(username) def send_message(db): user = db.get_current_user() if user is None: print('Log in first!') return recipient = input('Recipient user: ') if not db.user_exists(recipient): print('Unknown recipient!') return print('Recipient public key:', db.get_user_pubkey(recipient)) msg_enc = bytes.fromhex(input('Encrypted message: ')) sig = list(map(int, input('Signature: ').split())) if len(sig) != 2: print('Invalid signature!') return db.add_message(user, recipient, msg_enc, sig) print('Message sent!') def view_inbox(db): user = db.get_current_user() if user is None: print('Log in first!') return inbox = db.get_inbox(user) if len(inbox) == 0: print('Inbox is empty!') else: print(f'You have {len(inbox)} messages!') for i, (sender, timestamp, msg_enc, sig) in enumerate(inbox): print(f'Message #{i+1} from {sender} at {timestamp}') print(msg_enc.hex()) print(sig) print() def main(): db = Database() bots = Bots(db) bots.setup() while True: choice = menu() { 'r': register, 'l': login, 's': send_message, 'v': view_inbox }[choice](db) bots.perform_bot_user_actions() if __name__ == '__main__': main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/handshake/generate.py
ctfs/DownUnderCTF/2023/crypto/handshake/generate.py
from Crypto.PublicKey import ECC from Crypto.Signature import DSS from Crypto.Hash import SHA256 def get_signed_certificate(subject_name, pubkey, ca_privkey): signer = DSS.new(ca_privkey, 'fips-186-3') tbs = f'SUBJECT={subject_name}\n{pubkey.export_key(format="PEM")}' signature = signer.sign(SHA256.new(tbs.encode())) cert = f'{tbs}\n{signature.hex()}' return cert ca_privkey = ECC.generate(curve='p256') server_privkey = ECC.generate(curve='p256') admin_privkey = ECC.generate(curve='p256') you_privkey = ECC.generate(curve='p256') open('public/ca-pubkey.pem', 'w').write(ca_privkey.public_key().export_key(format='PEM')) open('private/server-privkey.pem', 'w').write(server_privkey.export_key(format='PEM')) open('public/server-pubkey.pem', 'w').write(server_privkey.public_key().export_key(format='PEM')) open('public/you-privkey.pem', 'w').write(you_privkey.export_key(format='PEM')) you_crt = get_signed_certificate('you', you_privkey.public_key(), ca_privkey) admin_crt = get_signed_certificate('admin', admin_privkey.public_key(), ca_privkey) open('public/you.cert', 'w').write(you_crt) open('public/admin.cert', 'w').write(admin_crt)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/handshake/server.py
ctfs/DownUnderCTF/2023/crypto/handshake/server.py
#!/usr/bin/env python3 from Crypto.PublicKey import ECC from Crypto.Signature import DSS from Crypto.Protocol.KDF import HKDF from Crypto.Hash import SHA256 from Crypto.Cipher import AES from Crypto.Util.Padding import pad from Crypto.Util.number import long_to_bytes import os cwd = os.path.dirname(__file__) ca_pubkey = ECC.import_key(open(os.path.join(cwd, 'public/ca-pubkey.pem'), 'r').read()) server_privkey = ECC.import_key(open(os.path.join(cwd, 'private/server-privkey.pem'), 'r').read()) print('Hello client!') print(server_privkey.public_key().export_key(format='PEM')) print('Please provide your certificate:') try: subject_line = input() assert subject_line.startswith('SUBJECT=') subject = subject_line[8:] client_pubkey_pem = '\n'.join(input() for _ in range(4)) client_pubkey = ECC.import_key(client_pubkey_pem) signature_hex = input() tbs = f'{subject_line}\n{client_pubkey_pem}' verifier = DSS.new(ca_pubkey, 'fips-186-3') verifier.verify(SHA256.new(tbs.encode()), bytes.fromhex(signature_hex)) except: print('Bad certificate') exit(-1) shared_secret = (server_privkey.d * client_pubkey.pointQ).x shared_secret = long_to_bytes(shared_secret) client_nonce = bytes.fromhex(input('Client nonce: ')) if not client_nonce: print('Invalid client nonce') exit(-1) server_nonce = os.urandom(16) print('Server nonce:', server_nonce.hex()) shared_nonce = SHA256.new(client_nonce + shared_secret + server_nonce).digest() print('Shared nonce:', shared_nonce.hex()) derived_key = HKDF(shared_secret + client_nonce + server_nonce + shared_nonce, 32, salt=b'DUCTF-2023', hashmod=SHA256) aes = AES.new(derived_key, AES.MODE_ECB) msg = f'Hello {subject}, it\'s nice to meet you.' if subject == 'admin': flag = open(os.path.join(cwd, 'flag.txt'), 'r').read() msg += f' Here is your flag: {flag}' print(aes.encrypt(pad(msg.encode(), 16)).hex())
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/fnv/fnv.py
ctfs/DownUnderCTF/2023/crypto/fnv/fnv.py
#!/usr/bin/env python3 import os def fnv1(s): h = 0xcbf29ce484222325 for b in s: h *= 0x00000100000001b3 h &= 0xffffffffffffffff h ^= b return h TARGET = 0x1337133713371337 print("Welcome to FNV!") print(f"Please enter a string in hex that hashes to 0x{TARGET:016x}:") s = bytearray.fromhex(input()) if fnv1(s) == TARGET: print('Well done!') print(os.getenv('FLAG')) else: print('Try again... :(')
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/flag_art/flag-art.py
ctfs/DownUnderCTF/2023/crypto/flag_art/flag-art.py
message = open('./message.txt', 'rb').read() + open('./flag.txt', 'rb').read() palette = '.=w-o^*' template = list(open('./mask.txt', 'r').read()) canvas = '' for c in message: for m in [2, 3, 5, 7]: while True: t = template.pop(0) if t == 'X': canvas += palette[c % m] break else: canvas += t print(canvas)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/apbq_rsa_i/apbq-rsa-i.py
ctfs/DownUnderCTF/2023/crypto/apbq_rsa_i/apbq-rsa-i.py
from Crypto.Util.number import getPrime, bytes_to_long from random import randint p = getPrime(1024) q = getPrime(1024) n = p * q e = 0x10001 hints = [] for _ in range(2): a, b = randint(0, 2**12), randint(0, 2**312) hints.append(a * p + b * q) FLAG = open('flag.txt', 'rb').read().strip() c = pow(bytes_to_long(FLAG), e, n) print(f'{n = }') print(f'{c = }') print(f'{hints = }')
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/randomly_chosen/randomly-chosen.py
ctfs/DownUnderCTF/2023/crypto/randomly_chosen/randomly-chosen.py
import random random.seed(random.randrange(0, 1337)) flag = open('./flag.txt', 'r').read().strip() out = ''.join(random.choices(flag, k=len(flag)*5)) print(out)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/crossed_monkes/monkestorage/main.py
ctfs/DownUnderCTF/2023/web/crossed_monkes/monkestorage/main.py
from flask import Flask, request, render_template, send_from_directory, abort, redirect, session from functools import wraps from werkzeug.security import safe_join from werkzeug.utils import secure_filename from pymongo import MongoClient from bson.objectid import ObjectId from datetime import datetime from cairosvg import svg2png import mimetypes import os import re from config import * app = Flask(__name__, static_folder='static/', static_url_path='/') app.secret_key = os.urandom(128) mongodb_client = MongoClient( MONGODB_CONFIG['host'], MONGODB_CONFIG['port'], username=MONGODB_CONFIG['username'], password=MONGODB_CONFIG['password'] ) files_collection = mongodb_client[MONGODB_CONFIG['database']][MONGODB_CONFIG['collection']] def validate_key(key: str) -> bool: if not type(key) is str: return False return bool(re.match(r"^[a-f0-9]{24}$", key)) def convert_svg2png(filename: str): new_filename = os.path.splitext(filename)[0] + ".png" file_path = safe_join(STORAGE_PATH, filename) new_path = safe_join(STORAGE_PATH, new_filename) try: svg2png( url=file_path, write_to=new_path, parent_height=1024, parent_width=1024 ) finally: os.remove(file_path) return new_filename def save_entry(share_key, filename, uploaded_file, published=False): file_path = safe_join(STORAGE_PATH, filename) uploaded_file.save(file_path) file_mimetype = mimetypes.guess_type(file_path)[0] if not file_mimetype in ALLOWED_MIME_TYPES: os.remove(file_path) raise Exception('Invalid MIME type') created_time = datetime.now().isoformat() return files_collection.insert_one({ 'share_key': share_key, 'filename': filename, 'created': created_time, 'updated': created_time, 'published': published, 'cleanup_id': session.get('cleanup_id'), 'search_id': None }) def get_entry(share_key, file_id): return files_collection.find_one({'_id': ObjectId(file_id), 'share_key': share_key}) def get_entries(share_key, published=True, search=None): if not validate_key(share_key): return [] if not type(search) is str: return files_collection.find({'share_key': share_key, 'published': published}) return files_collection.find({ 'share_key': share_key, 'published': published, '$or': [ {'filename': {'$regex': search}}, {'search_id': {'$regex': search}} ] }) def update_entry(share_key, file_id: str, **kwargs): if not get_entry(share_key, file_id): return files_collection.update_one( {'_id': ObjectId(file_id)}, {'$set': {**kwargs, 'updated': datetime.now().isoformat()}} ) def delete_entry(file_id): entry = files_collection.find({'_id': ObjectId(file_id)}) files_collection.delete_one({'_id': ObjectId(file_id)}) filename = entry['filename'] filepath = safe_join(STORAGE_PATH, filename) os.remove(filepath) def publish_entry(share_key, file_id): update_entry(share_key, file_id, published=True, search_id=str(file_id)) def require_auth(f): @wraps(f) def decorated_function(*args, **kwargs): if not session.get('logged_in', False): return redirect('/login') return f(*args, **kwargs) return decorated_function @app.route('/login', methods=['GET', 'POST']) def login(): if request.method == 'GET': return render_template('login.html') username = request.form.get('username', None) password = request.form.get('password', None) cleanup_id = request.form.get('cleanup_id', '') if username is None or password is None: return render_template('error.html', msg='Bruh have you ever seen a login page before?') if username == ADMIN_USERNAME and password == ADMIN_PASSWORD: session['logged_in'] = True session['cleanup_id'] = cleanup_id return redirect('/') return render_template('error.html', msg='Lol not a valid cred. Only monke admins allowed!') @app.route('/', methods=['GET']) @require_auth def index(): return render_template('index.html', share_key=os.urandom(12).hex()) @app.route('/upload', methods=['POST']) @require_auth def upload(): uploaded_file = request.files.get('file', None) share_key = request.form.get('share_key', None) if uploaded_file is None or share_key is None: return render_template('error.html', msg="Apes don't forget to send parameters!") if not validate_key(share_key): return render_template('error.html', msg='Even monkes can whack 24 hexadecimal characters into an input box!') share_key = secure_filename(share_key) os.makedirs(os.path.join(STORAGE_PATH, share_key), exist_ok=True) filename = secure_filename(f"{os.urandom(4).hex()}-{uploaded_file.filename}") if filename == '': return render_template('error.html', msg='Ya monke! Do you know how to name a file?') filename = os.path.join(share_key, filename) file_ext = os.path.splitext(filename)[1] if not file_ext in ALLOWED_FILE_TYPES: return render_template('error.html', msg="I throw my poop at a pedestrian each time you don't upload an image") try: saved_entry_id = save_entry(share_key, filename, uploaded_file).inserted_id except Exception as _e: return render_template('error.html', msg="I throw my poop at a pedestrian each time you don't upload an image") if file_ext == '.svg': try: filename = convert_svg2png(filename) except Exception as _e: delete_entry(saved_entry_id) return render_template('error.html', msg='What the heck mate?!? That SVG was scuffed!') update_entry(share_key, saved_entry_id, filename=filename) publish_entry(share_key, saved_entry_id) return render_template('result.html', link=f'/view/{share_key}/{saved_entry_id}') @app.route('/flag', methods=['GET']) @require_auth def flag(): return render_template('flag.html', flag=FLAG) @app.route('/cleanup', methods=['GET']) @require_auth def cleanup(): cleanup_id = session.get('cleanup_id') entries = files_collection.find({'cleanup_id': cleanup_id}) files_collection.delete_many({'cleanup_id': cleanup_id}) total_entries = 0 for entry in entries: filename = entry['filename'] filepath = safe_join(STORAGE_PATH, filename) os.remove(filepath) total_entries += 1 if total_entries > 0: os.removedirs(safe_join(STORAGE_PATH, entries[0]['share_key'])) return "Done" @app.route('/view/<string:share_key>', methods=['GET']) def view_folder(share_key): if not validate_key(share_key): return render_template('error.html', msg='Even monkes can whack 24 hexadecimal characters into an input box!') search = request.args.get('search', None) redirect_to = request.args.get('redirect_to', False) entries = get_entries(share_key, search=search) if redirect_to: try: entry_id = entries[0]['_id'] except Exception as e: return abort(404) return redirect(f'/view/{share_key}/{entry_id}') return render_template('view.html', files=entries) @app.route('/view/<string:share_key>/<string:file_id>', methods=['GET']) def view(share_key: str, file_id: str): if not validate_key(file_id) or not validate_key(share_key): return abort(404) file_entry = get_entry(share_key, file_id) if file_entry is None: return abort(404) basename = os.path.basename(file_entry['filename']) resp = send_from_directory(safe_join(STORAGE_PATH, share_key), basename) return resp if __name__ == "__main__": app.run(host='0.0.0.0', port=3000)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/crossed_monkes/monkestorage/config.py
ctfs/DownUnderCTF/2023/web/crossed_monkes/monkestorage/config.py
import os STORAGE_PATH='/storage' ALLOWED_FILE_TYPES = ['.jpeg', '.jpg', '.svg', '.png', '.gif'] ALLOWED_MIME_TYPES = [ 'image/jpeg', 'image/jpg', 'image/svg+xml', 'image/png', 'image/gif' ] MONGODB_CONFIG = { 'host': 'mongodb', 'port': 27017, 'username': 'monkeuser', 'password': 'gonnawhackmykeyboardasi)!@sdjSJED121', 'database': 'monkeyfsdb', 'collection': 'files' } FLAG = os.environ.get('FLAG', 'FAKE{monk3s_get_the_flag_on_the_challenge_server}') ADMIN_USERNAME = os.environ.get('ADMIN_USERNAME', 'monkeadmin') ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', 'password123')
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/crossed_monkes/monkebot/main.py
ctfs/DownUnderCTF/2023/web/crossed_monkes/monkebot/main.py
from flask import Flask, render_template, request import urllib.parse as urlparse import monkebot import threading app = Flask(__name__, static_folder='static/', static_url_path='/') threading.Thread(target=monkebot.monke_worker, daemon=True).start() @app.route("/", methods=["GET"]) def index(): return render_template("index.html") @app.route("/sendmonkebot", methods=["POST"]) def send_monke_bot(): url = request.form.get('url', None) if url is None: return render_template("index.html", error="No URL was sent!") url_parsed = urlparse.urlparse(url) if not url_parsed.scheme in ['http', 'https']: return render_template("index.html", error="Lol trying to be sneaky with different protocols!") monkebot.monke_queue.put((url,)) return render_template("index.html", msg="The monke has been sent to wreck your site!") if __name__ == "__main__": app.run(host="0.0.0.0", port=1337)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/crossed_monkes/monkebot/monkebot.py
ctfs/DownUnderCTF/2023/web/crossed_monkes/monkebot/monkebot.py
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC import logging, os, time from queue import Queue monke_queue = Queue(maxsize=5) monkestorage_host = os.environ.get("MONKESTORAGE_HOST", "http://monkestorage:3000") logging.basicConfig(level=logging.INFO) BUTTON_CLICK_TIMEOUT = 5 MAX_VISIT_TIME = 60 WAIT_ITERATIONS = MAX_VISIT_TIME // BUTTON_CLICK_TIMEOUT # if monke see tab then switch # but if monke sees too many tabs then no. # too lazy they will go eat banana MAX_TAB_SWITCH = 1 def get_driver() -> webdriver.Chrome: chrome_args = [ '--headless', '--no-sandbox', '--disable-dev-shm-usage', '--disable-background-networking', '--disable-default-apps', '--disable-extensions', '--disable-gpu', '--disable-sync', '--disable-translate', '--hide-scrollbars', '--metrics-recording-only', '--mute-audio', '--no-first-run', '--safebrowsing-disable-auto-update', '--js-flags=--noexpose_wasm,--jitless', '--disable-web-security' ] chrome_options = webdriver.ChromeOptions() for arg in chrome_args: chrome_options.add_argument(arg) return webdriver.Chrome(options=chrome_options) def login(driver: webdriver.Chrome, cleanup_id: str) -> webdriver.Chrome: driver.get(monkestorage_host) time.sleep(1) logging.info("logging into website") user_input = driver.find_element(By.ID, "username") user_input.send_keys(os.environ['ADMIN_USERNAME']) pass_input = driver.find_element(By.ID, "password") pass_input.send_keys(os.environ['ADMIN_PASSWORD']) # Needed to add in cleanup script ID driver.execute_script("document.getElementById('cleanup_id').removeAttribute('hidden')") cleanup_input = driver.find_element(By.ID, "cleanup_id") cleanup_input.send_keys(cleanup_id) submit_button = driver.find_element(By.ID, 'submit-login') submit_button.click() time.sleep(1) return driver def cleanup(cleanup_id: str): driver = None try: logging.info("cleaning up monke mess") driver = get_driver() driver = login(driver, cleanup_id) driver.get(f"{monkestorage_host}/cleanup?cleanup_id={cleanup_id}") time.sleep(5) finally: if not driver is None: driver.quit() logging.info("done cleaning") def visit_url(url: str, cleanup_id: str): total_tab_switch = 0 driver = None try: logging.info("initiating monkebot") driver = get_driver() driver = login(driver, cleanup_id) logging.info('visiting {}'.format(url)) driver.get(url) for _i in range(WAIT_ITERATIONS): try: WebDriverWait(driver, BUTTON_CLICK_TIMEOUT).until( EC.presence_of_element_located((By.TAG_NAME, "button")) ) button_element = driver.find_element(By.TAG_NAME, "button") # Monke see button, monke click button button_element.click() except Exception as e: pass if total_tab_switch < MAX_TAB_SWITCH and len(driver.window_handles) > 1: driver.switch_to.window(driver.window_handles[1]) total_tab_switch += 1 except Exception as _e: pass finally: if not driver is None: driver.quit() logging.info("done") def send_the_monke(url): cleanup_id = os.urandom(16).hex() visit_url(url, cleanup_id) cleanup(cleanup_id) def monke_worker(): while True: try: url = monke_queue.get()[0] send_the_monke(url) except Exception as e: logging.error(e) # Only process 1 URL every minute time.sleep(60)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/0day_blog/adminbot/adminbot.py
ctfs/DownUnderCTF/2023/web/0day_blog/adminbot/adminbot.py
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.service import Service import logging, os, time from queue import Queue USERNAME = "ghostccamm" # Password is different on challenge instance PASSWORD = "hmmmm idk what would be good for a passw0rd..." DRUPAL_HOST = os.environ["DRUPAL_HOST"] admin_queue = Queue(maxsize=5) logging.basicConfig(level=logging.INFO) def get_driver() -> webdriver.Chrome: service = Service(executable_path='/usr/bin/chromedriver') chrome_args = [ '--headless', '--incognito' ] chrome_options = webdriver.ChromeOptions() for arg in chrome_args: chrome_options.add_argument(arg) return webdriver.Chrome(service=service, options=chrome_options) def login(driver: webdriver.Chrome) -> webdriver.Chrome: driver.get(f"{DRUPAL_HOST}/user/login") time.sleep(1) logging.info("logging into website") user_input = driver.find_element(By.ID, "edit-name") user_input.send_keys(USERNAME) pass_input = driver.find_element(By.ID, "edit-pass") pass_input.send_keys(PASSWORD) submit_button = driver.find_element(By.ID, 'edit-submit') submit_button.click() time.sleep(5) return driver def timeout_handler(): raise Exception('Timeout!') def visit_url(url: str): driver = None try: logging.info("initiating adminbot") driver = get_driver() driver = login(driver) logging.info('visiting {}'.format(url)) driver.get(url) time.sleep(10) except Exception as _e: pass finally: if not driver is None: driver.quit() logging.info("done") def send_the_admin(url): visit_url(url) def worker(): while True: try: url = admin_queue.get()[0] send_the_admin(url) except Exception as e: logging.error(e) # Only process 1 URL every minute time.sleep(60)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/0day_blog/adminbot/main.py
ctfs/DownUnderCTF/2023/web/0day_blog/adminbot/main.py
from flask import Flask, render_template, request import urllib.parse as urlparse import adminbot import threading app = Flask(__name__, static_folder='static/', static_url_path='/') threading.Thread(target=adminbot.worker, daemon=True).start() @app.route("/", methods=["GET"]) def index(): return render_template("index.html") @app.route("/sendadminbot", methods=["POST"]) def send_admin_bot(): url = request.form.get('url', None) if url is None: return render_template("index.html", error="No URL was sent!") url_parsed = urlparse.urlparse(url) if not url_parsed.scheme in ['http', 'https']: return render_template("index.html", error="Lol trying to be sneaky with different protocols!") adminbot.admin_queue.put((url,)) return render_template("index.html", msg="The admin has been sent to your site! Hope you aren't trying to hack them!") if __name__ == "__main__": app.run(host="0.0.0.0", port=1337)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/grades_grades_grades/run.py
ctfs/DownUnderCTF/2023/web/grades_grades_grades/run.py
from src import create_app app = create_app() if __name__ == '__main__': app.run(host='0.0.0.0', debug=False)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/grades_grades_grades/src/__init__.py
ctfs/DownUnderCTF/2023/web/grades_grades_grades/src/__init__.py
from flask import Flask from src.routes import api from src import auth def create_app(): app = Flask(__name__) app.auth = auth app.register_blueprint(api) return app
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/grades_grades_grades/src/routes.py
ctfs/DownUnderCTF/2023/web/grades_grades_grades/src/routes.py
from flask import request, jsonify, Blueprint, current_app, make_response, render_template, redirect, url_for from src.auth import requires_token, is_authenticated, token_value, requires_teacher, is_teacher_role import random api = Blueprint('api', __name__) def ran_g(): grades = ['A', 'B', 'C', 'D', 'E', 'F'] return random.choice(grades) @api.route('/') def index(): if is_teacher_role(): return render_template('public.html', is_auth=True, is_teacher_role=True) elif is_authenticated(): return render_template('public.html', is_auth=True) return render_template('public.html') @api.route('/signup', methods=('POST', 'GET')) def signup(): # make sure user isn't authenticated if is_teacher_role(): return render_template('public.html', is_auth=True, is_teacher_role=True) elif is_authenticated(): return render_template('public.html', is_auth=True) # get form data if request.method == 'POST': jwt_data = request.form.to_dict() jwt_cookie = current_app.auth.create_token(jwt_data) if is_teacher_role(): response = make_response(redirect(url_for('api.index', is_auth=True, is_teacher_role=True))) else: response = make_response(redirect(url_for('api.index', is_auth=True))) response.set_cookie('auth_token', jwt_cookie, httponly=True) return response return render_template('signup.html') @api.route('/grades') @requires_token def grades(): token = request.cookies.get('auth_token') number, email, role_bool = token_value(token) role = "Student" if not role_bool else "Teacher" if is_teacher_role(): return render_template('grades.html', is_auth=True, number=number, email=email, role=role, mg=ran_g(), eg=ran_g(), sg=ran_g(), gg=ran_g(), ag=ran_g(), is_teacher_role=True) return render_template('grades.html', is_auth=True, number=number, email=email, role=role, mg=ran_g(), eg=ran_g(), sg=ran_g(), gg=ran_g(), ag=ran_g()) @api.route('/grades_flag', methods=('GET',)) @requires_teacher def flag(): return render_template('flag.html', flag="FAKE{real_flag_is_on_the_server}", is_auth=True, is_teacher_role=True) @api.route('/logout') def logout(): response = make_response(redirect(url_for('api.index'))) response.delete_cookie('auth_token') return response
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/grades_grades_grades/src/auth.py
ctfs/DownUnderCTF/2023/web/grades_grades_grades/src/auth.py
import jwt from flask import request, jsonify, current_app, make_response from functools import wraps import secrets SECRET_KEY = secrets.token_hex(32) def create_token(data): token = jwt.encode(data, SECRET_KEY, algorithm='HS256') return token def token_value(token): decoded_token = jwt.decode(token, SECRET_KEY, algorithms=['HS256']) return decoded_token['stu_num'], decoded_token['stu_email'], decoded_token.get('is_teacher', False) def decode_token(token): try: return jwt.decode(token, SECRET_KEY, algorithms=['HS256']) except jwt.ExpiredSignatureError: return None def is_teacher_role(): # if user isn't authed at all if 'auth_token' not in request.cookies: return False token = request.cookies.get('auth_token') try: data = decode_token(token) if data.get('is_teacher', False): return True except jwt.DecodeError: return False return False def is_authenticated(): # if user isn't authed at all if 'auth_token' not in request.cookies: return False token = request.cookies.get('auth_token') try: if jwt.decode(token, SECRET_KEY, algorithms=['HS256']) is not None: return True except jwt.DecodeError: return False return False def requires_teacher(f): @wraps(f) def decorated(*args, **kwargs): token = request.cookies.get('auth_token') if not token: return jsonify({'message': 'Token is missing'}), 401 try: data = decode_token(token) if data is None or data.get("is_teacher") is None: return jsonify({'message': 'Invalid token'}), 401 if data['is_teacher']: request.user_data = data else: return jsonify({'message': 'Invalid token'}), 401 except jwt.DecodeError: return jsonify({'message': 'Invalid token'}), 401 return f(*args, **kwargs) return decorated def requires_token(f): @wraps(f) def decorated(*args, **kwargs): token = request.cookies.get('auth_token') if not token: return jsonify({'message': 'Token is missing'}), 401 try: data = decode_token(token) if data is None: return jsonify({'message': 'Invalid token'}), 401 request.user_data = data except jwt.DecodeError: return jsonify({'message': 'Invalid token'}), 401 return f(*args, **kwargs) return decorated
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/static_file_server/app.py
ctfs/DownUnderCTF/2023/web/static_file_server/app.py
from aiohttp import web async def index(request): return web.Response(body=''' <header><h1>static file server</h1></header> Here are some files: <ul> <li><img src="/files/ductf.png"></img></li> <li><a href="/files/not_the_flag.txt">not the flag</a></li> </ul> ''', content_type='text/html', status=200) app = web.Application() app.add_routes([ web.get('/', index), # this is handled by https://github.com/aio-libs/aiohttp/blob/v3.8.5/aiohttp/web_urldispatcher.py#L654-L690 web.static('/files', './files', follow_symlinks=True) ]) web.run_app(app)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/manage.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/manage.py
#!/usr/bin/env python """Django's command-line utility for administrative tasks.""" import os import sys def main(): """Run administrative tasks.""" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'secureblog.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) from exc execute_from_command_line(sys.argv) if __name__ == '__main__': main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/admin.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/admin.py
from django.contrib import admin from app.models import Article, Flag @admin.register(Article) class ArticleAdmin(admin.ModelAdmin): pass @admin.register(Flag) class FlagAdmin(admin.ModelAdmin): pass
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/__init__.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/tests.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/tests.py
from django.test import TestCase # Create your tests here.
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/apps.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/apps.py
from django.apps import AppConfig class AppConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'app'
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/serializers/article.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/serializers/article.py
from rest_framework import serializers from app.models import Article class ArticleSerializer(serializers.ModelSerializer): """ Article serializer """ author = serializers.CharField(source='created_by.username') class Meta: model = Article fields = ('title', 'body', 'author')
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/serializers/__init__.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/serializers/__init__.py
from app.serializers.article import ArticleSerializer
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/models/article.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/models/article.py
from django.db import models from django.contrib.auth.models import User class Article(models.Model): """ Test Article model """ title = models.CharField(max_length=255) body = models.TextField() created_by = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self) -> str: return f"{self.title}-{self.created_by.username}" class Meta: ordering = ["title"]
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/models/__init__.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/models/__init__.py
from app.models.article import Article from app.models.flag import Flag
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/models/flag.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/models/flag.py
from django.db import models class Flag(models.Model): """ Flag model """ flag = models.CharField(max_length=255) def __str__(self) -> str: return "Top Secret Flag"
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/utils/hash.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/utils/hash.py
from django.contrib.auth.hashers import PBKDF2PasswordHasher class PBKDF2LowIterationHasher(PBKDF2PasswordHasher): """ Custom password hasher to make password cracking doable in a reasonable time period """ iterations = 1000
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/utils/__init__.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/utils/__init__.py
from app.utils.hash import PBKDF2LowIterationHasher
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/views/article.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/views/article.py
from rest_framework.views import APIView from rest_framework.request import Request from rest_framework.response import Response from app.models import Article from app.serializers import ArticleSerializer class ArticleView(APIView): """ View for Articles """ def get(self, request: Request, format=None): """ Just return all articles """ articles = Article.objects.all() serializer = ArticleSerializer(articles, many=True) return Response(serializer.data) def post(self, request: Request, format=None): """ Query articles """ articles = Article.objects.filter(**request.data) serializer = ArticleSerializer(articles, many=True) return Response(serializer.data)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/views/__init__.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/views/__init__.py
from app.views.article import ArticleView
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/migrations/0002_flag.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/migrations/0002_flag.py
# Generated by Django 4.2.2 on 2023-06-29 02:00 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('app', '0001_initial'), ] operations = [ migrations.CreateModel( name='Flag', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('flag', models.CharField(max_length=255)), ], ), ]
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/migrations/0001_initial.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/migrations/0001_initial.py
# Generated by Django 4.2.2 on 2023-06-29 01:50 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='Article', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(max_length=255)), ('body', models.TextField()), ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], options={ 'ordering': ['title'], }, ), ]
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/migrations/__init__.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/migrations/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/asgi.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/asgi.py
""" ASGI config for secureblog project. It exposes the ASGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ """ import os from django.core.asgi import get_asgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'secureblog.settings') application = get_asgi_application()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/settings.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/settings.py
""" Django settings for secureblog project. Generated by 'django-admin startproject' using Django 4.2.2. For more information on this file, see https://docs.djangoproject.com/en/4.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.2/ref/settings/ """ from pathlib import Path import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = os.urandom(64).hex() # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False ALLOWED_HOSTS = [ '127.0.0.1' ] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'app' ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'secureblog.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'secureblog.wsgi.application' # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases DATABASES = { "default": { "ENGINE": "django.db.backends.mysql", "HOST": os.environ.get("DB_HOST", "mysql"), "NAME": 'secureblogdb', "USER": 'root', "PASSWORD": 'wouldBefUnnYt0pUtiNt0oR!!1' } } # Password validation # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/4.2/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.2/howto/static-files/ STATIC_URL = 'static/' # Default primary key field type # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' PASSWORD_HASHERS = [ "app.utils.PBKDF2LowIterationHasher", "django.contrib.auth.hashers.PBKDF2PasswordHasher" ] STATIC_ROOT = '/var/www/html/static'
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/__init__.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/wsgi.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/wsgi.py
""" WSGI config for secureblog project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'secureblog.settings') application = get_wsgi_application()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/urls.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/urls.py
""" URL configuration for secureblog project. The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/4.2/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin from django.urls import re_path from app.views import ArticleView # Had some weird issues when combined with NGINX reverse proxy earlier so using re_path instead of path urlpatterns = [ re_path('admin/', admin.site.urls), re_path('api/articles/', ArticleView.as_view()), ]
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/pwn/rw.py/rw.py
ctfs/DownUnderCTF/2025/pwn/rw.py/rw.py
#!/usr/bin/env python3 import ctypes a = [{}, (), [], "", 0.0] while True: try: inp = input("> ") cmd, idx, *val = inp.split() idx = int(idx) match cmd: case "r": print(a[idx]) case "w": ctypes.cast( id(a) + idx, ctypes.POINTER(ctypes.c_char) )[0] = int(val[0]) case _: break except Exception as e: print("error:", e)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/pwn/fakeobj.py/fakeobj.py
ctfs/DownUnderCTF/2025/pwn/fakeobj.py/fakeobj.py
#!/usr/bin/env python3 import ctypes obj = {} print(f"addrof(obj) = {hex(id(obj))}") libc = ctypes.CDLL(None) system = ctypes.cast(libc.system, ctypes.c_void_p).value print(f"system = {hex(system or 0)}") fakeobj_data = bytes.fromhex(input("fakeobj: ")) for i in range(72): ctypes.cast(id(obj), ctypes.POINTER(ctypes.c_char))[i] = fakeobj_data[i] print(obj)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/rev/bilingual/bilingual.py
ctfs/DownUnderCTF/2025/rev/bilingual/bilingual.py
DATA='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' import argparse,base64,ctypes,zlib,pathlib,sys PASSWORD='cheese' FLAG='jqsD0um75+TyJR3z0GbHwBQ+PLIdSJ+rojVscEL4IYkCOZ6+a5H1duhcq+Ub9Oa+ZWKuL703' KEY='68592cb91784620be98eca41f825260c' HELPER=None def decrypt_flag(password):A='utf-8';flag=bytearray(base64.b64decode(FLAG));buffer=(ctypes.c_byte*len(flag)).from_buffer(flag);key=ctypes.create_string_buffer(password.encode(A));result=get_helper().Decrypt(key,len(key)-1,buffer,len(buffer));return flag.decode(A) def get_helper(): global HELPER if HELPER:return HELPER data=globals().get('DATA') if data: dll_path=pathlib.Path(__file__).parent/'hello.bin' if not dll_path.is_file(): with open(dll_path,'wb')as dll_file:dll_file.write(zlib.decompress(base64.b64decode(data))) HELPER=ctypes.cdll.LoadLibrary(dll_path) else:0 return HELPER def check_three(password):return check_ex(password,'Check3') def check_four(password):return check_ex(password,'Check4') def check_ex(password,func): GetIntCallbackFn=ctypes.CFUNCTYPE(ctypes.c_int,ctypes.c_wchar_p) class CallbackTable(ctypes.Structure):_fields_=[('E',GetIntCallbackFn)] @GetIntCallbackFn def eval_int(v):return int(eval(v)) table=CallbackTable(E=eval_int);helper=get_helper();helper[func].argtypes=[ctypes.POINTER(CallbackTable)];helper[func].restype=ctypes.c_int;return helper[func](ctypes.byref(table)) def check_two(password): @ctypes.CFUNCTYPE(ctypes.c_int,ctypes.c_int) def callback(i):return ord(password[i-3])+3 return get_helper().Check2(callback) def check_one(password): if len(password)!=12:return False return get_helper().Check1(password)!=0 def check_password(password): global PASSWORD;PASSWORD=password;checks=[check_one,check_two,check_three,check_four];result=True for check in checks:result=result and check(password) return result def main(): parser=argparse.ArgumentParser(description='CTF Challenge');parser.add_argument('password',help='Enter the password');args=parser.parse_args() if check_password(args.password):flag=decrypt_flag(args.password);print('Correct! The flag is DUCTF{%s}'%flag);return 0 else:print('That is not correct');return 1 if __name__=='__main__':sys.exit(main())
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/crypto/Speak_Friend_and_Enter/server.py
ctfs/DownUnderCTF/2025/crypto/Speak_Friend_and_Enter/server.py
#!/usr/bin/env python3 from Crypto.Hash import CMAC, SHA512 from Crypto.Cipher import AES from Crypto.PublicKey import RSA from Crypto.Util.number import long_to_bytes, bytes_to_long from binascii import unhexlify import random, json, string from cryptosecrets import NIST_SP_800_38B_Appendix_D1_K, flag ## Generated once and MAC saved # r = RSA.generate(2048) # cc = CMAC.new(NIST_SP_800_38B_Appendix_D1_K, ciphermod=AES) # server_cmac_publickey = cc.update(long_to_bytes(r.n)).digest() server_cmac_publickey = unhexlify('9d4dfd27cb483aa0cf623e43ff3d3432') challenge_string = "".join([random.choice(string.ascii_letters + string.digits) for _ in range(48)]).encode() print(f"Here is your challenge string: {challenge_string.decode()}") print('Enter your signature for verification as a json string {"public_key": (int), "signature" : (int)}:') js = input() try: j = json.loads(js) public_key = j['public_key'] signature = j['signature'] except Exception as e: print(f"Error in input: {e}") exit(0) ## Check public key hash matches server cc = CMAC.new(NIST_SP_800_38B_Appendix_D1_K, ciphermod=AES) mac = cc.update(long_to_bytes(public_key)).digest() if mac != server_cmac_publickey: print("Public key MAC did not match") exit(0) if public_key.bit_length() != 2048: print("Public key size incorrect") exit(0) r = RSA.construct((public_key, 65537)) s = bytes_to_long(SHA512.new(challenge_string).digest()) if pow(signature, 65537, r.n) == s: print(f'Signature verified! Here is your flag: {flag}') exit(0) else: print("Signature incorrect") exit(0)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/crypto/yet_another_login/chall.py
ctfs/DownUnderCTF/2025/crypto/yet_another_login/chall.py
#!/usr/bin/env python3 from Crypto.Util.number import getPrime, bytes_to_long, long_to_bytes from hashlib import sha256 from secrets import randbits import os FLAG = os.getenv('FLAG', 'DUCTF{FLAG_TODO}') class TokenService: def __init__(self): self.p = getPrime(512) self.q = getPrime(512) self.n = self.p * self.q self.n2 = self.n * self.n self.l = (self.p - 1) * (self.q - 1) self.g = self.n + 1 self.mu = pow(self.l, -1, self.n) self.secret = os.urandom(16) def _encrypt(self, m): r = randbits(1024) c = pow(self.g, m, self.n2) * pow(r, self.n, self.n2) % self.n2 return c def _decrypt(self, c): return ((pow(c, self.l, self.n2) - 1) // self.n) * self.mu % self.n def generate(self, msg): h = bytes_to_long(sha256(self.secret + msg).digest()) return long_to_bytes(self._encrypt(h)) def verify(self, msg, mac): h = sha256(self.secret + msg).digest() w = long_to_bytes(self._decrypt(bytes_to_long(mac))) return h == w[-32:] def menu(): print('1. Register') print('2. Login') return int(input('> ')) def main(): ts = TokenService() print(ts.n) while True: choice = menu() if choice == 1: username = input('Username: ').encode() if b'admin' in username: print('Cannot register admin user') exit(1) msg = b'user=' + username mac = ts.generate(msg) print('Token:', (msg + b'|' + mac).hex()) elif choice == 2: token = bytes.fromhex(input('Token: ')) msg, _, mac = token.partition(b'|') if ts.verify(msg, mac): user = msg.rpartition(b'user=')[2] print(f'Welcome {user}!') if user == b'admin': print(FLAG) else: print('Failed to verify token') else: exit(1) if __name__ == '__main__': main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/crypto/certvalidated/certvalidated.py
ctfs/DownUnderCTF/2025/crypto/certvalidated/certvalidated.py
#!/usr/bin/env python3 import base64 from endesive import plain TO_SIGN = 'just a random hex string: af17a1f2654d3d40f532e314c7347cfaf24af12be4b43c5fc95f9fb98ce74601' DUCTF_ROOT_CA = open('./root.crt', 'rb').read() print(f'Sign this! <<{TO_SIGN}>>') content_info = base64.b64decode(input('Your CMS blob (base64): ')) hashok, signatureok, certok = plain.verify(content_info, TO_SIGN.encode(), [DUCTF_ROOT_CA]) print(f'{hashok = }') print(f'{signatureok = }') print(f'{certok = }') if all([hashok, signatureok, certok]): print(open('flag.txt', 'r').read())
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/crypto/good_game_spawn_point/chal.py
ctfs/DownUnderCTF/2025/crypto/good_game_spawn_point/chal.py
#!/usr/bin/env python3 import os import secrets import hashlib from Crypto.Util.number import getPrime from Crypto.PublicKey import ECC FLAG = os.getenv("FLAG", "DUCTF{testflag}") # https://neuromancer.sk/std/nist/P-256 order = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551 * 0x1 def ec_key(): eck = ECC.generate(curve="p256") secret = int(eck.d) public_key = { "x": int(eck.public_key().pointQ.x), "y": int(eck.public_key().pointQ.y), } return secret, public_key def paillier_key(): p = getPrime(1024) q = getPrime(1024) n = p * q return p, q, n def mta_response(ciphertext, n, secret): beta = secrets.randbelow(n) nsq = n * n # E(plaintext * secret) mta_response = pow(ciphertext, secret, nsq) # E(beta) r = secrets.randbelow(n) beta_enc = (pow(r, n, nsq) * pow(n + 1, beta, nsq)) % nsq # E(plaintext * secret + beta) mta_response = (mta_response * beta_enc) % nsq return mta_response, beta def zk_schnorr(beta): r = secrets.randbelow(order) r_pub = ECC.construct(curve="p256", d=r % order).public_key().pointQ beta_pub = ECC.construct(curve="p256", d=beta % order).public_key().pointQ challenge_input = f"{beta}{order}{beta_pub}{r_pub}".encode() c_hash = int.from_bytes(hashlib.sha256(challenge_input).digest(), "big") z = (r + beta * c_hash) % order return { "hash": c_hash, "r_pub": { "x": int(r_pub.x), "y": int(r_pub.y), }, "beta_pub": { "x": int(beta_pub.x), "y": int(beta_pub.y), }, } def main(): print( """ it's 4pm on a school afternoon. you just got home, tossed your bag on the floor, and turned on ABC3. it's time.. for GGSP """ ) secret, public_key = ec_key() print("public key:", public_key) p, q, n = paillier_key() print("paillier key:", {"p": p, "q": q}) for _ in range(5): c = int(input("ciphertext:")) response, beta = mta_response(c, n, secret) print("mta response:", response) proof = zk_schnorr(beta) print("zk schnorr:", proof) guess = int(input("guess secret:")) if guess == secret: print("nice :o", FLAG) else: print("bad luck") if __name__ == "__main__": main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/crypto/SH_RSA/sh-rsa.py
ctfs/DownUnderCTF/2025/crypto/SH_RSA/sh-rsa.py
#!/usr/bin/env python3 from Crypto.Util.number import long_to_bytes, bytes_to_long from gmpy2 import mpz, next_prime from hashlib import shake_128 import secrets, signal, os def H(N, m): return shake_128(long_to_bytes(N) + m).digest(8) def sign(N, d, m): return pow(mpz(bytes_to_long(H(N, m))), d, N) def verify(N, e, m, s): return long_to_bytes(pow(s, e, N))[:8] == H(N, m) def main(): p = int(next_prime(secrets.randbits(2048))) q = int(next_prime(secrets.randbits(2048))) N = p * q e = 0x10001 d = pow(e, -1, (p - 1) * (q - 1)) print(f'{N = }') print(f'{e = }') for i in range(92): m = long_to_bytes(i) s = sign(N, d, m) print(m.hex(), hex(s)) signal.alarm(46) s = int(input('s: '), 16) if verify(N, e, b'challenge', s): print(os.getenv('FLAG', 'DUCTF{test_flag}')) else: print('Nope') if __name__ == '__main__': main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/beginner/hungry_hungry_caterpillar/challenge.py
ctfs/DownUnderCTF/2025/beginner/hungry_hungry_caterpillar/challenge.py
#!/usr/bin/env python3 import os def xor(a, b): return bytes(left ^ right for left, right in zip(a, b)) def main(): flag = open("flag.txt", "rb").read() assert flag[1] == ord("U") flag += os.urandom(len(flag) * 6) keystream = os.urandom(len(flag)) print( f""" In the light of the moon a little egg lay on a leaf. One Sunday morning the warm sun came up and - pop! - out of the egg came a tiny and very hungry caterpillar. ( drawing of the sun :D ) He started to look for some food. On Monday he ate through one apple. But he was still hungry. {xor(flag[::1], keystream).hex()} On Tuesday he ate through two pears, but he was still hungry. {xor(flag[::2], keystream).hex()} On Wednesday he ate through three plums, but he was still hungry. {xor(flag[::3], keystream).hex()} On Thursday he ate through four strawberries, but he was still hungry. {xor(flag[::4], keystream).hex()} On Friday he ate through five oranges, but he was still hungry. {xor(flag[::5], keystream).hex()} On Saturday he ate through one piece of chocolate cake, one ice-cream cone, one pickle, one slice of Swiss cheese, one slice of salami, one lollipop, one piece of cherry pie, one sausage, one cupcake, and one slice of watermelon. {xor(flag[::6], keystream).hex()} That night he had a stomachache! ( drawing of a leaf ~~ ) The next day was Sunday again. The caterpillar ate through one nice green leaf, and after that he felt much better. {xor(flag[::7], keystream).hex()} Now he wasn't hungry any more - and he wasn't a little caterpillar any more. He was a big fat caterpillar :< He built a small house, called a cocoon, around himself. He stayed inside for more than two weeks. Then he nibbled a hole in the cocoon, pushed his way out and ... he was a beautiful butterfly! """ ) if __name__ == "__main__": main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/pwn/babypywn/babypywn.py
ctfs/DownUnderCTF/2022/pwn/babypywn/babypywn.py
#!/usr/bin/env python3 from ctypes import CDLL, c_buffer libc = CDLL('/lib/x86_64-linux-gnu/libc.so.6') buf1 = c_buffer(512) buf2 = c_buffer(512) libc.gets(buf1) if b'DUCTF' in bytes(buf2): print(open('./flag.txt', 'r').read())
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/oracle-for-block-cipher-enthusiasts/ofb.py
ctfs/DownUnderCTF/2022/crypto/oracle-for-block-cipher-enthusiasts/ofb.py
#!/usr/bin/env python3 from os import urandom, path from Crypto.Cipher import AES FLAG = open(path.join(path.dirname(__file__), 'flag.txt'), 'r').read().strip() MESSAGE = f'Decrypt this... {urandom(300).hex()} {FLAG}' def main(): key = urandom(16) for _ in range(2): iv = bytes.fromhex(input('iv: ')) aes = AES.new(key, iv=iv, mode=AES.MODE_OFB) ct = aes.encrypt(MESSAGE.encode()) print(ct.hex()) if __name__ == '__main__': main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-ii/rsa-interval-oracle-ii.py
ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-ii/rsa-interval-oracle-ii.py
#!/usr/bin/env python3 import signal, time from os import urandom, path from Crypto.Util.number import getPrime, bytes_to_long FLAG = open(path.join(path.dirname(__file__), 'flag.txt'), 'r').read().strip() N_BITS = 384 TIMEOUT = 20 * 60 MAX_INTERVALS = 1 MAX_QUERIES = 384 def main(): p, q = getPrime(N_BITS//2), getPrime(N_BITS//2) N = p * q e = 0x10001 d = pow(e, -1, (p - 1) * (q - 1)) secret = bytes_to_long(urandom(N_BITS//9)) c = pow(secret, e, N) print(N) print(c) intervals = [] queries_used = 0 while True: print('1. Add interval\n2. Request oracle\n3. Get flag') choice = int(input('> ')) if choice == 1: if len(intervals) >= MAX_INTERVALS: print('No more intervals allowed!') continue lower = int(input(f'Lower bound: ')) upper = int(input(f'Upper bound: ')) intervals.insert(0, (lower, upper)) elif choice == 2: queries = input('queries: ') queries = [int(c.strip()) for c in queries.split(',')] queries_used += len(queries) if queries_used > MAX_QUERIES: print('No more queries allowed!') continue results = [] for c in queries: m = pow(c, d, N) for i, (lower, upper) in enumerate(intervals): in_interval = lower < m < upper if in_interval: results.append(i) break else: results.append(-1) print(','.join(map(str, results)), flush=True) time.sleep(MAX_INTERVALS * (MAX_QUERIES // N_BITS - 1)) elif choice == 3: secret_guess = int(input('Enter secret: ')) if secret == secret_guess: print(FLAG) else: print('Incorrect secret :(') exit() else: print('Invalid choice') if __name__ == '__main__': signal.alarm(TIMEOUT) main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-iv/rsa-interval-oracle-iv.py
ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-iv/rsa-interval-oracle-iv.py
#!/usr/bin/env python3 import signal, time from os import urandom, path from Crypto.Util.number import getPrime, bytes_to_long FLAG = open(path.join(path.dirname(__file__), 'flag.txt'), 'r').read().strip() N_BITS = 384 TIMEOUT = 3 * 60 MAX_INTERVALS = 4 MAX_QUERIES = 4700 def main(): p, q = getPrime(N_BITS//2), getPrime(N_BITS//2) N = p * q e = 0x10001 d = pow(e, -1, (p - 1) * (q - 1)) secret = bytes_to_long(urandom(N_BITS//9)) c = pow(secret, e, N) print(N) print(c) intervals = [(0, 2**(N_BITS - 11)), (0, 2**(N_BITS - 10)), (0, 2**(N_BITS - 9)), (0, 2**(N_BITS - 8))] queries_used = 0 while True: print('1. Add interval\n2. Request oracle\n3. Get flag') choice = int(input('> ')) if choice == 1: if len(intervals) >= MAX_INTERVALS: print('No more intervals allowed!') continue lower = int(input(f'Lower bound: ')) upper = int(input(f'Upper bound: ')) intervals.insert(0, (lower, upper)) elif choice == 2: if queries_used > 0: print('No more queries allowed!') continue queries = input('queries: ') queries = [int(c.strip()) for c in queries.split(',')] queries_used += len(queries) if queries_used > MAX_QUERIES: print('No more queries allowed!') continue results = [] for c in queries: m = pow(c, d, N) for i, (lower, upper) in enumerate(intervals): in_interval = lower < m < upper if in_interval: results.append(i) break else: results.append(-1) print(','.join(map(str, results)), flush=True) elif choice == 3: secret_guess = int(input('Enter secret: ')) if secret == secret_guess: print(FLAG) else: print('Incorrect secret :(') exit() else: print('Invalid choice') if __name__ == '__main__': signal.alarm(TIMEOUT) main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-i/rsa-interval-oracle-i.py
ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-i/rsa-interval-oracle-i.py
#!/usr/bin/env python3 import signal, time from os import urandom, path from Crypto.Util.number import getPrime, bytes_to_long FLAG = open(path.join(path.dirname(__file__), 'flag.txt'), 'r').read().strip() N_BITS = 384 TIMEOUT = 20 * 60 MAX_INTERVALS = 384 MAX_QUERIES = 384 def main(): p, q = getPrime(N_BITS//2), getPrime(N_BITS//2) N = p * q e = 0x10001 d = pow(e, -1, (p - 1) * (q - 1)) secret = bytes_to_long(urandom(N_BITS//9)) c = pow(secret, e, N) print(N) print(c) intervals = [] queries_used = 0 while True: print('1. Add interval\n2. Request oracle\n3. Get flag') choice = int(input('> ')) if choice == 1: if len(intervals) >= MAX_INTERVALS: print('No more intervals allowed!') continue lower = int(input(f'Lower bound: ')) upper = int(input(f'Upper bound: ')) intervals.insert(0, (lower, upper)) elif choice == 2: queries = input('queries: ') queries = [int(c.strip()) for c in queries.split(',')] queries_used += len(queries) if queries_used > MAX_QUERIES: print('No more queries allowed!') continue results = [] for c in queries: m = pow(c, d, N) for i, (lower, upper) in enumerate(intervals): in_interval = lower < m < upper if in_interval: results.append(i) break else: results.append(-1) print(','.join(map(str, results)), flush=True) time.sleep(MAX_INTERVALS * (MAX_QUERIES // N_BITS - 1)) elif choice == 3: secret_guess = int(input('Enter secret: ')) if secret == secret_guess: print(FLAG) else: print('Incorrect secret :(') exit() else: print('Invalid choice') if __name__ == '__main__': signal.alarm(TIMEOUT) main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/kyber/kyber.py
ctfs/DownUnderCTF/2022/crypto/kyber/kyber.py
#!/usr/bin/env python3 import ctypes MAX_QUERIES = 7681 FLAG = open('flag.txt', 'rb').read().strip() kyber_lib = ctypes.CDLL('./libpqcrystals_kyber512_ref.so') class Kyber: def __init__(self): self.pk_buf = ctypes.c_buffer(800) self.sk_buf = ctypes.c_buffer(1632) kyber_lib.pqcrystals_kyber512_ref_keypair(self.pk_buf, self.sk_buf) def kem_enc(self): ct_buf = ctypes.c_buffer(1024) ss_buf = ctypes.c_buffer(32) kyber_lib.pqcrystals_kyber512_ref_enc(ct_buf, ss_buf, self.pk_buf) return bytes(ct_buf), bytes(ss_buf) def kem_dec(self, c): assert len(c) == 1024 ct_buf = ctypes.c_buffer(c) ss_buf = ctypes.c_buffer(32) kyber_lib.pqcrystals_kyber512_ref_dec(ss_buf, ct_buf, self.sk_buf) return bytes(ss_buf) def main(): kyber = Kyber() print('pk:', bytes(kyber.pk_buf).hex()) print('H(pk):', bytes(kyber.sk_buf)[-64:].hex()) for _ in range(MAX_QUERIES): try: inp = input('> ') if inp.startswith('enc'): ct, ss = kyber.kem_enc() print('ct:', ct.hex()) print('ss:', ss.hex()) elif inp.startswith('dec '): ct = bytes.fromhex(inp[4:]) ss = kyber.kem_dec(ct) print('ss:', ss.hex()) else: break except: print('>:(') exit(1) enc = bytes([a ^ b for a, b in zip(FLAG, bytes(kyber.sk_buf))]) print('flag_enc:', enc.hex()) if __name__ == '__main__': main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/time-locked/time-locked.py
ctfs/DownUnderCTF/2022/crypto/time-locked/time-locked.py
from hashlib import sha256 from Crypto.Util.Padding import unpad from Crypto.Cipher import AES ct = bytes.fromhex('85534f055c72f11369903af5a8ac64e2f4cbf27759803041083d0417b5f0aaeac0490f018b117dd4376edd6b1c15ba02') p = 275344354044844896633734474527970577743 a = [2367876727, 2244612523, 2917227559, 2575298459, 3408491237, 3106829771, 3453352037] α = [843080574448125383364376261369231843, 1039408776321575817285200998271834893, 712968634774716283037350592580404447, 1166166982652236924913773279075312777, 718531329791776442172712265596025287, 766989326986683912901762053647270531, 985639176179141999067719753673114239] def f(n): if n < len(α): return α[n] n -= len(α) - 1 t = α[::-1] while n > 0: x = sum([a_ * f_ for a_, f_ in zip(a, t)]) % p t = [x] + t[:-1] n -= 1 return t[0] n = 2**(2**1337) key = sha256(str(f(n)).encode()).digest() aes = AES.new(key, AES.MODE_ECB) flag = unpad(aes.decrypt(ct), 16) print(flag.decode())
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/baby-arx/baby-arx.py
ctfs/DownUnderCTF/2022/crypto/baby-arx/baby-arx.py
class baby_arx(): def __init__(self, key): assert len(key) == 64 self.state = list(key) def b(self): b1 = self.state[0] b2 = self.state[1] b1 = (b1 ^ ((b1 << 1) | (b1 & 1))) & 0xff b2 = (b2 ^ ((b2 >> 5) | (b2 << 3))) & 0xff b = (b1 + b2) % 256 self.state = self.state[1:] + [b] return b def stream(self, n): return bytes([self.b() for _ in range(n)]) FLAG = open('./flag.txt', 'rb').read().strip() cipher = baby_arx(FLAG) out = cipher.stream(64).hex() print(out) # cb57ba706aae5f275d6d8941b7c7706fe261b7c74d3384390b691c3d982941ac4931c6a4394a1a7b7a336bc3662fd0edab3ff8b31b96d112a026f93fff07e61b
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-iii/rsa-interval-oracle-iii.py
ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-iii/rsa-interval-oracle-iii.py
#!/usr/bin/env python3 import signal, time from os import urandom, path from Crypto.Util.number import getPrime, bytes_to_long FLAG = open(path.join(path.dirname(__file__), 'flag.txt'), 'r').read().strip() N_BITS = 384 TIMEOUT = 3 * 60 MAX_INTERVALS = 4 MAX_QUERIES = 4700 def main(): p, q = getPrime(N_BITS//2), getPrime(N_BITS//2) N = p * q e = 0x10001 d = pow(e, -1, (p - 1) * (q - 1)) secret = bytes_to_long(urandom(N_BITS//9)) c = pow(secret, e, N) print(N) print(c) intervals = [] queries_used = 0 while True: print('1. Add interval\n2. Request oracle\n3. Get flag') choice = int(input('> ')) if choice == 1: if len(intervals) >= MAX_INTERVALS: print('No more intervals allowed!') continue lower = int(input(f'Lower bound: ')) upper = int(input(f'Upper bound: ')) intervals.insert(0, (lower, upper)) elif choice == 2: queries = input('queries: ') queries = [int(c.strip()) for c in queries.split(',')] queries_used += len(queries) if queries_used > MAX_QUERIES: print('No more queries allowed!') continue results = [] for c in queries: m = pow(c, d, N) for i, (lower, upper) in enumerate(intervals): in_interval = lower < m < upper if in_interval: results.append(i) break else: results.append(-1) print(','.join(map(str, results)), flush=True) time.sleep(MAX_INTERVALS * (MAX_QUERIES // N_BITS - 1)) elif choice == 3: secret_guess = int(input('Enter secret: ')) if secret == secret_guess: print(FLAG) else: print('Incorrect secret :(') exit() else: print('Invalid choice') if __name__ == '__main__': signal.alarm(TIMEOUT) main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/faulty-arx/faulty_arx.py
ctfs/DownUnderCTF/2022/crypto/faulty-arx/faulty_arx.py
#!/usr/bin/env python3 import os import signal import random FLAG = open(os.path.join(os.path.dirname(__file__), 'flag.txt'), 'r').read().strip() def rol(x, d): return ((x << d) | (x >> (32 - d))) & 0xffffffff def bytes_to_words(B): return [int.from_bytes(B[i:i+4], 'little') for i in range(0, len(B), 4)] def words_to_bytes(W): return b''.join([w.to_bytes(4, 'little') for w in W]) class faulty_arx: def __init__(self, key, nonce): self.ROUNDS = 20 self.counter = 0 self.f = 0 self.key = key self.nonce = nonce def _init_state(self, key, nonce, counter): state = bytes_to_words(b'downunderctf2022') state += bytes_to_words(key) state += [counter] + bytes_to_words(nonce) return state def _QR(self, S, a, b, c, d): S[a] = (S[a] + S[b]) & 0xffffffff; S[d] ^= S[a]; S[d] = rol(S[d], 16) S[c] = (S[c] + S[d]) & 0xffffffff; S[b] ^= S[c]; S[b] = rol(S[b], 12 ^ self.f) S[a] = (S[a] + S[b]) & 0xffffffff; S[d] ^= S[a]; S[d] = rol(S[d], 8) S[c] = (S[c] + S[d]) & 0xffffffff; S[b] ^= S[c]; S[b] = rol(S[b], 7) def block(self): initial_state = self._init_state(self.key, self.nonce, self.counter) state = initial_state.copy() for r in range(0, self.ROUNDS, 2): self._QR(state, 0, 4, 8, 12) self._QR(state, 1, 5, 9, 13) self._QR(state, 2, 6, 10, 14) self._QR(state, 3, 7, 11, 15) x = 0 if r == self.ROUNDS - 2: x = random.randint(0, 4) if x == 1: self.f = 1 self._QR(state, 0, 5, 10, 15) self.f = 0 if x == 2: self.f = 1 self._QR(state, 1, 6, 11, 12) self.f = 0 if x == 3: self.f = 1 self._QR(state, 2, 7, 8, 13) self.f = 0 if x == 4: self.f = 1 self._QR(state, 3, 4, 9, 14) self.f = 0 out = [(i + s) & 0xffffffff for i, s in zip(initial_state, state)] self.counter += 1 return words_to_bytes(out) def stream(self, length): out = bytearray() while length > 0: block = self.block() t = min(length, len(block)) out += block[:t] length -= t return out def main(): key = os.urandom(16).hex().encode() nonce = os.urandom(12) print(nonce.hex()) out = set() for _ in range(20): cipher = faulty_arx(key, nonce) out.add(cipher.stream(64).hex()) for c in out: print(c) key_guess = input('key> ') if key_guess == key.decode(): print(FLAG) else: print('Incorrect key!') if __name__ == '__main__': signal.alarm(180) main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/web/dyslexxec/getExcelMetadata.py
ctfs/DownUnderCTF/2022/web/dyslexxec/getExcelMetadata.py
import sys import uuid import os import shutil from lxml import etree from openpyxl import load_workbook from zipfile import ZipFile WORKBOOK = "xl/workbook.xml" def getMetadata(filename): properties = [] try: wb = load_workbook(filename) for e in wb.properties.__elements__: properties.append( { "Fieldname" : e, "Attribute" : None, "Value" : getattr(wb.properties, e) } ) for s in wb.sheetnames: properties.append( { "Fieldname" : "sheet", "Attribute" : s, "Value" : None } ) except Exception: print("error loading workbook") return None return properties def extractWorkbook(filename, outfile="xml"): with ZipFile(filename, "r") as zip: zip.extract(WORKBOOK, outfile) def findInternalFilepath(filename): try: prop = None parser = etree.XMLParser(load_dtd=True, resolve_entities=True) tree = etree.parse(filename, parser=parser) root = tree.getroot() internalNode = root.find(".//{http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac}absPath") if internalNode != None: prop = { "Fieldname":"absPath", "Attribute":internalNode.attrib["url"], "Value":internalNode.text } return prop except Exception: print("couldnt extract absPath") return None if __name__ == "__main__": if len(sys.argv) == 2: filename = sys.argv[1] else: print("Usage:", sys.argv[0], "<filename>") exit(1) tmpFolder = "./uploads/" + str(uuid.uuid4()) os.mkdir(tmpFolder) properties = getMetadata(filename) extractWorkbook(filename, tmpFolder) workbook = tmpFolder + "/" + WORKBOOK properties.append(findInternalFilepath(workbook)) for p in properties: print(p) print("Removing tmp folder:", workbook) shutil.rmtree(tmpFolder)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/web/dyslexxec/app.py
ctfs/DownUnderCTF/2022/web/dyslexxec/app.py
from flask import Flask, render_template, request, send_file from werkzeug.utils import secure_filename from getExcelMetadata import getMetadata, extractWorkbook, findInternalFilepath, WORKBOOK import shutil import os import uuid app = Flask(__name__) app.config['MAX_CONTENT_LENGTH'] = 32 * 1024 @app.errorhandler(413) def filesize_error(e): return render_template("error_filesize.html") @app.route("/") def index(): return render_template("index.html") @app.route("/downloads/fizzbuzz") def return_fizzbuzz(): return send_file("./fizzbuzz.xlsm") @app.route("/upload/testPandasImplementation") def upload_file(): return render_template("upload.html") @app.route("/metadata", methods = ['GET', 'POST']) def view_metadata(): if request.method == "GET": return render_template("error_upload.html") if request.method == "POST": f = request.files["file"] tmpFolder = "./uploads/" + str(uuid.uuid4()) os.mkdir(tmpFolder) filename = tmpFolder + "/" + secure_filename(f.filename) f.save(filename) try: properties = getMetadata(filename) extractWorkbook(filename, tmpFolder) workbook = tmpFolder + "/" + WORKBOOK properties.append(findInternalFilepath(workbook)) except Exception: return render_template("error_upload.html") finally: shutil.rmtree(tmpFolder) return render_template("metadata.html", items=properties) if __name__ == "__main__": app.run(host="0.0.0.0")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/web/sqli2022/app.py
ctfs/DownUnderCTF/2022/web/sqli2022/app.py
from flask import Flask, request import textwrap import sqlite3 import os import hashlib assert len(os.environ['FLAG']) > 32 app = Flask(__name__) @app.route('/', methods=['POST']) def root_post(): post = request.form # Sent params? if 'username' not in post or 'password' not in post: return 'Username or password missing from request' # We are recreating this every request con = sqlite3.connect(':memory:') cur = con.cursor() cur.execute('CREATE TABLE users (username TEXT, password TEXT)') cur.execute( 'INSERT INTO users VALUES ("admin", ?)', [hashlib.md5(os.environ['FLAG'].encode()).hexdigest()] ) output = cur.execute( 'SELECT * FROM users WHERE username = {post[username]!r} AND password = {post[password]!r}' .format(post=post) ).fetchone() # Credentials OK? if output is None: return 'Wrong credentials' # Nothing suspicious? username, password = output if username != post["username"] or password != post["password"]: return 'Wrong credentials (are we being hacked?)' # Everything is all good return f'Welcome back {post["username"]}! The flag is in FLAG.'.format(post=post) @app.route('/', methods=['GET']) def root_get(): return textwrap.dedent(''' <html> <head></head> <body> <form action="/" method="post"> <p>Welcome to admin panel!</p> <label for="username">Username:</label> <input type="text" id="username" name="username"><br><br> <label for="password">Password:</label> <input type="text" id="password" name="password"><br><br> <input type="submit" value="Submit"> </form> </body> </html> ''').strip()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2020/pwn-or-web/server.py
ctfs/DownUnderCTF/2020/pwn-or-web/server.py
#!/usr/bin/env python3 import os import sys import subprocess import tempfile MAX_SIZE = 100 * 1024 script_size = int(input("Enter the size of your exploit script (in bytes, max 100KB): ")) assert script_size < MAX_SIZE print("Minify your exploit script and paste it in: ") contents = sys.stdin.read(script_size) tmp = tempfile.mkdtemp(dir="/tmp", prefix=bytes.hex(os.urandom(8))) index_path = os.path.join(tmp, "exploit.js") with open(index_path, "w") as f: f.write(contents) sys.stderr.write("New submission at {}\n".format(index_path)) subprocess.run(["/home/ctf/d8", index_path], stderr=sys.stdout) # Cleanup os.remove(index_path) os.rmdir(tmp)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/small_enigma.py
ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/small_enigma.py
from Enigma.Enigma import Enigma print(''' ──────────────────────────────────────────────────────────────────────────────────────────────────────────── ─██████████████──██████──────────██████──██████████──██████████████──██████──────────██████──██████████████─ ─██░░░░░░░░░░██──██░░██████████──██░░██──██░░░░░░██──██░░░░░░░░░░██──██░░██████████████░░██──██░░░░░░░░░░██─ ─██░░██████████──██░░░░░░░░░░██──██░░██──████░░████──██░░██████████──██░░░░░░░░░░░░░░░░░░██──██░░██████░░██─ ─██░░██──────────██░░██████░░██──██░░██────██░░██────██░░██──────────██░░██████░░██████░░██──██░░██──██░░██─ ─██░░██████████──██░░██──██░░██──██░░██────██░░██────██░░██──────────██░░██──██░░██──██░░██──██░░██████░░██─ ─██░░░░░░░░░░██──██░░██──██░░██──██░░██────██░░██────██░░██──██████──██░░██──██░░██──██░░██──██░░░░░░░░░░██─ ─██░░██████████──██░░██──██░░██──██░░██────██░░██────██░░██──██░░██──██░░██──██████──██░░██──██░░██████░░██─ ─██░░██──────────██░░██──██░░██████░░██────██░░██────██░░██──██░░██──██░░██──────────██░░██──██░░██──██░░██─ ─██░░██████████──██░░██──██░░░░░░░░░░██──████░░████──██░░██████░░██──██░░██──────────██░░██──██░░██──██░░██─ ─██░░░░░░░░░░██──██░░██──██████████░░██──██░░░░░░██──██░░░░░░░░░░██──██░░██──────────██░░██──██░░██──██░░██─ ─██████████████──██████──────────██████──██████████──██████████████──██████──────────██████──██████──██████─ ──────────────────────────────────────────────────────────────────────────────────────────────────────────── ──────────────────────────────────────────────────────────────────────────────────────────────────────────── ─────────────────██████──██████──██████████████──────────██████████████──────────████████─────────────────── ─────────────────██░░██──██░░██──██░░░░░░░░░░██──────────██░░░░░░░░░░██──────────██░░░░██─────────────────── ─────────────────██░░██──██░░██──██░░██████░░██──────────██░░██████░░██──────────████░░██─────────────────── ─────────────────██░░██──██░░██──██░░██──██░░██──────────██░░██──██░░██────────────██░░██─────────────────── ─────────────────██░░██──██░░██──██░░██──██░░██──────────██░░██──██░░██────────────██░░██─────────────────── ─────────────────██░░██──██░░██──██░░██──██░░██──────────██░░██──██░░██────────────██░░██─────────────────── ─────────────────██░░██──██░░██──██░░██──██░░██──────────██░░██──██░░██────────────██░░██─────────────────── ─────────────────██░░░░██░░░░██──██░░██──██░░██──────────██░░██──██░░██────────────██░░██─────────────────── ─────────────────████░░░░░░████──██░░██████░░██──██████──██░░██████░░██──██████──████░░████───────────────── ───────────────────████░░████────██░░░░░░░░░░██──██░░██──██░░░░░░░░░░██──██░░██──██░░░░░░██───────────────── ─────────────────────██████──────██████████████──██████──██████████████──██████──██████████───────────────── ──────────────────────────────────────────────────────────────────────────────────────────────────────────── ''') print("some settings were conveniently set up for you :)") print("current enigma settings:") print("MODEL : | Enigma M3 |") print("RING SETTINGS : | A | A | A |") print("REFLECTOR : | UKW B |") print("PLUGBOARD : | [- DISABLED -] |") print("input your rotors (ex. I II III) :") inp_str = input() rotors = inp_str.split() print(rotors) print("input your rotor positions (ex. A A A) :") inp_str = input() rotor_pos = [ord(i) - 65 for i in inp_str.split()] print(rotor_pos) e = Enigma(rotors, "B", rotor_pos, [0, 0, 0], "") SECRET = "[REDACTED]" FLAG = "KUBANCTF" + SECRET enc = e.encrypt(FLAG) print(enc)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Tests/Tests.py
ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Tests/Tests.py
import random import numpy as np from Enigma_Project.Enigma.Enigma import Enigma def encryptTest(): e = Enigma(["I", "II", "III"], "B", [0,0,0], [0,0,0], "") input = "ABCDEFGHIJKLMNOPQRSTUVWXYZAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBABCDEFGHIJKLMNOPQRSTUVWXYZ" output = "BJELRQZVJWARXSNBXORSTNCFMEYHCXTGYJFLINHNXSHIUNTHEORXOPLOVFEKAGADSPNPCMHRVZCYECDAZIHVYGPITMSRZKGGHLSRBLHL" ciphertext = e.encrypt(input) assert ciphertext == output Enigma e = Enigma(["II", "V", "IV"], "B",[10, 5, 12],[1, 2, 3], "") ciphertext = e.encrypt(input) output = "FXXYTPNEWZQJFMFFTGEARJKBEJVUHOQMKLHZHCZQECFFMZUPQKPBLWAQAWISJFSYLIGLZCFCCYMTUXIHLVNJVMCOFNBFRTSPJXFOREBO" assert ciphertext == output def decryptTest(): allRotors = ["I","II","III","IV","V"] input = "".join([chr(random.randint(0,25)+65) for i in range(1000)]) for t in range(10): np.random.shuffle(allRotors) rotors = allRotors[:3] startPos = [random.randint(0,25),random.randint(0,25),random.randint(0,25)] ringSett = [random.randint(0,25),random.randint(0,25),random.randint(0,25)] e1 = Enigma(rotors,"B",startPos,ringSett,"") ct = e1.encrypt(input) e2 = Enigma(rotors, "B", startPos, ringSett, "") pt = e2.encrypt(ct) assert input == pt def plugboardTest(): e = Enigma(["I", "II", "III"], "B", [0, 0, 0], [0, 0, 0], "AC FG JY LW") input = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" output = "QREBNMCYZELKQOJCGJVIVGLYEMUPCURPVPUMDIWXPPWROOQEGI" ciphertext = e.encrypt(input) assert ciphertext == output e = Enigma(["I", "II", "III"], "B", [0, 1, 20], [5, 5, 4], "AG HR YT KI FL WE NM SD OP QJ") input = "RNXYAZUYTFNQFMBOLNYNYBUYPMWJUQSBYRHPOIRKQSIKBKEKEAJUNNVGUQDODVFQZHASHMQIHSQXICTSJNAUVZYIHVBBARPJADRH" output = "CFBJTPYXROYGGVTGBUTEBURBXNUZGGRALBNXIQHVBFWPLZQSCEZWTAWCKKPRSWOGNYXLCOTQAWDRRKBCADTKZGPWSTNYIJGLVIUQ" ciphertext = e.encrypt(input) assert ciphertext == output def allTest(): encryptTest() decryptTest() plugboardTest()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Plugboard.py
ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Plugboard.py
class Plugboard: def __init__(self, connections): self.wiring = Plugboard.decodePlugboard(connections) def forward(self,c): return self.wiring[c] @staticmethod def identityPlugboard(): return list(range(26)) @staticmethod def decodePlugboard(plugboard=None): mapping = Plugboard.identityPlugboard() if plugboard == None or plugboard == "": return mapping pairs = plugboard.split() for p in pairs: c1 = ord(p[0])-65 c2 = ord(p[1])-65 mapping[c1]=c2 mapping[c2]=c1 return mapping
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Enigma.py
ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Enigma.py
from Enigma_Project.Enigma.Reflector import Reflector from Enigma_Project.Enigma.Rotor import Rotor from Enigma_Project.Enigma.Plugboard import Plugboard class Enigma: def __init__(self,rotors,reflector,rotorPositions,ringSettings,plugboardConnections): self.leftRotor = Rotor.Create(rotors[0], rotorPositions[0], ringSettings[0]) self.middleRotor = Rotor.Create(rotors[1], rotorPositions[1], ringSettings[1]) self.rightRotor = Rotor.Create(rotors[2], rotorPositions[2], ringSettings[2]) self.reflector = Reflector.Create(reflector) self.plugboard = Plugboard(plugboardConnections) def rotate(self): if self.middleRotor.isAtNotch(): self.middleRotor.turnover() self.leftRotor.turnover() elif self.rightRotor.isAtNotch(): self.middleRotor.turnover() self.rightRotor.turnover() def _encrypt(self,c): c = ord(c)-65 self.rotate() c = self.plugboard.forward(c) c = self.rightRotor.forward(c) c = self.middleRotor.forward(c) c = self.leftRotor.forward(c) c = self.reflector.forward(c) c = self.leftRotor.backward(c) c = self.middleRotor.backward(c) c = self.rightRotor.backward(c) c = self.plugboard.forward(c) return chr(c+65) def encrypt(self,s): return "".join([self._encrypt(c) for c in s])
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Reflector.py
ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Reflector.py
class Reflector: def __init__(self,encoding): self.forwardWiring = Reflector.decodeWiring(encoding) @staticmethod def Create(name): if name == "B": return Reflector("YRUHQSLDPXNGOKMIEBFZCWVJAT") elif name == "C": return Reflector("FVPJIAOYEDRZXWGCTKUQSBNMHL") else: return Reflector("ZYXWVUTSRQPONMLKJIHGFEDCBA") @staticmethod def decodeWiring(encoding): wiring = [ord(i) - 65 for i in encoding] return wiring def forward(self,c): return self.forwardWiring[c]
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Rotor.py
ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Rotor.py
class Rotor: def __init__(self, name,encoding, rotorPos, notchPosition, ringSetting): self.name = name self.forwardWiring = Rotor.decodeWiring(encoding) self.backwardWiring = Rotor.inverseWiring(self.forwardWiring) self.rotorPosition = rotorPos self.notchPosition = notchPosition self.ringSetting = ringSetting @staticmethod def Create(name, rotorPosition, ringSetting): if name == "I": return Rotor("I", "EKMFLGDQVZNTOWYHXUSPAIBRCJ", rotorPosition, 16, ringSetting) elif name == "II": return Rotor("II", "AJDKSIRUXBLHWTMCQGZNPYFVOE", rotorPosition, 4, ringSetting) elif name == "III": return Rotor("III", "BDFHJLCPRTXVZNYEIWGAKMUSQO", rotorPosition, 21, ringSetting) elif name == "IV": return Rotor("IV", "ESOVPZJAYQUIRHXLNFTGKDCMWB", rotorPosition, 9, ringSetting) elif name == "V": return Rotor("V", "VZBRGITYUPSDNHLXAWMJQOFECK", rotorPosition, 25, ringSetting) else: return Rotor("{1}", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", rotorPosition, 0, ringSetting) def getName(self): return self.name def getPosition(self): return self.name @staticmethod def decodeWiring(encoding): wiring = [ord(i)-65 for i in encoding] return wiring @staticmethod def inverseWiring(wiring): inverse = [0]*len(wiring) for i in range(len(wiring)): inverse[wiring[i]]=i return inverse @staticmethod def cipher(k,pos,ring,mapping): shift = pos - ring return (mapping[(k+shift+26)%26] - shift + 26) % 26 def forward(self,c): return Rotor.cipher(c, self.rotorPosition, self.ringSetting, self.forwardWiring) def backward(self, c): return Rotor.cipher(c, self.rotorPosition, self.ringSetting, self.backwardWiring) def isAtNotch(self): return self.notchPosition == self.rotorPosition def turnover(self): self.rotorPosition = (self.rotorPosition+1) % 26
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PwnMe/2025/Quals/crypto/Vending_Machine/server.py
ctfs/PwnMe/2025/Quals/crypto/Vending_Machine/server.py
#!/usr/bin/env python3 from tinyec.ec import SubGroup, Curve from Crypto.Util.Padding import pad from Crypto.Cipher import AES from json import loads, dumps from hashlib import sha3_256 from random import choice from os import urandom from flag import FLAG import secrets import time class SignatureManager: def __init__(self): # FRP256v1 Parameters self.p = 0xf1fd178c0b3ad58f10126de8ce42435b3961adbcabc8ca6de8fcf353d86e9c03 self.a = 0xf1fd178c0b3ad58f10126de8ce42435b3961adbcabc8ca6de8fcf353d86e9c00 self.b = 0xee353fca5428a9300d4aba754a44c00fdfec0c9ae4b1a1803075ed967b7bb73f self.Gx = 0xb6b3d4c356c139eb31183d4749d423958c27d2dcaf98b70164c97a2dd98f5cff self.Gy = 0x6142e0f7c8b204911f9271f0f3ecef8c2701c307e8e4c9e183115a1554062cfb self.n = 0xf1fd178c0b3ad58f10126de8ce42435b53dc67e140d2bf941ffdd459c6d655e1 self.h = 1 subgroup = SubGroup(self.p, (self.Gx, self.Gy), self.n, self.h) self.curve = Curve(self.a, self.b, subgroup, name="CustomCurve") self.P = self.curve.g self.d = int.from_bytes(urandom(32), "big") while self.d >= self.n: self.d = int.from_bytes(urandom(32), "big") self.Q = self.d * self.P self.salt = int.from_bytes(urandom(32), "big") % self.n def inverse(self, a, n): return pow(a, -1, n) def gen_sign(self, m: bytes, alea_1, alea_2): a = int(alea_1) b = int(alea_2) assert a**2 < b**2 < 2**120 - 1 c = (hash(a) - hash(b)) * int.from_bytes(urandom(32), "big") ^ 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF randomized_main_part_l = 249 randomized_part = "" for _ in range(256 - randomized_main_part_l): randomized_part += choice(bin(c).split("0b")[1]) parity = int(randomized_part, 2) % 2 randomized_part = bin(self.salt ^ int(randomized_part, 2))[-(256 - randomized_main_part_l):] k = 0xFF000000000000000000000000000000000000000000000000000000000000FF ^ int(randomized_part + bin(secrets.randbits(randomized_main_part_l)).split("0b")[1].zfill(randomized_main_part_l) if parity else bin(secrets.randbits(randomized_main_part_l)) + randomized_part, 2) e = int.from_bytes(sha3_256(m).digest(), "big") R = k * self.P r = R.x % self.n assert r != 0 s = (self.inverse(k, self.n) * (e + self.d * r)) % self.n return r, s, int.from_bytes(m, "big") def verify(self, m: bytes, r: int, s: int): e = int.from_bytes(sha3_256(m).digest(), "big") assert 0 < r < self.n and 0 < s < self.n w = self.inverse(s, self.n) u1 = (e * w) % self.n u2 = (r * w) % self.n P_ = u1 * self.P + u2 * self.Q return r == P_.x % self.n class Server: def __init__(self): self.signature_manager = SignatureManager() self.credits = 1 self.signatures = [] self.credit_currency = 0 key = sha3_256(self.signature_manager.d.to_bytes(32, "big")).digest()[:16] self.iv = urandom(16) cipher = AES.new(key, IV=self.iv, mode=AES.MODE_CBC) self.encrypted_flag = cipher.encrypt(pad(FLAG.encode(), 16)).hex() self.used_credit = 0 def show_credits(self): return {"credits": self.credits} def show_currency(self): return {"currency": self.credit_currency} def get_encrypted_flag(self): return {"encrypted_flag": self.encrypted_flag, "iv": self.iv.hex()} def get_new_signatures(self, alea_1, alea_2): if self.credits > 0: self.credits -= 1 self.used_credit += 1 new_signatures = [] for i in range(10): m = sha3_256(b"this is my lovely loved distributed item " + str(i+10*self.used_credit).encode()).digest() r,s,_ = self.signature_manager.gen_sign(m, alea_1, alea_2) new_signatures.append((r, s)) self.signatures.append((m.hex(), r, s)) # ...Yeah, it's long, but it's just like vending machines... the cans take forever to drop, it's maddening... time.sleep(90) return {"signatures": new_signatures} else: return {"error": "Not enough credits."} def verify_proof_of_ownership(self, owner_proofs): owner_proofs = [tuple(item) for item in owner_proofs] if len(set(owner_proofs)) != self.credit_currency: return False for owner_proof in owner_proofs: if not self.signature_manager.verify(bytes.fromhex(owner_proof[0]), owner_proof[1], owner_proof[2]) or owner_proof in self.signatures: return False return True def buy_credit(self, owner_proofs): if self.verify_proof_of_ownership(owner_proofs): self.credits += 1 # each credit cost more and more proofs to ensure you are the owner self.credit_currency += 5 return {"status": "success", "credits": self.credits, "credit_currency": self.credit_currency} else: return {"error": f"You need {self.credit_currency} *NEW* signatures to buy more credits."} def main(): server = Server() print("Welcome to the signatures distributor, this is what you can do:") print("1. Show credits") print("2. Show currency") print("3. Get encrypted flag") print("4. Get signatures") print("5. Buy credit") print("6. Exit") while True: try: command = loads(input("Enter your command in JSON format: ")) if "action" not in command: print({"error": "Invalid command format."}) continue action = command["action"] if action == "show_credits": print(server.show_credits()) elif action == "show_currency": print(server.show_currency()) elif action == "get_encrypted_flag": print(server.get_encrypted_flag()) elif action == "get_signatures": if "alea_1" not in command or "alea_2" not in command: print({"error": "Invalid command format."}) alea_1 = command["alea_1"] alea_2 = command["alea_2"] print(server.get_new_signatures(alea_1, alea_2)) elif action == "buy_credit": if "owner_proofs" not in command: print({"error": "Invalid command format."}) print(server.buy_credit(command["owner_proofs"])) elif action == "exit": print({"status": "Goodbye!"}) break else: print({"error": "Unknown action."}) except Exception as e: print({"error": str(e)}) if __name__ == "__main__": main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PwnMe/2025/Quals/crypto/Mirror_Hash/challenge.py
ctfs/PwnMe/2025/Quals/crypto/Mirror_Hash/challenge.py
import hashlib import struct from secret import FLAG class CustomSHA: def __init__(self, data: bytes): self.data: bytes = data def process(self) -> str: h0 = 0x674523EFCD.to_bytes(5, byteorder='big') h = h0 data = self.preprocess() for i in range(0, len(data), 8): chunk = data[i:i+8] h = hashlib.sha256(chunk + h).digest()[:5] return f'{h.hex()}' def preprocess(self) -> bytes: data = self.data data = bytearray(data) data.append(0x80) while len(data) % 8 != 0: data.append(0x00) data += struct.pack('>Q', 8 * len(self.data)) return bytes(data) def sha_custom(self): return self.process() with open("Hack.zip", "rb") as f: data_hack = f.read() CustomSHA(data_hack) sha_custom_hack = CustomSHA(data_hack).sha_custom() def challenge(received_json): response_json = {} if 'action' in received_json: if received_json['action'] == 'hash': if 'data' in received_json: data = bytes.fromhex(received_json['data']) if data == data_hack: response_json['error'] = "Forbidden data" else: sha_custom = CustomSHA(data) response_json['hash'] = sha_custom.sha_custom() if sha_custom_hack == response_json['hash']: response_json['flag'] = FLAG else: response_json['error'] = 'No data provided' else: response_json['error'] = 'Invalid action' else: response_json['error'] = 'No action provided' return response_json
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PwnMe/2022/crypto/ToBasics/encrypt.py
ctfs/PwnMe/2022/crypto/ToBasics/encrypt.py
#!/usr/bin/env python3 from secrets import choice from string import digits FLAG = open("./flag.txt", "r").read() SECRET = choice(digits) * len(FLAG) def encrypt(flag): return [str((ord(v[0]) ^ ord(v[1]))+i) for i, v in enumerate(zip(flag, SECRET))] out = open('./flag-encrypted.txt', 'w') out.write(','.join(encrypt(FLAG)))
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PwnMe/2022/crypto/EncryptedCommunication/chall.py
ctfs/PwnMe/2022/crypto/EncryptedCommunication/chall.py
from Crypto.Util.number import * flag = open('flag.txt', 'rb').read() p, q, s = getPrime(2048), getPrime(2048), getPrime(2048) n1 = p * q n2 = s * p e = 2**16+1 d = pow(e, -1, (p-1)*(q-1)) c1 = pow(bytes_to_long(flag[:20]), e, n1) c2 = pow(bytes_to_long(flag[20:]), e, n2) out = open('output.txt', 'w') out.write(f'{n1 = }\n') out.write(f'{n2 = }\n') out.write(f'{e = }\n') out.write(f'{c1 = }\n') out.write(f'{c2 = }\n') out.close()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PwnMe/2022/crypto/RsaMadness/chall.py
ctfs/PwnMe/2022/crypto/RsaMadness/chall.py
from Crypto.Util.number import * flag = bytes_to_long(open('flag.txt', 'rb').read()) factors = [getPrime(32) for i in range(32)] n = 1 for factor in factors: n *= factor e = 2**16+1 c = pow(flag, e, n) out = open('output.txt', 'w') out.write(f'{n = }\n') out.write(f'{e = }\n') out.write(f'{c = }\n') out.close()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PwnMe/2022/crypto/ExponentialMachine/chall.py
ctfs/PwnMe/2022/crypto/ExponentialMachine/chall.py
from Crypto.Util.number import * LIMIT = 0 a = getPrime(512) x = bytes_to_long(b"PWNME{FAKE_FLAG}") n = getPrime(512) print("You can have the result of whatever operation between multiplication, exponentiation, addition, division and substraction !") print("Also you can choose the value with which you can apply the operation. You have only 30 attempts to retrieve the flag.\n") print("a =",a) print("x = ?") print("n =", n) print("(a**x) % n =", str(pow(a,x,n)), "\n") while LIMIT < 64: operation = input("[+] Give me the operation you want to make and I'll give you the result : ") try: value = int(input("[+] Give me the value of the number after your operation : ")) except ValueError: print("You can only enter numbers !\n") break if operation not in ["/", "+", "-", "*", "**"]: print("You are only allowed to use these operations : /, *, +, -, **\n") break elif operation == "/": result = pow(a,(x // value),n) elif operation == "*": result = pow(a,(x * value),n) elif operation == "+": result = pow(a,(x + value),n) elif operation == "-": result = pow(a,(x - value),n) elif operation == "**": result = pow(a,(x ** value),n) LIMIT += 1 print("Result :", result, "\n")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/Gift_Wrapping/solve.py
ctfs/NTUA_H4CK/2024/misc/Gift_Wrapping/solve.py
from pwn import * from json import loads,dumps from hashlib import sha256 context.encoding='ascii' t = remote('localhost',1337) def get_belt(seed:int, n:int) -> list[int]: random.seed(seed) return [random.randint(1,n**2) for _ in range(n)] def solve(belt: list[int],k:int) -> list[int]: return range(len(belt)) # Replace this with your solution def main(): # 3 easy belts, and 5 hard belts for _ in range(3 + 5): data = loads(t.recvline().decode()) belt = get_belt(data['seed'],data['n']) sol = solve(belt,data['k']) t.sendline(dumps({'sol_hash':sha256(str(sol).encode()).hexdigest()})) res = loads(t.recvline().decode()) if res['msg'] != 'Good job! 🎉🎉🎉': # Something went wrong print(res) exit() # GGs res = loads(t.recvline().decode()) print(res['msg']) print(res['prize']) main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/Learn/solver.py
ctfs/NTUA_H4CK/2024/misc/Learn/solver.py
from tqdm import tqdm # Progress bar :) from pwn import * # Import the pwntools module to interact with the server # Set the host and port HOST = '???' PORT = 000 t = remote(HOST, PORT) # Connect to the server t.level = 'debug' # This will print the data sent and received # Recieve until the challenges start t.recvlines(2) for _ in tqdm(range(25)): line = t.recvline().decode() # This returns bytes, so we need to decode it action = line.split()[1] match action: case 'math': equation = t.recvuntil(' = ').decode().split(' = ')[0] # Recieve until the '=' sign and just get the equation ... case 'aes': line = t.recvline().decode() key = line.split()[-1] line = t.recvline().decode() enc = line.split()[-1] ... res = t.recvline().decode() # Recieve the result of the challenge flag = t.recvline().decode() # If everything went well, the flag is printed print(flag)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/Learn/server.py
ctfs/NTUA_H4CK/2024/misc/Learn/server.py
from secret import FLAG from Crypto.Cipher import AES from random import randint,choice,choices import signal def timeout_handler(signum, frame): print("\nOut of Time 😔") exit() signal.signal(signal.SIGALRM, timeout_handler) signal.alarm(20) # Limit to 20s def rand_str(): charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' return ''.join(choices(charset, k=16)) def challenge(): CNT = 25 for _ in range(CNT): action = choice(['math','aes']) print(f'Challenge: {action}') match action: case "math": a = randint(1,1000) b = randint(1,1000) operation = choice(['+','-','*','//']) inp = input(f"{a} {operation} {b} = ") if eval(f"{a} {operation} {b}") != int(inp): return False case "aes": key = rand_str() cipher = AES.new(key.encode(), AES.MODE_ECB) s = rand_str() s_enc = cipher.encrypt(s.encode()) print(f'key = {key}') print(f'ciphertext = {s_enc.hex()}') inp = input("plaintext = ") if inp != s: return False print("Correct, moving on...") return True print("Welcome to the challenge!") print("Solve 25 challenges to get the flag") if challenge(): print(FLAG) else: print("Try harder!")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/Snekbox/server.py
ctfs/NTUA_H4CK/2024/misc/Snekbox/server.py
# unsafe (example of what not to do) def unsafe_eval(): inp = input("> ") eval(inp) # 100% safe BLACKLIST = ["builtins", "import", "=", "flag", ';', "print", "_", "open", "exec", "eval", "help", "br"] def safe_eval(): inp = input("> ") if any(banned in inp for banned in BLACKLIST) or any(ord(c) >= 128 for c in inp): print('bye') exit() eval(inp) safe_eval()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/na_kopso_glyko/server.py
ctfs/NTUA_H4CK/2024/misc/na_kopso_glyko/server.py
import random import json from secret import FLAG def random_flouri_generator(): m = 10**30 return random.randint(1, m)**11 + 17*random.randint(1, m)**7 - 42*random.randint(1, m)**5 + 1337*random.randint(1, m)*3 + 31337*random.randint(1, m) def check_password(password, your_guess): for i in range(len(password)): if FLAG[i] != password[i]: # password is incorrect, but let's see if you win the flouri for _ in range(10000): if your_guess == random_flouri_generator(): print(f"You're sweet AND lucky, here you go: {FLAG}") return True return False if len(FLAG) == len(password): return True return False print("NA KOPSO GLYKO???") print("Sweetie, tell me my password if you want dessert. Or guess my number, I'll give you 10000 chances because you're my favorite grandchild.") while True: try: inp = json.loads(input("Give me password and number in json: ")) password = inp["password"] guess = int(inp["number"]) except: print("Something wrong honey?") break if check_password(password, guess): print("GLYKO and HUGS") break else: print("It's ok honey, you'll get it next time")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/Backdoored_Calculator/totally_normal_integers.py
ctfs/NTUA_H4CK/2024/misc/Backdoored_Calculator/totally_normal_integers.py
from functools import reduce, partial sum = partial(reduce, lambda a, b: a + b) class Int: def __init__(self, value): self.value = int(value) def __repr__(self): return str(self.value) def __add__(self, other): return Int(3*self.value + 5*other.value) def __sub__(self, other): return Int(self.value - other.value) def __mul__(self, other): return Int(self.value + other.value) def __floordiv__(self, other): return Int(0) def __truediv__(self, other): return Int(1) def __mod__(self, other): return Int(self.value + 2*other.value) def __pow__(self, other): return Int(other.value) def __eq__(self, other): return self.value == other.value + 1337
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/Backdoored_Calculator/calculator.py
ctfs/NTUA_H4CK/2024/misc/Backdoored_Calculator/calculator.py
from totally_normal_integers import Int, sum from string import digits from secret import FLAG zero = Int(0) class Calculator: def __init__(self): self.ind = 0 self.vals = [zero]*6 self.t = [Int(tval) for tval in [1550, 1548, 8073, 5413, 1411]] def calc(self, a, op, b): result = eval(f"Int({a}) {op} Int({b})") if op == "+": try: self.vals[self.ind//2] = result except: self.vals = [zero]*6 self.check() self.ind += 1 return result def check(self): if all([t == sum(self.vals[i:i+2]) for i, t in enumerate(self.t)]) and sum(self.vals) == Int(78606): print(f"Backdoor activated!!! Spilling secrets: {FLAG}") exit() calculator = Calculator() WELCOME = "Welcome to the online calculator service. Enjoy your free trial while it's still in beta!" INPUT = "What do you want to calculate(enter in format '<num 1> <operator> <num 2>', e.g. '1 * 2'): " print(WELCOME) while True: inp = input(INPUT).split() assert len(inp) == 3, "One operation at a time" assert inp[1] in ["+", "-", "*", "/", "//", "%", "**"], "It's still in beta, sorry haven't implemented everything yet" assert inp[0].removeprefix("-").isdigit() and inp[2].removeprefix("-").isdigit(), "Only integers please :)" try: print(calculator.calc(*inp)) except ValueError: break
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/Baby_Prison/server.py
ctfs/NTUA_H4CK/2024/misc/Baby_Prison/server.py
from secret import FLAG as FLAAAAAAAAG from string import ascii_lowercase, digits M = 10 BLACKLIST = ascii_lowercase + digits + "_()" for _ in range(3): inp = input("> ") assert len(inp) < M, "too long" assert all(banned not in inp for banned in BLACKLIST), "that's banned" exec(inp)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/rev/onelinerev/challenge.py
ctfs/NTUA_H4CK/2024/rev/onelinerev/challenge.py
__import__("pickle").loads(bytes.fromhex("80048c086275696c74696e738c05696e70757493288c0c456e74657220666c61673a207452711a308c086275696c74696e738c0767657461747472937181308c0b5f5f6765746974656d5f5f71a230688128681a8c06656e636f64657452295271753055534a777e5b763551704128425925614b6e7954262a783072392d4f7066467d484e342447553256685340584571215a743e365f5237235d31627b7a334d5e443f29643865496d67636b504c69756f436c573c6a737187308c086f70657261746f728c0a6974656d67657474657293711d30688128550055046a6f696e74527108306808681d284b4c4d07004d42004b164b0d4d2e004d4c004b1674526887855285526808681d284d0d004d40004d400074526887855285529371bd306808681d284b4c4d07004b424b164b0d4b2e4b4c4d160074526887855285526808681d284b444d4b004d4e00745268878552855293716d306808681d284d4c004d07004d42004b164d0d004b2e4d4c004b1674526887855285526808681d284b524b4b4d37007452688785528552937174306808681d284b4c4b074b424b164d0d004b2e4b4c4d160074526887855285526808681d284b424b2b745268878552855293716c306808681d284d37004d4b004d4a004d4e004d2e004b4a4b0f4b5274526887855285526808681d284b424b144d42004b4674526887855285529328686d8c1565786974282257726f6e67206c656e67746822293b68744b01686c4b1e8c086275696c74696e738c036c656e93681a85528652865286527452306808681d284b164b0d4d0f004b404b4c4b4474526887855285526808681d284d52004d42004d42004d400074526887855285529371da306808681d284b164d0d004b0f4d40004b4c4b4474526887855285526808681d284d52004d0d004b444d07004d4e004d420074526887855285529371453068da4dede285523068086845681d284b4a4d4b004d4a004d2e004d0f004d52004b374b4e7452688785524d08008652855268da4d05aa85523068086845681d284b0d4b074d44007452688785524d0300865285529371b13068da4d844b85523068086845681d284d4a004d4e004d0f004b524b4b4d37004b2e4b4a7452688785524d08008652855268da4de76985523068086845681d284b0d4d4e004b4e7452688785524d0300865285529371523068da4dc6f385523068086845681d284b074d16004b164b424d0d004b4c4b2e4b4c7452688785524d08008652855268da4dff0285523068086845681d284d4c004b164b147452688785524d0300865285529371d43068da4d149185523068086845681d284d4c004d4e004d1b004d4b004d0f004d4c004b2e4b464d52007452688785524d09008652855268da4d200e85523068086845681d284b464d42004d42004d40004d4b004b167452688785524d060086528552937103308c086275696c74696e73688128688768a27452288c086275696c74696e738c05736c69636593284affffffff4aebffffff4afcffffff7452745293717b308c086275696c74696e73688128688768a2745228687b284affffffff4aeaffffff4af9ffffff745274529371843068da4d4d8285523068086845681d284d4e004b4a4b524b0f4b374d4a004d2e004b4b7452688785524d08008652855268da4ddc8385523068086845681d284b074b0f4d4a004b164b2e7452688785524d0500865285529371dc30685228284b014b024b034b044b054b066c715030685228686c284ddf06688468b128686d6850688128687568a2745228687b284b004b064e74527452745285527452686c284d7207688468b128686d6850688128687568a2745228687b284b064b0c4e74527452745285527452686c284d2808688468b128686d6850688128687568a2745228687b284b0c4b124e74527452745285527452686c284dd507688468b128686d6850688128687568a2745228687b284b124b184e74527452745285527452686c284d2e08688468b128686d6850688128687568a2745228687b284b184b1e4e745274527452855274526c8552685228686c284d3a00680368d4688128687568a2745228687b284b004b054e7452745286527452686c284d4700680368d4688128687568a2745228687b284b054b0a4e7452745286527452686c284d0700680368d4688128687568a2745228687b284b0a4b0f4e7452745286527452686c284d4200680368d4688128687568a2745228687b284b0f4b144e7452745286527452686c284d6b00680368d4688128687568a2745228687b284b144b194e7452745286527452686c284d3400680368d4688128687568a2745228687b284b194b1e4e74527452865274526c8552685228686c4dfb006884688128687568a2745228687b284b004e4b0a7452745285528652686c4d0e016884688128687568a2745228687b284b014e4b0a7452745285528652686c4df9006884688128687568a2745228687b284b024e4b0a7452745285528652686c4d1d016884688128687568a2745228687b284b034e4b0a7452745285528652686c4daf006884688128687568a2745228687b284b044e4b0a7452745285528652686c4d4c016884688128687568a2745228687b284b054e4b0a7452745285528652686c4d37016884688128687568a2745228687b284b064e4b0a7452745285528652686c4dc6006884688128687568a2745228687b284b074e4b0a7452745285528652686c4d44016884688128687568a2745228687b284b084e4b0a7452745285528652686c4d20016884688128687568a2745228687b284b094e4b0a74527452855286526c8552685228686c4ddc10686d28688128687568a27452284b067452688128687568a27452284b07745274528652686c4dd527686d28688128687568a27452284b157452688128687568a27452284b167452745286526c8552685228686c284dda04688428688128687568a2745228687b284e4b0f4e7452745274527452686c284da105688428688128687568a2745228687b284b0f4e4e74527452745274526c8552686c284320a5a2191fde8567bf183ea08d0698e702254be36935846969dd814c30592d7a306881288c07686173686c69628c0673686132353693687585528c066469676573747452295274526c855271c83068dc68bd686d68c88c08436f7272656374218652686d6874284b0168c874528c0657726f6e67218652865285522e"))
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/crypto/Secure_Encryption_Service/server.py
ctfs/NTUA_H4CK/2024/crypto/Secure_Encryption_Service/server.py
from Crypto.Cipher import AES from time import time from hashlib import sha256 from secret import FLAG key = sha256(sha256(str(int(time())).encode() + FLAG).digest() + FLAG).digest() cipher = AES.new(key= key, mode= AES.MODE_CTR, nonce= sha256(FLAG + sha256(FLAG + str(int(time())).encode()).digest()).digest()[:12]) MENU = '''Options: 1. Encrypt flag 2. Encrypt your own plaintext''' while True: print(MENU) option = input("> ") try: option = int(option) except ValueError: break if option == 1: print(cipher.encrypt(FLAG).hex()) elif option == 2: pt = input("your plaintext: ") try: pt = bytes.fromhex(pt) except ValueError: break print(cipher.encrypt(pt).hex()) else: print(sha256(b'Nice try, now give me a valid option').hexdigest())
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/crypto/New_Laptop/source.py
ctfs/NTUA_H4CK/2024/crypto/New_Laptop/source.py
from Crypto.Util.number import getPrime, isPrime from secrets import randbelow from secret import FLAG from supercomputer import superfast_product_up_to_x_mod_n # you need to have a supercomputer to use this sorry :/ # superfast_product_up_to_x_mod_n(x, n) returns 0 if x % n == 0, otherwise it calculates the product prod([i for i in range(x) if i % n != 0]) % n randbound = 10**3 while True: p = getPrime(256) if isPrime((p-1)//2): break rands_used = [] values = [] for i in range(len(FLAG)): value = 0 for j in range(len(FLAG)): rand = randbelow(randbound) rands_used.append(rand) value += FLAG[j] * superfast_product_up_to_x_mod_n(p - randbound//2 + rand, p) value %= p values.append(value) print(f"{p = }") print(f"{rands_used = }") print(f"{values = }") ''' p = 77679947832191133523517888021553169001562422468712596390238771089056438084667 rands_used = [588, 900, 583, 583, 113, 566, 172, 393, 108, 239, 267, 518, 796, 570, 671, 331, 66, 655, 264, 439, 887, 189, 159, 547, 219, 785, 963, 771, 180, 720, 435, 67, 430, 112, 291, 271, 739, 198, 245, 329, 246, 188, 15, 572, 576, 416, 398, 976, 830, 615, 503, 715, 616, 923, 184, 443, 430, 72, 525, 92, 147, 933, 569, 837, 190, 372, 877, 626, 499, 174, 325, 392, 136, 460, 607, 615, 305, 71, 380, 478, 208, 144, 110, 496, 864, 992, 453, 911, 213, 578, 641, 403, 755, 800, 455, 342, 429, 368, 403, 47, 591, 854, 423, 590, 252, 144, 364, 935, 17, 312, 785, 104, 768, 169, 685, 802, 771, 167, 532, 880, 713, 297, 741, 382, 128, 302, 19, 804, 907, 25, 798, 775, 435, 592, 623, 2, 491, 240, 748, 938, 342, 857, 875, 961, 922, 667, 140, 428, 188, 382, 58, 640, 262, 848, 578, 364, 300, 680, 624, 334, 372, 453, 419, 843, 324, 486, 535, 411, 457, 121, 348, 974, 524, 17, 439, 350, 674, 191, 378, 365, 623, 932, 193, 514, 305, 203, 861, 899, 89, 682, 660, 513, 70, 60, 156, 82, 927, 513, 713, 360, 702, 331, 960, 293, 352, 150, 798, 190, 761, 571, 601, 860, 836, 390, 620, 412, 162, 942, 581, 254, 424, 131, 628, 830, 68, 93, 526, 216, 748, 797, 457, 366, 250, 930, 292, 533, 640, 590, 984, 379, 242, 483, 234, 641, 386, 743, 369, 971, 289, 817, 800, 243, 99, 502, 268, 109, 724, 5, 984, 582, 432, 486, 190, 685, 360, 872, 421, 828, 508, 340, 379, 220, 873, 980, 431, 57, 416, 223, 93, 150, 318, 261, 881, 798, 356, 918, 283, 129, 262, 840, 772, 654, 762, 392, 870, 100, 229, 778, 876, 194, 797, 893, 704, 631, 268, 212, 632, 377, 778, 655, 103, 609, 115, 434, 353, 784, 505, 215, 241, 970, 553, 137, 348, 686, 169, 289, 165, 548, 779, 59, 956, 45, 592, 47, 512, 537, 829, 70, 734, 731, 364, 4, 496, 788, 73, 409, 813, 26, 594, 389, 486, 209, 693, 280, 753, 205, 337, 954, 813, 474, 855, 817, 799, 577, 48, 719, 75, 953, 867, 438, 186, 571, 375, 386, 972, 980, 794, 576, 532, 674, 3, 324, 305, 305, 449, 860, 908, 296, 661, 404, 839, 309, 224, 275, 585, 646, 288, 84, 907, 261, 959, 42, 869, 407, 587, 988, 814, 696, 557, 2, 622, 343, 459, 462, 760, 161, 766, 877, 387, 410, 313, 640, 506, 142, 241, 887, 261, 43, 998, 180, 246, 351, 982, 355, 120, 316, 630, 751, 508, 912, 292, 210, 646, 936, 178, 72, 324, 480, 216, 124, 83, 708, 237, 399, 515, 907, 367, 385, 607, 212, 126, 490, 401, 871, 23, 298, 946, 358, 733, 24, 625, 335, 815, 897, 914, 635, 113, 368, 652, 300, 72, 886, 372, 73, 76, 6, 745, 303, 332, 884, 779, 458, 53, 672, 805, 327, 967, 109, 718, 732, 922, 869, 939, 848, 790, 39, 81, 565, 81, 923, 570, 247, 46, 530, 303, 286, 663, 163, 563, 899, 939, 575, 104, 171, 155, 526, 479, 942, 567, 220, 244, 241, 491, 972, 832, 491, 978, 399, 855, 468, 14, 654, 539, 180, 972, 539, 156, 964, 634, 636, 938, 844, 894, 848, 816, 637, 355, 482, 964, 593, 891, 184, 66, 57, 270, 437, 536, 986, 924, 606, 224, 79, 945, 680, 176, 171, 968, 852, 904, 670, 446, 865, 56, 243, 264, 282, 659, 441, 962, 812, 226, 433, 710, 237, 991, 852, 399, 770, 148, 683, 20, 659, 388, 664, 790, 407, 658, 499, 767, 614, 256, 490, 899, 552, 77, 294, 282, 939, 171, 339, 704, 347, 126, 633, 753, 247, 395, 198, 686, 617, 633, 149, 828, 976, 722, 355, 829, 471, 462, 461, 509, 357, 268, 526, 663, 232, 55, 652, 826, 829, 489, 531, 526, 857, 865, 370, 562, 903, 362, 427, 301, 570, 900, 812, 29, 824, 446, 5, 173, 535, 542, 949, 57, 923, 766, 737, 759, 864, 348, 393, 708, 14, 808, 688, 401, 362, 338, 16, 526, 463, 502, 541, 592, 75, 884, 935, 935, 422, 794, 126, 998, 237, 195, 564, 911, 600, 8, 26, 350, 874, 95, 223, 681, 997, 199, 118, 154, 347, 826, 448, 911, 336, 546, 808, 163, 421, 748, 633, 885, 694, 467, 324, 111, 233, 296, 436, 410, 153, 290, 335, 568, 294, 392, 834, 91, 532, 740, 882, 353, 427, 175, 398, 60, 388, 873, 819, 523, 700, 20, 546, 173, 740, 317, 851, 889, 968, 125, 604, 87, 474, 216, 52, 294, 54, 416, 594, 351, 877, 739, 605, 37, 965, 662, 354, 531, 331, 376, 58, 248, 371, 82, 824, 23, 753, 170, 490, 952, 925, 10, 622, 53, 204, 88, 448, 77, 504, 513, 155, 112, 818, 882, 926, 698, 616, 743, 939, 231, 622, 945, 63, 873, 493, 500, 535, 877, 640, 913, 198, 188, 979, 247, 44, 950, 973, 567, 867, 306, 339, 923, 220, 420, 821, 777, 586, 901, 78, 556, 778, 952, 815, 190, 256, 756, 913, 564, 325, 724, 5, 353, 794, 437, 38, 18, 338, 292, 663, 954, 982, 254, 619, 933, 363, 158, 955, 868, 777, 580, 398, 285, 626, 472, 38, 592, 715, 556, 918, 893, 148, 517, 575, 677, 711, 838, 135, 939, 705, 475, 917, 654, 415] values = [18961269313481979991860053878854528531459157717464103987553753334333047531767, 3679957926714948656076112901744861957272651757981943696998658686635312582563, 3213525680577645314442108056895271273374691758540968541740489480341017746960, 49876276707558599625726086945261885360493810410581278262323426918565586943289, 12364739860507994135164249337855230093985318927798547739945440367837477144030, 50260651584284655536443864775829546115455934786038579728843430801186201384488, 68407503406509136427407092941793928074676260782196376769006676001805751639097, 21026155163768981217604928261986903157322654807669766538831853909813764394555, 68371881291390859067742000942534098406807369310059364826208072363886215174805, 48291763769139356940934909549316155103494024860922885818870233669938264412711, 41613460402677414012537049310474028131097510882436428491997008198805942141592, 16132423720366627445793267705972161821046179814463134220179068885338603488256, 22727639301178067097772101434914526102390785635489314789009153242548161398500, 63432644907808354624920079263205720256236862230359007388270401704315647141534, 59725823074421701127056833740978666663933290178821108672735630979772184382185, 49134097443374726457102109526248286779260519461657250149176335077513192815278, 47887622371924353518042148335513576469407974428663895529535598655562758641712, 77401278667543355790216213576126389056480395142842522512493624067576478647957, 42421818740357345269008297125039063498256069155482230332110328373475756354880, 50720612166765302920113352573577158255644183047862574403453539677091407427379, 63876103360121232899510143818245143640105668544885877370276591093988014501704, 61721909807203663925252684985485621255012442643078377644356014617601131395253, 21803540953486285882395548264941786702036878587769524591818364510951568905732, 66508904537561939583829063825411713457963153580568751858743952780040078537699, 73955364347203093461812330732441423658324476755793246807078992636213770612564, 16154121404109490850133554295816799812259115120653988436050967907122483933240, 30204108548337170867664410488680406651955856502320160369224126288557354450287, 44927574127697857269608503864341333742622132730576555086431003389323507206039, 52771399683417732796641179937781051074039930328470780435942535498621209477173, 56291951698406177798528654460283085130489679703644377707771892796738757306635] '''
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/crypto/wishcAErdS/source.py
ctfs/NTUA_H4CK/2024/crypto/wishcAErdS/source.py
from Crypto.Cipher import AES from Crypto.Util.Padding import pad import os from secret import FLAG def keygen(keysize): key = os.urandom(2) while len(key) != keysize: key += bytes([(key[-2] + key[-1]) % 256]) return key def aesenc(key, msg): return AES.new(key, AES.MODE_ECB).encrypt(pad(msg, 16)) def encrypt(msg): for _ in range(50): key = keygen(16) msg = aesenc(key, msg) return msg enc = encrypt(FLAG).hex() print(f"{enc = }") ''' enc = 666cdbe955066d7c3de97c8abc06427f306825769fc728d87cb683efb5e2567c96157e02869a7a1765245367424b5ca833c2446876686df9db115df63e96045c87e7a5ffec4fabd7c39d66608682a31dc3b3aca49a36f487c0851c6c8cbf3293d4d2cfc3a7a459e9cb45f9e69fa04bd1bad99aa43e3d1a7b12d29a0c1b34b72781eaf20ecd5d126a51484d04d30e9322617869672aad6986a812c0ca1f9b8bdc36fa739dd7d094190f17ae1b43df1f5c1c37e02af8a3bb1d059a0a021f00afe8afaae344b62a5a5b12d3086217f2c40a6a56bcddd2a3565a0ec49bc5e2a304e9c12e667646ea4b59be0b154dec5ccb3d68cac1a5084c6c95154ddead6e683d3dde2ffadcb14e50e67f7d31f8d3ec91f9fff1876541ecb7f91d98fe4955afa6468b095bddd31ec918c132b0115b83407945130efe54b057251d27826a4c4f9e559a1b45ed47ab8ea4d4d58b3b21a6ca84b3f42a28eceeaca2fa77e132413a98f23126da91335f417cf47f95f376a60934575c7e53e1af33da3e3336ee07c0fe21839ee5ef99ece150799d32a660bad69dcc37f2135db5f778b8b2af8ecafeed61cf9c59f1a0f39ec8789c1012d26b4b97d3bf915390b469a057d8d2bfc698ced1612d8b17c7a40f392fb2cfc2cc9781c58209952b6204c95a6bbd902c85171b80fdbeb427626dd01dbd120bcc20ade9c8ab37faa3b9601dc5f423bd2b90e617185c12d3782ef5d0462620c3b95639ef5ef8536f5f0878fe716fbe3719076e8f3922c0e5feceea6a4950306aa4c4088a3b1078d6d19e7c2d7f5819d4e08b7ff1911f5a9fbf2a8142429e6c2ea1c1af9259717014078d2f4e2eb40961ed13a743d1c1e02b33b37dfe26a4ca942b3277748e543a574b1eea039ecaf3f85f12bba0c5b259995ba219a397654bb7afb174a29688e6cf68c66f89921a26e635b6860bb2e9f5a3f8e970396441ac443a3ee880d51e11169a511424a2086dbe6bf769a2f38e7fbd42daed2741641aa291a598cea12452a9c41972051ffe91a1d2e1655bcd0f5a7412f2c1e0b6d8072ee1e7313f83a7934ed23c74bbc6e157732043eb51869dce0f6e3225a67fd2e8dc800027a8efa0b8299b235c1c7184b968fc5c5ea21a96ebec698b50c35fc6697dfe2047d7e9c055359477d459f12f48ae951c99339f42b0d72bc22d6770327fd0fdc14eacd1 '''
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/crypto/Factoring_Expert/server.py
ctfs/NTUA_H4CK/2024/crypto/Factoring_Expert/server.py
import random from Crypto.Util.number import isPrime from secret import FLAG e = 65537 NUMROUNDS = 7 def get_primes_and_messages(nbits): primes = [] messages = [] ind = 0 while True: num = random.randint(0, 2**nbits - 2) poss_prime = int(f"{(1 << nbits) + num}{ind:04}") if isPrime(poss_prime): primes.append(poss_prime) else: messages.append(int(f"{num}{ind:04}")) if len(primes) == 2: return primes, messages ind += 1 print("Welcome to the Advanced Factoring Challenge") print(f"Pass {NUMROUNDS} rounds of tests, and you'll have proven your worth") for i in range(1, 1 + NUMROUNDS): print(f"Round {i}") difficulty = 32*i primes, msgs = get_primes_and_messages(difficulty) p, q = primes n = p*q print(f"{n = }") print("Messages:", [pow(msg, e, n) for msg in msgs]) for msg in msgs: try: answer = int(input()) except: print("something went wrong") exit() if answer != msg: print("Nope") exit() print(FLAG)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/crypto/warmup_rsa/source.py
ctfs/NTUA_H4CK/2024/crypto/warmup_rsa/source.py
from Crypto.Util.number import getPrime, isPrime, bytes_to_long from secret import FLAG def keygen(bitsize): while True: p = getPrime(bitsize) b = getPrime(12) q = p + 42*b**(bitsize//12) + 17*b**(bitsize//24) + 42*b + 1337 if isPrime(q): return p, q SIZE = 384 p, q = keygen(SIZE) n = p*q e = 65537 m = bytes_to_long(FLAG) c = pow(m, e, n) print(f"{n = }") print(f"{c = }") ''' n = 729873623543656312134307118912665256781357935692626903169156150433937519752782083907499829904547040251053110020584673588552287964181185247366145284580956529366829912211930759566764271125168397271330673982376560489636282781549333563 c = 55998184521830999281817039472301544636818114568295094941847806390463936789530964194822878197897166490112675455011157083179676040236474209093809166224001096815812124353799949999248500406044583901981864080093522349557347259218634936 '''
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/crypto/RSA_se_olous_RSei/source.py
ctfs/NTUA_H4CK/2024/crypto/RSA_se_olous_RSei/source.py
from Crypto.Util.number import getPrime from math import prod from sympy import sieve from secret import FLAG FLAGLEN = 18 assert len(FLAG) == FLAGLEN p = getPrime(2048) q = getPrime(2048) n = p*q e = 3 m = prod(pow(sieve[i], FLAG[FLAGLEN - i], n) for i in range(1, FLAGLEN + 1)) c = pow(m, e, n) print(f"{n = }") print(f"{c = }") ''' n = 321349515590314206653975895432643161024198725364502097901215631564603177206154585461760766717276571316410658476289686508260532316793692608064919458948083382483101363059340017926999976568726918773459131692587387645281862701208824882320014814931713846065119696197851641589909024505716513113684648942511811428855541968716867558451395896997093547900543442307479204613943302833055258844470233285415576488376761043630775980792189968000117568621064255260454007993833440149881403737777700074253930163208368182458955127418840485108826775653094305883722679843120609842746545647980276739724453603945098639614587639553894325226064899255912615981939503289649680081061052014214551979109903716116146292105338418383864633246803381013023378185975437824201699259798724795235804527283395691872942543679896169808627298527835697909154189776058293601591652396377584328583130758231889962282254304091789715423552329159359744325620205165341922607813077159373695452179964089108558761156399290075972750245356513875690126014073854317461194248468631565219024533943376250425407183859075767307951412279124314025745800720287511382116534828215106045147829552357220181636869639381059497048529914148702349836113432637407651863422101592478222813758235959596281245096483 c = 261332720226137976530358137785198757089872077737947235494671199683831734450377618120600168743129902865816781161737250942399209702868032520039386249284115238379957133988920240278374695026010437799004653973649293981482252431562143407898652136999340238310717625974743822713232317800335432520580555526676805286700535627757399997430405788883996020667073820252059182768725911866782381816848001049060535665064751177817408100441812852918875511209023710995109768837716326305419984337322503671080842740160876423415829592862873099921788833917251903476825609929001437916213638677452781919466813239817675974854567941673868911691127662754877798002255347442804325092243875749279565769999138563526241734460845462521826321198454323372573536316286485174979152292216850678048992185667162096877672604667753412484304644675431763394997842271158988656189952785029745583181118742362444028707439510059483610703340503414661524126354027729569079905113675851615524351823520431108471456057629195611373530645397692617691297136809228350139475937326983575940694342685307945926705459989465914550726653667632456933670733441103838163008982437138560648251218309526780355286399621347793620941872995356229988532477423672671240951284188906821465163789297363338348704973444 '''
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/crypto/hashmash/source.py
ctfs/NTUA_H4CK/2024/crypto/hashmash/source.py
from hashlib import sha256 from secret import FLAG half = len(FLAG)//2 D1 = [] for i in range(half): D1.append(sha256(FLAG[:i+1]).hexdigest()) print(f"{D1 = }") D2 = [] for i in range(half): D2.append(sha256(FLAG[:half + i+1]).digest()[0]) print(f"{D2 = }") ''' D1 = ['8ce86a6ae65d3692e7305e2c58ac62eebd97d3d943e093f577da25c36988246b', '901a6dbb9f97c74007595dc1901290775e1529ae3f8d9a5640bbe91c4bf41c93', 'dc2a01319c8546410c711a2e401938939cb4814daac73a67c252ca26868400cb', '15f5a3d0069a9ab88cf387c7fcad24a62a224581b38d8ab9352a30abbefb8f64', '78c29bd5820b5cc5eb3b3c92827871e0bcb6c045859258ec40492d983f650baf', 'a13751379a54d556a80871873dc27644b1f0a66da441c461838b101a46d36f92', 'a3b99dd37325ea2c0d5eb60c76e3a39c660d6b5b440b3eafb9dcf5a1717ca344', '231f7a838f5debde215a2e2c74fad32e79e0782f800bfe39b54dcb06ee9892a2', 'd7b0fa0e74ba2014fe5c23c7e28dba562d43a47baeb6f0a0966c6d46d3f7d0a5', 'f40357c3c2ac5f74139ebc29166d92d6480c9a9c0d1376a9c9ef5b6c9c5b8f5b', 'e8bf443ec5b05a828b1217e6508e5737eb90518b310c23e44c4d092a56d48a34', 'f9a509621e4d9af0aef6b628591a01c2c75dc2cb957b52b89f97ae8926beeaa2', '72b8710e6d475eb802a2f0deba7fc37b3379dd597387fc5bd895942f6ac8c5a1', '2a46859282468dce001a26d0ede083f3c2cd8e8c5e17ed88f58e445c5ded64f5', '3e01dc25eb1baafa87dfa38dd077afce7a354b058f62f51c926f2628aebf1d26', '1fece0a3f260b1ce9151d7c16cdb58cad26ffe110f6be3ff270dc5b77010b83d', '684b8cd562d1741c7dd1c3f6ab06f0c9df0473f8431826386d7a65e302ea832e', 'bb7755dab81ab295c56b40975257c526018df0c9647402568768db3be5831dd0', 'd6f718ead48dbcff45ec8f612961b6818b8615b7631daf7942386d8dd7985967', '33797dfa26db72662d5651eb25d4d6510dec5c46c1a623c3c9322859f1c95847', 'bac9ab3ce066098a0bde23768aa113ecaf07803f084efb9fe8e2c7ec05e2fec1', 'e64831491afbb012f377bb58d6f2776813f217c24876d8b6e60688312e38d9b1', '1115f3d57f8d2f23ead7019747225fbf70045edc847fcc47e55b646405bae549', 'ba8e2a06994d0240ee60809bf86df988f1aa740ed4a0211c71fec5875b84ccc5', '5c7880b1dee83f0d7dec570800fc13e9cc557bd914e880c726b7bb6317b54c64', '6caf52846161319fd353c147f4cee1facf8d2506e62b08fb0229a102311e61c7', '72a3a98f3689314fc08db5d8e7a91652e2440898f4ec2bec6897f41e3267a174', 'ee1a111ab87a1e1e4da3962e20df737b6e34044ff274a3e7ae63d4255d6b7594', '03af69e3a8dccbca188b390e11dd38caff5fd70a23bf2c35e3752616818afac1', 'c71f632e1fdee4ee3ef214b1efdb9b6012547a2088fe54f75adca8d3fa55d02b', '5ac663c39cad50e7036a2a2d2527a65a69627476927ed6a405ab166d875e4fa7', 'f1a408975b72a772e98af08827056fb2fdb6c7082d486bd76b4be3929c8bd069', '0f4582100fc61731d946eaf6b288bbb402b925bd383e421ca028f19ff5839eec', '0580bb32ce7c3b941216cff02f3c19d7b0959dcc317787a3b9c0da439d68d4e2', 'fc4b02185991268a8034c0173df1f11404b037039b0d46599d2db886e5deae86', 'c9ce9ec15c04ba72137e2fa70171d2900ed5917938c14ba63d638971c382bfde', '9943e264c931d150eaad0f92da0373f881600fe9c930abc377d123156e501e7d', 'f74fb4aa537513496d3d4dced35c059b372ca2f6acc937d1b5b38a85799309cc', '3668b0c67347d254987491114cf774babd4d77a88a599bb010f2beb92aadf4f6', '56a7b9a211db73bdb2b42c4a54defab2eaa81e21c5c9bc7addff56cd7b637c11', '28aaea9c3e3e74e0b55fd579bfe894e4fd99ded6d3a8e3f802d20e76510a086a', '9798ad79f78c78f9d8e5a649d7e7778dbf305c30ca368f5a4af9b68ac419878b', 'a9cd3b73e792c3657819b900abb1abc7cccac6db40d3ce6c34f6dbaf6335569d', '3456753cc04eeb48a2b046579f171aa7dbfb24313478625408feae9871f4c5ae', '8f88d817c0aadff8876bfc61c16fd815a8c58b52f31eff1ea9906f606ef0099e', 'cf6fcb9e200b7d2fbd01773efb5e6abad96a63826ed380883ce1c5282a630e6e', '84fa03bc6c1d4d3b9ea3a0f16e9c9df5398a01b09161388474839bd53993b5db', 'd0383a2f3359d6382441141d310dd17554372b10b27b38ef9c13557bcd06383e', '7763d89ec6ef546936652b8b8250a0e81b6c3f1490ae1dfbb829f4080129067f', 'fda6a9e2a9ff0f7f3f35f44915eb831b76dcda291cd5b5b2ca95b9b802cdc77a', 'f5943185b2051b78d3cdd9053b6ac24bff2ded1c3359c92efd5eb266c3474496', '86a1a068ba8293987a7264085b6ae932e08d17e37d169ad1925c5d9c22772c59', '5631140684b89df9a779446c01c5e74c1a159005eb2356407099ed0623377164'] D2 = [61, 40, 86, 13, 146, 121, 101, 199, 108, 169, 239, 16, 155, 40, 205, 205, 239, 211, 52, 138, 167, 159, 52, 21, 145, 245, 119, 115, 46, 111, 166, 69, 104, 27, 52, 50, 194, 23, 166, 61, 32, 55, 119, 20, 27, 9, 27, 194, 62, 199, 111, 47, 102] '''
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2021/rev/pickled-onions/chall.py
ctfs/redpwn/2021/rev/pickled-onions/chall.py
__import__('pickle').loads(b'(I128\nI4\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI18\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI104\nI111\nI114\nI115\nI101\nI114\nI97\nI100\nI105\nI115\nI104\nI67\nI65\nI128\nI4\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI97\nI114\nI98\nI101\nI114\nI114\nI121\nI10\nI133\nI82\nI46\nI140\nI14\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI99\nI111\nI99\nI111\nI110\nI117\nI116\nI67\nI65\nI128\nI4\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI115\nI117\nI98\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI97\nI114\nI98\nI101\nI114\nI114\nI121\nI10\nI133\nI82\nI46\nI140\nI13\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI108\nI121\nI99\nI104\nI101\nI101\nI67\nI65\nI128\nI4\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI120\nI111\nI114\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI97\nI114\nI98\nI101\nI114\nI114\nI121\nI10\nI133\nI82\nI46\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI99\nI114\nI97\nI98\nI97\nI112\nI112\nI108\nI101\nI67\nI64\nI128\nI4\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI101\nI113\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI97\nI114\nI98\nI101\nI114\nI114\nI121\nI10\nI133\nI82\nI46\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI112\nI111\nI114\nI116\nI97\nI98\nI101\nI108\nI108\nI97\nI67\nI64\nI128\nI4\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI110\nI101\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI97\nI114\nI98\nI101\nI114\nI114\nI121\nI10\nI133\nI82\nI46\nI140\nI13\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI113\nI117\nI105\nI110\nI99\nI101\nI67\nI64\nI128\nI4\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI101\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI97\nI114\nI98\nI101\nI114\nI114\nI121\nI10\nI133\nI82\nI46\nI140\nI25\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI101\nI97\nI115\nI116\nI101\nI114\nI110\nI109\nI97\nI121\nI104\nI97\nI119\nI116\nI104\nI111\nI114\nI110\nI67\nI64\nI128\nI4\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI101\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI97\nI114\nI98\nI101\nI114\nI114\nI121\nI10\nI133\nI82\nI46\nI140\nI15\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI111\nI110\nI115\nI116\nI101\nI114\nI97\nI67\nI4\nI73\nI49\nI10\nI46\nI140\nI22\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI99\nI111\nI114\nI110\nI101\nI108\nI105\nI97\nI110\nI99\nI104\nI101\nI114\nI114\nI121\nI67\nI4\nI73\nI48\nI10\nI46\nI140\nI21\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI97\nI108\nI108\nI105\nI103\nI97\nI116\nI111\nI114\nI97\nI112\nI112\nI108\nI101\nI67\nI3\nI128\nI4\nI73\nI140\nI18\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI111\nI121\nI115\nI101\nI110\nI98\nI101\nI114\nI114\nI121\nI66\nI208\nI207\nI1\nI0\nI128\nI4\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI14\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI120\nI105\nI109\nI101\nI110\nI105\nI97\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI103\nI114\nI101\nI101\nI107\nI111\nI114\nI101\nI103\nI97\nI110\nI111\nI46\nI106\nI111\nI105\nI110\nI10\nI99\nI98\nI117\nI105\nI108\nI116\nI105\nI110\nI115\nI10\nI109\nI97\nI112\nI10\nI99\nI98\nI117\nI105\nI108\nI116\nI105\nI110\nI115\nI10\nI115\nI116\nI114\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI120\nI105\nI109\nI101\nI110\nI105\nI97\nI10\nI134\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI14\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI120\nI105\nI109\nI101\nI110\nI105\nI97\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI120\nI105\nI109\nI101\nI110\nI105\nI97\nI46\nI101\nI110\nI99\nI111\nI100\nI101\nI10\nI41\nI82\nI100\nI98\nI40\nI140\nI21\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI97\nI108\nI108\nI105\nI103\nI97\nI116\nI111\nI114\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI97\nI108\nI108\nI105\nI103\nI97\nI116\nI111\nI114\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI120\nI105\nI109\nI101\nI110\nI105\nI97\nI10\nI133\nI82\nI100\nI98\nI40\nI140\nI21\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI97\nI108\nI108\nI105\nI103\nI97\nI116\nI111\nI114\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI97\nI108\nI108\nI105\nI103\nI97\nI116\nI111\nI114\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI1\nI10\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI97\nI108\nI108\nI105\nI103\nI97\nI116\nI111\nI114\nI97\nI112\nI112\nI108\nI101\nI10\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI73\nI49\nI10\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82\nI100\nI98\nI40\nI140\nI17\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI98\nI108\nI97\nI99\nI107\nI97\nI112\nI112\nI108\nI101\nI46\nI95\nI95\nI97\nI100\nI100\nI95\nI95\nI10\nI67\nI241\nI112\nI48\nI10\nI48\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI16\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI103\nI48\nI10\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI103\nI116\nI95\nI95\nI10\nI73\nI51\nI50\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI40\nI140\nI23\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI121\nI101\nI108\nI108\nI111\nI119\nI112\nI101\nI97\nI114\nI116\nI111\nI109\nI97\nI116\nI111\nI46\nI95\nI95\nI97\nI110\nI100\nI95\nI95\nI10\nI99\nI105\nI111\nI10\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI109\nI97\nI99\nI97\nI100\nI97\nI109\nI105\nI97\nI46\nI95\nI95\nI108\nI116\nI95\nI95\nI10\nI73\nI49\nI50\nI55\nI10\nI133\nI82\nI133\nI82\nI100\nI98\nI48\nI133\nI82
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
true
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2021/crypto/scissor/encrypt.py
ctfs/redpwn/2021/crypto/scissor/encrypt.py
import random key = random.randint(0, 25) alphabet = 'abcdefghijklmnopqrstuvwxyz' shifted = alphabet[key:] + alphabet[:key] dictionary = dict(zip(alphabet, shifted)) print(''.join([ dictionary[c] if c in dictionary else c for c in input() ]))
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/yahtzee/server.py
ctfs/redpwn/2021/crypto/yahtzee/server.py
#!/usr/local/bin/python from Crypto.Cipher import AES from Crypto.Util.number import long_to_bytes from random import randint from binascii import hexlify with open('flag.txt','r') as f: flag = f.read().strip() with open('keyfile','rb') as f: key = f.read() assert len(key)==32 ''' Pseudorandom number generators are weak! True randomness comes from phyisical objects, like dice! ''' class TrueRNG: @staticmethod def die(): return randint(1, 6) @staticmethod def yahtzee(N): dice = [TrueRNG.die() for n in range(N)] return sum(dice) def __init__(self, num_dice): self.rolls = num_dice def next(self): return TrueRNG.yahtzee(self.rolls) def encrypt(message, key, true_rng): nonce = true_rng.next() cipher = AES.new(key, AES.MODE_CTR, nonce = long_to_bytes(nonce)) return cipher.encrypt(message) ''' Stick the flag in a random quote! ''' def random_message(): NUM_QUOTES = 25 quote_idx = randint(0,NUM_QUOTES-1) with open('quotes.txt','r') as f: for idx, line in enumerate(f): if idx == quote_idx: quote = line.strip().split() break quote.insert(randint(0, len(quote)), flag) return ' '.join(quote) banner = ''' ============================================================================ = Welcome to the yahtzee message encryption service. = = We use top-of-the-line TRUE random number generators... dice in a cup! = ============================================================================ Would you like some samples? ''' prompt = "Would you like some more samples, or are you ready to 'quit'?\n" if __name__ == '__main__': NUM_DICE = 2 true_rng = TrueRNG(NUM_DICE) inp = input(banner) while 'quit' not in inp.lower(): message = random_message().encode() encrypted = encrypt(message, key, true_rng) print('Ciphertext:', hexlify(encrypted).decode()) inp = input(prompt)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false