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/b01lers/2024/blockchain/burgercoin/solve-pow.py
ctfs/b01lers/2024/blockchain/burgercoin/solve-pow.py
import hashlib,random x = 100000000+random.randint(0,200000000000) for i in range(x,x+20000000000): m = hashlib.sha256() ticket = str(i) m.update(ticket.encode('ascii')) digest1 = m.digest() m = hashlib.sha256() m.update(digest1 + ticket.encode('ascii')) if m.hexdigest().startswith('0000000'): print(i) break...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2024/misc/TeXnically.../server-dist.py
ctfs/b01lers/2024/misc/TeXnically.../server-dist.py
import subprocess from colorama import Fore, Style with open("chal.tex", "w") as tex_file: tex_file.write(rf""" \documentclass{{article}} %%% % Redacted %%% \pagenumbering{{gobble}} \lfoot{{ % Page number formatting \hspace*{{\fill}} Page \arabic{{page}} % of \protect\pageref{{LastPage}} }} \newif\iflo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2024/misc/cppjail/compile.py
ctfs/b01lers/2024/misc/cppjail/compile.py
#!/bin/env python3 import os import time # # local testing stuff # input_code = [] # while True: # try: # line = input() # except EOFError: # break # input_code.append(line) # input_code = ' '.join(input_code) input_code = input("Input your code: ") if len(input_code) > 280: print("jai...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2024/crypto/choose_the_param/chal.py
ctfs/b01lers/2024/crypto/choose_the_param/chal.py
#!/usr/bin/python3 from Crypto.Util.number import long_to_bytes, bytes_to_long, getPrime import os from secret import flag padded_flag = os.urandom(200) + flag + os.urandom(200) m = bytes_to_long(padded_flag) def chal(): print("""Choose your parameter Enter the bit length of the prime! I'll choose two prime of th...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2024/crypto/shamir_for_dummies/server-dist.py
ctfs/b01lers/2024/crypto/shamir_for_dummies/server-dist.py
import os import sys import time import math import random from Crypto.Util.number import getPrime, isPrime, bytes_to_long, long_to_bytes def polynomial_evaluation(coefficients, x): at_x = 0 for i in range(len(coefficients)): at_x += coefficients[i] * (x ** i) at_x = at_x % p return at_x flag = b'bctf{REDACTED...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2024/crypto/R_esurre_C_tion_4/server-dist.py
ctfs/b01lers/2024/crypto/R_esurre_C_tion_4/server-dist.py
import random from Crypto.Util.number import getPrime, isPrime, bytes_to_long, long_to_bytes """ Key-scheduling algorithm (KSA) """ def KSA(key): S = [i for i in range(0, 256)] i = 0 for j in range(0, 256): i = (i + S[j] + key[j % len(key)]) % 256 S[i] ^= S[j] ## swap values of S[i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2024/crypto/half_big_rsa/half-big-rsa.py
ctfs/b01lers/2024/crypto/half_big_rsa/half-big-rsa.py
import math from Crypto.Util.number import getPrime, bytes_to_long, long_to_bytes import os num_bits = 4096 e = (num_bits - 1) * 2 n = getPrime(num_bits) with open("flag.txt","rb") as f: flag = f.read() m = bytes_to_long(flag) c = pow(m, e, n) print(c) with open("output.txt", "w") as f: f.write("e = {0}\n".for...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2024/crypto/Snoopy/snoopy.py
ctfs/b01lers/2024/crypto/Snoopy/snoopy.py
import time import os import numpy as np from Crypto.Cipher import AES from Crypto.Random.random import randrange from numba import jit FLAG = open("flag.txt", "rb").read().strip() assert FLAG[:5] == b"bctf{" and FLAG[-1:] == b"}" FLAG = FLAG[5:-1] assert len(FLAG) <= 16 HI = 3.3 @jit(nopython = True) # serious ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2024/crypto/schnore/chal.py
ctfs/b01lers/2024/crypto/schnore/chal.py
#!/usr/bin/python3 import sys from Crypto.Util import number from Crypto.Hash import SHA512 with open("flag.txt") as f: flag = f.read() # FIPS 186-4 Appendix A.1/A.2 compliant prime order q group and prime order p field #from Crypto.PublicKey import DSA as FFCrypto #(p,q,g) = FFCrypto.generate(2048).domain() p =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2024/crypto/count_the_counter/chal.py
ctfs/b01lers/2024/crypto/count_the_counter/chal.py
#!/bin/python3 from Crypto.Cipher import AES from Crypto.Util.number import long_to_bytes from secret import flag import os def Encrypt(key, message, nonce): cipher = AES.new(key, AES.MODE_CTR, nonce=long_to_bytes(nonce)) return cipher.encrypt(message).hex() def chal(): key = os.urandom(16) print("T...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2024/crypto/Propagating_Counter_Block_Chaining/chal.py
ctfs/b01lers/2024/crypto/Propagating_Counter_Block_Chaining/chal.py
from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad from functools import reduce from secret import flag import os import json BLOCK_SIZE = 16 key_ctr1 = os.urandom(BLOCK_SIZE) key_ctr2 = os.urandom(BLOCK_SIZE) key_cbc = os.urandom(BLOCK_SIZE) nonce1 = os.urandom(8) nonce2 = os.urandom(8) def AES...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2023/pwn/knock_knock/chall.py
ctfs/b01lers/2023/pwn/knock_knock/chall.py
import base64 from subprocess import Popen, PIPE import struct import shutil import uuid import os import sys MAX_CODE_SIZE = 4096 * 4 def main(): if len(sys.argv) == 2: # use user supplied file with open(sys.argv[1], 'rb') as f: data = f.read() else: code = input('Enter ba...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2023/crypto/poeticrypto/algo.py
ctfs/b01lers/2023/crypto/poeticrypto/algo.py
#!/usr/bin/env python3 # Use these algorithms from binascii import unhexlify, hexlify from Crypto.Cipher import AES from Crypto.Hash import SHA256 from Crypto.Protocol.KDF import PBKDF2 PUB_SALT = b'Grow grow grow!!' PRIV_SALT_BITS = 16 KEY_SIZE = 32 from SECRET.keygen import getKey from SECRET.vals import FLAG, SEE...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2023/crypto/MajesticLop/chal.py
ctfs/b01lers/2023/crypto/MajesticLop/chal.py
import itertools import os import datetime import math FLAG = open("flag.txt", "rb").read().strip() cache = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 2...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2025/jail/shakespearejail/server.py
ctfs/b01lers/2025/jail/shakespearejail/server.py
#!/usr/local/bin/python3 import io import random import sys from shakespearelang.shakespeare import Shakespeare print("You're nothing like a summers day.") print("enter your play > ") blacklist = [ "Heaven", "King", "Lord", "angel", "flower", "happiness", "joy", "plum", "summer's", "day", "hero", "rose", "kingdom", "...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2025/crypto/leetprime/server.py
ctfs/b01lers/2025/crypto/leetprime/server.py
from random import randint, randbytes from Crypto.Util.number import isPrime from hashlib import sha256 def proof_of_work(): while True: prefix = randbytes(4) print(f"prefix (hex): {prefix.hex()}") ans = bytes.fromhex(input("ans (hex): ").strip()) if int(sha256(prefix + ans).hexdigest(), 16) & (0xFFFFFF << 23...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2025/crypto/Pesky_CBC/pesky_cbc.py
ctfs/b01lers/2025/crypto/Pesky_CBC/pesky_cbc.py
import secrets from Crypto.Cipher import AES try: with open('./flag.txt', 'r') as f: flag = f.read() except: flag = 'bctf{REDACTED}' key1 = secrets.token_bytes(32) key2 = secrets.token_bytes(32) def pesky_decrypt(ciphertext): assert len(ciphertext) % 16 == 0 iv1 = secrets.token_bytes(16) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2025/crypto/ASSS/ASSS.py
ctfs/b01lers/2025/crypto/ASSS/ASSS.py
from Crypto.Util.number import getPrime, bytes_to_long def evaluate_poly(poly:list, x:int, s:int): return s + sum(co*x**(i+1) for i, co in enumerate(poly)) s = bytes_to_long(open("./flag.txt", "rb").read()) a = getPrime(64) poly = [a*getPrime(64) for _ in range(1, 20)] share = getPrime(64) print(f"Here is a ^_^:...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2022/pwn/veryfastvm/cpu.py
ctfs/b01lers/2022/pwn/veryfastvm/cpu.py
import sys import os import random import struct X13 = 1024*1024 X14 = 10 X15 = 2000 X16 = 55 class Instruction: op = None imm = 0 X11 = None X12 = None dsp = None X08 = None X10 = 0 X02 = 0 def __init__(self, tstr): def X06(tt): if tt.startswith("0x"): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2022/crypto/Hardcore2/Hardcore.py
ctfs/b01lers/2022/crypto/Hardcore2/Hardcore.py
import numpy as np from os import urandom import binascii import hashlib from secret import FLAG1, FLAG2 # Helpers def digest_to_array(digest): hex_digest = binascii.hexlify(digest) binary = bin(int(hex_digest, base=16)).lstrip('0b') binary = np.array(list(binary)) # currently leading 0s are gone...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/b01lers/2022/crypto/Hardcore/Hardcore.py
ctfs/b01lers/2022/crypto/Hardcore/Hardcore.py
import numpy as np from os import urandom import binascii import hashlib from secret import FLAG1, FLAG2 # Helpers def digest_to_array(digest): hex_digest = binascii.hexlify(digest) binary = bin(int(hex_digest, base=16)).lstrip('0b') binary = np.array(list(binary)) # currently leading 0s are gone...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2021/pwn/VeeAte/server.py
ctfs/idekCTF/2021/pwn/VeeAte/server.py
#!/usr/bin/env python3 # With credit/inspiration to the v8 problem in downUnder CTF 2020 import os import subprocess import sys import tempfile def p(a): print(a, flush=True) MAX_SIZE = 20000 input_size = int(input("Provide size. Must be < 5k:")) if input_size >= MAX_SIZE: p(f"Received size of {input_size},...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2021/rev/Custom_Neural_Network/cnn_flag_checker.py
ctfs/idekCTF/2021/rev/Custom_Neural_Network/cnn_flag_checker.py
import numpy as np import tensorflow as tf def Float32Equal(a,b): return np.abs(a - b) < np.finfo(np.float32).eps def CheckImage(image, model_filename='flag_model.h5'): if not Float32Equal(np.max(image), 1.0): return False if not Float32Equal(np.min(image), -1.0): return False model = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2021/crypto/Nameless/nameless.py
ctfs/idekCTF/2021/crypto/Nameless/nameless.py
#!/usr/bin/env python3 from Crypto.Util.number import getPrime, bytes_to_long flag = bytes_to_long(open("flag.txt", "rb").read()) p = getPrime(1024) q = getPrime(1024) n = p*q e = 65537 c = pow(flag, e, n) print(f"{n = }") print(f"{p**2 + q**2 = }") print(f"{c = }") # n = 1703935390757730443533506426340401455487...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2021/crypto/Destroyed_RSA/chall.py
ctfs/idekCTF/2021/crypto/Destroyed_RSA/chall.py
import random from Crypto.Util.number import bytes_to_long, getPrime, isPrime from flag import flag f = flag def interesting_prime(): #recognize me? D = 987 while True: s = random.randint(2**1020,2**1021-1) check = D * s ** 2 + 1 if check % 4 == 0 and isPrime((check // 4)): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2021/crypto/Seed_of_Life/garden.py
ctfs/idekCTF/2021/crypto/Seed_of_Life/garden.py
import random seed = REDACTED assert seed in range(10000000) random.seed(seed) for i in range(19): random.seed(random.random()) seedtosave = random.random() print("share1:") for add in range(0, 1000): random.seed(seedtosave+add) for i in range(0, 100): print(random.random()) print("share2:") for add in range(0, 1...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2021/crypto/Polyphenol/source.py
ctfs/idekCTF/2021/crypto/Polyphenol/source.py
import random from secret import flag assert flag[: 5] == b"idek{" assert flag[-1:] == b"}" L = len(flag[5: -1]) print(f"L = {L}") coeff = list(flag[5: -1]) points = random.sample(range(L), L // 2) evaluations = [] for p in points: evaluations += [sum(c * p ** i for i, c in enumerate(coeff))] print(f"points = {poi...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2021/crypto/Hashbrown/chall.py
ctfs/idekCTF/2021/crypto/Hashbrown/chall.py
import string import hashlib import random password2hash = b"REDACTED" hashresult = hashlib.md5(password2hash).digest() sha1 = hashlib.sha1(hashresult) sha224 = hashlib.sha224(sha1.digest()) for i in range(0, 10): sha1 = hashlib.sha1(sha224.digest()) sha224 = hashlib.sha224(sha1.digest()) output = sha224.hexdigest()...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2021/web/saas/util.py
ctfs/idekCTF/2021/web/saas/util.py
from PIL import Image import random import jwt import string import os from imghdr import tests import subprocess priv_key = open('keys/private.pem', 'r').read() def create_token(): priv_key = open('keys/private.pem', 'r').read() token = jwt.encode({"username": f"guest_{random.randint(1,10000)}"}, priv_key, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2021/web/saas/app.py
ctfs/idekCTF/2021/web/saas/app.py
from flask import Flask, request, render_template, make_response, redirect, send_file import imghdr from imghdr import tests import hashlib from util import * # https://stackoverflow.com/questions/36870661/imghdr-python-cant-detec-type-of-some-images-image-extension # there are no bugs here. just patching imghdr JPEG_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2021/web/fancy-notes/app.py
ctfs/idekCTF/2021/web/fancy-notes/app.py
from flask import Flask, redirect, request, session, send_from_directory, render_template import os import sqlite3 import subprocess app = Flask(__name__, static_url_path='/static', static_folder='static', template_folder='templates') app.secret_key = os.getenv('SECRET', 'secret') ADMIN_PASS = os.getenv('ADMIN_PASS', ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2021/web/escalator/escalator.py
ctfs/idekCTF/2021/web/escalator/escalator.py
from flask import Flask, render_template, session, request, redirect, flash, make_response, jsonify import mysql.connector import secrets import time import json import os import subprocess import sys from datetime import datetime app = Flask(__name__) app.secret_key = os.environ['SECRET_KEY'] flag = os.environ['FLAG'...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2021/web/generic-pastebin/app.py
ctfs/idekCTF/2021/web/generic-pastebin/app.py
from flask import Flask, redirect, request, session, send_from_directory, render_template, render_template_string, g, make_response, flash import os import sqlite3 import random import string import re import socket import subprocess app = Flask(__name__) app.secret_key = os.getenv('SECRET_KEY', 's3cr3t_k3y') ADMIN_P...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2021/web/baby-jinjail/app.py
ctfs/idekCTF/2021/web/baby-jinjail/app.py
from flask import Flask, render_template_string, request app = Flask(__name__) blacklist = [ 'request', 'config', 'self', 'class', 'flag', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '"', '\'', '.', '\\', '`', '%', '#', ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2021/web/jinjail/app.py
ctfs/idekCTF/2021/web/jinjail/app.py
from flask import Flask, render_template_string, request app = Flask(__name__) blacklist = [ 'request', 'config', 'self', 'class', 'flag', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '"', '\'', '.', '\\', '`', '%', '#', ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/pwn/coroutine/proxy.py
ctfs/idekCTF/2023/pwn/coroutine/proxy.py
import socket import sys import time import subprocess proc = subprocess.Popen('./CoroutineCTFChal',stdout=subprocess.PIPE) line = proc.stdout.readline() assert line.startswith(b'port number ') port = int(line[len('port number '):]) with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: for _ in range(14):...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/crypto/decidophobia/server.py
ctfs/idekCTF/2023/crypto/decidophobia/server.py
#!/usr/bin/env python3 from Crypto.Util.number import * import random import signal class Pool(): def __init__(self): self.p, self.q, self.r = None, None, None class PrimeMan(): def __init__(self): self.p, self.q, self.r = None, None, None def gen(self, nbits, ticket): self.p = getPrime(nbits) self....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/crypto/cleithrophobia/cleithrophobia.py
ctfs/idekCTF/2023/crypto/cleithrophobia/cleithrophobia.py
#!/usr/bin/env python3 # # Polymero # # Imports from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad import os # Local imports with open('flag.txt', 'rb') as f: FLAG = f.read() f.close() # Header HDR = r"""| | | __ _ ___ ____ ______ __ __ ____ ___ ____ __ __ ___ ____ __...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/crypto/megalophobia/megalophobia.py
ctfs/idekCTF/2023/crypto/megalophobia/megalophobia.py
#!/usr/bin/env python3 # # Polymero # # Imports from Crypto.Cipher import AES from Crypto.Util.number import getPrime, inverse import os # Local imports with open('flag.txt', 'rb') as f: FLAG = f.read() f.close() # Header HDR = r"""| | | ____ ____ ________ ______ _ _____ ___ _______...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/crypto/primonumerophobia/source.py
ctfs/idekCTF/2023/crypto/primonumerophobia/source.py
#!/usr/bin/env python3 from Crypto.Util.number import * import random import os class LFSR(): def __init__(self, taps): d = max(taps) self.taps = [d-t for t in taps] self.state = [random.randint(0, 1) for _ in range(d)] def _sum(self, L): res = 0 for t in L: res ^= t return res def next(self): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/crypto/tychophobia/server.py
ctfs/idekCTF/2023/crypto/tychophobia/server.py
#!/usr/bin/env python3 from Crypto.Util.number import * import random import os import signal class FeisteLCG(): def __init__(self, k, seed): self.k = k self.m = 2**(2*k) self.a = getPrime(k) self.x = seed self.b = 0 print(f"a = {self.a}") print(f"b = {self.b}") # Generate random permutation by ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/crypto/psychophobia/psychophobia.py
ctfs/idekCTF/2023/crypto/psychophobia/psychophobia.py
#!/usr/bin/env python3 # # Polymero # # Imports from Crypto.Util.number import inverse from secrets import randbelow from hashlib import sha256 # Local imports with open('flag.txt', 'rb') as f: FLAG = f.read() f.close() # Header HDR = r"""| | _ ___ | ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/crypto/formal-security-poop/ecc.py
ctfs/idekCTF/2023/crypto/formal-security-poop/ecc.py
from secrets import randbelow from hashlib import sha512 class Curve: def __init__(self, p, a, b) -> None: self.p = p self.a = a % p self.b = b % p self.O = Point(self, 0, 0) class Point: def __init__(self, E: Curve, x: int, y: int) -> None: self.E = E self.x = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/crypto/formal-security-poop/main.py
ctfs/idekCTF/2023/crypto/formal-security-poop/main.py
from Crypto.Util.Padding import pad, unpad from Crypto.Cipher import AES from ecc import * class Vault: def __init__(self) -> None: self.secrets = {} def authenticate(self, owner: str) -> None: # Please see https://en.wikipedia.org/wiki/Proof_of_knowledge#Schnorr_protocol for how to interact ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/crypto/chronophobia/server.py
ctfs/idekCTF/2023/crypto/chronophobia/server.py
#!/usr/bin/env python3 from Crypto.Util.number import * import random import signal class PoW(): def __init__(self, kbits, L): self.kbits = kbits self.L = L self.banner() self.gen() self.loop(1337) def banner(self): print("===================================") print("=== Welcome to idek PoW Servi...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/web/proxy-viewer/app/app.py
ctfs/idekCTF/2023/web/proxy-viewer/app/app.py
from flask import Flask, request, render_template from urllib.request import urlopen from waitress import serve from flask_limiter import Limiter from flask_limiter.util import get_remote_address import os app = Flask( __name__, static_url_path='/static', static_folder='./static', ) PR...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/web/json_beautifier/app.py
ctfs/idekCTF/2023/web/json_beautifier/app.py
from flask import Flask, send_file app = Flask(__name__) @app.after_request def add_csp_header(response): response.headers['Content-Security-Policy'] = "script-src 'unsafe-eval' 'self'; object-src 'none';" return response @app.route('/') def index(): return send_file('index.html') app.run('0.0.0.0', 13...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/web/task-manager/taskmanager.py
ctfs/idekCTF/2023/web/task-manager/taskmanager.py
import pydash class TaskManager: protected = ["set", "get", "get_all", "__init__", "complete"] def __init__(self): self.set("capture the flag", "incomplete") def set(self, task, status): if task in self.protected: return pydash.set_(self, task, status) return T...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/web/task-manager/app.py
ctfs/idekCTF/2023/web/task-manager/app.py
from flask import Flask, render_template, request, redirect from taskmanager import TaskManager import os app = Flask(__name__) @app.before_first_request def init(): if app.env == 'yolo': app.add_template_global(eval) @app.route("/<path:path>") def render_page(path): if not os.path.exists("templates/...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/web/simple-file-server/src/config.py
ctfs/idekCTF/2023/web/simple-file-server/src/config.py
import random import os import time SECRET_OFFSET = 0 # REDACTED random.seed(round((time.time() + SECRET_OFFSET) * 1000)) os.environ["SECRET_KEY"] = "".join([hex(random.randint(0, 15)) for x in range(32)]).replace("0x", "")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/web/simple-file-server/src/app.py
ctfs/idekCTF/2023/web/simple-file-server/src/app.py
import logging import os import re import sqlite3 import subprocess import uuid import zipfile from flask import (Flask, flash, redirect, render_template, request, abort, send_from_directory, session) from werkzeug.security import check_password_hash, generate_password_hash app = Flask(__name__) D...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/web/simple-file-server/src/wsgi.py
ctfs/idekCTF/2023/web/simple-file-server/src/wsgi.py
from app import app
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/idekCTF/2023/web/badblocker/challenge/app.py
ctfs/idekCTF/2023/web/badblocker/challenge/app.py
from flask import * from waitress import serve from os import environ PORT = environ.get("port", 1337) app = Flask(__name__) app.config["TEMPLATES_AUTO_RELOAD"] = True @app.route("/") def index(): return render_template("index.html") @app.route("/blocked.html") def blocked(): return render_template("blocked.html") ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/P3rf3ctr00t/2025/web/r00tch4t/main.py
ctfs/P3rf3ctr00t/2025/web/r00tch4t/main.py
from flask import Flask, , request, redirect, url_for, render_template_string, session import os app = Flask(__name__) app.secret_key = os.urandom(32) chat_logs = [] CHAT_TEMPLATE = """ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2024/misc/Voice_Lock/app.py
ctfs/IrisCTF/2024/misc/Voice_Lock/app.py
from speechbrain.pretrained import SpeakerRecognition, EncoderDecoderASR from flask import Flask, request, render_template, send_file from fuzzywuzzy import fuzz import threading import hashlib import random import time import os # setup ################### sessions = {} app = Flask(__name__) app.config['TEMPLATES_AU...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2024/crypto/dhash/chal.py
ctfs/IrisCTF/2024/crypto/dhash/chal.py
from Crypto.Util.number import getPrime, isPrime e = 65537 N = 1 while (N - 1) % e == 0: N = getPrime(2048) def xor(a, b): return bytes(x^y for x,y in zip(a,b)) class MySeededHash(): def __init__(self, N, e): self.N = N self.e = e self._state = b"\x00" * 256 self.seen = se...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2024/crypto/Beach_Party_Crypto/chal.py
ctfs/IrisCTF/2024/crypto/Beach_Party_Crypto/chal.py
#!/usr/bin/env pypy3 import secrets import signal import hashlib def tropical_pow(x, y, op): if 1 == y: return x exp = bin(y) value = x for i in range(3, len(exp)): value = op(value, value) if(exp[i:i+1]=='1'): value = op(value, x) return value def pair_add(*a...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2024/crypto/Baby_Charge/chal.py
ctfs/IrisCTF/2024/crypto/Baby_Charge/chal.py
# https://en.wikipedia.org/wiki/Salsa20#ChaCha20_adoption from Crypto.Util.number import long_to_bytes, bytes_to_long import secrets def ROTL(a, b): return (((a) << (b)) | ((a % 2**32) >> (32 - (b)))) % 2**32 def qr(x, a, b, c, d): x[a] += x[b]; x[d] ^= x[a]; x[d] = ROTL(x[d],16) x[c] += x[d]; x[b] ^= x[...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2024/crypto/Integral_Communication/chal.py
ctfs/IrisCTF/2024/crypto/Integral_Communication/chal.py
from json import JSONDecodeError, loads, dumps from binascii import hexlify, unhexlify from Crypto.Cipher import AES from Crypto.Random import get_random_bytes with open("flag") as f: flag = f.readline() key = get_random_bytes(16) def encrypt(plaintext: bytes) -> (bytes, bytes): iv = get_random_bytes(16) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2024/crypto/manykey/chal.py
ctfs/IrisCTF/2024/crypto/manykey/chal.py
from ecdsa import SigningKey import secrets sk = SigningKey.generate() pk = sk.verifying_key message = secrets.token_bytes(16) print("Hello,", message.hex()) sig = sk.sign(message) print(sig.hex()) print("Here's my public key") print(pk.to_der().hex()) print("What was my private key again? (send me DER-encoded hex b...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2024/crypto/Attack_of_the_Kleins/chal.py
ctfs/IrisCTF/2024/crypto/Attack_of_the_Kleins/chal.py
import secrets def ksa(key): buf = [] for i in range(256): buf.append(i) j = 0 for i in range(256): j = (j + buf[i] + key[i % len(key)]) % 256 buf[i], buf[j] = buf[j], buf[i] return buf def pgra(buf): i = 0 j = 0 while True: i = (i + 1) % 256 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2024/crypto/Accessible_Sesamum_Indicum/chal.py
ctfs/IrisCTF/2024/crypto/Accessible_Sesamum_Indicum/chal.py
#!/usr/bin/env python3 import random MAX_DIGITS = 65536 def vault() -> bool: pin = "".join([random.choice("0123456789abcdef") for _ in range(4)]) digits = ["z", "z", "z", "z"] counter = 0 print("What is the 4-digit PIN?") while True: attempt = list(input("Attempt> ")) for _ in range(len(attempt)): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2024/web/LameNote/lamenote/chal.py
ctfs/IrisCTF/2024/web/LameNote/lamenote/chal.py
from flask import Flask, request, g, send_file, redirect, make_response import secrets from urllib.parse import urlparse import re from functools import wraps import copy host = re.compile("^[a-z0-9\.:]+$") app = Flask(__name__) NOTES = {} def check_request(f): @wraps(f) def inner(*a, **kw): secFetc...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2024/web/Mokersee/chal.py
ctfs/IrisCTF/2024/web/Mokersee/chal.py
from flask import Flask, request, send_file, render_template import json from PIL import Image from io import BytesIO import numpy as np app = Flask(__name__) MOKERS = { "flag": {"description": "Free Flag (whatever)", "private": False, "preview": "%5B%7B%22filter%22%3A+%22blur%22%2C+%22args%22%3A+%5B20%5D%7D%...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2023/rev/MeaningOfPython1/python1.py
ctfs/IrisCTF/2023/rev/MeaningOfPython1/python1.py
import sys import zlib def apple(s, a, b): arr = list(s) tmp = arr[a] arr[a] = arr[b] arr[b] = tmp return "".join(arr) def banana(s, a, b): arr = list(s) arr[a] = chr(ord(arr[a]) ^ ord(arr[b])) return "".join(arr) def carrot(s, a, b): arr = bytearray(s) tmp = arr[a] arr[a]...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2023/crypto/babynotrsa/chal.py
ctfs/IrisCTF/2023/crypto/babynotrsa/chal.py
from Crypto.Util.number import getStrongPrime # We get 2 1024-bit primes p = getStrongPrime(1024) q = getStrongPrime(1024) # We calculate the modulus n = p*q # We generate our encryption key import secrets e = secrets.randbelow(n) # We take our input flag = b"irisctf{REDACTED_REDACTED_REDACTED}" assert len(flag) ==...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2023/crypto/babymixup/chal.py
ctfs/IrisCTF/2023/crypto/babymixup/chal.py
from Crypto.Cipher import AES import os key = os.urandom(16) flag = b"flag{REDACTED}" assert len(flag) % 16 == 0 iv = os.urandom(16) cipher = AES.new(iv, AES.MODE_CBC, key) print("IV1 =", iv.hex()) print("CT1 =", cipher.encrypt(b"Hello, this is a public message. This message contains no flags.").hex()) iv = os.ura...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2023/crypto/AES-BAD-256/chal.py
ctfs/IrisCTF/2023/crypto/AES-BAD-256/chal.py
from Crypto.Cipher import AES as AES_BLOCK import secrets import random AES_BLOCK_SIZE = 16 MODE_BLOCK_SIZE = AES_BLOCK_SIZE * 16 KEY = secrets.token_bytes(AES_BLOCK_SIZE) AES = AES_BLOCK.new(KEY, AES_BLOCK.MODE_ECB) import random random.seed(KEY) PERMUTATION = list(range(AES_BLOCK_SIZE)) random.shuffle(PERMUTATION...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2023/crypto/SMarT1/chal.py
ctfs/IrisCTF/2023/crypto/SMarT1/chal.py
from pwn import xor # I don't know how to make a good substitution box so I'll refer to AES. This way I'm not actually rolling my own crypto SBOX = [99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2023/web/FeelingTagged/tagged.py
ctfs/IrisCTF/2023/web/FeelingTagged/tagged.py
from flask import Flask, request, redirect from bs4 import BeautifulSoup import secrets import base64 app = Flask(__name__) SAFE_TAGS = ['i', 'b', 'p', 'br'] with open("home.html") as home: HOME_PAGE = home.read() @app.route("/") def home(): return HOME_PAGE @app.route("/add", methods=['POST']) def add(): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2023/web/mokerview/mokerview.py
ctfs/IrisCTF/2023/web/mokerview/mokerview.py
from flask import Flask, request, redirect, make_response, send_from_directory from werkzeug.urls import url_decode, url_encode from functools import wraps from collections import defaultdict import hashlib import requests import re import secrets import base64 app = Flask(__name__) FLAGMOKER = "REDACTED" MOKERS = {"...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2023/web/babycsrf/solve_template.py
ctfs/IrisCTF/2023/web/babycsrf/solve_template.py
from flask import Flask, request import time app = Flask(__name__) with open("solve.html") as f: SOLVE = f.read() @app.route("/") def home(): return SOLVE # You can define functions that return non-static data too, of course @app.route("/time") def page(): return f"{time.time()}" # Run "ngrok http 1234...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/IrisCTF/2023/web/babycsrf/chal.py
ctfs/IrisCTF/2023/web/babycsrf/chal.py
from flask import Flask, request app = Flask(__name__) with open("home.html") as home: HOME_PAGE = home.read() @app.route("/") def home(): return HOME_PAGE @app.route("/api") def page(): secret = request.cookies.get("secret", "EXAMPLEFLAG") return f"setMessage('irisctf{{{secret}}}');" app.run(port=...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2021/web/oh-my-note/source.py
ctfs/StarCTF/2021/web/oh-my-note/source.py
import string import random import time import datetime from flask import render_template, redirect, url_for, request, session, Flask from functools import wraps from exts import db from config import Config from models import User, Note from forms import CreateNoteForm app = Flask(__name__) app.config.from_object(Con...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2021/web/oh-my-socket/source/webserver/webserver/app.py
ctfs/StarCTF/2021/web/oh-my-socket/source/webserver/webserver/app.py
from flask import Flask, render_template, request from subprocess import STDOUT, check_output import os app = Flask(__name__) @app.route('/') def index(): return open(__file__).read() @app.route('/upload', methods=['GET', 'POST']) def upload_file(): if request.method == 'GET': return render_templat...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2021/web/oh-my-socket/source/server/server/server.py
ctfs/StarCTF/2021/web/oh-my-socket/source/server/server/server.py
from socket import * from time import ctime import time HOST = '172.21.0.2' PORT = 21587 BUFSIZ = 1024 ADDR = (HOST, PORT) tcpSerSock = socket(AF_INET, SOCK_STREAM) tcpSerSock.bind(ADDR) tcpSerSock.listen(5) cnt = 0 while True: print('waiting for connection...') tcpCliSock, addr = tcpSerSock.accept() cn...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2021/web/oh-my-socket/source/client/client/client.py
ctfs/StarCTF/2021/web/oh-my-socket/source/client/client/client.py
from socket import * from requests.exceptions import * HOST = '172.21.0.2' PORT = 21587 BUFSIZ =1024 ADDR = (HOST,PORT) tcpCliSock = socket(AF_INET,SOCK_STREAM) tcpCliSock.bind(('172.21.0.3',7775)) tcpCliSock.connect(ADDR) while True: try: data1 = tcpCliSock.recv(BUFSIZ) if not data1: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2021/web/oh-my-socket/source/client/client/app.py
ctfs/StarCTF/2021/web/oh-my-socket/source/client/client/app.py
from flask import Flask, request app = Flask(__name__) @app.route('/') def index(): return open(__file__).read() @app.route("/file", methods=['GET','POST']) def file(): file = request.args.get('name') content = open(file).read() return content if __name__ == "__main__": app.run(port=5000, host='...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2023/misc/Increasing/Increazing_code.py
ctfs/StarCTF/2023/misc/Increasing/Increazing_code.py
from func_timeout import func_set_timeout import torch from torch.nn import init import torch.nn as nn from copy import deepcopy import math model_num=181 @func_set_timeout(60) def getinput60(): tmps=input() return tmps def Net2Init(tmpnet): for key in tmpnet.state_dict(): if('weight' in key): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2023/crypto/gcccd/task.py
ctfs/StarCTF/2023/crypto/gcccd/task.py
#!/usr/bin/env python3 from secret import flag import socketserver import hashlib import signal import random import string import os p=20973268502876719886012765513713011996343752519737224550553652605696573094756255499211333096502971357908939298357512380813773140436677393056575164230564778609423872301899323721040416...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2023/crypto/ezCrypto/ezCrypto.py
ctfs/StarCTF/2023/crypto/ezCrypto/ezCrypto.py
import random import string characters = string.printable[:-6] digits = string.digits ascii_letters = string.ascii_letters def Ran_str(seed : int, origin: str): random.seed(seed) random_sequence = random.sample(origin, len(origin)) return ''.join(random_sequence) rseed = int(input()) assert rseed <= 100...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2022/crypto/ezRSA/ezRSA.py
ctfs/StarCTF/2022/crypto/ezRSA/ezRSA.py
from Crypto.Util.number import getStrongPrime from gmpy import next_prime from random import getrandbits from flag import flag p=getStrongPrime(1024) q=next_prime(p^((1<<900)-1)^getrandbits(300)) n=p*q e=65537 m=int(flag.encode('hex'),16) assert m<n c=pow(m,e,n) print(hex(n)) #0xe78ab40c343d4985c1de167e80ba2657c7ee8...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2022/crypto/Patches2/patches2.py
ctfs/StarCTF/2022/crypto/Patches2/patches2.py
from random import choice as c from random import randint,shuffle flag=open('flag','r').read() white_list = ['==','(',')','C0','C1','C2','C3','C4','C5','C6','0','1','and','or'] from Crypto.Util.number import * def calc(ans,chests,expr): try: C0, C1, C2, C3, C4, C5, C6 = chests r = eval(expr) except Exception a...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2022/crypto/InverseProblem2/problem.py
ctfs/StarCTF/2022/crypto/InverseProblem2/problem.py
import numpy as np from secret import flag def getQ(n): return np.linalg.qr(np.random.random([n,n]))[0] def pad(x,N=50,k=256): return np.hstack([x,np.random.random(N-len(x))*k]) n=len(flag) N=50 A=np.hstack([getQ(N)[:,:n]@np.diag(np.logspace(n,1,n))@getQ(n),getQ(N)[:,n:]@np.diag(np.linspace(N-n,1,N-n))@getQ(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2022/web/oh-my-lotto-revenge/app/source/gunicorn.conf.py
ctfs/StarCTF/2022/web/oh-my-lotto-revenge/app/source/gunicorn.conf.py
workers = 2 bind = "0.0.0.0:8080"
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2022/web/oh-my-lotto-revenge/app/source/app.py
ctfs/StarCTF/2022/web/oh-my-lotto-revenge/app/source/app.py
from flask import Flask,render_template, request import secrets import os app = Flask(__name__, static_url_path='') def safe_check(s): if 'LD' in s or 'HTTP' in s or 'BASH' in s or 'ENV' in s or 'PROXY' in s or 'PS' in s: return False return True @app.route("/", methods=['GET', 'POST']) def index()...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2022/web/oh-my-lotto-revenge/lotto/source/gunicorn.conf.py
ctfs/StarCTF/2022/web/oh-my-lotto-revenge/lotto/source/gunicorn.conf.py
workers = 2 bind = "0.0.0.0:80"
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2022/web/oh-my-lotto-revenge/lotto/source/app.py
ctfs/StarCTF/2022/web/oh-my-lotto-revenge/lotto/source/app.py
from flask import Flask, make_response import secrets app = Flask(__name__) @app.route("/") def index(): lotto = [] for i in range(1, 20): n = str(secrets.randbelow(40)) lotto.append(n) r = '\n'.join(lotto) response = make_response(r) response.headers['Content-Type'] = 'text/p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2022/web/oh-my-lotto/app/source/gunicorn.conf.py
ctfs/StarCTF/2022/web/oh-my-lotto/app/source/gunicorn.conf.py
workers = 2 bind = "0.0.0.0:8080"
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2022/web/oh-my-lotto/app/source/app.py
ctfs/StarCTF/2022/web/oh-my-lotto/app/source/app.py
from flask import Flask,render_template, request import os app = Flask(__name__, static_url_path='') def safe_check(s): if 'LD' in s or 'HTTP' in s or 'BASH' in s or 'ENV' in s or 'PROXY' in s or 'PS' in s: return False return True @app.route("/", methods=['GET', 'POST']) def index(): return re...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2022/web/oh-my-lotto/lotto/source/gunicorn.conf.py
ctfs/StarCTF/2022/web/oh-my-lotto/lotto/source/gunicorn.conf.py
workers = 2 bind = "0.0.0.0:80"
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/StarCTF/2022/web/oh-my-lotto/lotto/source/app.py
ctfs/StarCTF/2022/web/oh-my-lotto/lotto/source/app.py
from flask import Flask, make_response import secrets app = Flask(__name__) @app.route("/") def index(): lotto = [] for i in range(1, 20): n = str(secrets.randbelow(40)) lotto.append(n) r = '\n'.join(lotto) response = make_response(r) response.headers['Content-Type'] = 'text/p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TsukuCTF/2021/web/gyOTAKU/app.py
ctfs/TsukuCTF/2021/web/gyOTAKU/app.py
import io import os import random import string import requests import subprocess from flask import Flask, render_template, request, send_file app = Flask(__name__) def sanitize(text): #RCE is a non-assumed solution. <- This is not a hint. url = "" for i in text: if i in string.digits + string.asc...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TsukuCTF/2021/web/digits/program.py
ctfs/TsukuCTF/2021/web/digits/program.py
from typing import Optional from fastapi import FastAPI import random app = FastAPI() FLAG = "TsukuCTF{}" @app.get("/") def main(q: Optional[str] = None): if q == None: return { "msg": "please input param 'q' (0000000000~9999999999). example: /?q=1234567890" } if len(q) != 10: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TsukuCTF/2023/crypto/new_cipher_scheme/output.py
ctfs/TsukuCTF/2023/crypto/new_cipher_scheme/output.py
r = 103223593878323616966427038558164830926502672938304332798494105455624811850665520007232855349275322661436610278579342219045141961390918581096853786570821153558254045159535424052709695034827346813080563034864500825268678590931984539859870234179994586959855078548304376995608256368401270715737193311910694875689 n = 90...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TsukuCTF/2023/crypto/new_cipher_scheme/problem.py
ctfs/TsukuCTF/2023/crypto/new_cipher_scheme/problem.py
from Crypto.Util.number import * from flag import flag def magic2(a): sum = 0 for i in range(a): sum += i * 2 + 1 return sum def magic(p, q, r): x = p + q for i in range(3): x = magic2(x) return x % r m = bytes_to_long(flag.encode()) p = getPrime(512) q = getPrime(512) r = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TsukuCTF/2023/web/EXECpy/crawler/capp.py
ctfs/TsukuCTF/2023/web/EXECpy/crawler/capp.py
import os import asyncio from playwright.async_api import async_playwright from flask import Flask, render_template, request app = Flask(__name__) DOMAIN = "nginx" FLAG = os.environ.get("FLAG", "TsukuCTF23{**********REDACTED**********}") @app.route("/crawler", methods=["GET"]) def index_get(): return render_tem...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TsukuCTF/2023/web/EXECpy/app/app.py
ctfs/TsukuCTF/2023/web/EXECpy/app/app.py
from flask import Flask, render_template, request app = Flask(__name__) @app.route("/", methods=["GET"]) def index(): code = request.args.get("code") if not code: return render_template("index.html") try: exec(code) except: pass return render_template("result.html") if...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TsukuCTF/2023/web/MEMOwow/app/app.py
ctfs/TsukuCTF/2023/web/MEMOwow/app/app.py
import base64 import secrets import urllib.parse from flask import Flask, render_template, request, session, redirect, url_for, abort SECRET_KEY = secrets.token_bytes(32) app = Flask(__name__) app.secret_key = SECRET_KEY @app.route("/", methods=["GET"]) def index(): if not "memo" in session: session["me...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BlueWater/2024/misc/RSAjail_3/chall.py
ctfs/BlueWater/2024/misc/RSAjail_3/chall.py
from subprocess import Popen, PIPE, DEVNULL from Crypto.Util.number import getPrime from secret import fname, flag import time, string, secrets, os def keygen(): pr = Popen(['python3', '-i'], stdin=PIPE, stdout=DEVNULL, stderr=DEVNULL, text=True, bufsize=1) p, q = getPrime(1024), getPrime(1024) N, e = p *...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false