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/SECCON/2022/Quals/crypto/insufficient/problem.py | ctfs/SECCON/2022/Quals/crypto/insufficient/problem.py | from random import randint
from Crypto.Util.number import getPrime, bytes_to_long
from secret import FLAG
# f(x,y,z) = a1*x + a2*x^2 + a3*x^3
# + b1*y + b2*y^2 + b3*y^3
# + c*z + s mod p
def calc_f(coeffs, x, y, z, p):
ret = 0
ret += x * coeffs[0] + pow(x, 2, p) * coeffs[1] + pow(x, 3, p)*co... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2022/Quals/crypto/janken_vs_kurenaif/server.py | ctfs/SECCON/2022/Quals/crypto/janken_vs_kurenaif/server.py | import os
import signal
import random
import secrets
FLAG = os.getenv("FLAG", "fake{cast a special spell}")
def janken(a, b):
return (a - b + 3) % 3
signal.alarm(1000)
print("kurenaif: Hi, I'm a crypto witch. Let's a spell battle with me.")
witch_spell = secrets.token_hex(16)
witch_rand = random.Random()
witc... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2022/Quals/crypto/witches_symmetric_exam/problem.py | ctfs/SECCON/2022/Quals/crypto/witches_symmetric_exam/problem.py | from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
from Crypto.Util.Padding import pad, unpad
from flag import flag, secret_spell
key = get_random_bytes(16)
nonce = get_random_bytes(16)
def encrypt():
data = secret_spell
gcm_cipher = AES.new(key, AES.MODE_GCM, nonce=nonce)
gcm_ciphe... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2022/Quals/crypto/pqpq/problem.py | ctfs/SECCON/2022/Quals/crypto/pqpq/problem.py | from Crypto.Util.number import *
from Crypto.Random import *
from flag import flag
p = getPrime(512)
q = getPrime(512)
r = getPrime(512)
n = p * q * r
e = 2 * 65537
assert n.bit_length() // 8 - len(flag) > 0
padding = get_random_bytes(n.bit_length() // 8 - len(flag))
m = bytes_to_long(padding + flag)
assert m < n
c... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2022/Quals/crypto/this_is_not_lsb/problem.py | ctfs/SECCON/2022/Quals/crypto/this_is_not_lsb/problem.py | from Crypto.Util.number import *
from flag import flag
p = getStrongPrime(512)
q = getStrongPrime(512)
e = 65537
n = p * q
phi = (p - 1) * (q - 1)
d = pow(e, -1, phi)
print(f"n = {n}")
print(f"e = {e}")
print(f"flag_length = {flag.bit_length()}")
# Oops! encrypt without padding!
c = pow(flag, e, n)
print(f"c = {c}"... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2022/Quals/crypto/BBB/chall.py | ctfs/SECCON/2022/Quals/crypto/BBB/chall.py | from Crypto.Util.number import bytes_to_long, getPrime
from random import randint
from math import gcd
from secret import FLAG
from os import urandom
assert len(FLAG) < 100
def generate_key(rng, seed):
e = rng(seed)
while True:
for _ in range(randint(10,100)):
e = rng(e)
p = getP... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2022/Quals/crypto/BBB/secret.py | ctfs/SECCON/2022/Quals/crypto/BBB/secret.py | # dummy flag
FLAG = b"SECCON{this_is_a_dummy_flag_and_don't_submit}" | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2022/Quals/web/easylfi/web/app.py | ctfs/SECCON/2022/Quals/web/easylfi/web/app.py | from flask import Flask, request, Response
import subprocess
import os
app = Flask(__name__)
def validate(key: str) -> bool:
# E.g. key == "{name}" -> True
# key == "name" -> False
if len(key) == 0:
return False
is_valid = True
for i, c in enumerate(key):
if i == 0:
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2022/Quals/web/bffcalc/backend/app.py | ctfs/SECCON/2022/Quals/web/bffcalc/backend/app.py | import cherrypy
class Root(object):
ALLOWED_CHARS = "0123456789+-*/ "
@cherrypy.expose
def default(self, *args, **kwargs):
expr = str(kwargs.get("expr", 42))
if len(expr) < 50 and all(c in self.ALLOWED_CHARS for c in expr):
return str(eval(expr))
return expr
cherrypy... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2022/Quals/web/bffcalc/bff/app.py | ctfs/SECCON/2022/Quals/web/bffcalc/bff/app.py | import cherrypy
import time
import socket
def proxy(req) -> str:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("backend", 3000))
sock.settimeout(1)
payload = ""
method = req.method
path = req.path_info
if req.query_string:
path += "?" + req.query_string
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2020/Quals/SCSBX_Escape/pow.py | ctfs/SECCON/2020/Quals/SCSBX_Escape/pow.py | """
i.e.
sha256("????v0iRhxH4SlrgoUd5Blu0") = b788094e2d021fa16f30c83346f3c80de5afab0840750a49a9254c2a73ed274c
Suffix: v0iRhxH4SlrgoUd5Blu0
Hash: b788094e2d021fa16f30c83346f3c80de5afab0840750a49a9254c2a73ed274c
"""
import itertools
import hashlib
import string
table = string.ascii_letters + string.digits + "._"
suff... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2020/Quals/kstack/pow.py | ctfs/SECCON/2020/Quals/kstack/pow.py | """
i.e.
sha256("????v0iRhxH4SlrgoUd5Blu0") = b788094e2d021fa16f30c83346f3c80de5afab0840750a49a9254c2a73ed274c
Suffix: v0iRhxH4SlrgoUd5Blu0
Hash: b788094e2d021fa16f30c83346f3c80de5afab0840750a49a9254c2a73ed274c
"""
import itertools
import hashlib
import string
table = string.ascii_letters + string.digits + "._"
suff... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2020/Quals/mlml/env/run.py | ctfs/SECCON/2020/Quals/mlml/env/run.py | #!/usr/bin/env python3.7
import sys
import os
import binascii
import re
import subprocess
import signal
def handler(x, y):
sys.exit(-1)
signal.signal(signal.SIGALRM, handler)
signal.alarm(30)
def is_bad_str(code):
code = code.lower()
# I don't like these words :)
for s in ['__', 'open', 'read', '.'... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2020/Quals/Yet2AnotherPySandbox/run.py | ctfs/SECCON/2020/Quals/Yet2AnotherPySandbox/run.py | #!/usr/bin/env python2.7
from sys import modules
del modules['os']
del modules['sys']
del modules
keys = list(__builtins__.__dict__.keys())
EVAL = eval
LEN = len
RAW_INPUT = raw_input
TRUE = True
FALSE = False
TYPE = type
INT = int
for k in keys:
if k not in []: # Goodbye :)
del __builtins__.__dict__[k]
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2020/Quals/pincette/src/server/server.py | ctfs/SECCON/2020/Quals/pincette/src/server/server.py | #!/usr/bin/env python3
import subprocess
import tempfile
import sys
import shutil
import base64
import os
import pwd
import grp
import signal
ORIGINAL_LIBC = '/lib/x86_64-linux-musl/libc.so'
PIN_PATH = '/opt/pin/pin'
PINCETTE_DIR = '/opt/pincette'
DIRNAME_PREFIX = 'lib_'
IBT_PATH = '/opt/pincette/ibt.so'
def drop_pri... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2020/Quals/YetAnotherPySandbox/run.py | ctfs/SECCON/2020/Quals/YetAnotherPySandbox/run.py | #!/usr/bin/env python2.7
from sys import modules
del modules['os']
del modules['sys']
del modules
keys = list(__builtins__.__dict__.keys())
EVAL = eval
LEN = len
RAW_INPUT = raw_input
TRUE = True
FALSE = False
TYPE = type
INT = int
for k in keys:
if k not in ['False', 'None', 'True', 'bool', 'bytearray', 'bytes',... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SECCON/2020/Quals/encryptor/pow.py | ctfs/SECCON/2020/Quals/encryptor/pow.py | """
i.e.
sha256("????v0iRhxH4SlrgoUd5Blu0") = b788094e2d021fa16f30c83346f3c80de5afab0840750a49a9254c2a73ed274c
Suffix: v0iRhxH4SlrgoUd5Blu0
Hash: b788094e2d021fa16f30c83346f3c80de5afab0840750a49a9254c2a73ed274c
"""
import itertools
import hashlib
import string
table = string.ascii_letters + string.digits + "._"
suff... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WebArena/2025/rev/Reverse_Eng./shadowgate_challenge.py | ctfs/WebArena/2025/rev/Reverse_Eng./shadowgate_challenge.py | import sys
import random
import math
import functools
import operator
import string
import builtins as __b
AlphaCompute = lambda x: x
BetaProcess = lambda x, y: x + y - y
for Q in range(100):
exec(f'def QuantumFunc_{Q}(a): return a')
GammaList = [lambda x: x for _ in range(50)]
for Z in range(50):
GammaList[Z... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | true |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WebArena/2025/rev/Reverse_Again/main.py | ctfs/WebArena/2025/rev/Reverse_Again/main.py | """Phantom Init - CTF Challenge
%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%
%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%
%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%s%%9%%9%%9%%9%%9%%9%%9%%9%%9%%9%%... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | true |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SpringForwardCTF/2023/crypto/A_new_hope/encrypt.py | ctfs/SpringForwardCTF/2023/crypto/A_new_hope/encrypt.py | def encrypt(message, key):
encrypted = ""
for i in range(len(message)):
encrypted += chr(ord(message[i]) ^ ord(key[i % len(key)]))
return encrypted.encode("utf-8").hex()
message = #//////ERROR ERROR ERROR
key = #/////// ERROR OERROR ERROR ERROR
encrypted = encrypt(message,key) | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022-EU/blockchain/jump/scripts/challenge.py | ctfs/NahamCon/2022-EU/blockchain/jump/scripts/challenge.py | from brownie import *
def restricted_accounts():
return [accounts[9]]
def deploy():
Jump.deploy({'from': accounts[9], 'value': web3.toWei(1, 'ether')})
def solved():
if Jump[-1].balance() == 0:
return True, "Solved!"
else:
return False, "Still have funds!"
CONFIG = {
# "RPC": ''... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022-EU/blockchain/BrokenStorage/challenge.py | ctfs/NahamCon/2022-EU/blockchain/BrokenStorage/challenge.py | from brownie import *
def restricted_accounts():
return [accounts[8]]
def deploy():
ADMIN = accounts[8]
buckets = Buckets.deploy({'from': ADMIN})
bucketsProxy = BucketsProxy.deploy(buckets, 5, {'from': ADMIN})
def solved():
ADMIN = accounts[8]
proxy_buckets = Contract.from_abi("Bucke... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022-EU/blockchain/eth_welcome/scripts/challenge.py | ctfs/NahamCon/2022-EU/blockchain/eth_welcome/scripts/challenge.py | from brownie import *
def deploy(state, deployer, player):
Welcome.deploy({'from': deployer[0]})
def solved():
if Welcome[-1].balance() > 0:
return True, "Solved!"
else:
return False, "Need more coins!"
CONFIG = {
# "RPC": '',
# "BLOCK_NUMBER": '',
# 'FLAGS': '',
'MNEMONIC... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022-EU/blockchain/nft_lottery/scripts/challenge.py | ctfs/NahamCon/2022-EU/blockchain/nft_lottery/scripts/challenge.py | from brownie import *
def deploy(state, deployer, player):
ADMIN = deployer[0]
l = LdcNFT.deploy('LdcNFT', 'LDC', 'http://halborn.com', {'from':ADMIN})
l.flipPublicSaleOn({'from': ADMIN})
l.flipSantaAlgorithmOn({'from': ADMIN})
ADMIN.transfer(l, web3.toWei(6, 'ether'))
def solved(state, deplo... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022-EU/blockchain/merkle_heist/scripts/challenge.py | ctfs/NahamCon/2022-EU/blockchain/merkle_heist/scripts/challenge.py | from brownie import *
from brownie import convert
def restricted_accounts():
return [accounts[9]]
def deploy():
ADMIN = accounts[9]
token = SimpleToken.deploy('Simple Token', 'STK', {'from': ADMIN})
_merkleRoot = 0x654ef3fa251b95a8730ce8e43f44d6a32c8f045371ce6a18792ca64f1e148f8c
airdrop = Airdrop... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022-EU/blockchain/proposal_unlock/scripts/challenge.py | ctfs/NahamCon/2022-EU/blockchain/proposal_unlock/scripts/challenge.py | from brownie import *
def deploy(state, deployer, player):
ADMIN = deployer[0]
vedeg = VeHAL.deploy(web3.toWei(100, 'ether'), "Voting HAL", 18, "VeHAL", {'from':ADMIN})
deg = HAL.deploy(web3.toWei(1000000, 'ether'), "HAL Token", 18, "HAL", {'from':ADMIN})
on = OnboardProposal.deploy(deg, vedeg, {'fr... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022-EU/crypto/dont_hack_my_d/gen.py | ctfs/NahamCon/2022-EU/crypto/dont_hack_my_d/gen.py | import random
import time
from Crypto.Util.number import bytes_to_long as b2l, long_to_bytes as l2b, getPrime
time.clock = time.time
# params
p = getPrime(2048)
q = getPrime(2048)
n = p*q
phi = (p-1)*(q-1)
e = 0x10001
d = pow(e, -1, phi)
print(f'e = {e}\nn = {n}')
# flag stuff
flag = open('flag.txt', 'r').read().str... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022-EU/crypto/rektcursion/rektcursion.py | ctfs/NahamCon/2022-EU/crypto/rektcursion/rektcursion.py | import math
import hashlib
from Crypto.Cipher import AES
ENC_MSG = open('msg.enc', 'rb').read()
NUM_HASH = "636e276981116cf433ac4c60ba9b355b6377a50e"
def f(i):
if i < 5:
return i+1
return 1905846624*f(i-5) - 133141548*f(i-4) + 3715204*f(i-3) - 51759*f(i-2) + 360*f(i-1)
# Decrypt the flag
def dec... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022-EU/crypto/Shapeshifter/shapeshifter.py | ctfs/NahamCon/2022-EU/crypto/Shapeshifter/shapeshifter.py | from Crypto.Util.number import bytes_to_long as b2l
FLAG = open('flag.txt', 'r').read().strip().encode()
class LFSR():
def __init__(self, iv):
self.state = [int(c) for c in iv]
#self.state = self.iv
def shift(self):
s = self.state
newbit = s[15] ^ s[13] ^ s[12] ^ s[10] # ^ s[0... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022-EU/web/sigma/scripts/challenge.py | ctfs/NahamCon/2022-EU/web/sigma/scripts/challenge.py | from brownie import *
def deploy():
pass
# EscrowReward.at('0x34a1Ba8Ab01a78747e3623be9Fa90926e0019c87')
# transferOp1 = (
# 0,
# ADMIN,
# approve_selector,
# HALF_ETHER,
# approve_signature["signature"]
# )
# transferOp2 = (
# 0,
# EscrowRe... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2021/crypto/DiceRoll/dice_roll.py | ctfs/NahamCon/2021/crypto/DiceRoll/dice_roll.py | #!/usr/bin/env python3
import random
import os
banner = """
_______
______ | . . |\\
/ /\\ | . |.\\
/ ' / \\ | . . |.'|
/_____/. . \\ |_______|.'|
\\ . . \\ / \\ ' . \\'|
\\ . . \\ / \\____'__\\|
\\_____\\/
D I C E R O L L
"""
menu = """
0. Info
1. Shake... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2021/web/AgentTester/app/app.py | ctfs/NahamCon/2021/web/AgentTester/app/app.py | from flask_uwsgi_websocket import GeventWebSocket
import re
import subprocess
from backend.backend import *
ws = GeventWebSocket(app)
@app.route("/", methods=["GET"])
@login_required
def home():
success = request.args.get("success", None)
error = request.args.get("error", None)
return render_template(
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2021/web/AgentTester/app/backend/models.py | ctfs/NahamCon/2021/web/AgentTester/app/backend/models.py | from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(40), unique=True)
email = db.Column(db.String(100), unique=True)
password = db.Column(db.String(1000), unique=False)
about = db.Column(db.Str... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2021/web/AgentTester/app/backend/backend.py | ctfs/NahamCon/2021/web/AgentTester/app/backend/backend.py | from flask import (
Flask,
render_template,
render_template_string,
request,
redirect,
make_response,
session,
jsonify,
url_for,
g,
)
from functools import wraps
from sqlalchemy import or_
from backend.models import db, User
import os
template_dir = os.path.abspath(".")
app = Fl... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2024/misc/Hashes_on_Hashes_on_Hashes/server.py | ctfs/NahamCon/2024/misc/Hashes_on_Hashes_on_Hashes/server.py | import socket
import base64
from hashlib import md5
from datetime import datetime
host = '0.0.0.0'
port = 9001
class log:
@staticmethod
def print(message):
with open('./decryption_server.log', 'a') as f:
now = datetime.now()
f.write(now.strftime("%d/%m/%Y %H:%M:%S") + "\t")
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2024/crypto/Magic_RSA/rsa_with_a_magic_number.py | ctfs/NahamCon/2024/crypto/Magic_RSA/rsa_with_a_magic_number.py | from secrets import randbits
from sympy import nextprime
e = 3
def encrypt(inp):
p = nextprime(randbits(2048))
q = nextprime(randbits(2048))
n = p * q
enc = [pow(ord(c), e, n) for c in inp]
return [n, enc]
plaintext = open('flag.txt').read()
with open('output.txt', 'w') as f:
data = encrypt(plaintext)
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2024/crypto/Rigged_Lottery/server.py | ctfs/NahamCon/2024/crypto/Rigged_Lottery/server.py | from inputimeout import inputimeout, TimeoutOccurred
import random, sys
with open('flag.txt') as f:
flag = f.read()
def main():
print("Here is how the lottery works:")
print("- Players purchase tickets comprising their choices of six different numbers between 1 and 70")
print("- During the draw, six balls are ran... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2024/crypto/Blackjack/server.py | ctfs/NahamCon/2024/crypto/Blackjack/server.py | # A lot of this code is taken from https://github.com/rishimule/blackjack-python
from inputimeout import inputimeout, TimeoutOccurred
import os, sys
suits = ("Hearts", "Clubs", "Diamonds", "Spades")
ranks = ("Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King", "Ace")
values ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2024/crypto/Encryption_Server/RSA_Encryption_Server.py | ctfs/NahamCon/2024/crypto/Encryption_Server/RSA_Encryption_Server.py | #!/usr/bin/python3
from secrets import randbits
from sympy import nextprime
import random
e = random.randint(500,1000)
def encrypt(inp):
p = nextprime(randbits(1024))
q = nextprime(randbits(1024))
n = p * q
c = [pow(ord(m), e, n) for m in inp]
return [n, c]
def main():
while True:
print('Welcome to the Re... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2023/crypto/ForgeMe_1/crypto.py | ctfs/NahamCon/2023/crypto/ForgeMe_1/crypto.py | import struct
import binascii
""" Implements the SHA1 hash function [1].
Emulates a barebones version of Python's `hashlib.hash` interface [2],
providing the simplest parts:
- update(data): adds binary data to the hash
- hexdigest(): returns the hexed hash value for the data added thus far
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2023/crypto/ForgeMe_1/oracle.py | ctfs/NahamCon/2023/crypto/ForgeMe_1/oracle.py | import socket
import threading
from _thread import *
from Crypto import Random
from binascii import hexlify, unhexlify
import crypto
HOST = '0.0.0.0' # Standard loopback interface address (localhost)
PORT = 1234 # Port to listen on (non-privileged ports are > 1023)
FLAG = open('flag.txt', 'r').read().strip()
ME... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2023/crypto/ForgeMe_2/crypto.py | ctfs/NahamCon/2023/crypto/ForgeMe_2/crypto.py | import struct
import binascii
""" Implements the SHA1 hash function [1].
Emulates a barebones version of Python's `hashlib.hash` interface [2],
providing the simplest parts:
- update(data): adds binary data to the hash
- hexdigest(): returns the hexed hash value for the data added thus far
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2023/crypto/ForgeMe_2/oracle.py | ctfs/NahamCon/2023/crypto/ForgeMe_2/oracle.py | import socket
import threading
from _thread import *
from Crypto.Random import get_random_bytes, random
from binascii import hexlify, unhexlify
import crypto
from wonderwords import RandomWord
HOST = '0.0.0.0' # Standard loopback interface address (localhost)
PORT = 1234 # Port to listen on (non-privileged po... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2023/crypto/RSA_Intro/gen.py | ctfs/NahamCon/2023/crypto/RSA_Intro/gen.py | from Crypto.Util.number import getStrongPrime, getPrime, bytes_to_long as b2l
FLAG = open('flag.txt', 'r').read().strip()
OUT = open('output.txt', 'w')
l = len(FLAG)
flag1, flag2, flag3 = FLAG[:l//3], FLAG[l//3:2*l//3], FLAG[2*l//3:]
# PART 1
e = 0x10001
p = getStrongPrime(1024)
q = getStrongPrime(1024)
n = p*q
ct =... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2023/crypto/Just_One_More/jom.py | ctfs/NahamCon/2023/crypto/Just_One_More/jom.py | import random
OUT = open('output.txt', 'w')
FLAG = open('flag.txt', 'r').read().strip()
N = 64
l = len(FLAG)
arr = [random.randint(1,pow(2, N)) for _ in range(l)]
OUT.write(f'{arr}\n')
s_arr = []
for i in range(len(FLAG) - 1):
s_i = sum([arr[j]*ord(FLAG[j]) for j in range(l)])
s_arr.append(s_i)
arr = [ar... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2023/crypto/RSA_Outro/gen.py | ctfs/NahamCon/2023/crypto/RSA_Outro/gen.py | from Crypto.Util.number import getStrongPrime, isPrime, inverse, bytes_to_long as b2l
FLAG = open('flag.txt', 'r').read()
# safe primes are cool
# https://en.wikipedia.org/wiki/Safe_and_Sophie_Germain_primes
while True:
q = getStrongPrime(512)
p = 2*q + 1
if (isPrime(p)):
break
n = p*q
phi = (p-... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2023/web/Transfer/app.py | ctfs/NahamCon/2023/web/Transfer/app.py | from flask import Flask, request, render_template, redirect, url_for, flash, g, session, send_file
import io
import base64
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user, current_user
from functools import wraps
import sqlite3
import pickle
import os
import uuid
from werkzeug.u... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2025/misc/SSH_Key_Tester/main.py | ctfs/NahamCon/2025/misc/SSH_Key_Tester/main.py | #!/usr/bin/env python3
import os
import base64
import binascii as bi
import tempfile
import traceback
import subprocess
import sys
from flask import Flask, request
import random
sys.path.append("../")
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = '/tmp'
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 1... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2025/crypto/Cookie_Encryption/encryption.py | ctfs/NahamCon/2025/crypto/Cookie_Encryption/encryption.py | from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_v1_5
private_key = RSA.importKey(open('private_key.pem').read())
public_key = private_key.publickey()
def encrypt(plaintext):
cipher_rsa = PKCS1_v1_5.new(public_key)
ciphertext = cipher_rsa.encrypt(plaintext)
return ciphertext
def decrypt(ciphertext... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2025/crypto/Cookie_Encryption/app.py | ctfs/NahamCon/2025/crypto/Cookie_Encryption/app.py | import requests
from flask import Flask, render_template, request, session, redirect, abort, url_for, make_response
from models import db, Users
from sqlalchemy_utils import database_exists
from sqlalchemy.exc import OperationalError
from encryption import encrypt, decrypt
app = Flask(__name__)
app.config.from_object... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2025/crypto/Cryptoclock/server.py | ctfs/NahamCon/2025/crypto/Cryptoclock/server.py | #!/usr/bin/env python3
import socket
import threading
import time
import random
import os
from typing import Optional
def encrypt(data: bytes, key: bytes) -> bytes:
"""Encrypt data using XOR with the given key."""
return bytes(a ^ b for a, b in zip(data, key))
def generate_key(length: int, seed: Optional[floa... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2025/crypto/Cookie_Encryption_2/app.py | ctfs/NahamCon/2025/crypto/Cookie_Encryption_2/app.py | import requests
from flask import (
Flask,
render_template,
request,
session,
redirect,
abort,
url_for,
make_response,
)
from models import db, Users
from sqlalchemy_utils import database_exists
from sqlalchemy.exc import OperationalError
import socket
import time
app = Flask(__name__)... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022/crypto/XORROX/xorrox.py | ctfs/NahamCon/2022/crypto/XORROX/xorrox.py | #!/usr/bin/env python3
import random
with open("flag.txt", "rb") as filp:
flag = filp.read().strip()
key = [random.randint(1, 256) for _ in range(len(flag))]
xorrox = []
enc = []
for i, v in enumerate(key):
k = 1
for j in range(i, 0, -1):
k ^= key[j]
xorrox.append(k)
enc.append(flag[i] ^... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022/crypto/Unimod/unimod.py | ctfs/NahamCon/2022/crypto/Unimod/unimod.py | import random
flag = open('flag.txt', 'r').read()
ct = ''
k = random.randrange(0,0xFFFD)
for c in flag:
ct += chr((ord(c) + k) % 0xFFFD)
open('out', 'w').write(ct)
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022/web/Personnel/app.py | ctfs/NahamCon/2022/web/Personnel/app.py | #!/usr/bin/env python
from flask import Flask, Response, abort, request, render_template
import random
from string import *
import re
app = Flask(__name__)
flag = open("flag.txt").read()
users = open("users.txt").read()
users += flag
@app.route("/", methods=["GET", "POST"])
def index():
if request.method == "... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022/web/Flaskmetal_Alchemist/src/models.py | ctfs/NahamCon/2022/web/Flaskmetal_Alchemist/src/models.py | from database import Base
from sqlalchemy import Column, Integer, String
class Metal(Base):
__tablename__ = "metals"
atomic_number = Column(Integer, primary_key=True)
symbol = Column(String(3), unique=True, nullable=False)
name = Column(String(40), unique=True, nullable=False)
def __init__(self, ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022/web/Flaskmetal_Alchemist/src/seed.py | ctfs/NahamCon/2022/web/Flaskmetal_Alchemist/src/seed.py | from models import Metal, Flag
from database import db_session, init_db
def seed_db():
init_db()
metals = [
Metal(3, "Li", "Lithium"),
Metal(4, "Be", "Beryllium"),
Metal(11, "Na", "Sodium"),
Metal(12, "Mg", "Magnesium"),
Metal(13, "Al", "Aluminum"),
Metal(19, "K... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022/web/Flaskmetal_Alchemist/src/database.py | ctfs/NahamCon/2022/web/Flaskmetal_Alchemist/src/database.py | from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine("sqlite:////tmp/test.db")
db_session = scoped_session(
sessionmaker(autocommit=False, autoflush=False, bind=engine)
)
Base = declarative_base()... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NahamCon/2022/web/Flaskmetal_Alchemist/src/app.py | ctfs/NahamCon/2022/web/Flaskmetal_Alchemist/src/app.py | from flask import Flask, render_template, request, url_for, redirect
from models import Metal
from database import db_session, init_db
from seed import seed_db
from sqlalchemy import text
app = Flask(__name__)
@app.teardown_appcontext
def shutdown_session(exception=None):
db_session.remove()
@app.route("/", me... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NOESCAPE/2022/crypto/HelloSantaII/helloSanta.py | ctfs/NOESCAPE/2022/crypto/HelloSantaII/helloSanta.py | def enc(msg,key):
m=""
i=0
for char in msg:
m+=chr(ord(char)+ord(key[i]))
i+=1
if(i==len(key)):
i=0
return m
def bitEnc(text,key):
m=""
for char in text:
for k in key:
char = chr(ord(char)+ord(k))
m+=char
return m
import io
filename = "helloSanta.txt"
def encryptFile(filename,key):
file = open... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NOESCAPE/2022/crypto/HelloSanta/helloSanta.py | ctfs/NOESCAPE/2022/crypto/HelloSanta/helloSanta.py | def enc(msg,key):
m=""
i=0
for char in msg:
m+=chr(ord(char)+ord(key[i]))
i+=1
if(i==len(key)):
i=0
return m
def bitEnc(text,key):
m=""
for char in text:
for k in key:
char = chr(ord(char)+ord(k))
m+=char
return m
import io
filename = "helloSanta.txt"
def encryptFile(filename,key):
file = open... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2021/rev/babushka/babushka.py | ctfs/UMassCTF/2021/rev/babushka/babushka.py | import copy
import pickle
import types
def DUURNYCDMBIJBETCYLLY(s):
b = True
b = b and (((ord(s[2]) & 0xf0) ^ 64 == 0) and ((ord(s[2]) & 0x0f) ^ 1 == 0))
b = b and (((ord(s[34]) & 0xf0) ^ 112 == 0) and ((ord(s[34]) & 0x0f) ^ 13 == 0))
if ord(s[0]) & 0xf0 == 38:
i = 1
else:
i = 25
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | true |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2021/crypto/malware/malware.py | ctfs/UMassCTF/2021/crypto/malware/malware.py | from Crypto.Cipher import AES
from Crypto.Util import Counter
import binascii
import os
key = os.urandom(16)
iv = int(binascii.hexlify(os.urandom(16)), 16)
for file_name in os.listdir():
data = open(file_name, 'rb').read()
cipher = AES.new(key, AES.MODE_CTR, counter = Counter.new(128, initial_value=iv))
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2021/crypto/Weird_RSA/chall.py | ctfs/UMassCTF/2021/crypto/Weird_RSA/chall.py | import random
from Crypto.Util.number import isPrime
m, Q = """REDACTED""", 1
def genPrimes(size):
base = random.getrandbits(size // 2) << size // 2
base = base | (1 << 1023) | (1 << 1022) | 1
while True:
temp = base | random.getrandbits(size // 4)
if isPrime(temp):
p = temp
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2024/crypto/Third_Times_the_Charm/main.py | ctfs/UMassCTF/2024/crypto/Third_Times_the_Charm/main.py | from Crypto.Util.number import getPrime
with open("flag.txt",'rb') as f:
FLAG = f.read().decode()
f.close()
def encrypt(plaintext, mod):
plaintext_int = int.from_bytes(plaintext.encode(), 'big')
return pow(plaintext_int, 3, mod)
while True:
p = [getPrime(128) for _ in range(6)]
if len(p) ==... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2024/crypto/B4_the_B8/b4b8.py | ctfs/UMassCTF/2024/crypto/B4_the_B8/b4b8.py | import random
import os
import numpy as np
from Crypto.Cipher import AES
ket_0 = np.matrix([1, 0])
ket_1 = np.matrix([0, 1])
ket_plus = (ket_0 + ket_1) / (2 ** (1 / 2))
ket_minus = (ket_0 - ket_1) / (2 ** (1 / 2))
def input_matrix(n):
mat = []
for i in range(n):
row = []
for j in range(n):
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2024/crypto/Brutal_Mogging/main.py | ctfs/UMassCTF/2024/crypto/Brutal_Mogging/main.py | import os
from hashlib import sha256
from flag import FLAG
def xor(data1, data2):
return bytes([data1[i] ^ data2[i] for i in range(len(data1))])
def do_round(data, key):
m = sha256()
m.update(xor(data[2:4], key))
return bytes(data[2:4]) + xor(m.digest()[0:2], data[0:2])
def do_round_inv(data, key):
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2024/crypto/Reader_Exercise/reader-exercise.py | ctfs/UMassCTF/2024/crypto/Reader_Exercise/reader-exercise.py | from Crypto.Util.number import *
from Crypto.Random.random import *
class Polynomial:
def __init__(self, entries):
self.entries = entries
def __add__(self, other):
if len(self.entries) < len(other.entries):
return other + self
return Polynomial(
[x if y == 0 el... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2024/crypto/Shuffling_as_a_Service/saas.py | ctfs/UMassCTF/2024/crypto/Shuffling_as_a_Service/saas.py | import random
import string
from Crypto.Random.random import shuffle
from secrets import randbelow
class BitOfShuffling:
def __init__(self, key_length):
self.perm = [x for x in range(key_length)]
shuffle(self.perm)
def shuffle_int(self, input_int: int):
shuffled_int = 0
for x... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2025/hw/Hidden_in_Flash/client.py | ctfs/UMassCTF/2025/hw/Hidden_in_Flash/client.py | from sys import argv
import socket
import time
MAX_SIZE = 64 * 1024
HOST = "hardware.ctf.umasscybersec.org"
PORT = 10003
if len(argv) != 2:
print(f"Usage: {argv[0]} FIRMWARE_PATH")
exit(1)
with open(argv[1], 'rb') as f:
data = f.read()
if len(data) > MAX_SIZE:
print(f"firmware too large. {len(data)}... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2025/crypto/Brainrot_Gamba/chall.py | ctfs/UMassCTF/2025/crypto/Brainrot_Gamba/chall.py | from Crypto.Cipher import AES
from Crypto.Util.number import getStrongPrime, getRandomNBitInteger
import os
import json
import itertools
normal_deck = [''.join(card) for card in itertools.product("23456789TJQKA", "chds")]
# https://www.rfc-editor.org/rfc/rfc3526#section-3
p = int(""" FFFFFFFF FFFFFFFF C90FDAA2 2168C2... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2025/crypto/Disordered_Tree/redacted_source.py | ctfs/UMassCTF/2025/crypto/Disordered_Tree/redacted_source.py | from Crypto.Util.number import getStrongPrime, getPrime, GCD
import datetime
def encrypt(block, f, g, time):
for c in time:
if c == '1':
block = f(block)
elif c == '0':
block = g(block)
return block
def distribute_keys(block, f, g, start, end, so_far=''):
if all(c... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2025/crypto/BuRGerCode/partial_source.py | ctfs/UMassCTF/2025/crypto/BuRGerCode/partial_source.py | import os
FLAG_OFFSET = REDACTED
FLAG = REDACTED
BURGER_LAYERS = ["Bun (1)", "Lettuce (2)", "Tomato (3)", "Cheese (4)", "Patty (5)", "Onion (6)", "Pickle (7)", "Mayonnaise (8)", "Egg (9)", "Avocado (10)"]
def print_towers(towers):
for i, tower in enumerate(towers):
print(f"Tower {i + 1}: {[BURGER_LAYERS[... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2025/crypto/xorsa/main.py | ctfs/UMassCTF/2025/crypto/xorsa/main.py | from Crypto.Util import number
flag = b"UMASS{REDACTED}"
bits = 1024
p = number.getPrime(bits)
q = number.getPrime(bits)
n = p * q
phi = (p - 1) * (q - 1)
e = 65537
d = number.inverse(e, phi)
c = pow(int.from_bytes(flag, 'big'), e, n)
print(f"n: {n}")
print(f"e: {e}")
print(f"c: {c}")
print(f"partial p^q: {hex((p^q... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2025/crypto/Lazy_Streamer/chall.py | ctfs/UMassCTF/2025/crypto/Lazy_Streamer/chall.py | order = ~(-1 << 512)
mask = 0b10110101001101101110100110111001000101000111000010011000100100101000110001000001011101110101111000110011100001110011100000010100101111001101010101111100110010111011000000111010001001100111000000000100100111100001100010000110011110010001011110101010001001111100010111010111110010111110101010... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2022/crypto/order_of_the_eight_apollonii/ordereightapollonii.py | ctfs/UMassCTF/2022/crypto/order_of_the_eight_apollonii/ordereightapollonii.py | #!/usr/bin/env python3
#
# Polymero
#
# Imports
import numpy as np
import os, random, hashlib
# Local imports
with open('flag.txt','rb') as f:
FLAG = f.read()
f.close()
NBYT = 6
class O8A:
def __init__(self, secret):
if len(secret) > 2*3*NBYT:
raise ValueError('INIT ERROR -- Secret i... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2022/crypto/fastcrypt/fastcrypt_trial.py | ctfs/UMassCTF/2022/crypto/fastcrypt/fastcrypt_trial.py | #!/usr/bin/env python3
#
# Polymero
#
# Imports
import os
# Local imports
with open("flag.txt",'rb') as f:
FLAG = f.read()
f.close()
HDR = r"""|
| __________ ______________ _____
| ___ ____/_____ _________ /__ ____/___________ ___________ /_
| __ /_ _ __ `/_ ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2022/crypto/mtrsass/mtrsass.py | ctfs/UMassCTF/2022/crypto/mtrsass/mtrsass.py | #!/usr/local/bin/python
#
# Polymero
#
# Imports
from Crypto.Util.number import long_to_bytes, bytes_to_long, getPrime, inverse
from base64 import urlsafe_b64encode, urlsafe_b64decode
from hashlib import sha256
import json
# Local imports
with open("flag.txt",'rb') as f:
FLAG = f.read().decode()
f.close()
# ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/UMassCTF/2022/crypto/hatmash/hatmash.py | ctfs/UMassCTF/2022/crypto/hatmash/hatmash.py | #!/usr/bin/env python3
#
# Polymero
#
# Imports
import os
# Local imports
with open('flag.txt','rb') as f:
FLAG = f.read()
f.close()
def bytes_to_mat(x):
assert len(x) == 32
bits = list('{:0256b}'.format(int.from_bytes(x,'big')))
return [[int(j) for j in bits[i:i+16]] for i in range(0,256,16)]
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/pwn/WeX/wex.py | ctfs/X-MAS/2021/pwn/WeX/wex.py | from unicorn import *
from unicorn.x86_const import *
import random
import os
import sys
shellcode = bytes.fromhex(input("Shellcode as hex string? "))
SHELLCODE_LENGTH = len(shellcode)
if SHELLCODE_LENGTH >= 25:
print("Shellcode too long!")
sys.exit(1)
mu = Uc(UC_ARCH_X86, UC_MODE_64)
for reg in [UC_X86_REG... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/rev/Snake_ransomware/mаth.py | ctfs/X-MAS/2021/rev/Snake_ransomware/mаth.py | def print(*Ԯ):
# ይህ ሥራ በቅድሚያ 1,000,000 ዶላር እንደሚያስወጣ ልብ ይበሉ። እባካችሁ ተመከሩ። ትከፍላለህ።
# Talk to me tomorrow. -- Mike
global t
import sys as _
for __ in Ԯ:
_.stdout.write(__)
_.stdout.write("\n")
t -= 1 + int((ord(str("a")) * 10 - 2 / 3 * (3 if _.stdin else 1)) * 0)
t = int(ord(str("а")... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/rev/Snake_ransomware/encryptor.py | ctfs/X-MAS/2021/rev/Snake_ransomware/encryptor.py | import random as ___
import sys as __
import hаshlib as ____
from mаth import print, str, hypot
print(str("your file is encrypting..."))
_____ = str("\162") + str("")
_____ = ____.scrypt("hidden_key_2_do_not_leak_ab283ba920af", _____)
_____ = _____.replace(str("\x00"), str(""))
_ = __.argv[1]
____._ = _
with open(_, ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/rev/Snake_ransomware/hаshlib.py | ctfs/X-MAS/2021/rev/Snake_ransomware/hаshlib.py | #. Copyright (C) 2005-2010 Gregory P. Smith (greg@krypto.org)
# Licensed to PSF under a Contributor Agreement.
#
__doc__ = """hashlib module - A common interface to many hash functions.
new(name, data=b'', **kwargs) - returns a new hash object implementing the
given hash function; ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/crypto/Gnome_Oriented_Programming/challenge.py | ctfs/X-MAS/2021/crypto/Gnome_Oriented_Programming/challenge.py | import os
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls]
class OTPGenerator(metaclass=Singleton):
_OTP_LEN = 128
de... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/crypto/Worst_two_reindeer/proof_of_work.py | ctfs/X-MAS/2021/crypto/Worst_two_reindeer/proof_of_work.py | import os
import string
import sys
import functools
from binascii import unhexlify
from hashlib import sha256
def proof_of_work(nibble_count: int) -> bool:
rand_str = os.urandom(10)
rand_hash = sha256(rand_str).hexdigest()
print(f"Provide a hex string X such that sha256(unhexlify(X))[-{nibble_count}:] = ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/crypto/Worst_two_reindeer/constants.py | ctfs/X-MAS/2021/crypto/Worst_two_reindeer/constants.py | POW_NIBBLES = 5
ACTION_CNT = 4
KEY_SIZE = 64
BLOCK_SIZE = 64
WORD_SIZE = 32
HALF_WORD_SIZE = 16
ROUNDS = 8
FLAG = '[REDACTED]'
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/crypto/Worst_two_reindeer/challenge.py | ctfs/X-MAS/2021/crypto/Worst_two_reindeer/challenge.py | from utils import *
from constants import *
def round_function(inp, key):
i1 = inp[:HALF_WORD_SIZE]
i0 = inp[HALF_WORD_SIZE:]
k1 = key[:HALF_WORD_SIZE]
k0 = key[HALF_WORD_SIZE:]
x = 2 * k1[7] + k1[3]
o1 = rotate_right(xor(i0, k0), x)
o0 = xor(rotate_left(i1, 3), k1)
return o1 + o0
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/crypto/Worst_two_reindeer/utils.py | ctfs/X-MAS/2021/crypto/Worst_two_reindeer/utils.py | def bytes_2_bit_array(x):
result = []
for b in x:
result += [int(a) for a in bin(b)[2:].zfill(8)]
return result
def bit_array_2_bytes(x):
result = b''
for i in range(0, len(x), 8):
result += int(''.join([chr(a + ord('0')) for a in x[i: i + 8]]), 2).to_bytes(1, byteorder='big')
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/crypto/Still_Two_Bad_Reindeer/proof_of_work.py | ctfs/X-MAS/2021/crypto/Still_Two_Bad_Reindeer/proof_of_work.py | import os
import string
import sys
import functools
from binascii import unhexlify
from hashlib import sha256
def proof_of_work(nibble_count: int) -> bool:
rand_str = os.urandom(10)
rand_hash = sha256(rand_str).hexdigest()
print(f"Provide a hex string X such that sha256(unhexlify(X))[-{nibble_count}:] = ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/crypto/Still_Two_Bad_Reindeer/constants.py | ctfs/X-MAS/2021/crypto/Still_Two_Bad_Reindeer/constants.py | ROT_CONSTANTS = [23, 46, 16, 47, 61, 26, 31, 18, 23, 60, 1, 2]
ROUNDS = 6
WORD_SIZE = 64
BLOCK_SIZE = WORD_SIZE * 2
KEY_SIZE = BLOCK_SIZE * ROUNDS
ACTION_COUNT = 8
STEP_COUNT = 10000
POW_NIBBLES = 5
FLAG = '[REDACTED]'
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/crypto/Still_Two_Bad_Reindeer/challenge.py | ctfs/X-MAS/2021/crypto/Still_Two_Bad_Reindeer/challenge.py | import struct
import numpy as np
from constants import *
def rotate_left(word, shift):
return np.bitwise_or(np.left_shift(word, shift), np.right_shift(word, WORD_SIZE - shift))
def rotate_right(word, shift):
return np.bitwise_or(np.right_shift(word, shift), np.left_shift(word, WORD_SIZE - shift))
def roun... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/crypto/Still_Two_Bad_Reindeer/server.py | ctfs/X-MAS/2021/crypto/Still_Two_Bad_Reindeer/server.py | import functools
import os
import sys
import string
import binascii
from constants import *
from proof_of_work import proof_of_work
from challenge import hash_func
def intro_prompt():
print("Randolf: OK, ok... so our first cipher was bad because the xor didn't produce enough randomness"
"and the key-dep... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/crypto/Santas_Secret_Encoding_Machine/proof_of_work.py | ctfs/X-MAS/2021/crypto/Santas_Secret_Encoding_Machine/proof_of_work.py | import os
import string
import sys
import functools
from binascii import unhexlify
from hashlib import sha256
def proof_of_work(nibble_count: int) -> bool:
rand_str = os.urandom(10)
rand_hash = sha256(rand_str).hexdigest()
print(f"Provide a hex string X such that sha256(unhexlify(X))[-{nibble_count}:] = ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/crypto/Santas_Secret_Encoding_Machine/constants.py | ctfs/X-MAS/2021/crypto/Santas_Secret_Encoding_Machine/constants.py | POW_NIBBLES = 5
NO_PRIMES = 8
BIT_SIZE = 16
ACTION_CNT = 16
MAX_ACTIONS = 10000
FLAG = "[REDACTED]"
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/crypto/Santas_Secret_Encoding_Machine/challenge.py | ctfs/X-MAS/2021/crypto/Santas_Secret_Encoding_Machine/challenge.py | import os
from random import SystemRandom
from Crypto.Util.number import isPrime, long_to_bytes
from Crypto.Cipher import AES
from math import ceil
def pad(arr: bytes, size: int) -> bytes:
arr += (16 * size - len(arr)) * b'\x00'
return arr
class challenge:
def __init__(self, bit_cnt: int, no_primes: int... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/crypto/Santas_Secret_Encoding_Machine/server.py | ctfs/X-MAS/2021/crypto/Santas_Secret_Encoding_Machine/server.py | import sys
import functools
import string
import binascii
from constants import *
from proof_of_work import proof_of_work
from challenge import challenge
def intro_prompt(action_count: int):
print(f"Hello there fellow mathematician, as you well know, you have to break this encoding machine!\nAnd not only once, bu... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/web/imagehub/bot/bot.py | ctfs/X-MAS/2021/web/imagehub/bot/bot.py | from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from pyvirtualdisplay import Display
import os
import time
import requ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/web/imagehub/files/main.py | ctfs/X-MAS/2021/web/imagehub/files/main.py | #!/usr/bin/env python3
from flask import Flask, render_template, request, redirect
from flask_hcaptcha import hCaptcha
import uuid
import os
ADMIN_COOKIE = os.environ.get('FLAG', 'X-MAS{test}')
app = Flask (__name__)
images = [{'url': img_url, 'desc': 'meme'} for img_url in open("images.txt", "r").read().strip().spl... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/web/quotehub/bot/bot.py | ctfs/X-MAS/2021/web/quotehub/bot/bot.py | from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from pyvirtualdisplay import Display
import os
import time
import requ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/X-MAS/2021/web/quotehub/files/main.py | ctfs/X-MAS/2021/web/quotehub/files/main.py | #!/usr/bin/env python3
from flask import Flask, render_template, request, redirect
import uuid
import os
FLAG = os.environ.get('FLAG', 'X-MAS{test}')
ADMIN_COOKIE = os.environ.get('ADMIN_COOKIE')
SECRET_TOKEN = os.urandom(64).hex()
app = Flask (__name__)
quotes = [
{'text': 'Man cannot live by bread alone; he mu... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.