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/CyberSecurityRumble/2022/web/Numbaz/generator/server.py
ctfs/CyberSecurityRumble/2022/web/Numbaz/generator/server.py
import os from werkzeug.utils import secure_filename from flask import Flask, redirect, url_for, render_template, request, flash, Response import hashlib import requests import base64 import shutil import time import string import random import json from subprocess import run, PIPE def randomString(stringLength=8): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSecurityRumble/2022/web/Numbaz/frontend/server.py
ctfs/CyberSecurityRumble/2022/web/Numbaz/frontend/server.py
import os from werkzeug.utils import secure_filename from flask import Flask, redirect, url_for, render_template, request, flash import hashlib import requests import base64 import shutil import time import string import random import re import time from flask import Response, session from flask_session import Session...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSecurityRumble/2022/web/RobertIsAGangsta/app/Userdb.py
ctfs/CyberSecurityRumble/2022/web/RobertIsAGangsta/app/Userdb.py
import json from uuid import uuid4 as uuid import hashlib import os class UserDB: def __init__(self, filename): self.db_file = "data/" + filename if not os.path.exists(self.db_file): with open(self.db_file, 'w'): pass with open(self.db_file, "r+") as f: if len(f.r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyberSecurityRumble/2022/web/RobertIsAGangsta/app/app.py
ctfs/CyberSecurityRumble/2022/web/RobertIsAGangsta/app/app.py
from re import U import secrets from flask import ( Flask, request, make_response, render_template, redirect, url_for, session, ) import json from uuid import uuid4 as uuid import random import time from Userdb import UserDB import subprocess # Look Ma, I wrote my own web app! app = Flask(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/L3HCTF/2021/crypto/EzECDSA/task.py
ctfs/L3HCTF/2021/crypto/EzECDSA/task.py
import gmpy2 import hashlib import socketserver import os,random,string from hashlib import sha256 from Crypto.Util.number import bytes_to_long from SECRET import FLAG p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f a = 0 b = 7 xG = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/L3HCTF/2024/misc/End_of_Programming/backend/src/main.py
ctfs/L3HCTF/2024/misc/End_of_Programming/backend/src/main.py
from flask import Flask,request,render_template import hashlib from client.Python.client import JudgeServerClient, JudgeServerClientError,cpp_lang_config import os import requests import re flag = os.environ.get('FLAG') client = JudgeServerClient(server_base_url='http://judge_server:8080',token='2q3r4t5y6u7i8o9p0sacuh...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/L3HCTF/2024/misc/End_of_Programming/backend/src/client/__init__.py
ctfs/L3HCTF/2024/misc/End_of_Programming/backend/src/client/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/L3HCTF/2024/misc/End_of_Programming/backend/src/client/Python/client.py
ctfs/L3HCTF/2024/misc/End_of_Programming/backend/src/client/Python/client.py
import hashlib import json import requests from .languages import c_lang_config, cpp_lang_config, java_lang_config, c_lang_spj_config, c_lang_spj_compile, py2_lang_config, py3_lang_config, go_lang_config, php_lang_config, js_lang_config class JudgeServerClientError(Exception): pass class JudgeServerClient(obj...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/L3HCTF/2024/misc/End_of_Programming/backend/src/client/Python/languages.py
ctfs/L3HCTF/2024/misc/End_of_Programming/backend/src/client/Python/languages.py
# coding=utf-8 from __future__ import unicode_literals default_env = ["LANG=en_US.UTF-8", "LANGUAGE=en_US:en", "LC_ALL=en_US.UTF-8"] c_lang_config = { "compile": { "src_name": "main.c", "exe_name": "main", "max_cpu_time": 3000, "max_real_time": 5000, "max_memory": 128 * 10...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/L3HCTF/2024/misc/End_of_Programming/backend/src/client/Python/__init__.py
ctfs/L3HCTF/2024/misc/End_of_Programming/backend/src/client/Python/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/L3HCTF/2024/misc/End_of_Programming/data/tests/test_case/pal/1.py
ctfs/L3HCTF/2024/misc/End_of_Programming/data/tests/test_case/pal/1.py
import hashlib all_tests = {} for i in range(1,2): item_info = {} name = f'{i}' inp = open(f'{name}.in','rb').read() outp = open(f'{name}.out','rb').read() item_info["input_name"] = f'{name}.in' item_info["input_size"] = len(inp) item_info["output_name"] = f'{name}.out' item_info["outpu...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/L3HCTF/2024/crypto/babySPN_revenge/task.py
ctfs/L3HCTF/2024/crypto/babySPN_revenge/task.py
import random import time from secret import flag, K from hashlib import sha256 from Crypto.Util.number import * def bin_to_list(r, bit_len): list = [r >> d & 1 for d in range(bit_len)][::-1] return list def list_to_int(list): return int("".join(str(i) for i in list), 2) Pbox=[1, 5, 9, 13, 2, 6, 10, 14, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/L3HCTF/2024/crypto/babySPN/task.py
ctfs/L3HCTF/2024/crypto/babySPN/task.py
import random import time from secret import flag from hashlib import sha256 from Crypto.Util.number import * def bin_to_list(r, bit_len): list = [r >> d & 1 for d in range(bit_len)][::-1] return list def list_to_int(list): return int("".join(str(i) for i in list), 2) Pbox=[1, 5, 9, 13, 2, 6, 10, 14, 3, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/L3HCTF/2024/crypto/can_you_guess_me/can_you_guess_me_3.py
ctfs/L3HCTF/2024/crypto/can_you_guess_me/can_you_guess_me_3.py
from Crypto.Util.number import * from random import * from secret import flag q = getPrime(128) n = 5 T = 2**48 E = 2**32 t = [randint(1,T) for i in range(n)] e = [randint(1,E) for i in range(n)] a = [(t[i] * flag - e[i]) % q for i in range(n)] print('q =', q) print('a =', a) flag = "L3HSEC{" + hex(flag)[2:] + "}"...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/L3HCTF/2024/web/intractable_problem/files/web.py
ctfs/L3HCTF/2024/web/intractable_problem/files/web.py
import flask import time import random import os import subprocess codes="" with open("oj.py","r") as f: codes=f.read() flag="" with open("/flag","r") as f: flag=f.read() app = flask.Flask(__name__) @app.route('/') def index(): return flask.render_template('ui.html') @app.route('/judge', methods=['POST']...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/L3HCTF/2024/web/intractable_problem/files/oj.py
ctfs/L3HCTF/2024/web/intractable_problem/files/oj.py
import sys import os codes=''' <<codehere>> ''' try: codes.encode("ascii") except UnicodeEncodeError: exit(0) if "__" in codes: exit(0) codes+="\nres=factorization(c)" locals={"c":"696287028823439285412516128163589070098246262909373657123513205248504673721763725782111252400832490434679394908376105858691...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2021/Quals/pwn/uc_goood/uc_goood.py
ctfs/0CTF/2021/Quals/pwn/uc_goood/uc_goood.py
#!/usr/bin/env python import os import struct import types from unicorn import * from unicorn.x86_const import * from syscall import hook_syscall CODE = 0xdeadbeef000 STACK = 0xbabecafe000 MAIN = b'\x48\x83\xec\x20\x66\xc7\x44\x24\x0e\x00\x00\x48\x8d\x5c\x24\x0e\x48\xc7\x44\x24\x10\x00\x00\x00\x00\x48\xc7\x44\x24\x1...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2021/Quals/pwn/uc_goood/syscall.py
ctfs/0CTF/2021/Quals/pwn/uc_goood/syscall.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from unicorn import * from unicorn.x86_const import * import os.path import sys def hook_syscall(uc, user_data): arg_regs = [UC_X86_REG_RDI, UC_X86_REG_RSI, UC_X86_REG_RDX, UC_X86_REG_R10, UC_X86_REG_R8, UC_X86_REG_R9] rax = uc.reg_read(UC_X86_REG_RAX) if rax...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2021/Quals/pwn/uc_masteeer/syscall.py
ctfs/0CTF/2021/Quals/pwn/uc_masteeer/syscall.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from unicorn import * from unicorn.x86_const import * import os.path import sys def hook_syscall(uc, user_data): arg_regs = [UC_X86_REG_RDI, UC_X86_REG_RSI, UC_X86_REG_RDX, UC_X86_REG_R10, UC_X86_REG_R8, UC_X86_REG_R9] rax = uc.reg_read(UC_X86_REG_RAX) if rax...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2021/Quals/pwn/uc_masteeer/uc_masteeer.py
ctfs/0CTF/2021/Quals/pwn/uc_masteeer/uc_masteeer.py
#!/usr/bin/env python import os import struct import types from unicorn import * from unicorn.x86_const import * from syscall import hook_syscall CODE = 0xdeadbeef000 STACK = 0xbabecafe000 MAIN = b'\x48\x83\xec\x20\x66\xc7\x44\x24\x0e\x00\x00\x48\x8d\x5c\x24\x0e\x48\xc7\x44\x24\x10\x00\x00\x00\x00\x48\xc7\x44\x24\x1...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2021/Quals/crypto/zer0lfsr/task.py
ctfs/0CTF/2021/Quals/crypto/zer0lfsr/task.py
#!/usr/bin/env python3 import random import signal import socketserver import string from hashlib import sha256 from os import urandom from secret import flag def _prod(L): p = 1 for x in L: p *= x return p def _sum(L): s = 0 for x in L: s ^= x return s def n2l(x, l): ret...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2021/Quals/crypto/cloudpass/task.py
ctfs/0CTF/2021/Quals/crypto/cloudpass/task.py
#!/usr/bin/python3 import os import socketserver import random import signal import string import struct from hashlib import sha256 import secrets import pykeepass from flag import flag MAXSIZE = 0x2000 class Task(socketserver.BaseRequestHandler): def proof_of_work(self): proof = ''.join([random.choice(s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2021/Quals/crypto/zer0lfsrplus/task.py
ctfs/0CTF/2021/Quals/crypto/zer0lfsrplus/task.py
#!/usr/bin/env python3 import random import signal import socketserver import string from hashlib import sha256 from os import urandom from secret import flag def _prod(L): p = 1 for x in L: p *= x return p def _sum(L): s = 0 for x in L: s ^= x return s def b2n(x): return...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2018/Quals/pwn/BabyStack/pow.py
ctfs/0CTF/2018/Quals/pwn/BabyStack/pow.py
#!/usr/bin/python -u # encoding: utf-8 import random, string, subprocess, os, sys from hashlib import sha256 os.chdir(os.path.dirname(os.path.realpath(__file__))) def proof_of_work(): chal = ''.join(random.choice(string.letters+string.digits) for _ in xrange(16)) print chal sol = sys.stdin.read(4) if...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2018/Quals/pwn/BabyStack/coll.py
ctfs/0CTF/2018/Quals/pwn/BabyStack/coll.py
import random, string, subprocess, os, sys from hashlib import sha256 random_str='' for i in xrange (0,1000000000): if (sha256(random_stra + str(i)).digest().startswith('\0\0\0')): print "Index is = ",i,"Result is =", sha256(random_str + str(i)).hexdigest()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2018/Quals/pwn/BlackHoleTheory/pow.py
ctfs/0CTF/2018/Quals/pwn/BlackHoleTheory/pow.py
#!/usr/bin/python -u # encoding: utf-8 import random, string, subprocess, os, sys from hashlib import sha256 os.chdir(os.path.dirname(os.path.realpath(__file__))) def proof_of_work(): chal = ''.join(random.choice(string.letters+string.digits) for _ in xrange(16)) print chal sol = sys.stdin.read(4) if...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2018/Quals/pwn/HeapStormII/pow.py
ctfs/0CTF/2018/Quals/pwn/HeapStormII/pow.py
#!/usr/bin/python -u # encoding: utf-8 import random, string, os, sys from hashlib import sha256 os.chdir(os.path.dirname(os.path.realpath(__file__))) def proof_of_work(): chal = ''.join(random.choice(string.letters+string.digits) for _ in xrange(16)) print chal sol = sys.stdin.read(4) if len(sol) !=...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2018/Finals/pwn/pemu/wrapper.py
ctfs/0CTF/2018/Finals/pwn/pemu/wrapper.py
#!/usr/bin/python -u import os import time from backports import tempfile time.sleep(1) dirname = os.path.abspath(os.path.dirname(__file__)) pemu = os.path.join(dirname, "pemu", "loader") bin = os.path.join(dirname, "binary", "main") with tempfile.TemporaryDirectory() as tmp: os.chdir(tmp) os.system("%s %s" % (...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2018/Finals/pwn/blackhole2/pow.py
ctfs/0CTF/2018/Finals/pwn/blackhole2/pow.py
#!/usr/bin/python -u # encoding: utf-8 import random, string, subprocess, os, sys from hashlib import sha256 os.chdir(os.path.dirname(os.path.realpath(__file__))) def proof_of_work(): chal = ''.join(random.choice(string.letters+string.digits) for _ in xrange(16)) print chal sol = sys.stdin.read(4) if...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2019/Quals/pwn/If_on_a_winters_night_a_traveler/service.py
ctfs/0CTF/2019/Quals/pwn/If_on_a_winters_night_a_traveler/service.py
#! /usr/bin/python import subprocess import tempfile import sys,os import random,string from hashlib import sha256 def proof_of_work(): proof = ''.join([random.choice(string.ascii_letters+string.digits) for _ in xrange(20)]) digest = sha256(proof).hexdigest() sys.stdout.write("sha256(XXXX+%s) == %s\n" % (...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/misc/economical_sort/pow.py
ctfs/0CTF/2023/misc/economical_sort/pow.py
import random, sys import gmpy2 def proof_of_work(sec = 60): # From 0CTF/TCTF 2021 p = gmpy2.next_prime(random.getrandbits(512)) q = gmpy2.next_prime(random.getrandbits(512)) n = p*q c = 2900000 t = c*sec + random.randint(0,c) print('Show me your computation:') print(f'2^(2^{t}) mod {n}...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/misc/economical_sort/secret.py
ctfs/0CTF/2023/misc/economical_sort/secret.py
flag = 'flag{xxxxxxx}'
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/misc/economical_sort/server.py
ctfs/0CTF/2023/misc/economical_sort/server.py
from unicorn import * from unicorn.x86_const import * import os import gc from secret import flag DATA = 0x400000 STACK = 0x800000 CODE = 0x1000000 instruction_cnt = 0 buffer_len = 100 def hook_code(uc, address, size, user_data): global instruction_cnt instruction_cnt += 1 if instruction_cnt > 1000000: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/misc/ctar/task.py
ctfs/0CTF/2023/misc/ctar/task.py
#!/usr/bin/python3 import os import socketserver import random import signal import string import tempfile import tarfile from hashlib import sha256 from Crypto.Cipher import ChaCha20 from secret import flag,key MAXNUM = 9 MAXFILESZ = 100 MAXTARSZ = 100000 class LicenseRequired(Exception): pass class Task(socketse...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/pwn/Half_Promise/pow.py
ctfs/0CTF/2023/pwn/Half_Promise/pow.py
import random, sys import gmpy2 def proof_of_work(sec = 60): # From 0CTF/TCTF 2021 p = gmpy2.next_prime(random.getrandbits(512)) q = gmpy2.next_prime(random.getrandbits(512)) n = p*q c = 2900000 t = c*sec + random.randint(0,c) print('Show me your computation:') print(f'2^(2^{t}) mod {n}...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/pwn/Half_Promise/read.py
ctfs/0CTF/2023/pwn/Half_Promise/read.py
import sys import os def main(): if not os.path.exists(sys.argv[1]): return print('Please input script:') script = sys.stdin.read(30000) end = script.find('EOF') if end != -1: script = script[:end] with open(sys.argv[1], 'w') as f: f.write(script) if __name__ == '__main...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/pwn/Promise/pow.py
ctfs/0CTF/2023/pwn/Promise/pow.py
import random, sys import gmpy2 def proof_of_work(sec = 60): # From 0CTF/TCTF 2021 p = gmpy2.next_prime(random.getrandbits(512)) q = gmpy2.next_prime(random.getrandbits(512)) n = p*q c = 2900000 t = c*sec + random.randint(0,c) print('Show me your computation:') print(f'2^(2^{t}) mod {n}...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/pwn/Promise/read.py
ctfs/0CTF/2023/pwn/Promise/read.py
import sys import os def main(): if not os.path.exists(sys.argv[1]): return print('Please input script:') script = sys.stdin.read(30000) end = script.find('EOF') if end != -1: script = script[:end] with open(sys.argv[1], 'w') as f: f.write(script) if __name__ == '__main...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/pwn/Nothing_is_True/server.py
ctfs/0CTF/2023/pwn/Nothing_is_True/server.py
#!/usr/bin/python3 -u import os, sys, random, subprocess, gmpy2 from io import BytesIO from hashlib import sha3_256 from elftools.elf.elffile import ELFFile from elftools.elf.constants import P_FLAGS os.chdir(os.path.dirname(__file__)) def proof_of_work(sec = 10): # From 0CTF/TCTF 2021 p = gmpy2.next_prime(r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/pwn/Everything_is_Permitted/wrapper.py
ctfs/0CTF/2023/pwn/Everything_is_Permitted/wrapper.py
#!/usr/bin/python3 -u import os, sys, random, subprocess, gmpy2 from io import BytesIO from hashlib import sha3_256 from elftools.elf.elffile import ELFFile from elftools.elf.constants import P_FLAGS os.chdir(os.path.dirname(__file__)) def proof_of_work(sec = 10): # From 0CTF/TCTF 2021 "checkin" p = gmpy2.ne...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/rev/how2compile_allinone/pow.py
ctfs/0CTF/2023/rev/how2compile_allinone/pow.py
import random, sys import gmpy2 def proof_of_work(sec = 60): # From 0CTF/TCTF 2021 p = gmpy2.next_prime(random.getrandbits(512)) q = gmpy2.next_prime(random.getrandbits(512)) n = p*q c = 2900000 t = c*sec + random.randint(0,c) print('Show me your computation:') print(f'2^(2^{t}) mod {n}...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/crypto/blocky_4.5/Cipher.py
ctfs/0CTF/2023/crypto/blocky_4.5/Cipher.py
from GF import GF SBOX, INV_SBOX = dict(), dict() for i in range(3 ** 5): v = GF(23) + (GF(0) if i == 0 else GF(i).inverse()) SBOX[GF(i)] = v INV_SBOX[v] = GF(i) class BlockCipher: def __init__(self, key: bytes, rnd: int): assert len(key) == 9 sks = [GF(b) for b in key] for i i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/crypto/blocky_4.5/task.py
ctfs/0CTF/2023/crypto/blocky_4.5/task.py
#!/usr/bin/env python3 import random import signal import socketserver import string from Cipher import BlockCipher from hashlib import sha256 from os import urandom from secret import FLAG MENU = """ [1] Encrypt [2] Decrypt [3] Guess""" def get_key(): key = b'' while len(key) < 9: b = urandom(1) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/crypto/blocky_4.5/GF.py
ctfs/0CTF/2023/crypto/blocky_4.5/GF.py
class GF: def __init__(self, value): if type(value) == int: self.value = [(value // (3 ** i)) % 3 for i in range(5)] elif type(value) == list and len(value) == 5: self.value = value else: assert False, "Wrong input to the constructor" def __str__(self...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/crypto/Double_RSA_2/task.py
ctfs/0CTF/2023/crypto/Double_RSA_2/task.py
#!/usr/bin/env python3 import random import signal import socketserver import string from Crypto.Util.number import * from hashlib import sha256 from secret import FLAG from os import urandom P_BITS = 512 E_BITS = int(P_BITS * 2 * 0.292) + 30 CNT_MAX = 760 class LCG: def __init__(self): self.init() ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/crypto/Double_RSA_0/task.py
ctfs/0CTF/2023/crypto/Double_RSA_0/task.py
#!/usr/bin/env python3 import random import signal import socketserver import string from Crypto.Util.number import * from hashlib import sha256 from secret import FLAG from os import urandom P_BITS = 512 E_BITS = int(P_BITS * 2 * 0.292) + 30 CNT_MAX = 7 class LCG: def __init__(self): self.init() de...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/crypto/Double_RSA_1/task.py
ctfs/0CTF/2023/crypto/Double_RSA_1/task.py
#!/usr/bin/env python3 import random import signal import socketserver import string from Crypto.Util.number import * from hashlib import sha256 from secret import FLAG from os import urandom P_BITS = 512 E_BITS = int(P_BITS * 2 * 0.292) + 30 CNT_MAX = 70 class LCG: def __init__(self): self.init() d...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/crypto/blocky_4.5_lite/Cipher.py
ctfs/0CTF/2023/crypto/blocky_4.5_lite/Cipher.py
from GF import GF SBOX, INV_SBOX = dict(), dict() for i in range(3 ** 5): v = GF(23) + (GF(0) if i == 0 else GF(i).inverse()) SBOX[GF(i)] = v INV_SBOX[v] = GF(i) class BlockCipher: def __init__(self, key: bytes, rnd: int): assert len(key) == 9 sks = [GF(b) for b in key] for i i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/crypto/blocky_4.5_lite/task.py
ctfs/0CTF/2023/crypto/blocky_4.5_lite/task.py
#!/usr/bin/env python3 import random import signal import socketserver import string from Cipher import BlockCipher from hashlib import sha256 from os import urandom from secret import FLAG MENU = """ [1] Encrypt [2] Decrypt [3] Guess""" def get_key(): key = b'' while len(key) < 9: b = urandom(1) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/crypto/blocky_4.5_lite/GF.py
ctfs/0CTF/2023/crypto/blocky_4.5_lite/GF.py
class GF: def __init__(self, value): if type(value) == int: self.value = [(value // (3 ** i)) % 3 for i in range(5)] elif type(value) == list and len(value) == 5: self.value = value else: assert False, "Wrong input to the constructor" def __str__(self...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/crypto/Double_RSA_3/task.py
ctfs/0CTF/2023/crypto/Double_RSA_3/task.py
#!/usr/bin/env python3 import random import signal import socketserver import string from Crypto.Util.number import * from hashlib import sha256 from secret import FLAG from os import urandom P_BITS = 512 E_BITS = int(P_BITS * 2 * 0.292) + 30 CNT_MAX = 910 class LCG: def __init__(self): self.init() ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2023/web/olapinfra/hive/init_db.py
ctfs/0CTF/2023/web/olapinfra/hive/init_db.py
#!/usr/bin/python3 import time import os import subprocess import pymysql def check_mysql(): while True: try: conn = pymysql.connect(host = 'mysql', port = 3306, user='root', password='123456', charset='utf8', autocommit=True) if conn: break except Exception as e: pass time.sle...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2025/crypto/baby_discriminator/task.py
ctfs/0CTF/2025/crypto/baby_discriminator/task.py
import random from hashlib import md5, sha256 import secrets import string import numpy as np import sys try: from secret import flag except ImportError: flag = "0ops{this_is_a_test_flag}" window = 5 total_nums = 20000 vector_size = 140 def proof_of_work(): challenge = ''.join(secrets.choice(string.asci...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2022/pwn/babysnitch/service.py
ctfs/0CTF/2022/pwn/babysnitch/service.py
#! /usr/bin/python2 import subprocess import tempfile import sys,os import random,string from hashlib import sha256 def proof_of_work(): proof = ''.join([random.choice(string.ascii_letters+string.digits) for _ in xrange(20)]) digest = sha256(proof).hexdigest() sys.stdout.write("sha256(XXXX+%s) == %s\n" % ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2022/crypto/leopard/task.py
ctfs/0CTF/2022/crypto/leopard/task.py
#!/usr/bin/env python3 import random import signal import socketserver import string from cipher import AEAD from hashlib import sha256 from os import urandom from secret import flag class Task(socketserver.BaseRequestHandler): def __init__(self, *args, **kargs): super().__init__(*args, **kargs) def ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2022/crypto/leopard/cipher.py
ctfs/0CTF/2022/crypto/leopard/cipher.py
def pad(s): l = 8 - (len(s) % 8) return s + l * bytearray([l]) def unpad(s): assert s[-1] <= 8 return s[: -s[-1]] def gmul(a, b): c = 0 while a and b: if b & 1: c ^= a a <<= 1 if a & 0x100: a ^= 0x11d b >>= 1 return c def gen_sbox():...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2022/crypto/real_magic_dlog/task.py
ctfs/0CTF/2022/crypto/real_magic_dlog/task.py
#!/usr/bin/env python3 import random import signal import socketserver import string from Crypto.Util.number import * from hashlib import sha256, sha384 from os import urandom from secret import flag LEN = 17 class Task(socketserver.BaseRequestHandler): def __init__(self, *args, **kargs): super().__init_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2022/crypto/ezRSA_plusplus/task.py
ctfs/0CTF/2022/crypto/ezRSA_plusplus/task.py
from Crypto.Util.number import * from os import urandom from secret import flag def ExGCD(a, b): if 0 == b: return 1, 0, a x, y, q = ExGCD(b, a % b) x, y = y, (x - a // b * y) return x, y, q def gen(p_size, d_size, l_size): while True: p = getPrime(p_size) q = getPrime(p_si...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2022/crypto/chimera/SPN.py
ctfs/0CTF/2022/crypto/chimera/SPN.py
from copy import deepcopy S_BOX = [47, 13, 50, 214, 119, 149, 138, 113, 200, 93, 180, 247, 86, 189, 125, 97, 226, 249, 159, 168, 55, 118, 169, 178, 18, 49, 102, 65, 34, 231, 10, 192, 100, 122, 75, 177, 205, 29, 40, 124, 103, 131, 232, 234, 72, 114, 127, 66, 154, 243, 27, 236, 106, 181, 87, 129, 38, 26, 140, 151, 135,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2022/crypto/chimera/task.py
ctfs/0CTF/2022/crypto/chimera/task.py
#!/usr/bin/env python3 import random import signal import socketserver import string from Chimera import Chimera from hashlib import sha256 from os import urandom from secret import flag assert len(flag) == 21 MENU = ''' Feistel + SPN = Chimera 1. Enc 2. Dec 3. Exit ''' def to_base64(x): bs = [] while x: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2022/crypto/chimera/Feistel.py
ctfs/0CTF/2022/crypto/chimera/Feistel.py
SBOX = [ [5, 7, 4, 15, 3, 10, 13, 12, 9, 2, 8, 11, 6, 14, 0, 1, 3, 2, 13, 12, 1, 10, 11, 9, 7, 0, 4, 15, 14, 6, 8, 5, 5, 10, 7, 8, 9, 15, 1, 12, 4, 6, 3, 14, 2, 11, 13, 0, 9, 3, 10, 12, 8, 14, 5, 15, 2, 1, 0, 13, 11, 6, 4, 7], [7, 13, 2, 9, 4, 6, 14, 10, 12, 8, 0, 15, 3, 1, 11, 5, 3, 5, 14, 4, 11, 10, 2, 1, 13, 8, 12,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2022/crypto/chimera/Chimera.py
ctfs/0CTF/2022/crypto/chimera/Chimera.py
from SPN import SPN from Feistel import Feistel def nsplit(s, n): return [s[k: k + n] for k in range(0, len(s), n)] P = [3 * _ % 16 for _ in range(16)] P_INV = [P.index(_) for _ in range(16)] class Chimera(): def __init__(self, key, rnd=4): self.key = key self.C1a = Feistel(key[: 6], rnd) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2020/Quals/pwn/chromium_sbx/server.py
ctfs/0CTF/2020/Quals/pwn/chromium_sbx/server.py
#!/usr/bin/env python3 -u import hashlib import os import random import string import sys import subprocess import tempfile MAX_SIZE = 100 * 1024 print("Proof of work is required.") prefix = "".join([random.choice(string.digits + string.ascii_letters) for i in range(10)]) resource = prefix + "mojo" bits = 28 cash = i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/0CTF/2020/Quals/pwn/chromium_fullchain/server.py
ctfs/0CTF/2020/Quals/pwn/chromium_fullchain/server.py
#!/usr/bin/env python3 -u import hashlib import os import random import string import sys import subprocess import tempfile MAX_SIZE = 100 * 1024 print("Proof of work is required.") prefix = "".join([random.choice(string.digits + string.ascii_letters) for i in range(10)]) resource = prefix + "mojo" bits = 28 cash = i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Union/2021/pwn/nutty/pow.py
ctfs/Union/2021/pwn/nutty/pow.py
#!/usr/bin/env python2.7 # # Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Union/2021/pwn/nutty/hashcash.py
ctfs/Union/2021/pwn/nutty/hashcash.py
#!/usr/bin/env python2.3 """Implement Hashcash version 1 protocol in Python +-------------------------------------------------------+ | Written by David Mertz; released to the Public Domain | +-------------------------------------------------------+ Double spend database not implemented in this module, but stub for ca...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Union/2021/crypto/cr0wn_st3rling/cr0wn_sterling.py
ctfs/Union/2021/crypto/cr0wn_st3rling/cr0wn_sterling.py
#!/usr/bin/env python3 from secrets import flag, musical_key from Crypto.Util.number import isPrime import math def sieve_for_primes_to(n): # Copyright Eratosthenes, 204 BC size = n//2 sieve = [1]*size limit = int(n**0.5) for i in range(1, limit): if sieve[i]: val = 2*i+1 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Union/2021/crypto/neoclassical/neoclassical.py
ctfs/Union/2021/crypto/neoclassical/neoclassical.py
import os from hashlib import sha1 from random import randint from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad FLAG = b"union{XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}" def list_valid(l): x = l // 2 checked = set([x]) while x * x != l: x = (x + (l // x)) // 2 if x in checke...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Union/2021/crypto/human_server/human_server.py
ctfs/Union/2021/crypto/human_server/human_server.py
import os, random, hashlib, textwrap, json from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad from Crypto.Util.number import getPrime, long_to_bytes from fastecdsa.curve import secp256k1 from fastecdsa.point import Point FLAG = b'union{XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2021/Quals/rev/hardskull/debug.py
ctfs/CSAW/2021/Quals/rev/hardskull/debug.py
# debug.py: companion debug tool for hardskull # # Copyright (C) 2021 theKidOfArcrania # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2021/Quals/rev/checker/checker.py
ctfs/CSAW/2021/Quals/rev/checker/checker.py
def up(x): x = [f"{ord(x[i]) << 1:08b}" for i in range(len(x))] return ''.join(x) def down(x): x = ''.join(['1' if x[i] == '0' else '0' for i in range(len(x))]) return x def right(x,d): x = x[d:] + x[0:d] return x def left(x,d): x = right(x,len(x)-d) return x[::-1] def encode(plain):...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2021/Quals/rev/ncore/server.py
ctfs/CSAW/2021/Quals/rev/ncore/server.py
import os import shutil import subprocess def main(): print("WELCOME") txt = input() print(txt) addr = os.environ.get("SOCAT_PEERADDR") if(os.path.exists(addr)): shutil.rmtree(addr) os.mkdir(addr) shutil.copy("flag.hex",f"{addr}/flag.hex") shutil.copy("nco",f"{addr}/nco") ra...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2021/Quals/rev/turning_trees/constants.py
ctfs/CSAW/2021/Quals/rev/turning_trees/constants.py
GRID_SIZE = 1000 ANIMATION_SPEED = 150
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2021/Quals/rev/turning_trees/anim.py
ctfs/CSAW/2021/Quals/rev/turning_trees/anim.py
import itertools from typing import List from enum import Enum from .constants import ANIMATION_SPEED from .defs import LogOrientation def ease_in_out(t,a,b): fac = 4 * t**3 if t < 0.5 else 1 - pow(-2 * t + 2, 3) / 2 return (float(a) * (1 - fac)) + (float(b) * fac) def linear(t,a,b): fac = t retur...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2021/Quals/rev/turning_trees/camera.py
ctfs/CSAW/2021/Quals/rev/turning_trees/camera.py
ZOOM_MIN = -8 ZOOM_MAX = -3 class Camera(object): x: float y: float zoom_level: int def __init__(self, x, y, zoom_level): self.x = x self.y = y self.zoom_level = zoom_level def zoom_in(self): self.zoom_level = min(self.zoom_level + 1, ZOOM_MAX) def zoom_out(s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2021/Quals/rev/turning_trees/main.py
ctfs/CSAW/2021/Quals/rev/turning_trees/main.py
import pathlib import os os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = 'hide' import pygame from .map import Map from .camera import Camera from .anim import Animation LEVEL = 1 def init_map(): print('Loading level %d' % LEVEL) if LEVEL == 1: return Map.load(str(pathlib.Path(__file__).parent / 'leve...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2021/Quals/rev/turning_trees/__init__.py
ctfs/CSAW/2021/Quals/rev/turning_trees/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2021/Quals/rev/turning_trees/map.py
ctfs/CSAW/2021/Quals/rev/turning_trees/map.py
from typing import List, Tuple from enum import Enum import json import itertools import numpy as np import pygame from pygame import gfxdraw from .constants import GRID_SIZE from .anim import Animation, Transition, PlayerMoveAnimation, TreeFallAnimation, \ TreeIntoWaterAnimation, TreeRollAnimation, MakeRaftAnim...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2021/Quals/rev/turning_trees/defs.py
ctfs/CSAW/2021/Quals/rev/turning_trees/defs.py
from enum import Enum class LogOrientation(Enum): TREE = 0 STANDING = 1 VERTICAL = 2 HORIZONTAL = 3 TRANSITION_UP = 4 TRANSITION_DOWN = 5 TRANSITION_LEFT = 6 TRANSITION_RIGHT = 7 class Tiles(object): WATER = 1 LAND = 2 STUMP = 3 LAND_ROCK = 4
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2021/Quals/crypto/Forgery/forgery.py
ctfs/CSAW/2021/Quals/crypto/Forgery/forgery.py
from Crypto.Util.number import getPrime from random import randint from math import gcd with open("flag.txt",'r') as f: flag = f.read() p = getPrime(1024) g = 3 MASK = 2**1024 - 1 def gen_keys(): x = randint(1, p-2) y = pow(g, x, p) return (x, y) def sign(answer: str, x: int): while True: m = int(asnwer, 16)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2021/Quals/web/Gatekeeping/server/server.py
ctfs/CSAW/2021/Quals/web/Gatekeeping/server/server.py
import os import json import string import binascii from flask import Flask, Blueprint, request, jsonify, render_template, abort from Crypto.Cipher import AES app = Flask(__name__) def get_info(): key = request.headers.get('key_id') if not key: abort(400, 'Missing key id') if not all(c in '012345...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2024/Quals/crypto/CBC/app.py
ctfs/CSAW/2024/Quals/crypto/CBC/app.py
from Crypto.Util.Padding import pad, unpad from Crypto.Cipher import AES import os def decrypt(txt: str) -> (str, int): try: token = bytes.fromhex(txt) c = AES.new(os.environ["AES_KEY"].encode(), AES.MODE_CBC, iv=os.environ["AES_IV"].encode()) plaintext = c.decrypt(token) unpadded ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2024/Quals/crypto/Diffusion_Pop_Quiz/anf_extractor.py
ctfs/CSAW/2024/Quals/crypto/Diffusion_Pop_Quiz/anf_extractor.py
# To ensure correctly formatted answers for the challenge, use 1-indexed values for the output bits. # For example, if you have an S-Box of 8 bits to 8 bits, the first output bit is 1, the second is 2, and so forth. # Your ANF expression will have the variables y1, y2, ..., y8. # Put your S-Boxes here. example = [1, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2024/Quals/web/Playing_on_the_Backcourts/app_public.py
ctfs/CSAW/2024/Quals/web/Playing_on_the_Backcourts/app_public.py
from flask import Flask, render_template, request, session, jsonify, send_file from hashlib import sha256 from os import path as path app = Flask(__name__) app.secret_key = 'safe' leaderboard_path = 'leaderboard.txt' safetytime = 'csawctf{i_look_different_in_prod}' @app.route('/') def index() -> str: cookie = re...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2023/Quals/misc/Discord_Admin_Bot/bot_send.py
ctfs/CSAW/2023/Quals/misc/Discord_Admin_Bot/bot_send.py
############################################# # Author: Krishnan Navadia # This is main working file for this chal ############################################# import discord from discord.ext import commands, tasks import subprocess from settings import ADMIN_ROLE import os from dotenv import load_dotenv from time i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2023/Quals/misc/stonk/user.py
ctfs/CSAW/2023/Quals/misc/stonk/user.py
import requests import json ADDRESS = "http://127.0.0.1" PORT = 8000 print(\ """Thank you for choosing City Subway Auction Website (CSAW)'s Trading Platform As a thank you for using our platform, all new registrants will be granted $2000 and the flags are on sale for $9001 dollars. Have fun trading! Here are the opt...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2023/Quals/misc/stonk/process.py
ctfs/CSAW/2023/Quals/misc/stonk/process.py
from collections import defaultdict from enum import Enum from collections import deque from time import sleep COMPANIES = { "AAPLISH": { "name": "AAPLISH Inc.", "price": 175.42 }, "AMAZING": { "name": "AMAZING Enterprises", "price": 194.87 }, "FACEFLOP": { ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2023/Quals/misc/stonk/app.py
ctfs/CSAW/2023/Quals/misc/stonk/app.py
from flask import Flask, render_template, request, session, url_for, redirect,abort,jsonify, flash, send_file import time from collections import deque from process import COMPANIES, processTransaction, loginDB, Throttle_Splash, threadTransact, market_scrape from threading import Thread app = Flask(__name__,static_fol...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2023/Quals/crypto/Blocky_Noncense/sig_sage.py
ctfs/CSAW/2023/Quals/crypto/Blocky_Noncense/sig_sage.py
# This file was *autogenerated* from the file sig.sage from sage.all_cmdline import * # import sage library _sage_const_2 = Integer(2); _sage_const_3 = Integer(3); _sage_const_0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F = Integer(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFF...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2023/Quals/crypto/Blocky_Noncense/blocks_sage.py
ctfs/CSAW/2023/Quals/crypto/Blocky_Noncense/blocks_sage.py
# This file was *autogenerated* from the file blocks.sage from sage.all_cmdline import * # import sage library _sage_const_0 = Integer(0); _sage_const_1 = Integer(1) from Crypto.Cipher import AES import sig_sage as sig # this is generated from sig.sage import hashlib class Chain: def __init__(self, seed): self...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2023/Quals/crypto/Mental_Poker/server.py
ctfs/CSAW/2023/Quals/crypto/Mental_Poker/server.py
from inputimeout import inputimeout, TimeoutOccurred import os, sys from Crypto.Util.number import getPrime, bytes_to_long, long_to_bytes from math import gcd card_value_dict = {0: "Zero", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five", 6: "Six", 7: "Seven", 8: "Eight", 9: "Nine", 10: "Ten", 11: "Jack", 12: "Que...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2023/Quals/crypto/lottery/server.py
ctfs/CSAW/2023/Quals/crypto/lottery/server.py
from inputimeout import inputimeout, TimeoutOccurred import random, sys with open('flag.txt') as f: flag = f.read() def main(): print("Here is how the lottery works:") print("- Players purchase tickets comprising their choices of six different numbers between 1 and 70") print("- During the draw, six balls are ran...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2023/Quals/crypto/Circles/server.py
ctfs/CSAW/2023/Quals/crypto/Circles/server.py
from secret import special_function from Crypto.Cipher import AES from Crypto.Util.Padding import pad with open('flag.png','rb') as f: data = f.read() key = special_function(0xcafed3adb3ef1e37).to_bytes(32,"big") iv = b"r4nd0m_1v_ch053n" cipher = AES.new(key, AES.MODE_CBC, iv) enc = cipher.encrypt(pad(data,AES.block...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2023/Quals/intro/my_first_pwnie/my_first_pwnie.py
ctfs/CSAW/2023/Quals/intro/my_first_pwnie/my_first_pwnie.py
#!/usr/bin/env python3 # Pwn mostly builds on top of rev. # While rev is more about understanding how a program works, pwn is more about figuring out how to exploit a program to reach the holy grail: Arbitrary Code Execution # # If you can execute arbitrary code on a system, that system might as well be yours...becaus...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CSAW/2023/Quals/intro/Babys_First/babysfirst.py
ctfs/CSAW/2023/Quals/intro/Babys_First/babysfirst.py
#!/usr/bin/env python3 # Reversing is hard. But....not always. # # Usually, you won't have access to source. # Usually, these days, programmers are also smart enough not to include sensitive data in what they send to customers.... # # But not always.... if input("What's the password? ") == "csawctf{w3_411_star7_5om3w...
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/pwn/how2pwn/bin/exp.py
ctfs/CSAW/2022/Quals/pwn/how2pwn/bin/exp.py
from pwn import * context.log_level='debug' p = process("./chal1") # p = remote("127.0.0.1", 60001) context.terminal = ['tmux', 'splitw', '-h', '-F' '#{pane_pid}', '-P'] gdb.attach(p) # attach to debug, don't forget to run "tmux" before running the script # Tip: In x64, # rdi/rsi/rdx is the register to store the first...
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/rev/TheBigBang/challenge.py
ctfs/CSAW/2022/Quals/rev/TheBigBang/challenge.py
import random import binascii MAGIC = ? K1 = b'\xae@\xb9\x1e\xb5\x98\x97\x81!d\x90\xed\xa9\x0bm~G\x92{y\xcd\x89\x9e\xec2\xb8\x1d\x13OB\x84\xbf\xfaI\xe1o~\x8f\xe40g!%Ri\xda\xd14J\x8aV\xc2x\x1dg\x07K\x1d\xcf\x86{Q\xaa\x00qW\xbb\xe0\xd7\xd8\x9b\x05\x88' K2 = b"Q\xbfF\xe1Jgh~\xde\x9bo\x12V\xf4\x92\x81\xb8m\x84\x862va\x13\...
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/GottaCrackThemAll/encrypt.py
ctfs/CSAW/2022/Quals/crypto/GottaCrackThemAll/encrypt.py
with open('key.txt','rb') as f: key = f.read() def encrypt(plain): return b''.join((ord(x) ^ y).to_bytes(1,'big') for (x,y) in zip(plain,key))
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/Beyond_Quantum/mathutils.py
ctfs/CSAW/2022/Quals/crypto/Beyond_Quantum/mathutils.py
import math from sympy import GF, invert import numpy as np from sympy.abc import x from sympy import ZZ, Poly def is_prime(n): for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def is_2_power(n): return n != 0 and (n & (n - 1) == 0) def random_poly(length...
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/Beyond_Quantum/cipher.py
ctfs/CSAW/2022/Quals/crypto/Beyond_Quantum/cipher.py
from cipher.mathutils import * import numpy as np from sympy.abc import x from sympy.polys.polyerrors import NotInvertible from sympy import ZZ, Poly from collections import Counter class Cipher: N = None p = None q = None f_poly = None g_poly = None h_poly = None f_p_poly = None f_q_p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false