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/Hack.lu/2022/web/YummyGIFs/adminbot/bot-master/src/worker.py
ctfs/Hack.lu/2022/web/YummyGIFs/adminbot/bot-master/src/worker.py
import json import subprocess from queue import Queue from threading import Thread, current_thread import log import config bot_queue = Queue() POISON_PILL = 'POISON_PILL' workers = [] def start_worker(i): t = Thread(name='worker-{}'.format(i), target=worker_main, args=[i]) t.start() workers.append(t) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/YummyGIFs/adminbot/bot-master/src/log.py
ctfs/Hack.lu/2022/web/YummyGIFs/adminbot/bot-master/src/log.py
def log(tag, *msg): print(tag, *msg)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/YummyGIFs/adminbot/bot-master/src/config.py
ctfs/Hack.lu/2022/web/YummyGIFs/adminbot/bot-master/src/config.py
import json from time import sleep from threading import Thread from log import log from worker import workers, start_worker, kill_one_worker config = {} old_config = {} config_load = None config_loader = None running = True def init_config(config_file): global config_loader load_config(config_file) con...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/YummyGIFs/adminbot/bot-master/src/recaptcha.py
ctfs/Hack.lu/2022/web/YummyGIFs/adminbot/bot-master/src/recaptcha.py
import json import requests def verify(secret_key, response): """Performs a call to reCaptcha API to validate the given response""" data = { 'secret': secret_key, 'response': response, } r = requests.post('https://www.google.com/recaptcha/api/siteverify', data=data) try: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/YummyGIFs/adminbot/bot-master/src/app.py
ctfs/Hack.lu/2022/web/YummyGIFs/adminbot/bot-master/src/app.py
#!/usr/bin/env python from curses.ascii import SI import os import re import sys import datetime from flask import Flask, request, render_template import config import worker import recaptcha PORT = int(os.getenv('PORT', '5000')) BIND_ADDR = os.getenv('BIND_ADDR', '127.0.0.1') ADMIN_PASS = os.getenv('ADMIN_PASSWORD'...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/babyelectron_2/adminbot/bot-master/src/worker.py
ctfs/Hack.lu/2022/web/babyelectron_2/adminbot/bot-master/src/worker.py
import json import subprocess from queue import Queue from threading import Thread, current_thread import log import config bot_queue = Queue() POISON_PILL = 'POISON_PILL' workers = [] def start_worker(i): t = Thread(name='worker-{}'.format(i), target=worker_main, args=[i]) t.start() workers.append(t) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/babyelectron_2/adminbot/bot-master/src/log.py
ctfs/Hack.lu/2022/web/babyelectron_2/adminbot/bot-master/src/log.py
def log(tag, *msg): print(tag, *msg)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/babyelectron_2/adminbot/bot-master/src/config.py
ctfs/Hack.lu/2022/web/babyelectron_2/adminbot/bot-master/src/config.py
import json from time import sleep from threading import Thread from log import log from worker import workers, start_worker, kill_one_worker config = {} old_config = {} config_load = None config_loader = None running = True def init_config(config_file): global config_loader load_config(config_file) con...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/babyelectron_2/adminbot/bot-master/src/recaptcha.py
ctfs/Hack.lu/2022/web/babyelectron_2/adminbot/bot-master/src/recaptcha.py
import json import requests def verify(secret_key, response): """Performs a call to reCaptcha API to validate the given response""" data = { 'secret': secret_key, 'response': response, } r = requests.post('https://www.google.com/recaptcha/api/siteverify', data=data) try: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/babyelectron_2/adminbot/bot-master/src/app.py
ctfs/Hack.lu/2022/web/babyelectron_2/adminbot/bot-master/src/app.py
#!/usr/bin/env python from curses.ascii import SI import os import re import sys import datetime from flask import Flask, request, render_template import config import worker import recaptcha PORT = int(os.getenv('PORT', '5000')) BIND_ADDR = os.getenv('BIND_ADDR', '127.0.0.1') ADMIN_PASS = os.getenv('ADMIN_PASSWORD'...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/culinary_class_room/worker/app.py
ctfs/Hack.lu/2022/web/culinary_class_room/worker/app.py
from flask import Flask, request, jsonify from tempfile import NamedTemporaryFile import subprocess import re # Reference solution uses 140 lines of code, 250 should be well enough. MAX_DECORATION = 250 decorator_re = re.compile(r'^@[a-z._]+$', re.IGNORECASE) app = Flask(__name__) def checkCode(code): lines = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/foodAPI/src/browser-bot/bot-master/src/worker.py
ctfs/Hack.lu/2022/web/foodAPI/src/browser-bot/bot-master/src/worker.py
import json import subprocess from queue import Queue from threading import Thread, current_thread import log import config bot_queue = Queue() POISON_PILL = 'POISON_PILL' workers = [] def start_worker(i): t = Thread(name='worker-{}'.format(i), target=worker_main, args=[i]) t.start() workers.append(t) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/foodAPI/src/browser-bot/bot-master/src/log.py
ctfs/Hack.lu/2022/web/foodAPI/src/browser-bot/bot-master/src/log.py
def log(tag, *msg): print(tag, *msg)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/foodAPI/src/browser-bot/bot-master/src/config.py
ctfs/Hack.lu/2022/web/foodAPI/src/browser-bot/bot-master/src/config.py
import json from time import sleep from threading import Thread from log import log from worker import workers, start_worker, kill_one_worker config = {} old_config = {} config_load = None config_loader = None running = True def init_config(config_file): global config_loader load_config(config_file) con...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/foodAPI/src/browser-bot/bot-master/src/recaptcha.py
ctfs/Hack.lu/2022/web/foodAPI/src/browser-bot/bot-master/src/recaptcha.py
import json import requests def verify(secret_key, response): """Performs a call to reCaptcha API to validate the given response""" data = { 'secret': secret_key, 'response': response, } r = requests.post('https://www.google.com/recaptcha/api/siteverify', data=data) try: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/foodAPI/src/browser-bot/bot-master/src/app.py
ctfs/Hack.lu/2022/web/foodAPI/src/browser-bot/bot-master/src/app.py
#!/usr/bin/env python import os import re import sys import datetime from flask import Flask, request, render_template import config import worker import recaptcha PORT = int(os.getenv('PORT', '5000')) BIND_ADDR = os.getenv('BIND_ADDR', '127.0.0.1') app = Flask(__name__) @app.route('/', methods=['GET', 'POST']) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/babyelectron_1/adminbot/bot-master/src/worker.py
ctfs/Hack.lu/2022/web/babyelectron_1/adminbot/bot-master/src/worker.py
import json import subprocess from queue import Queue from threading import Thread, current_thread import log import config bot_queue = Queue() POISON_PILL = 'POISON_PILL' workers = [] def start_worker(i): t = Thread(name='worker-{}'.format(i), target=worker_main, args=[i]) t.start() workers.append(t) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/babyelectron_1/adminbot/bot-master/src/log.py
ctfs/Hack.lu/2022/web/babyelectron_1/adminbot/bot-master/src/log.py
def log(tag, *msg): print(tag, *msg)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/babyelectron_1/adminbot/bot-master/src/config.py
ctfs/Hack.lu/2022/web/babyelectron_1/adminbot/bot-master/src/config.py
import json from time import sleep from threading import Thread from log import log from worker import workers, start_worker, kill_one_worker config = {} old_config = {} config_load = None config_loader = None running = True def init_config(config_file): global config_loader load_config(config_file) con...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/babyelectron_1/adminbot/bot-master/src/recaptcha.py
ctfs/Hack.lu/2022/web/babyelectron_1/adminbot/bot-master/src/recaptcha.py
import json import requests def verify(secret_key, response): """Performs a call to reCaptcha API to validate the given response""" data = { 'secret': secret_key, 'response': response, } r = requests.post('https://www.google.com/recaptcha/api/siteverify', data=data) try: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2022/web/babyelectron_1/adminbot/bot-master/src/app.py
ctfs/Hack.lu/2022/web/babyelectron_1/adminbot/bot-master/src/app.py
#!/usr/bin/env python from curses.ascii import SI import os import re import sys import datetime from flask import Flask, request, render_template import config import worker import recaptcha PORT = int(os.getenv('PORT', '5000')) BIND_ADDR = os.getenv('BIND_ADDR', '127.0.0.1') ADMIN_PASS = os.getenv('ADMIN_PASSWORD'...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2020/right-spot/run.py
ctfs/Hack.lu/2020/right-spot/run.py
#!/usr/bin/env python3 import zlib import sys import os import subprocess import io import bz2 import sys from flag import flag COMPRESSED_LIMIT = 2**20 # 1 MB compressed DECOMPRESSED_LIMIT = 30*2**20 # 30 MB uncompressed EXPECTED_STRING = b"pwned!\n" NUM_TESTS = 4 def compress(data): if len(data) > DE...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hack.lu/2020/right-spot/flag.py
ctfs/Hack.lu/2020/right-spot/flag.py
flag = "flag{fake_flag}"
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GLSC/2021/crypto/Bashing_My_Head_In/passwordgen.py
ctfs/GLSC/2021/crypto/Bashing_My_Head_In/passwordgen.py
import time import os import sys class Random: def __init__(self, seed=None): if seed is None: self.seed = int(time.time() * (10 ** 7)) else: try: self.seed = int(seed) except ValueError: raise ValueError("Please use a valid integ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/EBCTF/2022/crypto/cryptomachine01/encrypt.py
ctfs/EBCTF/2022/crypto/cryptomachine01/encrypt.py
#!/usr/bin/env python import sys import binascii import base64 import string if len(sys.argv) < 2: print "Usage: %s <plaintext message>" % sys.argv[0] sys.exit(1) message = sys.argv[1] def h(m): return binascii.hexlify(m) def b(m): return base64.b64encode(m) def r(m): t = string.maketrans( ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/EBCTF/2022/crypto/squaringoff/squaring_off.py
ctfs/EBCTF/2022/crypto/squaringoff/squaring_off.py
#!/usr/bin/python from Crypto.Util.number import bytes_to_long from secret import flag # parameters BASE = 2 MODULUS = 0xfffffffe00000002fffffffe0000000100000001fffffffe00000001fffffffe00000001fffffffefffffffffffffffffffffffe000000000000000000000001 print( pow(BASE, bytes_to_long(flag), MODULUS) )
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/EBCTF/2022/crypto/cryptomachine02/encrypt.py
ctfs/EBCTF/2022/crypto/cryptomachine02/encrypt.py
#!/usr/bin/python import sys, binascii, base64, string, random if len(sys.argv) < 2: print "Usage: %s <flag>" % sys.argv[0] sys.exit(1) flag = sys.argv[1] def H(m): return binascii.hexlify(m) def B(m): return base64.b64encode(m) def R(m): t = string.maketrans( "ABCDEFGHIJKLMNOPQRSTUVWX...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/EBCTF/2022/crypto/everything/query.py
ctfs/EBCTF/2022/crypto/everything/query.py
import sys import gzip import pickle import numpy as np # Import our fancy neural network from gpt import sample if __name__ == "__main__": # Load the model weights ParamW, ParamB, itos, stoi = pickle.load(gzip.open("weights.p.gz","rb")) vocab_size = len(itos) # Get model prompt from first argument ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/EBCTF/2022/crypto/everything/build_model.py
ctfs/EBCTF/2022/crypto/everything/build_model.py
# set up logging import numba import time import pickle import logging from numba.pycc import CC cc = CC('gpt') import numpy as np import math @cc.export('sample', 'i8[:](i8[:], f4[:,:,::1], f4[:,::1])') def sample(xx, ParamW, ParamB): block_size = 128 for k in range(100): x_cond = xx[-block_size...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/EBCTF/2022/crypto/everything/build_weights.py
ctfs/EBCTF/2022/crypto/everything/build_weights.py
import pickle import numpy if __name__ == "__main__": Param = pickle.load(open("model_before.p","rb")) Param.append(np.zeros(94,dtype=np.float32)) itos = np.array([10, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 61, 63, 64, 65, 66, 67, 68...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyBRICS/2021/crypto/Signer/signer.py
ctfs/CyBRICS/2021/crypto/Signer/signer.py
from multiprocessing import Process import os import random import socket from ecdsa import ecdsa as ec from datetime import datetime RNG = random.Random() import hashlib g = ec.generator_192 N = g.order() secret = RNG.randrange(1, N) PUBKEY = ec.Public_key(g, g * secret) PRIVKEY = ec.Private_key(PUBKEY, secret) de...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyBRICS/2021/crypto/To_The_Moon/tothemoon_encrypt.py
ctfs/CyBRICS/2021/crypto/To_The_Moon/tothemoon_encrypt.py
#!/usr/bin/python3.7 import hashlib import os from Crypto.Cipher import AES NUM_REDUNDANT_BITS = 7 def pos_redundant_bits(data, r): # Place redundancy bits to the positions of the power of 2 j = 0 k = 1 m = len(data) res = '' # Insert '0' to the positions of the power of 2 for i in ran...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2024/misc/A_Blockchain_Challenge/interaction.py
ctfs/KalmarCTF/2024/misc/A_Blockchain_Challenge/interaction.py
from pwn import * from Crypto.Hash import SHA256 # my accounts public_keys = {} private_keys = {} balances = {} # Takes sender name and requested new account name, produces an account on chain. def account_generate(rem, sender, name): assert balances[sender] >= 10 rem.recvuntil(b'what would you like to do?') ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2024/misc/A_Blockchain_Challenge/chal.py
ctfs/KalmarCTF/2024/misc/A_Blockchain_Challenge/chal.py
from Crypto.Util.number import getStrongPrime from Crypto.Hash import SHA256 e = 65537 # account name to public keys public_keys = {} # account name to balances balances = {} # account name to secret key, for my own accounts foundation_accounts_sk = {} # total value on the blockchain. starts at 10k (9k foundation, 1...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2024/crypto/Re_Cracking_The_Casino/Pedersen_commitments.py
ctfs/KalmarCTF/2024/crypto/Re_Cracking_The_Casino/Pedersen_commitments.py
from Crypto.Util.number import getStrongPrime from Crypto.Random.random import randint ## Implementation of Pedersen Commitment Scheme ## Computationally binding, information theoreticly hiding # Generate public key for Pedersen Commitments def gen(): q = getStrongPrime(1024) g = randint(1,q-1) s = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2024/crypto/Re_Cracking_The_Casino/casino.py
ctfs/KalmarCTF/2024/crypto/Re_Cracking_The_Casino/casino.py
#!/usr/bin/python3 from Pedersen_commitments import gen, commit, verify # I want to host a trustworthy online casino! # To implement blackjack and craps in a trustworthy way i need verifiable dice and cards! # I've used information theoretic commitments to prevent players from cheating. # Can you audit these functi...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2024/crypto/poLy1305CG/chal.py
ctfs/KalmarCTF/2024/crypto/poLy1305CG/chal.py
#!/usr/bin/env python3 from Crypto.Hash import Poly1305 from Crypto.Cipher import ChaCha20 import os N = 240 S = 10 L = 3 I = 13 with open("flag.txt", "rb") as f: flag = f.read().strip() # "Poly1305 is a universal hash family designed by Daniel J. Bernstein for use in cryptography." - wikipedia def poly1305_has...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2024/crypto/Cracking_The_Casino/Pedersen_commitments.py
ctfs/KalmarCTF/2024/crypto/Cracking_The_Casino/Pedersen_commitments.py
from Crypto.Util.number import getStrongPrime from Crypto.Random.random import randint ## Implementation of Pedersen Commitment Scheme ## Computationally binding, information theoreticly hiding # Generate public key for Pedersen Commitments def gen(): q = getStrongPrime(1024) g = randint(1,q-1) s = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2024/crypto/Cracking_The_Casino/casino.py
ctfs/KalmarCTF/2024/crypto/Cracking_The_Casino/casino.py
#!/usr/bin/python3 from Pedersen_commitments import gen, commit, verify # I want to host a trustworthy online casino! # To implement blackjack and craps in a trustworthy way i need verifiable dice and cards! # I've used information theoretic commitments to prevent players from cheating. # Can you audit these functi...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2023/pwn/mjs/remote.py
ctfs/KalmarCTF/2023/pwn/mjs/remote.py
#!/usr/bin/env python3 import subprocess print("Welcome to mjs.") print("Please give input. End with \"EOF\":") s = "" try: while True: _s = input() if _s == 'EOF': break s += _s except EOFError: pass p = subprocess.Popen(["./mjs", "-e", s]) p.wait()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2023/crypto/EasyOneTimePad/challenge.py
ctfs/KalmarCTF/2023/crypto/EasyOneTimePad/challenge.py
#!/usr/bin/env python3 import os PASS_LENGTH_BYTES = 128 def encrypt_otp(cleartext): key = os.urandom(len(cleartext)) ciphertext = bytes([key[i % len(key)] ^ x for i,x in enumerate(cleartext.hex().encode())]) return ciphertext, key if __name__ == '__main__': print('According to Wikipedia:') pri...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2023/crypto/BabyOneTimePad/challenge_file.py
ctfs/KalmarCTF/2023/crypto/BabyOneTimePad/challenge_file.py
#!/usr/bin/env python3 import os PASS_LENGTH_BYTES = 128 def encrypt_otp(cleartext, key = os.urandom(PASS_LENGTH_BYTES)): ciphertext = bytes([key[i % len(key)] ^ x for i,x in enumerate(cleartext.hex().encode())]) return ciphertext, key if __name__ == '__main__': print('According to Wikipedia:') pri...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2023/crypto/DreamHash/challenge_file.py
ctfs/KalmarCTF/2023/crypto/DreamHash/challenge_file.py
#!/usr/bin/env python3 import random import base64 VALUESIZE = 216 BLOCKSIZE = 16 class Value: def __init__(self, n): if isinstance(n, Value): n = n.n if not (isinstance(n, int) and 0 <= n <= VALUESIZE): raise ValueError self.n = n def __eq__(self, other): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2023/web/HealthyCalc/chall.py
ctfs/KalmarCTF/2023/web/HealthyCalc/chall.py
import asyncio, os from random import choice, randint from celery import Celery from flask import Flask, Blueprint, jsonify OPERATION_SYMBOLS = {"add": "+", "sub": "-", "mult": "*"} OPERATIONS = { "add": lambda lhs, rhs: cache_lookup(_add, lhs, rhs), "sub": lambda lhs, rhs: cache_lookup(_sub, lhs, rhs), ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2023/web/PasswordHomecoming/handout-app.py
ctfs/KalmarCTF/2023/web/PasswordHomecoming/handout-app.py
from flask import Flask, render_template, make_response app = Flask(__name__) # ... @app.before_request def enable_firewall(): if firewall.is_banned(...): return make_response("Your IP has been reported for abusing this websites functionality. Please behave and wait 60 seconds!") def do_render_template(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2025/crypto/Very_Serious_Cryptography/chal.py
ctfs/KalmarCTF/2025/crypto/Very_Serious_Cryptography/chal.py
from Crypto.Cipher import AES from Crypto.Util.Padding import pad import os with open("flag.txt", "rb") as f: flag = f.read() key = os.urandom(16) # Efficient service for pre-generating personal, romantic, deeply heartfelt white day gifts for all the people who sent you valentines gifts for _ in range(1024): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2025/crypto/basic_sums/chal.py
ctfs/KalmarCTF/2025/crypto/basic_sums/chal.py
with open("flag.txt", "rb") as f: flag = f.read() # I found this super cool function on stack overflow \o/ https://stackoverflow.com/questions/2267362/how-to-convert-an-integer-to-a-string-in-any-base def numberToBase(n, b): if n == 0: return [0] digits = [] while n: digits.append(int(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2025/crypto/MonoDOOM/chal.py
ctfs/KalmarCTF/2025/crypto/MonoDOOM/chal.py
from sage.all import * FLAG = b"kalmar{???}" #Formulae from https://www.hyperelliptic.org/EFD/g1p/auto-montgom-xz.html #dbl-1987-m-3 def double(a24, P): X1, Z1 = P A = X1+Z1 AA = A*A B = X1-Z1 BB = B*B C = AA-BB X3 = AA*BB Z3 = C*(BB+a24*C) return (X3, Z3) #dadd-1987-m-3 def dif...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2025/crypto/ZZKAoK/intarg.py
ctfs/KalmarCTF/2025/crypto/ZZKAoK/intarg.py
import hashlib SEP = 'ZProof' def generate_primes(n): num = 3 primes = [2] while len(primes) < n: is_prime = True for i in range(2, int(num ** 0.5) + 1): if num % i == 0: is_prime = False break if is_prime: primes.append(num)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2025/crypto/ZZKAoK/server.py
ctfs/KalmarCTF/2025/crypto/ZZKAoK/server.py
import json from intarg import Verifier, rel_factor try: FLAG = open('flag.txt', 'r').read().strip() except: FLAG = "kalmar{testflag}" NUMBER = int(''' 2519590847565789349402718324004839857142928212620403202777713783604366202070 7595556264018525880784406918290641249515082189298559149176184502808489120072 844...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KalmarCTF/2025/crypto/Not_so_complex_multiplication/chal.py
ctfs/KalmarCTF/2025/crypto/Not_so_complex_multiplication/chal.py
from sage.all import * FLAG = b"kalmar{???}" # Generate secret primes of the form x^2 + 7y^2 ps = [] x = randint(0, 2**100) while gcd(x, 7) > 1: x = randint(0, 2**100) while len(ps) < 10: pi = x**2 + 7*randint(0, 2**100)**2 if is_prime(pi): ps.append(pi) for p in ps: F = GF(p) E = Ellipt...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/pwn/Peaky_and_the_Brain/app.py
ctfs/FwordCTF/2021/pwn/Peaky_and_the_Brain/app.py
# -*- coding: utf-8 -*- from flask import Flask, render_template, request from werkzeug.exceptions import RequestEntityTooLarge from PIL import Image import subprocess import os app = Flask(__name__) app.config['UPLOAD_FOLDER'] = os.path.join('static','uploads') app.config['MAX_CONTENT_LENGTH'] = 10 * 1000 app.secret_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/crypto/Leaky_Blinders/leaky_blinders.py
ctfs/FwordCTF/2021/crypto/Leaky_Blinders/leaky_blinders.py
#!/usr/bin/env python3.8 from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad import sys, os FLAG = b"FwordCTF{###############################################################}" WELCOME = ''' Welcome to Enc/Dec Oracle. ''' key = os.urandom(32) def xor(a, b): return bytearray...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/crypto/Boombastic/boombastic.py
ctfs/FwordCTF/2021/crypto/Boombastic/boombastic.py
#!/usr/bin/env python3.8 from Crypto.Util.number import getStrongPrime, inverse from json import loads, dumps import hashlib, sys, os, signal, random FLAG = "FwordCTF{###############################}" WELCOME = ''' ______________ _(______________() ______ _- | || | ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/crypto/Invincible/invincible.py
ctfs/FwordCTF/2021/crypto/Invincible/invincible.py
#!/usr/bin/env python3.8 from Crypto.Util.number import inverse from Crypto.Cipher import AES from collections import namedtuple import random, sys, os, signal, hashlib FLAG = "FwordCTF{#######################################################}" WELCOME = ''' Welcome to my Invincible Game, let's play. If you can decryp...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/crypto/Procyon/procyon.py
ctfs/FwordCTF/2021/crypto/Procyon/procyon.py
#!/usr/bin/env python3.8 from Crypto.Util.number import getStrongPrime, bytes_to_long, inverse from json import loads, dumps from time import time import os, sys, hashlib, random, signal FLAG = "FwordCTF{####################################################}" assert len(FLAG) < 1024//8 prime = getStrongPrime(1024) cl...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/crypto/Login/login.py
ctfs/FwordCTF/2021/crypto/Login/login.py
#!/usr/bin/env python3.8 from Crypto.Util.number import bytes_to_long, long_to_bytes, inverse, getPrime, GCD import os, hashlib, sys, signal from time import time FLAG = "FwordCTF{####################################################################}" WELCOME = ''' Welcome to CTFCreators Website. We a...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/crypto/Transfer/ed25519.py
ctfs/FwordCTF/2021/crypto/Transfer/ed25519.py
from Crypto.Util.number import long_to_bytes, bytes_to_long, inverse import hashlib b = 256 q = 2**255 - 19 l = 2**252 + 27742317777372353535851937790883648493 d = -121665 * inverse(121666, q) % q I = pow(2, (q-1)//4, q) def H(m): return hashlib.sha512(m).digest() def Hint(m): return bytes_to_long(H(m)) def ad...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/crypto/Transfer/transfer.py
ctfs/FwordCTF/2021/crypto/Transfer/transfer.py
#!/usr/bin/env python3.8 from Crypto.Util.number import long_to_bytes, bytes_to_long, inverse from ed25519 import B, l, H, Hint, mult, add, point_to_bytes, bytes_to_point import os, sys, hashlib, hmac, signal FLAG = "FwordCTF{###########################################################}" WELCOME = '''...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/web/L33k/app/form.py
ctfs/FwordCTF/2021/web/L33k/app/form.py
from flask_wtf import Form, RecaptchaField from wtforms import StringField, validators class ReportForm(Form): url = StringField('Url To Visit', [validators.DataRequired(), validators.Length(max=255)],render_kw={"placeholder": "http://URL/"}) recaptcha = RecaptchaField()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/web/L33k/app/app.py
ctfs/FwordCTF/2021/web/L33k/app/app.py
from flask import Flask,request,render_template,session,redirect from form import ReportForm import os,pymysql import requests,secrets,random,string app= Flask(__name__) app.config["SECRET_KEY"]=os.urandom(15).hex() app.config['RECAPTCHA_USE_SSL']= False app.config['RECAPTCHA_PUBLIC_KEY']= os.getenv("PUBLIC_KEY") app....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/web/Shisui/task/form.py
ctfs/FwordCTF/2021/web/Shisui/task/form.py
from flask_wtf import Form, RecaptchaField from wtforms import StringField, validators class ReportForm(Form): url = StringField('Url To Visit', [validators.DataRequired(), validators.Length(max=255)],render_kw={"placeholder": "http://URL/"}) recaptcha = RecaptchaField()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/web/Shisui/task/app.py
ctfs/FwordCTF/2021/web/Shisui/task/app.py
from flask import Flask,request,render_template,session,redirect from flask_wtf.csrf import CSRFProtect from form import ReportForm import os,ipaddress,pymysql import requests app= Flask(__name__) app.config["SECRET_KEY"]=os.urandom(15).hex() app.config['RECAPTCHA_USE_SSL']= False app.config['RECAPTCHA_PUBLIC_KEY']= o...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/web/SeoFtw/backend/main.py
ctfs/FwordCTF/2021/web/SeoFtw/backend/main.py
from flask import Flask, jsonify,Response, request,g from neo4j import GraphDatabase, basic_auth import os from flask_cors import CORS import ipaddress app = Flask(__name__, static_url_path='/static/') CORS(app) url = os.getenv("NEO4J_URI", "neo4j://neo4j") username = os.getenv("NEO4J_USER", "neo4j") password = os.g...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/web/SeoFtw/backend/init.py
ctfs/FwordCTF/2021/web/SeoFtw/backend/init.py
import os from neo4j import GraphDatabase, basic_auth url = os.getenv("NEO4J_URI", "neo4j://neo4j") username = os.getenv("NEO4J_USER", "neo4j") password = os.getenv("NEO4J_PASSWORD", "fword") database = os.getenv("NEO4J_DATABASE", "neo4j") driver = GraphDatabase.driver(url, auth=basic_auth(username, password),encrypt...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/web/SeoFtw_Revenge/backend/main.py
ctfs/FwordCTF/2021/web/SeoFtw_Revenge/backend/main.py
from flask import Flask, jsonify,Response, request,g from neo4j import GraphDatabase, basic_auth import os from flask_cors import CORS import ipaddress app = Flask(__name__, static_url_path='/static/') CORS(app) url = os.getenv("NEO4J_URI", "neo4j://neo4j") username = os.getenv("NEO4J_USER", "neo4j") password = os.g...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/FwordCTF/2021/web/SeoFtw_Revenge/backend/init.py
ctfs/FwordCTF/2021/web/SeoFtw_Revenge/backend/init.py
import os from neo4j import GraphDatabase, basic_auth url = os.getenv("NEO4J_URI", "neo4j://neo4j") username = os.getenv("NEO4J_USER", "neo4j") password = os.getenv("NEO4J_PASSWORD", "fword") database = os.getenv("NEO4J_DATABASE", "neo4j") driver = GraphDatabase.driver(url, auth=basic_auth(username, password),encrypt...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VolgaCTF/2021/Quals/crypto/Carry/fcsr.py
ctfs/VolgaCTF/2021/Quals/crypto/Carry/fcsr.py
import random import math class FCSR(): def __init__(self, q: int, m: int, a: int): self.m = m self.q = q + 1 self.k = int(math.log(q, 2)) self.a = a @staticmethod def get_i(n: int, i: int) -> int: # right to left return (n & (0b1 << i)) >> i def clock...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VolgaCTF/2021/Quals/crypto/Carry/task.py
ctfs/VolgaCTF/2021/Quals/crypto/Carry/task.py
from fcsr import FCSR if __name__ == '__main__': q = ??? m = ??? a = ??? generator = FCSR(q, m, a) fd = open('original.png', 'rb') data = fd.read() fd.close() encrypted_png = generator.encrypt(data) fd = open('encrypted_png', 'wb') fd.write(encrypted_png) fd.close()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VolgaCTF/2021/Quals/crypto/Knock-Knock/task.py
ctfs/VolgaCTF/2021/Quals/crypto/Knock-Knock/task.py
import os import time class mersenne_rng(object): def __init__(self, seed=5489): self.state = [0] * 624 self.f = 1812433253 self.m = 397 self.u = 11 self.s = 7 self.b = 0x9D2C5680 self.t = 15 self.c = 0xEFC60000 self.l = 18 self.index...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VolgaCTF/2021/Quals/web/flask-admin/routes.py
ctfs/VolgaCTF/2021/Quals/web/flask-admin/routes.py
from app import app, db from flask import render_template, render_template_string, request, flash, redirect, url_for, send_from_directory, make_response, abort import flask_admin as admin from flask_admin import Admin, expose, base from flask_admin.contrib.sqla import ModelView from flask_login import current_user, log...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VolgaCTF/2018/Quals/forbidden/task.py
ctfs/VolgaCTF/2018/Quals/forbidden/task.py
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.ciphers import ( Cipher, algorithms, modes ) from secret import key def encrypt(iv, key, plaintext, associated_data): encryptor = Cipher( algorithms.AES(key), modes.GCM(iv), backend=default_bac...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VolgaCTF/2024/Quals/crypto/Single_R/single_r.py
ctfs/VolgaCTF/2024/Quals/crypto/Single_R/single_r.py
from elliptic_curve import * from secret import flag if __name__ == '__main__': a1 = 0 a3 = 0 p_mod = 116360488056395870563055365435965488415153606823814815615564505122749038681516533 a2 = 7887616263821947558686653170941677360444444810256780630032698031345317313838358 a4 = 96797989774847387504509...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VolgaCTF/2024/Quals/crypto/PQ/pq.py
ctfs/VolgaCTF/2024/Quals/crypto/PQ/pq.py
from secret import flag import gmpy2 import os e = 65537 def generate_pq(): seed_1 = os.urandom(256) seed_2 = os.urandom(128) p = gmpy2.next_prime(int.from_bytes(seed_1, 'big')) q = gmpy2.next_prime(p + int.from_bytes(seed_2, 'big')) return p, q def crypt(text: bytes, number: int, n: int) ->...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/VolgaCTF/2024/Quals/crypto/QR/qr.py
ctfs/VolgaCTF/2024/Quals/crypto/QR/qr.py
from PIL import Image from secret import flag from lfsr_parameters import register, branches import qrcode QR_FILE = 'qr_flag.png' class LFSR: def __init__(self, register, branches): self.register = register self.branches = branches self.n = len(register) def next_bit(self): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/misc/cookie/checker.py
ctfs/AmateursCTF/2024/misc/cookie/checker.py
server_map = open('out.txt').read() player_map = open('player.txt').read() w, l, server_map = server_map.split("/") w2, l2, player_map = player_map.split("/") assert w == w2 and l == l2 and len(server_map) == len(player_map) w, l = int(w), int(l) grid = [[] for i in range(l)] for i in range(len(server_map)//2): id...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/algo/lis/server.py
ctfs/AmateursCTF/2024/algo/lis/server.py
#!/usr/bin/env python3 import secret def check_input(arr): for x in arr: assert 1 <= x <= int(1e9) def check_output(arr, ans): ans.sort() for i in range(len(ans) - 1): assert arr[ans[i]] < arr[ans[i + 1]] def main(): tcs = [] tcs.append(secret.gen(int(9e4), int(1e5))) for...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/rev/dill_with_it/main.py
ctfs/AmateursCTF/2024/rev/dill_with_it/main.py
# Python 3.10.12 from pickle import loads larry = b"\x80\x04ctypes\nFunctionType\n(ctypes\nCodeType\n(I1\nI0\nI0\nI4\nI8\nI67\nCbt\x00\xa0\x01|\x00d\x01\xa1\x02}\x01t\x02|\x01\x83\x01d\x00d\x00d\x02\x85\x03\x19\x00d\x00d\x03\x85\x02\x19\x00}\x00d\x04}\x02t\x03d\x05t\x04|\x00\x83\x01d\x06\x83\x03D\x00]\x11}\x03|\x02t\x0...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/rev/typo/mian.py
ctfs/AmateursCTF/2024/rev/typo/mian.py
import random as RrRrRrrrRrRRrrRRrRRrrRr RrRrRrrrRrRRrrRRrRRrRrr = int('1665663c', 20) RrRrRrrrRrRRrrRRrRRrrRr.seed(RrRrRrrrRrRRrrRRrRRrRrr) arRRrrRRrRRrRRRrRrRRrRr = bytearray(open('flag.txt', 'rb').read()) arRRrrRrrRRrRRRrRrRRrRr = '\r'r'\r''r''\\r'r'\\r\r'r'r''r''\\r'r'r\r'r'r\\r''r'r'r''r''\\r'r'\\r\r'r'r''r''\\r'r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/osint/cherry_blossoms/main.py
ctfs/AmateursCTF/2024/osint/cherry_blossoms/main.py
#!/usr/bin/env python3 # modified from HSCTF 10 grader import json with open("locations.json") as f: locations = json.load(f) wrong = False for i, coords in enumerate(locations, start=1): x2, y2 = coords x, y = map(float, input(f"Please enter the lat and long of the location: ").replace(",","").split(" ")) # inc...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/jail/javajail2/main.py
ctfs/AmateursCTF/2024/jail/javajail2/main.py
#!/usr/local/bin/python3 import subprocess BANNED = ['import', 'throws', 'new'] BANNED += ['File', 'Scanner', 'Buffered', 'Process', 'Runtime', 'ScriptEngine', 'Print', 'Stream', 'Field', 'javax'] BANNED += ['flag.txt', '^', '|', '&', '\'', '\\', '[]', ':'] print(''' Welcome to the Java Jail. Have fun co...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/jail/sansomega/shell.py
ctfs/AmateursCTF/2024/jail/sansomega/shell.py
#!/usr/local/bin/python3 import subprocess BANNED = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\\"\'`:{}[]' def shell(): while True: cmd = input('$ ') if any(c in BANNED for c in cmd): print('Banned characters detected') exit(1) if len(cmd) >= 20: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/jail/zig_jail_2/chal.py
ctfs/AmateursCTF/2024/jail/zig_jail_2/chal.py
#!/usr/local/bin/python3 from tempfile import NamedTemporaryFile, TemporaryDirectory from subprocess import run from os import urandom from string import ascii_letters, digits, punctuation whitelist = [ "import", "bitSizeOf", "sizeOf", "compileError", "TypeOf", "popCount", "clz", "ctz"...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/jail/zig_jail_1/chal.py
ctfs/AmateursCTF/2024/jail/zig_jail_1/chal.py
#!/usr/local/bin/python3 from tempfile import NamedTemporaryFile, TemporaryDirectory from os import urandom, system, mkdir from string import printable from pathlib import Path from shutil import copy blacklist = [ "cInclude", "embedFile", ] character_whitelist = printable def err(code: int, msg: str): p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/jail/pyquinejailgolf/main.py
ctfs/AmateursCTF/2024/jail/pyquinejailgolf/main.py
#!/usr/local/bin/python3 import time from tempfile import TemporaryDirectory with TemporaryDirectory() as workdir: __import__('os').chdir(workdir) __import__('os').mkdir('runtime') print("Enter a reverse quine. It must print its source code backwards (including any trailing newlines).") print("It mus...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/jail/javajail1/main.py
ctfs/AmateursCTF/2024/jail/javajail1/main.py
#!/usr/local/bin/python3 import subprocess BANNED = ['import', 'class', 'Main', '{', '}'] # good luck getting anything to run print(''' Welcome to the Java Jail. Have fun coding in Java! ''') print('''Enter in your code below (will be written to Main.java), end with --EOF--\n''') code = '' while ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/crypto/unsuspicious_rsa/unsuspicious-rsa.py
ctfs/AmateursCTF/2024/crypto/unsuspicious_rsa/unsuspicious-rsa.py
from Crypto.Util.number import * def nextPrime(p, n): p += (n - p) % n p += 1 iters = 0 while not isPrime(p): p += n return p def factorial(n): if n == 0: return 1 return factorial(n-1) * n flag = bytes_to_long(open('flag.txt', 'rb').read().strip()) p = getPrime(512) q = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/crypto/decryption_as_a_service/decryption-as-a-service.py
ctfs/AmateursCTF/2024/crypto/decryption_as_a_service/decryption-as-a-service.py
#!/usr/local/bin/python3 from Crypto.Util.number import * from math import isqrt flag = bytes_to_long(open('flag.txt', 'rb').read()) p, q = getPrime(1024), getPrime(1024) N = p * q e = getPrime(64) d = pow(e, -1, N - p - q + 1) encrypted_flag = pow(flag, e, N) print(f"{encrypted_flag = }") try: for i in range(1...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/crypto/drunk_lcg/drunk-lcg.py
ctfs/AmateursCTF/2024/crypto/drunk_lcg/drunk-lcg.py
#!/usr/local/bin/python3 import sys from random import randint from Crypto.Util.number import * m = 150094635296999121 flag = bytes_to_long(open('flag.txt', 'rb').read()) upper = 1 << (flag.bit_length() + 1) bl = upper.bit_length()//4 def print(a): sys.stdout.write(hex(a)[2:].zfill(bl)) sys.stdout.write('\n'...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/crypto/less_suspicious_rsa/less-suspicious-rsa.py
ctfs/AmateursCTF/2024/crypto/less_suspicious_rsa/less-suspicious-rsa.py
from Crypto.Util.number import * def nextPrime(p, n): p += (n - p) % n p += 1 iters = 0 while not isPrime(p): p += n return p def factorial(n): if n == 0: return 1 return factorial(n-1) * n flag = bytes_to_long(open('flag.txt', 'rb').read().strip()) p = getPrime(512) q = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/crypto/pilfer_techies/pilfer-techies.py
ctfs/AmateursCTF/2024/crypto/pilfer_techies/pilfer-techies.py
#!/usr/local/bin/python3 import hmac from os import urandom def strxor(a: bytes, b: bytes): return bytes([x ^ y for x, y in zip(a, b)]) class Cipher: def __init__(self, key: bytes): self.key = key self.block_size = 16 self.rounds = 256 def F(self, x: bytes): return hmac.n...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/crypto/faked_onion/faked-onion.py
ctfs/AmateursCTF/2024/crypto/faked_onion/faked-onion.py
#!/usr/local/bin/python3 import hmac from os import urandom def strxor(a: bytes, b: bytes): return bytes([x ^ y for x, y in zip(a, b)]) class Cipher: def __init__(self, key: bytes): self.key = key self.block_size = 16 self.rounds = 1 def F(self, x: bytes): return hmac.new...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/crypto/ecsuses/ecsuses.py
ctfs/AmateursCTF/2024/crypto/ecsuses/ecsuses.py
tr = eval(open('tr').read()) flagtxt = open('flagtxt.py').read() exec(flagtxt) with open('flagtxt', 'w') as f: f.write(flagtxt.translate(tr))
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2024/web/one_shot/app.py
ctfs/AmateursCTF/2024/web/one_shot/app.py
from flask import Flask, request, make_response import sqlite3 import os import re app = Flask(__name__) db = sqlite3.connect(":memory:", check_same_thread=False) flag = open("flag.txt").read() @app.route("/") def home(): return """ <h1>You have one shot.</h1> <form action="/new_session" method="POST"><in...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/misc/Censorship_Lite/main.py
ctfs/AmateursCTF/2023/misc/Censorship_Lite/main.py
#!/usr/local/bin/python from flag import flag for _ in [flag]: while True: try: code = ascii(input("Give code: ")) if any([i in code for i in "\lite0123456789"]): raise ValueError("invalid input") exec(eval(code)) except Exception as err: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/misc/q-CHeSHires_game/template.py
ctfs/AmateursCTF/2023/misc/q-CHeSHires_game/template.py
from base64 import b64encode from qiskit import QuantumCircuit # alice_x_0 alice_x_0 = QuantumCircuit(2, 1) ## define your circuit here # alice_x_1 alice_x_1 = QuantumCircuit(2, 1) ## define your circuit here # bob_y_0 bob_y_0 = QuantumCircuit(2, 1) ## define your circuit here # bob_y_1 bob_y_1 = QuantumCircuit(2, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/misc/q-CHeSHires_game/q-cheshires-game.py
ctfs/AmateursCTF/2023/misc/q-CHeSHires_game/q-cheshires-game.py
#!/usr/local/bin/python from base64 import b64decode from tqdm import tqdm from random import randint, shuffle from qiskit import QuantumCircuit, Aer, transpile backend = Aer.get_backend('qasm_simulator') import sys def simulate_round(alice_strategy, bob_strategy): qc = QuantumCircuit(2, 1) qc.h(0) qc.cx(0...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/misc/Censorship/main.py
ctfs/AmateursCTF/2023/misc/Censorship/main.py
#!/usr/local/bin/python from flag import flag for _ in [flag]: while True: try: code = ascii(input("Give code: ")) if "flag" in code or "e" in code or "t" in code or "\\" in code: raise ValueError("invalid input") exec(eval(code)) except Exception...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/misc/q-warmup/q-warmup.py
ctfs/AmateursCTF/2023/misc/q-warmup/q-warmup.py
from qiskit import QuantumCircuit from qiskit import Aer, execute backend = Aer.get_backend('qasm_simulator') def encode(bits): circuit = QuantumCircuit(8) for i, bit in enumerate(bits): if bit == '1': circuit.x(i) for i in range(7, 0, -1): circuit.cx(i, i-1) c...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/algo/whiteboard/main.py
ctfs/AmateursCTF/2023/algo/whiteboard/main.py
#!/usr/local/bin/python from flag import flag import random def my_very_cool_function(x): return pow(x, 2141, 998244353) successes = 0 prefixes = ["1", "4", "1", "2"] suffixes = ["0533", "0708", "1133"] # skittles1412 birthday Orz... May has 30 days ofc (he claims 12/03 but i call cap) def gen_goal(): go...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false