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/WHY/2025/Quals/web/Flyer/flyer.py
ctfs/WHY/2025/Quals/web/Flyer/flyer.py
from flask import Flask, request, render_template, abort, make_response import subprocess import string import random import os from werkzeug.exceptions import HTTPException app = Flask(__name__) colors = [ "#61f2ff", "#f25e95", "#fffb96", "#b03bbf", "#5234bf", "#f24534" ] command_text_add = r"""convert -size 840x{...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WHY/2025/Finals/misc/TitleCase/TitleCase.py
ctfs/WHY/2025/Finals/misc/TitleCase/TitleCase.py
#!/usr/bin/env python3 eval(input().title())
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WHY/2025/Finals/web/Flyer/flyer.py
ctfs/WHY/2025/Finals/web/Flyer/flyer.py
from flask import Flask, request, render_template, abort, make_response import subprocess import string import random import os from werkzeug.exceptions import HTTPException app = Flask(__name__) colors = [ "#61f2ff", "#f25e95", "#fffb96", "#b03bbf", "#5234bf", "#f24534" ] command_text_add = r"""convert -size 840x{...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/THCon/2021/crypto/Babysign/server.py
ctfs/THCon/2021/crypto/Babysign/server.py
from Crypto.Util.number import getPrime, GCD, inverse, bytes_to_long import os class SecureSigner(): def __init__(self): p = getPrime(512) q = getPrime(512) e = 0x10001 phi = (p-1)*(q-1) while GCD(e,phi) != 1: p = getPrime(512) q = getPrime(512) phi = (p-1)*(q-1) self.d = inverse(e,phi) self.n...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/THCon/2021/crypto/Too_old_to_sign/server.py
ctfs/THCon/2021/crypto/Too_old_to_sign/server.py
#!/usr/local/bin/python3.8 from Crypto.PublicKey import RSA from Crypto.Util.number import long_to_bytes,bytes_to_long from secret import FLAG, aes_key from hashlib import sha1 from os import urandom def sign1(sk, m): mq, dq = m % sk.q, sk.d % (sk.q - 1) mp, dp = m % sk.p, sk.d % (sk.p - 1) s1 = pow(mq, dp, sk.q)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/THCon/2021/crypto/ECDSAFE/server.py
ctfs/THCon/2021/crypto/ECDSAFE/server.py
#!/usr/local/bin/python3.8 from os import urandom from Crypto.Util.number import inverse from hashlib import sha256 from Crypto.Random import random import ecdsa from flag import FLAG class PRNG: def __init__(self,seed,m,flag): self.state = seed self.m = m self.counter = 0 self.flag = flag def next_state(s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/THCon/2021/crypto/weebox.py/weebox.py
ctfs/THCon/2021/crypto/weebox.py/weebox.py
import hashlib import sys # # weebox.py # - written by plcp # - owned by quarkslab # - only engages its author for code quality :) # nb_bits = 256 nb_bytes = 32 nb_words = 64 word_len = 4 word_mask = (2**word_len) - 1 ladder_size = 2**word_len group = 11579208921035624876269744694940757353008614341529031419553363130...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/THCon/2021/crypto/Rsa_internal_attacker/chall.py
ctfs/THCon/2021/crypto/Rsa_internal_attacker/chall.py
#!/usr/bin/env python3 from Crypto.Util.number import getPrime, inverse, bytes_to_long import random from math import gcd def init(): p = getPrime(1024) q = getPrime(1024) return p, q def new_user(p, q): phi = (p - 1) * (q - 1) while True: e = random.randint(2, 100000) if gcd(e, p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/THCon/2021/crypto/Kidsign/server.py
ctfs/THCon/2021/crypto/Kidsign/server.py
from Crypto.Util.number import inverse, isPrime from random import SystemRandom from hashlib import sha256 from flag import FLAG import os rand = SystemRandom() class ElGamal: def __init__(self): self.q = 8966609407579935833391255375154491466554551538628382401199255823112028665721378555915151305602728086902061611...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/THCon/2025/crypto/OTPas_ouf/OTP_encryption.py
ctfs/THCon/2025/crypto/OTPas_ouf/OTP_encryption.py
from random import randint def generate_OTP(): OTP = b'' for _ in range(10): OTP += int.to_bytes(randint(0,255)) return OTP def encrypt_file(input_file: str, output_file: str, passwd: bytes): with open(input_file, "rb") as ifile: input_data = ifile.read() with open(output_file, 'w...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/THCon/2025/crypto/Mammoths_Personnal_Slot_Machine/server_REDACTED.py
ctfs/THCon/2025/crypto/Mammoths_Personnal_Slot_Machine/server_REDACTED.py
import random import socket import time random.seed(some_number) print("Random values:", [random.getrandbits(32) for _ in range(here_too)]) server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.bind(("0.0.0.0", 12345)) server_socket.listen(5) print("Server listening on port 12345") while T...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/THCon/2022/pwn/codemov/codemov.py
ctfs/THCon/2022/pwn/codemov/codemov.py
#!/usr/bin/env python3 from pwn import * context.arch = 'amd64' print("Enter your shellcode (80 bytes max): ") shellcode = [] while True: try: code = input().replace(';', '').lower().strip() if code == "end": break if not code.startswith("mov"): log.failure("Inva...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Auvergnhack/2025/crypto/Monkey_News/back.py
ctfs/Auvergnhack/2025/crypto/Monkey_News/back.py
from flask import Flask, render_template, request, redirect, url_for, session, make_response from werkzeug.security import check_password_hash import os import time import base64 import subprocess app = Flask(__name__) app.secret_key = os.urandom(24) f=open('flag.txt') flag=f.read().rstrip('\n') def load_users(): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyKor/2025/crypto/x2=-1/prob.py
ctfs/CyKor/2025/crypto/x2=-1/prob.py
#!/usr/bin/python3 import math import os import signal from Crypto.Util.number import * from hashlib import sha256 ##### PARAMS ##### P = 2**47 - 297 # Field size N = 256 # Number of parties kappa = 64 # Security parameter tau = 50 # Number of repetitions ################## # No more suffering from MTU/slow interacti...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyKor/2025/crypto/Rock_Scissors_Paper/chall.py
ctfs/CyKor/2025/crypto/Rock_Scissors_Paper/chall.py
import hashlib import random import json from secret import flag RSP = ['Rock', 'Scissors', 'Paper'] HASH_LIST = ['md5', 'sha1', 'sha256'] SALT_MAX = 10 ROUND = 2000 class Alice: def __init__(self): self.rsp_list = [random.choice(RSP) for _ in range(ROUND)] self.hash_choice = [random.choice(HASH_L...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyKor/2025/web/dbchat/pow-solver.py
ctfs/CyKor/2025/web/dbchat/pow-solver.py
from __future__ import annotations import base64 import hashlib import json import os import threading import time from typing import Optional # Paste the /pow/start token here. CHALLENGE = "" THREADS = os.cpu_count() or 1 def b64url_decode(s: str) -> bytes: pad = "=" * (-len(s) % 4) return base64.urlsafe_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyKor/2025/web/se1enium/pow-solver.py
ctfs/CyKor/2025/web/se1enium/pow-solver.py
from __future__ import annotations import base64 import hashlib import json import os import threading import time from typing import Optional # Paste the /pow/start token here. CHALLENGE = "" THREADS = os.cpu_count() or 1 def b64url_decode(s: str) -> bytes: pad = "=" * (-len(s) % 4) return base64.urlsafe_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/CyKor/2025/web/asterisk/pow-solver.py
ctfs/CyKor/2025/web/asterisk/pow-solver.py
from __future__ import annotations import base64 import hashlib import json import os import threading import time from typing import Optional # Paste the /pow/start token here. CHALLENGE = "" THREADS = os.cpu_count() or 1 def b64url_decode(s: str) -> bytes: pad = "=" * (-len(s) % 4) return base64.urlsafe_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Cygenix/2024/crypto/DH_900/encrypt.py
ctfs/Cygenix/2024/crypto/DH_900/encrypt.py
mod = int(input('Public mod: ')) base = int(input('Public base: ')) a_secret = int(input('A secret: ')) b_secret = int(input('B secret: ')) a_public = (base ** a_secret) % mod b_public = (base ** b_secret) % mod print('=================') print('A public = ' + str(a_public)) print('B public = ' + str(b_public)) a_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/misc/Befuddled2/challenge.py
ctfs/WolvCTF/2024/misc/Befuddled2/challenge.py
from befunge import befunge, create_grid import sys code = input('code? ') grid = create_grid(code + '\n') if code == '': print('no code?') sys.exit(1) if len(grid) > 1: print('must be a one liner!') sys.exit(1) if any(c in code for c in '<>'): print('no') sys.exit(1) if len(grid[0]) > 16: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/misc/Befuddled2/befunge.py
ctfs/WolvCTF/2024/misc/Befuddled2/befunge.py
import sys def create_grid(code): GRID = [] r = 0 c = 0 row = [] for x in code: if x == '\n': r += 1 c = 0 GRID.append(row) row = [] else: row.append(x) c += 1 # right pad with spaces maxlen = max(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/misc/Befuddled3/challenge.py
ctfs/WolvCTF/2024/misc/Befuddled3/challenge.py
from befunge import befunge, create_grid import sys code = input('code? ') grid = create_grid(code + '\n') if code == '': print('no code?') sys.exit(1) if len(grid) > 1: print('must be a one liner!') sys.exit(1) if len(grid[0]) > 8: print('too long :(') sys.exit(1) befunge(grid, open('flag.t...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/misc/Befuddled3/befunge.py
ctfs/WolvCTF/2024/misc/Befuddled3/befunge.py
import sys def create_grid(code): GRID = [] r = 0 c = 0 row = [] for x in code: if x == '\n': r += 1 c = 0 GRID.append(row) row = [] else: row.append(x) c += 1 # right pad with spaces maxlen = max(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/misc/Befuddled1/challenge.py
ctfs/WolvCTF/2024/misc/Befuddled1/challenge.py
from befunge import befunge, create_grid import sys code = input('code? ') grid = create_grid(code + '\n') if code == '': print('no code?') sys.exit(1) if len(grid) > 1: print('must be a one liner!') sys.exit(1) if len(grid[0]) > 16: print('too long :(') sys.exit(1) befunge(grid, open('flag....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/misc/Befuddled1/befunge.py
ctfs/WolvCTF/2024/misc/Befuddled1/befunge.py
import sys def create_grid(code): GRID = [] r = 0 c = 0 row = [] for x in code: if x == '\n': r += 1 c = 0 GRID.append(row) row = [] else: row.append(x) c += 1 # right pad with spaces maxlen = max(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/rev/Shredded/shredder.py
ctfs/WolvCTF/2024/rev/Shredded/shredder.py
import random with open(".\\shredded.c", "r") as f: lines = f.readlines() longest = 0 for i in lines: i = i.replace("\n", " ") if len(i) > longest: longest = len(i) padLines = [] for i in lines: padLines.append(i.replace("\n"," ") + " " * (longest - len(i))) print(i) split = ["" for _ ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/rev/befudged_up/runner.py
ctfs/WolvCTF/2024/rev/befudged_up/runner.py
from befunge import read_in, befunge prog = read_in('prog.befunge') print('flag? ') befunge(prog) print('')
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/rev/befudged_up/befunge.py
ctfs/WolvCTF/2024/rev/befudged_up/befunge.py
import sys def read_in(filename): GRID = [] r = 0 c = 0 row = [] with open(filename, 'r') as f: contents = f.read() for x in contents: if x == '\n': r += 1 c = 0 GRID.append(row) row = [] else: row.append(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/crypto/TagSeries1/chal.py
ctfs/WolvCTF/2024/crypto/TagSeries1/chal.py
import sys import os from Crypto.Cipher import AES MESSAGE = b"GET FILE: flag.txt" QUERIES = [] BLOCK_SIZE = 16 KEY = os.urandom(BLOCK_SIZE) def oracle(message: bytes) -> bytes: aes_ecb = AES.new(KEY, AES.MODE_ECB) return aes_ecb.encrypt(message)[-BLOCK_SIZE:] def main(): for _ in range(3): com...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/crypto/Limited_2/NY_chal_time.py
ctfs/WolvCTF/2024/crypto/Limited_2/NY_chal_time.py
import time import random import sys if __name__ == '__main__': flag = input("Flag? > ").encode('utf-8') correct = [192, 123, 40, 205, 152, 229, 188, 64, 42, 166, 126, 125, 13, 187, 91] if len(flag) != len(correct): print('Nope :(') sys.exit(1) if time.gmtime().tm_year >= 2024 or time.g...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/crypto/TagSeries3/chal.py
ctfs/WolvCTF/2024/crypto/TagSeries3/chal.py
import sys import os from hashlib import sha1 MESSAGE = b"GET FILE: " SECRET = os.urandom(1200) def main(): _sha1 = sha1() _sha1.update(SECRET) _sha1.update(MESSAGE) sys.stdout.write(_sha1.hexdigest() + '\n') sys.stdout.flush() _sha1 = sha1() command = sys.stdin.buffer.readline().strip() ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/crypto/Limited_1/chal_time.py
ctfs/WolvCTF/2024/crypto/Limited_1/chal_time.py
import time import random import sys if __name__ == '__main__': flag = input("Flag? > ").encode('utf-8') correct = [189, 24, 103, 164, 36, 233, 227, 172, 244, 213, 61, 62, 84, 124, 242, 100, 22, 94, 108, 230, 24, 190, 23, 228, 24] time_cycle = int(time.time()) % 256 if len(flag) != len(correct): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/crypto/Blocked2/server.py
ctfs/WolvCTF/2024/crypto/Blocked2/server.py
import random import secrets import sys import time from Crypto.Cipher import AES from Crypto.Util.Padding import pad from Crypto.Util.strxor import strxor MASTER_KEY = secrets.token_bytes(16) def encrypt(message): if len(message) % 16 != 0: print("message must be a multiple of 16 bytes long! don't fo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/crypto/yORs_Truly_heart/yors-truly.py
ctfs/WolvCTF/2024/crypto/yORs_Truly_heart/yors-truly.py
import base64 plaintext = "A string of text can be encrypted by applying the bitwise XOR operator to every character using a given key" key = "" # I have lost the key! def byte_xor(ba1, ba2): return bytes([_a ^ _b for _a, _b in zip(ba1, ba2)]) ciphertext_b64 = base64.b64encode(byte_xor(key.encode(), plaintext.en...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/crypto/TwoTimePad/chall.py
ctfs/WolvCTF/2024/crypto/TwoTimePad/chall.py
from Crypto.Random import random, get_random_bytes BLOCK_SIZE = 16 with(open('./genFiles/wolverine.bmp', 'rb')) as f: wolverine = f.read() with(open('./genFiles/flag.bmp', 'rb')) as f: flag = f.read() w = open('eWolverine.bmp', 'wb') f = open('eFlag.bmp', 'wb') f.write(flag[:55]) w.write(wolverine[:55]) fo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/crypto/TagSeries2/chal.py
ctfs/WolvCTF/2024/crypto/TagSeries2/chal.py
import sys import os from Crypto.Cipher import AES MESSAGE = b"GET: flag.txt" QUERIES = [] BLOCK_SIZE = 16 KEY = os.urandom(BLOCK_SIZE) RANDOM_IV = os.urandom(BLOCK_SIZE) def oracle(message: bytes) -> bytes: aes_cbc = AES.new(KEY, AES.MODE_CBC, RANDOM_IV) return aes_cbc.encrypt(message)[-BLOCK_SIZE:] def m...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2024/crypto/Blocked1/server.py
ctfs/WolvCTF/2024/crypto/Blocked1/server.py
""" ---------------------------------------------------------------------------- NOTE: any websites linked in this challenge are linked **purely for fun** They do not contain real flags for WolvCTF. ---------------------------------------------------------------------------- """ import random import secrets import sy...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2023/crypto/keyexchange/challenge.py
ctfs/WolvCTF/2023/crypto/keyexchange/challenge.py
#!/opt/homebrew/bin/python3 from Crypto.Util.strxor import strxor from Crypto.Util.number import * from Crypto.Cipher import AES n = getPrime(512) s = getPrime(256) a = getPrime(256) # n can't hurt me if i don't tell you print(pow(s, a, n)) b = int(input("b? >>> ")) secret_key = pow(pow(s, a, n), b, n) flag = ope...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2023/crypto/Galois-t_is_this/server.py
ctfs/WolvCTF/2023/crypto/Galois-t_is_this/server.py
#!/usr/bin/python3 from Crypto.Cipher import AES from Crypto.Random import get_random_bytes from Crypto.Util.number import * from Crypto.Util.strxor import * import os from pathlib import Path def GF_mult(x, y): product = 0 for i in range(127, -1, -1): product ^= x * ((y >> i) & 1) x = (x >> 1)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2023/crypto/Z2kDH/Z2kDH.py
ctfs/WolvCTF/2023/crypto/Z2kDH/Z2kDH.py
#!/usr/bin/python3 modulus = 1 << 258 def Z2kDH_init(private_exponent): """ Computes the public result by taking the generator 5 to the private exponent, then removing the last 2 bits private_exponent must be a positive integer less than 2^256 """ return pow(5, private_exponent, modulus) // 4 def Z2kDH_exchange...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2023/crypto/DownUnder/key_exchange.py
ctfs/WolvCTF/2023/crypto/DownUnder/key_exchange.py
from flask import Flask, request, jsonify from json import loads from Crypto.Util.number import long_to_bytes, bytes_to_long from hashlib import sha256 from hmac import new from uuid import uuid4 from generate import generate app = Flask(__name__) key = { '0' : 0 , '1' : 1 , '2' : 2 , '3' : 3 , '4' : 4 , '5' : 5 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2022/crypto/CPA-SecureDiffie–Hellman/key_exchange.py
ctfs/WolvCTF/2022/crypto/CPA-SecureDiffie–Hellman/key_exchange.py
from flask import Flask from flask import request from Crypto.Util.number import bytes_to_long, long_to_bytes from hashlib import sha256 from hmac import new app = Flask(__name__) # ephemerals live on as seeds! # wrap flag in wsc{} # Someone has cracked sha-256 and has started impersonating me to Alice on the inter...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2022/crypto/EAV-SecureDiffie–Hellman/key_exchange.py
ctfs/WolvCTF/2022/crypto/EAV-SecureDiffie–Hellman/key_exchange.py
from Crypto.Util.number import bytes_to_long # I love making homespun cryptographic schemes! def diffie_hellman(): f = open("flag.txt", "r") flag = f.read() a = bytes_to_long(flag.encode('utf-8')) p = 320907854534300658334827579113595683489 g = 3 A = pow(g,a,p) #2364984627340178911437273644815...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WolvCTF/2022/crypto/RSAFrustration/RSA_Frustration_-_encrypt.py
ctfs/WolvCTF/2022/crypto/RSAFrustration/RSA_Frustration_-_encrypt.py
from Crypto.Util.number import getPrime, bytes_to_long, long_to_bytes def encrypt(numToEncrypt): def getPrimeCustom(bitLength, e): while True: i = getPrime(bitLength) if (i-1) % e**2 == 0: return i global e global C bitLength = ((len(bin(numToEncrypt)) -...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DarkCTF/2020/pynotes/share/template.py
ctfs/DarkCTF/2020/pynotes/share/template.py
#!/usr/bin/python3 import sys import os import binascii import re import subprocess import signal def handler(x, y): sys.exit(-1) signal.signal(signal.SIGALRM, handler) signal.alarm(30) def gen_filename(): return '/tmp/' + binascii.hexlify(os.urandom(16)).decode('utf-8') def is_bad_str(code): code =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DarkCTF/2020/pynotes/share/pppp.py
ctfs/DarkCTF/2020/pynotes/share/pppp.py
from _note import * from sys import modules del modules['os'] keys = list(__builtins__.__dict__.keys()) for k in keys: # present for you if k not in ['int', 'id', 'print', 'range', 'hex', 'bytearray', 'bytes']: del __builtins__.__dict__[k] /** code **/
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NewYear/2024/misc/As_a_programmer/code_RSA.py
ctfs/NewYear/2024/misc/As_a_programmer/code_RSA.py
from Crypto.Util.number import getPrime , bytes_to_long , GCD import random random.seed() flag = b'grodno{fake_flag}' KEY_SIZE = 512 RSA_E = 3 def gen_RSA_params(N, e): while True: p, q = getPrime(N), getPrime(N) if GCD(e, (p - 1) * (q - 1)) == 1: break n = p * q check(p, q, n) retur...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NewYear/2024/code/Random_cipher/code_terror.py
ctfs/NewYear/2024/code/Random_cipher/code_terror.py
from random import randint def encrypt(text): key = randint(1, 2 * len(text)) print (ord(text[0]), key) result = [] for c in text: result.append(ord(c) + (ord(c) % key)) key = key + 1 return result
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NewYear/2024/code/Negative_hash/-PolynomialHash.py
ctfs/NewYear/2024/code/Negative_hash/-PolynomialHash.py
def PolynomialHash(string, a): result = 0 l = len(string) for i in range(l): result += ord(string[i]) * ((-a) ** (l - i - 1)) return result flag = "****************" PolynomialHash(flag, 100)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NewYear/2024/code/Polynomial_hash/PolynomialHash.py
ctfs/NewYear/2024/code/Polynomial_hash/PolynomialHash.py
def PolynomialHash(s, a): return sum([ord(s[i]) * pow(a, len(s)-i-1) for i in range(len(s))]) flag = "***********" PolynomialHash(flag, 256) #35201194166317999524907401661096042001277
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NewYear/2024/code/assert/crackme.py
ctfs/NewYear/2024/code/assert/crackme.py
# uncompyle6 version 3.5.0 # Python bytecode 2.7 (62211) # Decompiled from: Python 2.7.5 (default, Nov 16 2020, 22:23:17) # [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] # Embedded file name: crackme.py # Compiled at: 2011-09-19 04:54:37 import sys, types assert len(sys.argv) == 10 a, b, c, d, e, f, g, h, i = [ int(x) for x...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NewYear/2024/crypto/AND_encryption/AND-encryption.py
ctfs/NewYear/2024/crypto/AND_encryption/AND-encryption.py
#! /usr/bin/python3 from random import randint def and_encr(key): mess = [randint(32, 127) for x in range(0,len(key))] return "".join([hex(ord(k) & m)[2:].zfill(2) for (k,m) in zip(key, mess)]) flag = 'fake-flag' while True: while True: choise = input("1. Прислать шифр\n2. Проверить флаг\nВ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NewYear/2024/crypto/Gift_from_Cyber_Santa_Claus/Gift_from_Santa.py
ctfs/NewYear/2024/crypto/Gift_from_Cyber_Santa_Claus/Gift_from_Santa.py
import random from math import gcd def _prime_factors(n): # Returns a list that includes prime factors with their repetitions prime_factors = lambda n: [i for i in range(2, n+1) if n%i == 0 and all(i % j != 0 for j in range(2, int(i**0.5)+1))] factors = [] while n > 1: for factor in prime_factor...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NewYear/2024/crypto/39_Bobs_friends/39_letters.py
ctfs/NewYear/2024/crypto/39_Bobs_friends/39_letters.py
from Crypto.Util.number import getPrime, bytes_to_long flag = b'grodno{fake_flag}' m = bytes_to_long(flag) e = 39 n = [getPrime(1024) * getPrime(1024) for i in range(e)] c = [pow(m, e, n[i]) for i in range(e)] open("all_letters.txt", 'w').write(f"e = {e}\nc = {c}\nn = {n}")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NewYear/2024/crypto/Like_a_simple_RSA/Asim_en.py
ctfs/NewYear/2024/crypto/Like_a_simple_RSA/Asim_en.py
from random import randint def gen_key(): a, b, c, d = randint(3 * 64), randint(4 * 64), randint(5 * 64), randint(6 * 64) e = a * b - 1 f = c * e + a + e g = d * e + b * f h = c * d * e + a * d + c * b + g * g public_key = (h, f) private_key = g key = (public_key, private_key) r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NewYear/2024/crypto/Highly_ambiguous_RSA/Triple_ambiguous_RSA.py
ctfs/NewYear/2024/crypto/Highly_ambiguous_RSA/Triple_ambiguous_RSA.py
from Crypto.Util.number import bytes_to_long n1 = 1852892720062887225761965098961519184717028045747184821229381416690649150175077469195015762879827 e1 = 18712 n2 = 1684786560529453911475754845780536300328197792513126663487817526891350560429162837595257498214731 e2 = 17656 n3 = 1476397917727380110001203955119376...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NewYear/2024/crypto/Tabular_integral/code-1_RSA.py
ctfs/NewYear/2024/crypto/Tabular_integral/code-1_RSA.py
from Crypto.Util.number import getPrime , bytes_to_long , GCD import random random.seed() flag = b'grodno{fake_flag}' KEY_SIZE = 512 RSA_E = 65535 def gen_RSA_params(N, e): while True: p, q = getPrime(N), getPrime(N) if GCD(e, (p - 1) * (q - 1)) == 1: break n = p * q check(p, q, n) r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2024/crypto/flip/main.py
ctfs/TetCTF/2024/crypto/flip/main.py
# Please ensure that you solved the challenge properly at the local. # If things do not run smoothly, you generally won't be allowed to make another attempt. from secret.network_util import check_client, ban_client import sys import os import subprocess import tempfile OFFSET_PLAINTEXT = 0x4010 OFFSET_KEY = 0x4020 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2024/web/X_Et_Et/challenge/bot/utils.py
ctfs/TetCTF/2024/web/X_Et_Et/challenge/bot/utils.py
from uuid import UUID def is_valid_uuid(uuid_to_test, version=4): try: uuid_obj = UUID(uuid_to_test, version=version) except ValueError: return False return str(uuid_obj) == uuid_to_test
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2024/web/X_Et_Et/challenge/bot/app.py
ctfs/TetCTF/2024/web/X_Et_Et/challenge/bot/app.py
from flask import Flask, request, render_template import os import subprocess from utils import * import base64 app = Flask(__name__) PORT = int(os.getenv('PORT', '5001')) BIND_ADDR = os.getenv('BIND_ADDR', '0.0.0.0') app.config["LOG_TYPE"] = os.environ.get("LOG_TYPE", "stream") app.config["LOG_LEVEL"] = os.environ.ge...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2024/web/X_Et_Et/challenge/server/models.py
ctfs/TetCTF/2024/web/X_Et_Et/challenge/server/models.py
from app import db class User(db.Model): username = db.Column(db.String(50), primary_key=True) password = db.Column(db.String(50)) # Define the Ticket model class Ticket(db.Model): id = db.Column(db.String(36), primary_key=True, unique=True) title = db.Column(db.String(100)) new = db.Column(db.Int...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2024/web/X_Et_Et/challenge/server/utils.py
ctfs/TetCTF/2024/web/X_Et_Et/challenge/server/utils.py
from uuid import UUID import json import requests def is_valid_uuid(uuid_to_test, version=4): try: uuid_obj = UUID(uuid_to_test, version=version) except ValueError: return False return str(uuid_obj) == uuid_to_test def is_valid_captcha(secret, captcha): if secret == "": retur...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2024/web/X_Et_Et/challenge/server/app.py
ctfs/TetCTF/2024/web/X_Et_Et/challenge/server/app.py
from utils import * from flask import Flask, render_template, request,Response, session, redirect, url_for,jsonify import requests from flask_sqlalchemy import SQLAlchemy import uuid import os import logging import bleach, time app = Flask(__name__) app.config["LOG_TYPE"] = os.environ.get("LOG_TYPE", "stream") app.con...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2023/crypto/toy/toy.py
ctfs/TetCTF/2023/crypto/toy/toy.py
import base64 import json import random import sys import os from Crypto.Util.number import isPrime from Crypto.Cipher import AES RSA_KEY_SZ = 256 AES_KEY_SZ = 128 class AuthEncryption: def __init__(self, key: bytes): self._rand = random.Random(key) mask = (0b11 << (RSA_KEY_SZ // 2 - 2)) | 1 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2023/crypto/shuffle64/shuffle64.py
ctfs/TetCTF/2023/crypto/shuffle64/shuffle64.py
import sys from typing import List, Iterator from bitarray import bitarray # https://pypi.org/project/bitarray/ import random import base64 import string ALPHABET = (string.ascii_letters + string.digits + '+/').encode() assert len(ALPHABET) == 64 State = List[int] def swap(arr: State, i: int, j: int): arr[i] ^=...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2023/crypto/shuffle128/shuffle128.py
ctfs/TetCTF/2023/crypto/shuffle128/shuffle128.py
import sys from typing import List, Iterator from bitarray import bitarray # https://pypi.org/project/bitarray/ import random State = List[int] def swap(arr: State, i: int, j: int): arr[i] ^= arr[j] arr[j] ^= arr[i] arr[i] ^= arr[j] def rc4_key_scheduling(key: bytes) -> State: S = list(range(128))...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2023/web/NewYearBot/main.py
ctfs/TetCTF/2023/web/NewYearBot/main.py
from flask import Flask, request import re, random, os app = Flask(__name__) FL4G = os.environ.get('secret_flag') fail = "???<br><img src='https://i.imgur.com/mUfnGmL.png' width='20%' />" NewYearCategoryList = ["NewYearCommonList", "NewYearHealthList", "NewYearFamilyList", "NewYearWealthList"] NewYearCommonList = ["Ch...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2023/web/AdminLairayOldSchool/container/images-services/src/bot.py
ctfs/TetCTF/2023/web/AdminLairayOldSchool/container/images-services/src/bot.py
import requests import os, sys import base64 if sys.version_info.major < 3: from urllib import url2pathname else: from urllib.request import url2pathname # https://stackoverflow.com/questions/10123929/fetch-a-file-from-a-local-url-with-python-requests class LocalFileAdapter(requests.adapters.BaseAdapter): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2023/web/ImageServicesViewer/container/images-services/src/bot.py
ctfs/TetCTF/2023/web/ImageServicesViewer/container/images-services/src/bot.py
import requests import os, sys import base64 if sys.version_info.major < 3: from urllib import url2pathname else: from urllib.request import url2pathname # https://stackoverflow.com/questions/10123929/fetch-a-file-from-a-local-url-with-python-requests class LocalFileAdapter(requests.adapters.BaseAdapter): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2023/web/TetCTFToken/TetCTFToken/app.py
ctfs/TetCTF/2023/web/TetCTFToken/TetCTFToken/app.py
# from ducnt && khanghh import <3. GLHF everyone import uuid import json import time import logging import hashlib import string import pycurl import random import string from web3 import Web3 from flask import Flask, render_template, json, request, redirect, session, jsonify, url_for from flaskext.mysql import MySQL ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2022/pwn/ezflag/www/cgi-bin/upload.py
ctfs/TetCTF/2022/pwn/ezflag/www/cgi-bin/upload.py
#!/usr/bin/env python3 import os import cgi import base64 import socket def write_header(key, value) -> None: print('{:s}: {:s}'.format(key, value)) def write_status(code, msg) -> None: print('Status: {:d} {:s}'.format(code, msg), end='\n\n') def write_location(url) -> None: print('Location: {:s}'.forma...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2022/pwn/ezflag/www/upload/shell.py
ctfs/TetCTF/2022/pwn/ezflag/www/upload/shell.py
import socket import base64 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('127.0.0.1', 4444)) s.settimeout(5) s.send(b'admin\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n') print(base64.b64encode(s.recv(256)).decode('ascii...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2022/crypto/shares_v2/shares_v2.py
ctfs/TetCTF/2022/crypto/shares_v2/shares_v2.py
""" In this new version, I introduce a new feature: master share. A master share is always required to recover the original secret/password. I implement this feature by using the master share to "encrypt" the linear combination results. """ from shares import * from typing import Tuple, List from secrets import randbi...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2022/crypto/shares/shares.py
ctfs/TetCTF/2022/crypto/shares/shares.py
""" This is an (incomplete) implement for a new (and experimental) secret/password sharing scheme. The idea is simple. Basically, a secret or password is turned into a set of finite field elements and each share is just a linear combination of these elements. On the other hand, when enough shares are collected, the fi...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2022/crypto/fault/fault.py
ctfs/TetCTF/2022/crypto/fault/fault.py
from secrets import randbits from Crypto.Util.number import getPrime # pycryptodome NBITS = 1024 D_NBITS = 128 # small `d` makes decryption faster class Cipher: def __init__(self): p = getPrime(NBITS // 2) q = getPrime(NBITS // 2) self.n = p * q self.d = getPrime(D_NBITS) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2022/crypto/algebra/algebra.py
ctfs/TetCTF/2022/crypto/algebra/algebra.py
# We will be working with Fp p = 50824208494214622675210983238467313009841434758617398532295301998201478298245257311594403096942992643947506323356996857413985105233960391416730079425326309 # Just a random constant C = 80379912026773603990268914880965786237795942003171352992699622801055267868482844505315443532546262256...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TetCTF/2020/smallservice/client.py
ctfs/TetCTF/2020/smallservice/client.py
import hmac from pwn import * from json import loads from time import time import sys class Client(): def __init__(self, host, port): #remote self.r = remote(host, port) # def __init__(self, filename): #local # self.r = process(filename) def Hmac(self, src, key): HMAC = hmac...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/p4ctf/2023/Quals/ai/On_Fire/app/main.py
ctfs/p4ctf/2023/Quals/ai/On_Fire/app/main.py
import torch from torch import nn from flask import Flask, request, jsonify, render_template import numpy as np from app.flag import flag_list app = Flask(__name__) def list_to_tensor(l): return torch.tensor(l, pin_memory=True) correct_preds = list_to_tensor([215, 13, 436, 35, 140, 418, 48, 79, 411, 136, 368, 4...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/p4ctf/2023/Quals/ai/On_Fire/app/gunicorn_conf.py
ctfs/p4ctf/2023/Quals/ai/On_Fire/app/gunicorn_conf.py
import multiprocessing bind = "127.0.0.1:8000" #workers = multiprocessing.cpu_count() workers = 4
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/p4ctf/2023/Quals/ai/On_Fire/app/flag.py
ctfs/p4ctf/2023/Quals/ai/On_Fire/app/flag.py
flag_list = [(ord(x)) for x in "p4{fakeflag}"]
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/p4ctf/2023/Quals/ai/GeoHacker/app/flag.py
ctfs/p4ctf/2023/Quals/ai/GeoHacker/app/flag.py
flag_s = "p4{fakeflag}"
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/p4ctf/2023/Quals/ai/GeoHacker/app/app.py
ctfs/p4ctf/2023/Quals/ai/GeoHacker/app/app.py
# app.py from flask import Flask, render_template, request, jsonify import hashlib import math import time import sqlite3 import secrets from haversine import haversine from geotask.eval_one import load_model, eval_one, eval_multi from geotask.downloader.streetview import panoids from flag import flag_s app = Flask(__...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/p4ctf/2023/Quals/ai/GeoHacker/app/geotask/split_earth_s2.py
ctfs/p4ctf/2023/Quals/ai/GeoHacker/app/geotask/split_earth_s2.py
import os, re import pickle def get_classes(): if os.path.isfile("./geotask/points.pickle"): print("Using existing points.pickle") with open('./geotask/points.pickle', 'rb') as handle: b = pickle.load(handle) return b
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/p4ctf/2023/Quals/ai/GeoHacker/app/geotask/eval_one.py
ctfs/p4ctf/2023/Quals/ai/GeoHacker/app/geotask/eval_one.py
from sqlite3 import DatabaseError import torch import torchvision import torchvision.transforms as transforms import torch.nn.functional as F import glob import os import json import random import math from geotask.downloader.get_one_by_coords import get_image_by_coords, get_image_by_panoid from geotask.train_resnet i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/p4ctf/2023/Quals/ai/GeoHacker/app/geotask/train_resnet.py
ctfs/p4ctf/2023/Quals/ai/GeoHacker/app/geotask/train_resnet.py
import os import time import sys import re import math import random import statistics import glob import torch import torch.nn as nn import torch.optim as optim from datetime import date from torchvision import models from torchvision import transforms from torch.utils.data import Dataset, DataLoader from PIL import I...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/p4ctf/2023/Quals/ai/GeoHacker/app/geotask/downloader/streetview.py
ctfs/p4ctf/2023/Quals/ai/GeoHacker/app/geotask/downloader/streetview.py
# -*- coding: utf-8 -*- """ Original code is from https://github.com/robolyst/streetview Functions added in this file are download_panorama_v1, download_panorama_v2, download_panorama_v3 Usage: given latitude and longitude panoids = panoids( lat, lon ) panoid = panoids[0]['panoid'] panorama_img = downl...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/p4ctf/2023/Quals/ai/GeoHacker/app/geotask/downloader/get_one_by_coords.py
ctfs/p4ctf/2023/Quals/ai/GeoHacker/app/geotask/downloader/get_one_by_coords.py
import geotask.downloader.streetview as streetview import matplotlib.pyplot as plt import os import random import sys def get_image_by_panoid(panoid): panorama = streetview.download_panorama_v3(panoid, zoom=2, disp=False) return panorama def get_image_by_coords(lat, lon): sys.stdout.flush() panoids =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/p4ctf/2022/crypto/aesium/task.py
ctfs/p4ctf/2022/crypto/aesium/task.py
import random # https://raw.githubusercontent.com/boppreh/aes/master/aes.py import aes from aes import AES def inline_round(s, key): keym = aes.bytes2matrix(key) plain_state = aes.bytes2matrix(s) aes.sub_bytes(plain_state) aes.shift_rows(plain_state) aes.mix_columns(plain_state) aes.add_round...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/p4ctf/2022/crypto/aesium/aes.py
ctfs/p4ctf/2022/crypto/aesium/aes.py
#!/usr/bin/env python3 """ This is an exercise in secure symmetric-key encryption, implemented in pure Python (no external libraries needed). Original AES-128 implementation by Bo Zhu (http://about.bozhu.me) at https://github.com/bozhu/AES-Python . PKCS#7 padding, CBC mode, PKBDF2, HMAC, byte array and string support...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/p4ctf/2022/crypto/hello_crypto/hello.py
ctfs/p4ctf/2022/crypto/hello_crypto/hello.py
import os import sys from flag import FLAG def xor(key, data): return bytes(ac ^ bc for ac, bc in zip(key*len(data), data)) def viscrypt(data): return xor(data, data[1:] + b"\xaa") def round(key, rawdata): return viscrypt(xor(key, rawdata)) key = os.urandom(8) pt = FLAG for i in range(8833): pt...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/p4ctf/2022/crypto/rsa/rsa.py
ctfs/p4ctf/2022/crypto/rsa/rsa.py
import sys import random from Crypto.PublicKey import RSA import secret difficulty = 128 degree = 8 def generate_rsa_key(): while True: key = RSA.generate(1024) e = 47 n, p, q = key.n, key.p, key.q if secret.is_hard_enough(e, p, q, difficulty): return e, key.p, key.q...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BITSCTF/2024/crypto/Not_Suspicous_Agency/encrypt.py
ctfs/BITSCTF/2024/crypto/Not_Suspicous_Agency/encrypt.py
#!/usr/bin/env python3 from Crypto.Util.number import bytes_to_long, long_to_bytes from nsa_ecc_secret import P, Q import os flag = b'REDACTED' s = bytes_to_long(os.urandom(16)) def generate(P, Q, s): while True: r = int((s * P).x) yield from long_to_bytes((r * Q).x)[2:] s = int((r * P)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BITSCTF/2024/forensic/Refresh/prng.py
ctfs/BITSCTF/2024/forensic/Refresh/prng.py
#part of the code that used the prng def good_prng(seed=None): state = seed while True: state = (state * 1103515245 + 12345) & 0x7FFFFFFF yield state arr0 = [0] * len(flag) arr1 = [0] * len(flag) prng = good_prng(seed_value) for i in range(len(flag)): arr0[i] = next(prng) % 128 arr1[i]...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BITSCTF/2025/misc/The_Ghosting_Protocol/ghosting_protocol.py
ctfs/BITSCTF/2025/misc/The_Ghosting_Protocol/ghosting_protocol.py
import struct from enum import IntEnum class PacketType(IntEnum): DATA = 0x01 SEEN = 0x02 ERROR = 0x03 class Flags: DEV = 0b10000000 SYN = 0b01000000 ACK = 0b00100000 ERROR = 0b00010000 FIN = 0b00001000 PSH = 0b00000100 class GhostingPacket: """ Packet structure: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BITSCTF/2025/rev/Baby_Rev/chall.py
ctfs/BITSCTF/2025/rev/Baby_Rev/chall.py
# Python obfuscation by freecodingtools.org _ = lambda __ : __import__('zlib').decompress(__import__('base64').b64decode(__[::-1]));exec((_)(b'==QfWoizP8/vvPv/tuVzbgu38ZSv1J0vDFdewTskFOqPbM+WKx2jqyeNPjmjdv0UEvzJE8gv9CRQ+J7PE9hk+7ckGqlNUcWpUWR5BoF7Nh9b7jAd1AkzqcA1MAXHT2ThGtUsZyz/twhfFdyuZBPJjVvWGVv...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BITSCTF/2025/crypto/RSA_Bummer/chall.py
ctfs/BITSCTF/2025/crypto/RSA_Bummer/chall.py
#!/usr/bin/env python3 from Crypto.Util.number import * from Secrets import FLAG def lmao(n,k,x): #Better function needed pseudo_p = 1 for i in range(2,k*n-x): try: if (GCD(i,n-1)^(n-1)!=0): pseudo_p = (pseudo_p*inverse(i,n))%n except: continue retu...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BITSCTF/2025/crypto/Noob_RSA_Returns/encrypt.py
ctfs/BITSCTF/2025/crypto/Noob_RSA_Returns/encrypt.py
from Crypto.Util.number import getPrime, bytes_to_long def GenerateKeys(p, q): e = 65537 n = p * q phi = (p-1)*(q-1) d = pow(e, -1, phi) C = 0xbaaaaaad D = 0xdeadbeef A= 0xbaadf00d K = (A*p**2 - C*p + D)*d return (e, n, K) def Encrypt(): flag = b"REDACTED" # HEHEHEHEHE p = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BITSCTF/2025/crypto/Alice_n_Bob_in_Wonderland/chall.py
ctfs/BITSCTF/2025/crypto/Alice_n_Bob_in_Wonderland/chall.py
#!/usr/bin/python3 import random import hashlib from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad from ecdsa import SigningKey, SECP256k1, VerifyingKey import ecdsa from secret import conversation_length,messages,secret # Story setup print(""" Alice and Bob are two secret agents communicating ov...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LIT/2021/rev/shuffle/shuffle.py
ctfs/LIT/2021/rev/shuffle/shuffle.py
import random f = open("flag.txt", "r").read() random.seed(random.randint(0, 1000)) l = list(f[:-1]) random.shuffle(l) print(''.join(l))
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/LIT/2021/rev/Evaluation/eval.py
ctfs/LIT/2021/rev/Evaluation/eval.py
print(eval(eval(eval(eval(eval(eval("''.join([chr(i) for i in [39,39,46,106,111,105,110,40,91,99,104,114,40,105,41,32,102,111,114,32,105,32,105,110,32,91,51,57,44,51,57,44,52,54,44,49,48,54,44,49,49,49,44,49,48,53,44,49,49,48,44,52,48,44,57,49,44,57,57,44,49,48,52,44,49,49,52,44,52,48,44,49,48,53,44,52,49,44,51,50,44,4...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
true