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/CSAW/2022/Quals/crypto/Beyond_Quantum/server.py | ctfs/CSAW/2022/Quals/crypto/Beyond_Quantum/server.py | import numpy as np
import sys
from cipher.cipher import Cipher
from cipher.mathutils import random_poly
from sympy.abc import x
from sympy import ZZ, Poly
import math
def encrypt_command(data, public_key):
input_arr = np.unpackbits(np.frombuffer(data, dtype=np.uint8))
input_arr = np.trim_zeros(input_arr, 'b')... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2022/Quals/crypto/PoodleGiftShop/server.py | ctfs/CSAW/2022/Quals/crypto/PoodleGiftShop/server.py | #!/usr/bin/python3
import hashlib
import hmac
import sys
from base64 import b64encode, b64decode
from Crypto import Random
from Crypto.Cipher import AES
key = open('./key', 'r').read().strip().encode()
flag = open('./flag.txt', 'r').readline().strip().encode()
def get_hmac(m):
return hmac.new(key, msg=m, digest... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2022/Quals/web/GoodIntentions/server/run.py | ctfs/CSAW/2022/Quals/web/GoodIntentions/server/run.py | from application.main import app
from application.database import migrate_db
with app.app_context():
migrate_db()
app.run(host='0.0.0.0', port=1337, debug=False) | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2022/Quals/web/GoodIntentions/server/application/util.py | ctfs/CSAW/2022/Quals/web/GoodIntentions/server/application/util.py | import os
from flask import current_app, abort
from flask_login import current_user
import functools
generate = lambda x: os.urandom(x).hex()
def admin_only(f):
@functools.wraps(f)
def wrap(*args, **kwargs):
if current_user.username == current_app.config['ADMIN_USERNAME']:
return f(*args, ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2022/Quals/web/GoodIntentions/server/application/main.py | ctfs/CSAW/2022/Quals/web/GoodIntentions/server/application/main.py | from flask import Flask, current_app
from flask_login import LoginManager
from flask_session import Session
import logging
import logging.config
from application.blueprints.routes import web, api, response
from application.database import db, User
app=Flask(__name__)
app.config.from_object('application.config.Conf... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2022/Quals/web/GoodIntentions/server/application/database.py | ctfs/CSAW/2022/Quals/web/GoodIntentions/server/application/database.py | from flask_sqlalchemy import SQLAlchemy
from flask_login import UserMixin
from flask import current_app
db = SQLAlchemy()
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(100), unique=True)
password = db.Column(db.String(100))
class Image(db.Mod... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2022/Quals/web/GoodIntentions/server/application/config.py | ctfs/CSAW/2022/Quals/web/GoodIntentions/server/application/config.py | from application.util import generate
import os
class Config(object):
ADMIN_USERNAME = 'admin'
ADMIN_PASSWORD = generate(15)
UPLOAD_FOLDER = f'{os.getcwd()}/application/static'
SECRET_KEY = generate(50)
SESSION_PERMANENT = False
SESSION_TYPE = 'filesystem'
SESSION_KEY_PREFIX = ''
SESSIO... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2022/Quals/web/GoodIntentions/server/application/static/docs/api_client.py | ctfs/CSAW/2022/Quals/web/GoodIntentions/server/application/static/docs/api_client.py | # Sample API client for users who want to get started helping us collect and label space pictures!
import requests
import json
api_url = "http://[IP]:[PORT]"
username = "[USERNAME HERE]"
password = "[PASSWORD HERE]"
image_file = "[FILE NAME HERE]"
label = "[LABEL HERE]"
def register(username, password):
url ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2022/Quals/web/GoodIntentions/server/application/blueprints/routes.py | ctfs/CSAW/2022/Quals/web/GoodIntentions/server/application/blueprints/routes.py | import json
from application.database import User, Image, db, migrate_db
from application.util import admin_only, generate
import sys, os
from subprocess import PIPE, run
from flask import Blueprint, jsonify, redirect, render_template, request, current_app, send_file
from flask_login import current_user, login_require... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2020/Quals/slithery/sandbox.py | ctfs/CSAW/2020/Quals/slithery/sandbox.py | #!/usr/bin/env python3
from base64 import b64decode
import blacklist # you don't get to see this :p
"""
Don't worry, if you break out of this one, we have another one underneath so that you won't
wreak any havoc!
"""
def main():
print("EduPy 3.8.2")
while True:
try:
command = input(">>> "... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/pwn/Blind_Shell/blind.py | ctfs/ImaginaryCTF/2021/pwn/Blind_Shell/blind.py | #!/usr/bin/env python3.8
from subprocess import run
if __name__ == "__main__":
while True:
cmd = input(">>> ")
proc = run([cmd], capture_output=True, shell=True, timeout=60)
if proc.returncode == 0:
print("SUCCESS")
else:
print("FAILURE") | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/pwn/ICICLE_Jail/pwn.py | ctfs/ImaginaryCTF/2021/pwn/ICICLE_Jail/pwn.py | #!/usr/bin/python3 -u
from icicle import *
if __name__ == '__main__':
code = input("Enter a line of icicle code: ")
blacklist = ["read", "write", "flag", "txt", "ictf"]
for i in blacklist:
if i in code:
print("Don't hack me!")
exit()
vm = VM(program=code)
vm.run() | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/pwn/ICICLE_Jail/icicle.py | ctfs/ImaginaryCTF/2021/pwn/ICICLE_Jail/icicle.py | #!/usr/bin/env python3
import sys
from Crypto.Util.number import *
import time
MEMSIZE = 2**16
REGNAMES = ["r%d"%i for i in range(16)]+['rip']
DEBUG = 0
def prd(*args):
if DEBUG:
print(*args)
class MemoryException(Exception):
pass
class Memory():
def __init__(self, size=MEMSIZE, mem=None, rname... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/pwn/Frozen_exploit/icicle.py | ctfs/ImaginaryCTF/2021/pwn/Frozen_exploit/icicle.py | import ast, operator, random, string, sys
from itertools import cycle
TRACE = False
def as_b(x):
if isinstance(x, bytes): return x
return str(x).encode()
def bytes_to_long(a):
return int.from_bytes(a, "big")
def long_to_bytes(a):
return a.to_bytes((a.bit_length() + 7) // 8, "big") or b"\x00"
def equ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/rev/ICICLEs_Facing_the_Sky/icicle.py | ctfs/ImaginaryCTF/2021/rev/ICICLEs_Facing_the_Sky/icicle.py | #!/usr/bin/env python3
import sys
from Crypto.Util.number import *
import time
MEMSIZE = 2**16
REGNAMES = ["r%d"%i for i in range(16)]+['rip']
DEBUG = 0
def prd(*args):
if DEBUG:
print(*args)
class MemoryException(Exception):
pass
class Memory():
def __init__(self, size=MEMSIZE, mem=None, rname... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/rev/Roolang/roolang.py | ctfs/ImaginaryCTF/2021/rev/Roolang/roolang.py | #!/usr/bin/env python3
import sys
from PIL import Image
import numpy as np
class Stack(list):
def push(self, x):
self.append(x)
def peek(self):
return self[-1]
stack = Stack([])
program = []
register = 0
insn_pointer = 0
DEBUG = 0
def robinify(im):
tiles = [im[x:x+128,y:y+128,0:4] for ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/rev/lookup-rev/wpre.py | ctfs/ImaginaryCTF/2021/rev/lookup-rev/wpre.py | from math import sqrt
from itertools import count, islice
def sequence(index):
"""
Generate a W*****l number given the index
"""
element = (index << index) - 1
return element
def is_prime(n):
"""
Check if a given number is prime
"""
return all(n % i for i in islice(count(2), int(sq... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/rev/Salty/bash.py | ctfs/ImaginaryCTF/2021/rev/Salty/bash.py | #!/usr/bin/env python3
import os
import hashlib
def main():
while True:
command = input("bash-4.2$ ")
checkInput(command)
os.system(command)
def checkInput(inp):
if hashlib.sha512(("salt" + inp).encode()).hexdigest() == "".join([chr(ord(n) ^ 69) for n in "p\'|$!$\'\'rttvp#\'utvw# q \'$#v#v\'#|qupr&t\'| ursvv... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/rev/ReDOS/redos.py | ctfs/ImaginaryCTF/2021/rev/ReDOS/redos.py | #!/usr/local/bin/python
import re
# https://pypi.org/project/timeout-decorator/
import timeout_decorator
currentUser = None
users = {"admin@gmail.com":"REDACTED"}
emailRegex = re.compile(r'[A-Za-z0-9]+@((gmail)+)*\.(com|org|edu|gg)')
class TimeoutError(Exception):
pass
def checkUserExists(email):
return email in ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/rev/Ay_Yi_Yi/iii.py | ctfs/ImaginaryCTF/2021/rev/Ay_Yi_Yi/iii.py | #!/usr/bin/env python3
from icicle import *
from PIL import Image
def iii_to_png(fname):
assert fname[-4:] == ".iii"
iii = open(fname, 'rb').read()
assert iii[:4] == b"\x7fIiI"
iii = iii[4:]
w = bytes_to_long(iii[:2])
h = bytes_to_long(iii[2:4])
iii = iii[4:]
assert len(iii)%3 == 0
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/rev/Ay_Yi_Yi/icicle.py | ctfs/ImaginaryCTF/2021/rev/Ay_Yi_Yi/icicle.py | #!/usr/bin/env python3
import sys
from Crypto.Util.number import *
import time
MEMSIZE = 2**16
REGNAMES = ["r%d"%i for i in range(16)]+['rip']
DEBUG = 0
def prd(*args):
if DEBUG:
print(*args)
class MemoryException(Exception):
pass
class ICICLEException(Exception):
pass
class Memory():
def ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/rev/filling-blanks/solve.py | ctfs/ImaginaryCTF/2021/rev/filling-blanks/solve.py | from pwn import *
from ctypes import CDLL, c_int
exe = ELF('./predict', checksec=False)
libc = CDLL('libc.so.6')
p = process(exe.path)
# p = remote('20.94.210.205', 1337)
constants = [____.rand() for i in range(4)]
p.recvuntil('flag: \n')
seed = libc.____(0) // 10
libc.srand(seed)
for i in range(4):
random = lib... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/Flip_Flops/flop.py | ctfs/ImaginaryCTF/2021/crypto/Flip_Flops/flop.py | #!/usr/local/bin/python
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
import binascii
import os
print('''
,,~~~~~~,,..
...., ,'~ |
\ V /
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/Roll_it_back/roll_it_back.py | ctfs/ImaginaryCTF/2021/crypto/Roll_it_back/roll_it_back.py | from itertools import *
from gmpy2 import *
def x(a,b):
return bytes(islice((x^y for x,y in zip(cycle(a), cycle(b))), max(*map(len, [a, b]))))
def t(x):
return sum((((x & 28) >> 4) & 1) << i for i, x in enumerate(x))
T = t(x(b"jctf{not_the_flag}", b"*-*")) | 1
with open("flag.txt", "rb") as f:
flag = int.fr... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/Do_Some_Arithmetic/do_some_arithmetic.py | ctfs/ImaginaryCTF/2021/crypto/Do_Some_Arithmetic/do_some_arithmetic.py | from Crypto.Util.number import bytes_to_long
import hashlib, random
with open("flag.txt", "rb") as f:
flag = bytes_to_long(f.read().strip())
rnd = random.SystemRandom()
def H(m):
return bytes_to_long(hashlib.sha256(m).digest())
def sign(m, x):
k = pow(g2, rnd.randint(1, q - 1), q)
r = pow(g, k, p) %... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/New_Technology/new_technology.py | ctfs/ImaginaryCTF/2021/crypto/New_Technology/new_technology.py | from Crypto.Cipher import AES
from Crypto.Util.number import getPrime, getRandomRange
from Crypto.Util.Padding import pad
import hashlib, itertools
from flag import FLAG
def normalize(fac):
n = 1
for p, e in fac:
n *= p**e
return n
def gen():
private = []
for _ in range(5):
p = ge... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/Textbook_RSA_2_Timmy_the_Lonely_Oracle/oracle.py | ctfs/ImaginaryCTF/2021/crypto/Textbook_RSA_2_Timmy_the_Lonely_Oracle/oracle.py | #!/usr/bin/env -S python3 -u
from Crypto.Util.number import *
from hidden import p, q, flag1
e = 65537
n = p*q
ns = str(n)
ctxt = pow(bytes_to_long(flag1), e, n)
class SneakyUserException(Exception):
pass
def print_ctxt(t):
print("Here's the encrypted message:", t)
print("e =", e)
print("n =", ns)
def encrypt(... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/Too_Old/old.py | ctfs/ImaginaryCTF/2021/crypto/Too_Old/old.py | #!/usr/bin/env python3
import random
from secret import flag
key = random.randint(10**7, 10**8)
out = b""
for c in flag:
out += bytes([c ^ (key&0xff)])
key = int("{:016d}".format(key**2)[4:12])
print(f"{out.hex()}")
# Output:
# e649fd7458fb36acb341346324635da87427d8d25f5c8b7665b921052727bf730f1c0273d00... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/Caesar_Tart/caesartart.py | ctfs/ImaginaryCTF/2021/crypto/Caesar_Tart/caesartart.py | from random import randint
with open('message.txt', 'r') as file:
msg = ''.join(filter(str.isalpha, file.read().strip().upper()))
def caesar(a, key):
return chr(((ord(a) - 0x41 + key) % 26) + 0x41)
keys = [randint(0, 25) for _ in range(randint(5, 10))]
enc = []
for i, c in enumerate(msg):
enc.append(cae... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/neat-rsa/main.py | ctfs/ImaginaryCTF/2021/crypto/neat-rsa/main.py | #!/usr/bin/python3
from Crypto.Util.number import getPrime, bytes_to_long
from os import urandom
with open('flag.txt', 'r') as f:
flag = f.read()
p, q, r = [getPrime(512) for _ in range(3)]
n1, n2 = p * q, q * r
e = 65537
elusive = bytes_to_long(urandom(4))
pt = bytes_to_long(flag.encode())
ct = pow(pt, e, n1)
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/Easy_Crypto_Challenge/super_safe_encryption.py | ctfs/ImaginaryCTF/2021/crypto/Easy_Crypto_Challenge/super_safe_encryption.py | from sage.all import *
import os.path
##############################################################
################ NOT NEEDED TO SOLVE THE CHAL ################
##############################################################
def is_point_on_curve(P,a,b,p):
x = P[0]
y = P[1]
if ((y**2) % p == (x**3 + a*x + b) % p... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/Easy_Crypto_Challenge/super_safe_decryption.py | ctfs/ImaginaryCTF/2021/crypto/Easy_Crypto_Challenge/super_safe_decryption.py | from sage.all import *
# read encrypted
Cs = open("out.txt", "r").readlines()
# initialize same curve
p = 692893
a = 1
b = 6
E = EllipticCurve(GF(p),[a,b])
# initialize Bob's decryption
P = E(683798, 652629)
kA = 4001
#!!!0hH no0... tH3 F1le g07 corRuPt3D!!!#56
B = #!!!0hH no0... tH3 F1le g07 corRuPt3D!!!#* P
# con... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/Lines/lines.py | ctfs/ImaginaryCTF/2021/crypto/Lines/lines.py | from Crypto.Util.number import bytes_to_long
import random
flag = bytes_to_long(open("flag.txt", "rb").read())
msg = bytes_to_long(b":roocursion:")
p = 82820875767540480278499859101602250644399117699549694231796720388646919033627
g = 2
a = random.randint(0, p)
b = random.randint(0, p)
s = pow(pow(g, a, p), b, p)
def... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/Add_and_Add/add_and_add.py | ctfs/ImaginaryCTF/2021/crypto/Add_and_Add/add_and_add.py | import random
with open("flag.txt") as f:
flag = f.read().strip().encode()
x = bytes([random.randrange(256)])
while flag:
y = flag[:len(x)]
flag = flag[len(x):]
x += bytes([(a + b) % 256 for a, b in zip(x, y)])
with open("output.txt", "w") as f:
f.write(x[1:].hex())
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/Horst/horst.py | ctfs/ImaginaryCTF/2021/crypto/Horst/horst.py | import hashlib
ROUNDS = 25
BLOCKSIZE = 32
def xor(a, b):
assert len(a) == len(b)
return bytes(x ^ y for x, y in zip(a, b))
def F(x):
return hashlib.sha256(x).digest()
def round(x):
assert len(x) == 2 * BLOCKSIZE
L = x[:BLOCKSIZE]
R = x[BLOCKSIZE:]
return R + xor(L, F(R))
def encrypt(x):... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/neatX2-rsa/main.py | ctfs/ImaginaryCTF/2021/crypto/neatX2-rsa/main.py | #!/usr/bin/python3
from Crypto.Util.number import getPrime, bytes_to_long
from os import urandom
with open('flag.txt', 'r') as f:
flag = f.read()
l = len(flag)
f1, f2 = flag[:l//2], flag[l//2:]
p, q, r = [getPrime(512) for _ in range(3)]
n1, n2 = p * q, q * r
e = 65537
elusive = bytes_to_long(urandom(4))
pt1 = ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/ZKPoD/zkpod.py | ctfs/ImaginaryCTF/2021/crypto/ZKPoD/zkpod.py | #!/usr/local/bin/python
from Crypto.Util.number import bytes_to_long, getRandomRange
import hashlib
N = 0xbb00128c1c1555dc8fc1cd09b3bb2c3efeaae016fcb336491bd022f83a10a501175c044843dbec0290c5f75d9a93710246361e4822331348e9bf40fc6810d5fc7315f37eb8f06fb3f0c0e9f63c2c207c29f367dc45eef2e5962eff35634b7a29d913a59cd0918fa395571... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/small_enough/small_enough.py | ctfs/ImaginaryCTF/2021/crypto/small_enough/small_enough.py | from Crypto.Util.number import getPrime, bytes_to_long
from math import prod
ps = [getPrime(512) for _ in range(5)]
N1 = prod(ps[:3])
N2 = prod(ps[2:])
e = 0x10001
with open("flag.txt", "rb") as f:
flag = bytes_to_long(f.read())
c1 = pow(flag, e, N1)
c2 = pow(flag, e, N2)
with open("output.txt", "w") as f:
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/Enigma/more_hidden.py | ctfs/ImaginaryCTF/2021/crypto/Enigma/more_hidden.py | from random import randint
with open('flag.txt', 'r') as f:
flag = f.read()
out = open('output.txt', 'a')
def caesar_encrypt(flag, key):
enc_flag = ''
for i in range(len(flag)):
if ord(flag[i]) < 65 or ord(flag[i]) > 90:
enc_flag += flag[i]
else:
enc_flag += chr((((ord(flag[i]) - 65) + key[... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/Reversing_Some_Algorithms/chall.py | ctfs/ImaginaryCTF/2021/crypto/Reversing_Some_Algorithms/chall.py | #!/usr/bin/env python3
from random import randint
import sys
def f(x, y):
if y == 0:
return 1
if y == 1:
return x
return (f((x*x)%n, y//2)*x**(y&1))%n
def main():
flag = input("Enter flag: ")
flagnum = 0
for c in flag:
flagnum += ord(c)
flagnum <<= 8
flagnu... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/crypto/Primetime/primetime.py | ctfs/ImaginaryCTF/2021/crypto/Primetime/primetime.py | #!/usr/bin/env python3
from itertools import islice
from math import gcd
from random import randint
ELEMENT_LEN = 16
def primes():
num = 2
while True:
prime = 1
for i in range(2, num):
if num%i == 0:
prime = 0
if prime:
yield num
num += ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/web/Super_Quantum_League/superquantumleague.py | ctfs/ImaginaryCTF/2021/web/Super_Quantum_League/superquantumleague.py | from flask import Flask, render_template, request
from random import choice
import sqlite3
from sqlite3 import Error
web_site = Flask(__name__)
@web_site.route('/')
def index():
return render_template('index.html')
@web_site.route('/user')
def user():
try:
username = request.args.get('username')
passwo... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/web/Build-A-Website/app.py | ctfs/ImaginaryCTF/2021/web/Build-A-Website/app.py | #!/usr/bin/env python3
from flask import Flask, render_template_string, request, redirect, url_for
from base64 import b64encode, b64decode
app = Flask(__name__)
@app.route('/')
def index():
# i dont remember how to return a string in flask so
# here goes nothing :rooNervous:
return render_template_string(open(... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/web/Sinking_Calculator/app.py | ctfs/ImaginaryCTF/2021/web/Sinking_Calculator/app.py | #!/usr/bin/env python3
from flask import Flask, render_template_string, request
app = Flask(__name__)
@app.route('/')
def index():
return open('templates/index.html').read()
@app.route('/calc')
def calc():
query = request.args['query']
request.args = {}
request.headers = {} # no outside help!
re... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/web/Awkward_Bypass/app.py | ctfs/ImaginaryCTF/2021/web/Awkward_Bypass/app.py | import re
import sqlite3
from flask import Flask, render_template, url_for, request, redirect, make_response
app = Flask(__name__)
blacklist = ["ABORT", "ACTION", "ADD", "AFTER", "ALL", "ALTER", "ALWAYS", "ANALYZE", "AND", "AS", "ASC", "ATTACH", "AUTOINCREMENT", "BEFORE", "BEGIN", "BETWEEN", "CASCADE", "CASE", "CAST"... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/web/SaaS/app.py | ctfs/ImaginaryCTF/2021/web/SaaS/app.py | from flask import Flask, render_template, request
import html
import os
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
blacklist = ["flag", "cat", "|", "&", ";", "`", "$"]
@app.route('/backend')
def backend():
for word in blacklist:
if word in request.args['q... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/web/aMAZEing-challenge/client.py | ctfs/ImaginaryCTF/2021/web/aMAZEing-challenge/client.py | import json
import requests
from os import system
from pprint import pprint
from maze import Maze
from cookie_decoder import cookie_decode
API = "http://127.0.0.1:9001"
# IMPORTANT:
# This is just a template, you can change it or create your own client to talk to the server.
# It's almost impossible to get the flag... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/web/aMAZEing-challenge/cookie_decoder.py | ctfs/ImaginaryCTF/2021/web/aMAZEing-challenge/cookie_decoder.py | """ Flask Session Cookie Decoder/Encoder """
__author__ = 'Wilson Sumanang, Alexandre ZANNI'
# https://github.com/noraj/flask-session-cookie-manager/blob/master/flask_session_cookie_manager3.py
# standard imports
import sys
import zlib
from itsdangerous import base64_decode
import ast
# external Imports
from flask.s... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/web/aMAZEing-challenge/server.py | ctfs/ImaginaryCTF/2021/web/aMAZEing-challenge/server.py | import random
from time import time
from base64 import b64encode
from flask import Flask, session, request, make_response
from maze import Maze
from solver import solve
from random import choice
def gen_sec_key():
return "]!74hc_51ht_3vl0s_yltn4tsn1_ot_no155e5_wen_a_3ta3rc_tn4c_u0y_3rus_m4_I[ftci"[::-1]
def is_pr... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/web/aMAZEing-challenge/maze.py | ctfs/ImaginaryCTF/2021/web/aMAZEing-challenge/maze.py | import random
from os import system
from time import sleep
from solver import solve
START_POS = (1, 1)
MIN_STEPS = 2
WALL = "โโ"
NEWLINE = "\n"
CLEAR = " "
FLAG = "{}"
PLAYER = "[]"
WALL_ALT = "##"
NEWLINE_ALT = "n"
UP, LEFT, DOWN, RIGHT = "w", "a", "s", "d"
class Maze:
def __init__(self, size=(79,39), data... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2021/web/Cookie_Stream/app.py | ctfs/ImaginaryCTF/2021/web/Cookie_Stream/app.py | from flask import Flask, render_template, request, make_response, redirect
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
from binascii import hexlify, unhexlify
from os import urandom
from random import randint
from hashlib import sha512
app = Flask(__name__)
key = urandom(16)
cnonce = uran... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2024/misc/gdbjail1_492_pts/main.py | ctfs/ImaginaryCTF/2024/misc/gdbjail1_492_pts/main.py | import gdb
def main():
gdb.execute("file /bin/cat")
gdb.execute("break read")
gdb.execute("run")
while True:
try:
command = input("(gdb) ")
if command.strip().startswith("break") or command.strip().startswith("set") or command.strip().startswith("continue"):
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2024/misc/Left_in_the_Dark/maze.py | ctfs/ImaginaryCTF/2024/misc/Left_in_the_Dark/maze.py | #!/usr/bin/env python3
from random import choice
from copy import deepcopy
# https://pypi.org/project/console/
from console.utils import wait_key
class Maze:
def __init__(self, dim, size):
self.dim = dim
self.size = size
self.maze = '#'
self.loc = tuple([0]*dim)
for i in ra... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2024/misc/ok_nice/jail.py | ctfs/ImaginaryCTF/2024/misc/ok_nice/jail.py | #!/usr/bin/env python3
flag = open('flag.txt').read()
print("Welcome to the jail! It is so secure I even have a flag variable!")
blacklist=['0','1','2','3','4','5','6','7','8','9','_','.','=','>','<','{','}','class','global','var','local','import','exec','eval','t','set','blacklist']
while True:
inp = input("Enter in... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2024/misc/starship/main.py | ctfs/ImaginaryCTF/2024/misc/starship/main.py | #!/usr/bin/env python3
import pandas as pd
from io import StringIO
from sklearn.neighbors import KNeighborsClassifier
from gen import gen_data
done = False
flag = open("flag.txt").read().strip()
def menu():
print("1. show dataset")
print("2. train model")
print("3. predict state")
print("4. check incoming ob... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2024/misc/gdbjail2/main.py | ctfs/ImaginaryCTF/2024/misc/gdbjail2/main.py | import gdb
blacklist = ["p", "-", "&", "(", ")", "[", "]", "{", "}", "0x"]
def main():
gdb.execute("file /bin/cat")
gdb.execute("break read")
gdb.execute("run")
while True:
try:
command = input("(gdb) ")
if any([word in command for word in blacklist]):
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2024/misc/gdbjail1/main.py | ctfs/ImaginaryCTF/2024/misc/gdbjail1/main.py | import gdb
def main():
gdb.execute("file /bin/cat")
gdb.execute("break read")
gdb.execute("run")
while True:
try:
command = input("(gdb) ")
if command.strip().startswith("break") or command.strip().startswith("set") or command.strip().startswith("continue"):
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2024/misc/calc/server.py | ctfs/ImaginaryCTF/2024/misc/calc/server.py | #!/usr/bin/env python3
from sys import addaudithook
from os import _exit
from re import match
def safe_eval(exit, code):
def hook(*a):
exit(0)
def dummy():
pass
dummy.__code__ = compile(code, "<code>", "eval")
addaudithook(hook)
return dummy()
if __name__ == "__main__":
exp... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2024/rev/vokram/vm.py | ctfs/ImaginaryCTF/2024/rev/vokram/vm.py | #!/usr/bin/env python3
def vokram(text, program):
while True:
for pat, repl, stop in program:
if pat in text:
text = text.replace(pat, repl, 1)
if stop:
return text
break
else:
return text
def parse(source)... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2024/crypto/solitude/main.py | ctfs/ImaginaryCTF/2024/crypto/solitude/main.py | #!/usr/bin/env python3
import random
def xor(a: bytes, b: bytes):
out = []
for m,n in zip(a,b):
out.append(m^n)
return bytes(out)
class RNG():
def __init__(self, size, state=None):
self.size = size
self.state = list(range(self.size+2))
random.shuffle(self.state)
def next(self):
idx = se... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2024/crypto/integrity/main.py | ctfs/ImaginaryCTF/2024/crypto/integrity/main.py | from Crypto.Util.number import *
from binascii import crc_hqx
p = getPrime(1024)
q = getPrime(1024)
n = p*q
e = 65537
tot = (p-1)*(q-1)
d = pow(e, -1, tot)
flag = bytes_to_long(open("flag.txt", "rb").read())
ct = pow(flag, e, n)
#signature = pow(flag, d, n) # no, im not gonna do that
signature = pow(flag, crc_hqx(l... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2024/crypto/notitle/chall.py | ctfs/ImaginaryCTF/2024/crypto/notitle/chall.py | from sage.all import *
import os
from Crypto.Cipher import AES
from hashlib import sha512
proof.all(False)
p = 0x7AADA0BA1C05D63803BA6BCE66CB6BC091C7ADA62B5CB5BC9F924B528FC113971D4BC54C7FAF3C146ADEB0548BFB9258DFF316741266B802DD7A2F46F77593BAD983E6DF394C1519E8DB0130289FA5A9C628E3ABCE58C63B3379DB7088AAC7A40B63776959774B... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2024/crypto/lf3r/chall.py | ctfs/ImaginaryCTF/2024/crypto/lf3r/chall.py | import secrets, os
n = 256
MASK = 0x560074275752B31E43E64E99D996BC7B5A8A3DAC8B472FE3B83E6C6DDB5A26E7
class LF3R:
def __init__(self, n, key, mask):
self.n = n
self.state = key & ((1 << n) - 1)
self.mask = mask
def __call__(self):
v = self.state % 3
self.state = (self.s... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2024/crypto/tango/server.py | ctfs/ImaginaryCTF/2024/crypto/tango/server.py | from Crypto.Cipher import Salsa20
from Crypto.Util.number import bytes_to_long, long_to_bytes
import json
from secrets import token_bytes, token_hex
from zlib import crc32
from secret import FLAG
KEY = token_bytes(32)
def encrypt_command(command):
if len(command) != 3:
print('Nuh uh.')
return
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2024/crypto/base64/main.py | ctfs/ImaginaryCTF/2024/crypto/base64/main.py | from Crypto.Util.number import bytes_to_long
q = 64
flag = open("flag.txt", "rb").read()
flag_int = bytes_to_long(flag)
secret_key = []
while flag_int:
secret_key.append(flag_int % q)
flag_int //= q
print(f"{secret_key = }")
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/misc/Temu/temu.py | ctfs/ImaginaryCTF/2023/misc/Temu/temu.py | #!/usr/bin/env python3
# https://pypi.org/project/console/
from console.screen import Screen
from console.utils import wait_key
from console import fg
from multiprocessing import Process, Manager
from typing import List
from dataclasses import dataclass
import re
@dataclass
class File:
name: str
contents: st... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/misc/deletion/main.py | ctfs/ImaginaryCTF/2023/misc/deletion/main.py | #!/usr/bin/env python3
canary = "You will not get the flag!"
inp = input("Enter your payload: ")
reward = input("Enter your reward: ")
for c in inp:
if ord(c) < ord('\n') or ord(c) > ord('~'):
print("Fail!")
exit()
if any([n in inp for n in "dfjlquvwz=_.~!@#$%^&*()[]{}\n;\"'?<>/\\-+|`0123456789 \t"]):
p... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/misc/Get_and_set/server.py | ctfs/ImaginaryCTF/2023/misc/Get_and_set/server.py | #!/usr/bin/env python3
import pydash
class Dummy:
pass
if __name__ == "__main__":
obj = Dummy()
while True:
src = input("src: ")
dst = input("dst: ")
pydash.set_(obj, dst, pydash.get(obj, src))
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/misc/You_shall_not_call_Revenge/server.py | ctfs/ImaginaryCTF/2023/misc/You_shall_not_call_Revenge/server.py | import __main__
import pickle
import io
# Security measure -- forbid calls
for op in ['reduce', 'inst', 'obj', 'newobj', 'newobj_ex']: #pickle.REDUCE, pickle.INST, pickle.OBJ, pickle.NEWOBJ, pickle.NEWOBJ_EX]:
id = getattr(pickle, op.upper())[0]
delattr(pickle._Unpickler, pickle._Unpickler.dispatch[id].__name_... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/misc/You_shall_not_call/server.py | ctfs/ImaginaryCTF/2023/misc/You_shall_not_call/server.py | import __main__
import pickle
import io
# Security measure -- forbid calls
for op in ['reduce', 'inst', 'obj', 'newobj', 'newobj_ex']: #pickle.REDUCE, pickle.INST, pickle.OBJ, pickle.NEWOBJ, pickle.NEWOBJ_EX]:
id = getattr(pickle, op.upper())[0]
delattr(pickle._Unpickler, pickle._Unpickler.dispatch[id].__name_... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/rev/chaos/chall.py | ctfs/ImaginaryCTF/2023/rev/chaos/chall.py | inp = input("What is the flag? ").encode().zfill(51)
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | true |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/rev/Sheepish/sheepish.py | ctfs/ImaginaryCTF/2023/rev/Sheepish/sheepish.py | print((((lambda _____________:((lambda ___:_____________(lambda _______:___(___)(_______)))(lambda ___:_____________(lambda _______:___(___)(_______)))))(lambda _____________:lambda ___________:lambda ______:(lambda ____:(lambda _:_(lambda __________:lambda _____:__________))(____))(___________)(lambda _:(lambda ______... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/rev/snailchecker/check.py | ctfs/ImaginaryCTF/2023/rev/snailchecker/check.py | #!/usr/bin/env python3
def enc(b):
a = [n for n in range(b[0]*2**24+b[1]*2**16+b[2]*2**8+b[3]+1)][1:]
c,i = 0,0
while len([n for n in a if n != 0]) > 1:
i%=len(a)
if (a[i]!=0 and c==1):
a[i],c=0,0
if (a[i] != 0):
c+=1
i += 1
return sum(a)
print(r"""
.----. @ @
/ .-"-.`. \v/
| | '\ \ \... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/rev/Goated/goated.py | ctfs/ImaginaryCTF/2023/rev/Goated/goated.py | print((((lambda ______:((lambda ___:______(lambda _:___(___)(_)))(lambda ___:______(lambda _:___(___)(_)))))(lambda ______:lambda __:lambda _________________:(lambda _________:(lambda _____________:_____________(lambda ____________:lambda ______________:____________))(_________))(__)(lambda _:(lambda ____________:lambd... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | true |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/crypto/Imaginary_Casino/server.py | ctfs/ImaginaryCTF/2023/crypto/Imaginary_Casino/server.py | import ctypes
import os
from hashlib import sha512
import signal
# libcsidh interop start
# modified from DiceCTF 2023 - seaside
PRIVATE_KEY_SIZE = 74
PUBLIC_KEY_SIZE = 64
MAX_EXPONENT = 5
# libcsidh: https://yx7.cc/code/csidh/csidh-latest.tar.xz
# Run this to build libcsidh: `(cd csidh-20210627; make; mv libcsidh.s... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/crypto/emoticons/gen.py | ctfs/ImaginaryCTF/2023/crypto/emoticons/gen.py | import random
emojis = [n for n in "๐ธ๐๐ณ๐๐๐๐ฆ๐๐ถ๐๐บ๐ธโก๏ธ๐ฆ๐ผ๐"]
m = open("text.txt", "rb").read().hex()
random.shuffle(emojis)
for e, c in zip(emojis, "0123456789abcdef"):
m = m.replace(c, e)
open("out.txt", "w").write(m)
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/crypto/Sus/challenge.py | ctfs/ImaginaryCTF/2023/crypto/Sus/challenge.py | from Crypto.Util.number import getPrime, isPrime, bytes_to_long
def sus(sz, d):
while True:
p = getPrime(sz)
pp = sum([p**i for i in range(d)])
if isPrime(pp):
return p, pp
p, q = sus(512, 3)
r = getPrime(512 * 3)
n = p * q * r
e = 65537
m = bytes_to_long(open("flag.txt", "rb... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/crypto/Wasteful/chall.py | ctfs/ImaginaryCTF/2023/crypto/Wasteful/chall.py | from Crypto.Util.number import *
from math import gcd
def keygen(sz):
p = getPrime(sz // 2)
q = getPrime(sz // 2)
n = p * q
phi = (p - 1) * (q - 1)
e_fast = getPrime(sz // 2)
# to make encryption more time consuming :P
e_slow = e_fast + getPrime(sz // 3) * phi
d = pow(e_fast, -1, phi)
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/crypto/Blind_guess/main.py | ctfs/ImaginaryCTF/2023/crypto/Blind_guess/main.py | from random import getrandbits
from galois import GF
import numpy as np
DECK = "๐ก๐ข๐ฃ๐ค๐ฅ๐ฆ๐ง๐จ๐ฉ๐ช๐ซ๐ญ๐ฎ"
F = GF(13) # lucky number
n = 10
# Let's not use a singular matrix, please.
# We do quality random over here.
M = [[0]]
while np.linalg.det(M) == 0:
M = F.Random((n, n))
money = 15000
cards = F.Random(n)
w... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/crypto/signer/main.py | ctfs/ImaginaryCTF/2023/crypto/signer/main.py | import textwrap
from binascii import crc32
from Crypto.Util.number import getPrime
p, q = getPrime(1024), getPrime(1024)
n = p*q
e = 65537
d = pow(e, -1, (p-1)*(q-1))
PASSWORD = b"give me the flag!!!"
print("--------------------------------------------------------------")
print(" Welcome to the secure ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/forensic/crypto/gen.py | ctfs/ImaginaryCTF/2023/forensic/crypto/gen.py | #!/usr/bin/env python3
import os
key = [line.strip() for line in open("private.pem", "rb").readlines()[1:-1]]
c = open("core.raw", "rb").read() # coredump of `python3 script.py`
for line in key:
c = c.replace(line, b"A"*len(line))
open("core", "wb").write(c)
os.system("openssl rsautl -encrypt -inkey public.pem -... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/forensic/crypto/script.py | ctfs/ImaginaryCTF/2023/forensic/crypto/script.py | from Crypto.PublicKey import RSA
t = open('private.pem', "r").read()
key = RSA.importKey(t)
input()
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/web/amogus/auth/app.py | ctfs/ImaginaryCTF/2023/web/amogus/auth/app.py | from flask import Flask, request, make_response, redirect, url_for
from jinja2 import Environment, select_autoescape, FileSystemLoader
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////database.db"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/web/amogus/mail/app.py | ctfs/ImaginaryCTF/2023/web/amogus/mail/app.py | from flask import Flask, render_template, request, make_response, redirect
from flask_sqlalchemy import SQLAlchemy
import os
import random
import string
import faker
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////database.db"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
fake = faker... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2023/web/Perfect_Picture/app.py | ctfs/ImaginaryCTF/2023/web/Perfect_Picture/app.py | from flask import Flask, render_template, request
from PIL import Image
import exiftool
import random
import os
app = Flask(__name__)
app.debug = False
os.system("mkdir /dev/shm/uploads/")
app.config['UPLOAD_FOLDER'] = '/dev/shm/uploads/'
app.config['ALLOWED_EXTENSIONS'] = {'png'}
def check(uploaded_image):
with... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/pwn/FormatStringFoolery/wrapper.py | ctfs/ImaginaryCTF/2022/pwn/FormatStringFoolery/wrapper.py | #!/usr/bin/env python3
from subprocess import PIPE, Popen
import sys
flag = open("flag.txt", "rb").read().strip()
# thanks to pepsipu for the idea
sys.stdout.write("Enter input:\n")
inp = sys.stdin.readline().encode()
for _ in range(10):
p = Popen("./fmt_foolery", stdin=PIPE, stdout=PIPE, stderr=PIPE)
if flag i... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/pwn/pywrite/vuln.py | ctfs/ImaginaryCTF/2022/pwn/pywrite/vuln.py | from ctypes import c_ulong
def read(where):
return c_ulong.from_address(where).value
def write(what, where):
c_ulong.from_address(where).value = what
menu = '''|| PYWRITE ||
1: read
2: write
> '''
while True:
choice = int(input(menu))
if choice == 1:
where = int(input("where? "))
print(read(where))
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/rev/desrever/desrever.py | ctfs/ImaginaryCTF/2022/rev/desrever/desrever.py | #!/usr/bin/env python3
cexe = exec
cexe(')]"}0p381o91_flnj_3ycvgyhz_av_tavferire{sgpv"==)]pni ni _ rof _ esle "9876543210_}{" ni ton _ fi ]_[d.siht[(nioj.""[)"tcerroc","gnorw"((tnirp;)" >>>"(tupni=pni;)"?galf eht si tahW"(tnirp;siht tropmi'[::-1])
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/rev/OneLinerRevenge/revenge.py | ctfs/ImaginaryCTF/2022/rev/OneLinerRevenge/revenge.py | [globals().__setitem__(chr(0x67),globals()),g.__setitem__(chr(0x74),lambda*a:bytes.fromhex('{:x}'.format(a[0])).decode()),g.__setitem__(t(103),type('',(dict,),{t(6872320826472685407):lambda*a:{**{_:getattr(a[0],t(115298706365414908258770783))(*[(i%8if type(i)is(1).__class__ else i)for(i)in _[::-1]])for(_)in a[1:]},a.__... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/crypto/SecureEncodingBase64/encode.py | ctfs/ImaginaryCTF/2022/crypto/SecureEncodingBase64/encode.py | #!/usr/bin/env python3
from base64 import b64encode
from random import shuffle
charset = b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/='
shuffled = [i for i in charset]
shuffle(shuffled)
d = {charset[i]:v for(i,v)in enumerate(shuffled)}
pt = open("flag.txt").read()
while "\n\n\n" in pt:
pt ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/crypto/huge/chal.py | ctfs/ImaginaryCTF/2022/crypto/huge/chal.py | from Crypto.Util.number import bytes_to_long, getPrime
from random import randint
flag = open("flag.txt", "rb").read()
def get_megaprime():
primes = [getPrime(10) for _ in range(200)]
out = 1
for n in range(100):
if randint(0,1) == 0:
out *= primes[n]
return out
p = get_megaprime()
q = get_megaprim... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/crypto/Poker/poker.py | ctfs/ImaginaryCTF/2022/crypto/Poker/poker.py | from random import getrandbits
from math import prod
HEARTS = "๐ฑ๐ฒ๐ณ๐ด๐ต๐ถ๐ท๐ธ๐น๐บ๐ป๐ฝ๐พ"
SPADES = "๐ก๐ข๐ฃ๐ค๐ฅ๐ฆ๐ง๐จ๐ฉ๐ช๐ซ๐ญ๐ฎ"
DIAMONDS = "๐๐๐๐๐
๐๐๐๐๐๐๐๐"
CLUBS = "๐๐๐๐๐๐๐๐๐๐๐๐๐"
DECK = SPADES+HEARTS+DIAMONDS+CLUBS # Bridge Ordering of a Deck
ALPHABET52 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgh... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/crypto/hash/chal.py | ctfs/ImaginaryCTF/2022/crypto/hash/chal.py | #!/usr/bin/env python3
import string
import random
config = [[int(a) for a in n.strip()] for n in open("jbox.txt").readlines()] # sbox pbox jack in the box
# secure hashing algorithm 42
def sha42(s: bytes, rounds=42):
out = [0]*21
for round in range(rounds):
for c in range(len(s)):
if config[((c//21)+r... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/crypto/SecureEncodingHex/encode.py | ctfs/ImaginaryCTF/2022/crypto/SecureEncodingHex/encode.py | #!/usr/bin/env python3
from random import shuffle
charset = '0123456789abcdef'
shuffled = [i for i in charset]
shuffle(shuffled)
d = {charset[i]:v for(i,v)in enumerate(shuffled)}
pt = open("flag.txt").read()
assert all(ord(i)<128 for i in pt)
ct = ''.join(d[i] for i in pt.encode().hex())
f = open('out.txt', 'w')
f... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/crypto/LivingWithoutExpectations/lwe.py | ctfs/ImaginaryCTF/2022/crypto/LivingWithoutExpectations/lwe.py | import numpy as np
import secrets
def rand(seed):
seeds = [(seed >> (3 * i)) & 7 for i in range(nseeds)]
a = 5
b = 7
while True:
for i in range(nseeds):
seeds[i] = (a * seeds[i] + b) & 7
yield seeds[i]
q = 2**142 + 217
n = 69
nseeds = 142
rng = rand(secrets.randbits(3 *... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/crypto/smoll/smoll.py | ctfs/ImaginaryCTF/2022/crypto/smoll/smoll.py | from secret import p, q
from sage.all import factor
for r in [p, q]:
for s, _ in factor(r - 1):
assert int(s).bit_length() <= 20
n = p * q
e = 0x10001
with open("flag.txt", "rb") as f:
flag = int.from_bytes(f.read().strip(), "big")
assert flag < n
ct = pow(flag, e, n)
print(f"{n = }")
print(f"{e = }... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/crypto/cbc/cbc.py | ctfs/ImaginaryCTF/2022/crypto/cbc/cbc.py | from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
from os import urandom
def cbc_encrypt(msg: bytes):
msg = pad(msg, 16)
msg = [msg[i:i+16] for i in range(0, len(msg), 16)]
key = urandom(16)
out = []
for block in msg:
cipher = AES.new(key, AES.MODE_ECB)
next = cipher.encrypt(bl... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/crypto/otp/otp.py | ctfs/ImaginaryCTF/2022/crypto/otp/otp.py | #!/usr/bin/env python3
from Crypto.Util.number import long_to_bytes, bytes_to_long
import random
import math
def secureRand(bits, seed):
jumbler = []
jumbler.extend([2**n for n in range(300)])
jumbler.extend([3**n for n in range(300)])
jumbler.extend([4**n for n in range(300)])
jumbler.extend([5**n for n in... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/crypto/Lorge/lorge.py | ctfs/ImaginaryCTF/2022/crypto/Lorge/lorge.py | from secret import p, q
from sage.all import factor
for r in [p, q]:
for s, _ in factor(r - 1):
assert int(s).bit_length() <= 25
n = p * q
e = 0x10001
with open("flag.txt", "rb") as f:
flag = int.from_bytes(f.read().strip(), "big")
assert flag < n
ct = pow(flag, e, n)
print(f"{n = }")
print(f"{e = }... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ImaginaryCTF/2022/web/maas/app.py | ctfs/ImaginaryCTF/2022/web/maas/app.py | from flask import Flask, render_template, request, make_response, redirect
from hashlib import sha256
import time
import uuid
import random
app = Flask(__name__)
memes = [l.strip() for l in open("memes.txt").readlines()]
users = {}
taken = []
def adduser(username):
if username in taken:
return "username taken"... | 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.