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/Ugra/2024/Quals/crypto/Eat_the_rich/prover.py
ctfs/Ugra/2024/Quals/crypto/Eat_the_rich/prover.py
import gmpy2 import json import random import requests import time BASE = "https://securityisamyth.q.2024.ugractf.ru" TOKEN = input("Enter token: ") p, g, y = [int(n, 16) for n in requests.post(f"{BASE}/{TOKEN}/get-parameters").text.split(", ")] print("Computing, please wait...") rs = [random.randint(0, p - 2) for...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Null/2025/misc/Reservation/reservation.py
ctfs/Null/2025/misc/Reservation/reservation.py
import os import socket from dotenv import load_dotenv # from python-dotenv load_dotenv() FLAG = os.getenv("FLAG", "nullctf{aergnoujiwaegnjwkoiqergwnjiokeprgwqenjoig}") PROMPT = os.getenv("PROMPT", "bananananannaanan") PORT = int(os.getenv("PORT", 3001)) # This is missing from the .env file, but it still printed som...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/openECSC/2024-round1/misc/CableFish/chall.py
ctfs/openECSC/2024-round1/misc/CableFish/chall.py
#!/usr/bin/env python3 import os import subprocess import time flag = os.getenv('FLAG', 'openECSC{redacted}') def filter_traffic(filter): filter = filter[:50] sanitized_filter = f'(({filter}) and (not frame contains "flag_placeholder"))' p1 = subprocess.Popen(['tshark', '-r', '/home/user/capture.pcapng',...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/openECSC/2024-round1/crypto/Stealing_Seeds/stealing-seeds.py
ctfs/openECSC/2024-round1/crypto/Stealing_Seeds/stealing-seeds.py
#!/usr/bin/env python3 import os import signal import random from Crypto.Util.number import getPrime, long_to_bytes, bytes_to_long from hashlib import sha256 assert("FLAG" in os.environ) FLAG = os.environ["FLAG"] assert(FLAG.startswith("openECSC{")) assert(FLAG.endswith("}")) def main(): seed_size = 256 see...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/openECSC/2024-round2/crypto/BabyFeistel/babyfeistel.py
ctfs/openECSC/2024-round2/crypto/BabyFeistel/babyfeistel.py
#!/usr/bin/env python3 import os from hashlib import sha256 from Crypto.Util.Padding import pad flag = os.getenv('FLAG', 'openECSC{redacted}') S1 = [ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x1, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0x...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/openECSC/2024-round2/crypto/MathMAC/mathmac.py
ctfs/openECSC/2024-round2/crypto/MathMAC/mathmac.py
#!/usr/bin/env python3 import os from random import randint import json flag = os.getenv('FLAG', 'flag{redacted}') class MAC: def __init__(self, n): self.p = 8636821143825786083 self.n = n self.sk = [randint(0, self.p) for _ in range(n)] self.base = pow(4, randint(0, self.p), self...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/openECSC/2024-round3/crypto/LWE2048/lwe2048.py
ctfs/openECSC/2024-round3/crypto/LWE2048/lwe2048.py
#!/usr/bin/env python3 import os from secrets import randbelow, randbits flag = os.getenv('FLAG', 'flag{redacted}') class Chall: def __init__(self, nbits=2048): self.n = randbits(nbits) self.s = [randbelow(self.n) for _ in range(4)] self.B = self.n // (3*nbits) def query(self, x)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/openECSC/2024-round3/crypto/LazyDH/lazydh.py
ctfs/openECSC/2024-round3/crypto/LazyDH/lazydh.py
from Crypto.Util.number import getPrime, isPrime, long_to_bytes from Crypto.Util.Padding import pad from Crypto.Cipher import AES from hashlib import sha256 with open('flag.txt', 'rb') as rf: flag = rf.read().strip() path = "lazydh.txt" p = getPrime(160) q = (p-1)//2 while not isPrime(q): p = getPrime(160) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Shaastra/2024/crypto/Laplace_Fourier_and_CNN/Encoder.py
ctfs/Shaastra/2024/crypto/Laplace_Fourier_and_CNN/Encoder.py
def add(a, b): if a in c1: if b in c1: return (c1.index(a) + c1.index(b) + 2) % 26 else: return (c1.index(a) + c2.index(b) + 2) % 26 else: if b in c1: return (c2.index(a) + c1.index(b) + 2) % 26 else: return (c2.index(a) + c2.index(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BTCTF/2024/rev/bad_programming/bad-programming.py
ctfs/BTCTF/2024/rev/bad_programming/bad-programming.py
def part2(): #i think strings can be arrays right? #seems out of order but i dont care at all part2 = [] part2[3] = '4' part2[0] = '4' part2[5] = 'S' part2[2] = 'w' part2[1] = 'l' part2[4] = 'y' # i think the numbers are positions print(part2[3]) print(part2[0]...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BTCTF/2024/crypto/Rumours_Say_Aliens/encrypt.py
ctfs/BTCTF/2024/crypto/Rumours_Say_Aliens/encrypt.py
import random import math from Crypto.Util.number import getPrime, bytes_to_long with open("flag.txt", 'rb') as f: flag = f.read() p = getPrime(1024) q = getPrime(1024) e = getPrime(8) m = bytes_to_long(flag) n = p * q c = pow(m, e, n) #change paths later with open('enc.txt', 'w') as f: f.write(f'p:{p}\n') ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/BTCTF/2024/crypto/XORry/encrypt.py
ctfs/BTCTF/2024/crypto/XORry/encrypt.py
import random def shift_text_file(input_file, output_file): # Read content from the input file with open(input_file, 'r') as file: text_content = file.read() # Generate a random number from 0 to 50 for shifting num = random.randint(0, 50) print(num) # Shift the content by adding...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/vikeCTF/2024/misc/Robo_Erik/bot.py
ctfs/vikeCTF/2024/misc/Robo_Erik/bot.py
import io from os import environ import time import discord from discord import ApplicationContext, option from discord.ext import commands from pyrate_limiter import BucketFullException, Duration, Limiter, RequestRate limiter = Limiter(RequestRate(1, Duration.MINUTE), RequestRate(10, Duration.HOUR)) VIKECTF_DISCORD...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GREP/2023/crypto/DOGEDOGEDOGE/doge.py
ctfs/GREP/2023/crypto/DOGEDOGEDOGE/doge.py
from Crypto.Util.number import * from pwn import xor flag = b'REDACTED' key = b'REDACTED' enc = b'' for i in range(len(flag)): enc += xor(key[i], flag[i]) print(enc) # enc = b'#="5\x07\x1b\x01>4#s<u! \x1a3~3-\x1b7w7\x1b&4\x1a":)8'
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GREP/2023/crypto/Birdseed/encrypt.py
ctfs/GREP/2023/crypto/Birdseed/encrypt.py
import random flag = open('flag.txt').read() rand_seed = random.randint(0, 999) random.seed(rand_seed) encrypted = '' for chr in flag: encrypted += f'{(ord(chr) ^ random.randint(0, 255)):02x}' with open('out.txt', 'w') as f: f.write(encrypted)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GREP/2023/crypto/9Musketeer/enc.py
ctfs/GREP/2023/crypto/9Musketeer/enc.py
# path.py import numpy as np import binascii message = "REDACTED" key = "Musketeer" list = [message[i : i + 2] for i in range(0, len(message), 2)] list = [eval(i) for i in list] list2 = [key[i] for i in range(len(key))] # print(list) # print(list2) val = [chr(x) for x in list] # print(val) new = [ord(i) ^ ord(j) f...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GREP/2023/crypto/UneasyAlliance/question.py
ctfs/GREP/2023/crypto/UneasyAlliance/question.py
from Crypto.Util.number import * import math import time from random import Random seed = math.floor(time.time()) rnd = Random(seed) rand_fn = lambda n: long_to_bytes(rnd.getrandbits(n)) p = getPrime(128, randfunc=rand_fn) q = getPrime(128, randfunc=rand_fn) e = 65537 n = p * q assert p != q m = bytes_to_long(b"GRE...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GREP/2023/crypto/CaeX0R/enc.py
ctfs/GREP/2023/crypto/CaeX0R/enc.py
#enc.py from random import * flag="REDACTED" a=randint(1,1000) c=[] for f in flag: c.append(str(ord(f)^a)) print(c) print(a) #c=['162', '177', '188', '169', '136', '187', '138', '145', '172', '187', '138', '145', '172', '190', '152', '156', '187', '195', '177', '142'] #a=REDACTED
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/GREP/2023/crypto/CaeX0R2/enc (3).py
ctfs/GREP/2023/crypto/CaeX0R2/enc (3).py
#enc.py from random import * flag="REDACTED" a=randint(1,1000) c=[] for f in flag: c.append(str(ord(f)^a)) print(c) print(a) #c=['313', '296', '295', '304', '274', '280', '263', '280', '263', '310', '315', '310', '316', '345', '268', '263', '310', '302', '345', '296', '276'] #a=REDACTED
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/OSCTF/2024/rev/The_Broken_Sword/challenge.py
ctfs/OSCTF/2024/rev/The_Broken_Sword/challenge.py
from Crypto.Util.number import * from secret import flag,a,v2,pi z1 = a+flag y = long_to_bytes(z1) print("The message is",y) s = '' s += chr(ord('a')+23) v = ord(s) f = 5483762481^v g = f*35 r = 14 l = g surface_area= pi*r*l w = surface_area//1 s = int(f) v = s^34 for i in range(1,10,1): h = v2*30 h ^= 34 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/OSCTF/2024/crypto/Couple_Primes/source.py
ctfs/OSCTF/2024/crypto/Couple_Primes/source.py
from Crypto.Util.number import * from sympy import nextprime flag = b'REDACTED' p = getPrime(1024) q = nextprime(p) e = 65537 n = p * q c = pow(bytes_to_long(flag), e, n) print(f"n = {n}") print(f"c = {c}")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/OSCTF/2024/crypto/Sheep_Counting/sheepCounter.py
ctfs/OSCTF/2024/crypto/Sheep_Counting/sheepCounter.py
from Crypto.Cipher import AES from os import urandom KEY = b'REDACTED' class StepUpCounter(object): def __init__(self, step_up=False): self.value = urandom(16).hex() self.step = 1 self.stup = step_up def increment(self): if self.stup: self.newIV = hex(int(self.va...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/OSCTF/2024/crypto/QR/source.py
ctfs/OSCTF/2024/crypto/QR/source.py
from Crypto.Util.number import * from random import * flag = b'REDACTED' p = 96517490730367252566551196176049957092195411726055764912412605750547823858339 a = 1337 flag = bin(bytes_to_long(flag))[2:] encrypt = [] for bit in flag: encrypt.append(pow(a, (randint(2, p) * randrange(2, p, 2)) + int(bit), p)) pr...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/OSCTF/2024/crypto/Efficient_RSA/chall.py
ctfs/OSCTF/2024/crypto/Efficient_RSA/chall.py
from Cryptodome.Util.number import getPrime, bytes_to_long Flag = bytes_to_long(b"REDACTED") p = getPrime(112) q = getPrime(112) n = p*q e = 65537 ciphertext = pow(Flag, e, n) print([n, e, ciphertext])
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/OSCTF/2024/crypto/The_Secret_Message/chall.py
ctfs/OSCTF/2024/crypto/The_Secret_Message/chall.py
from Cryptodome.Util.number import getPrime, bytes_to_long flag = bytes_to_long(b"REDACTED") p = getPrime(512) q = getPrime(512) n = p*q e = 3 ciphertext = pow(flag, e, n) print("n: ", n) print("e: ", e) print("ciphertext: ", ciphertext)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MidnightSun/2021/Quals/pwn/Shapes/communicate.py
ctfs/MidnightSun/2021/Quals/pwn/Shapes/communicate.py
import socket import sys import time import struct def SendCommand(cmd): global sock asBytes = cmd.encode() sock.send(len(asBytes).to_bytes(1,"big")+asBytes) got = sock.recv(1000).decode() return got sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_address = ('127.0.0.1', 1111) sock.connec...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MidnightSun/2021/Quals/crypto/Dbcsig_64434/keygen_sign_proto.py
ctfs/MidnightSun/2021/Quals/crypto/Dbcsig_64434/keygen_sign_proto.py
""" We have designed a determinstic signature scheme with password-based keys, suitable for the post-modern blockchain. It is resistant to partitioning oracle attacks and requires no access to randomness under a fixed modulus. Although not quantum safe, we deem the threat from quantum attacks to be negligible. ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MidnightSun/2024/Quals/crypto/1mag1n3_dr4g0nfly_v2/dragonfly_implementation-v2.py
ctfs/MidnightSun/2024/Quals/crypto/1mag1n3_dr4g0nfly_v2/dragonfly_implementation-v2.py
#!/usr/bin/env python3 """ Code from https://github.com/NikolaiT/Dragonfly-SAE/blob/master/dragonfly_implementation.py """ import time import hashlib import hmac import secrets import logging from collections import namedtuple import socket import struct import random import os import signal import string import secr...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MidnightSun/2024/Quals/crypto/1mag1n3_dr4g0nfly/dragonfly_implementation.py
ctfs/MidnightSun/2024/Quals/crypto/1mag1n3_dr4g0nfly/dragonfly_implementation.py
#!/usr/bin/env python3 """ Code from https://github.com/NikolaiT/Dragonfly-SAE/blob/master/dragonfly_implementation.py """ import time import hashlib import hmac import secrets import logging from collections import namedtuple import socket import struct import random import os import signal logger = logging.getLogg...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MidnightSun/2022/Quals/crypto/BabyZK/babyzk.py
ctfs/MidnightSun/2022/Quals/crypto/BabyZK/babyzk.py
#!/usr/bin/python3 from sys import stdin, stdout, exit from secrets import randbelow from gmpy import next_prime from flag import FLAG class BabyZK: def __init__(self, degree, nbits): self.p = self.__safeprime(nbits) self.degree = degree self.m = [randbelow(self.p-1) for i in range(self...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MidnightSun/2022/Quals/crypto/PellesRotor-SupportedArithmetic/pelles_rotor_supported_arithmetic.py
ctfs/MidnightSun/2022/Quals/crypto/PellesRotor-SupportedArithmetic/pelles_rotor_supported_arithmetic.py
#!/usr/bin/python3 from sys import stdin, stdout, exit from flag import FLAG from secrets import randbelow from gmpy import next_prime p = int(next_prime(randbelow(2**512))) q = int(next_prime(randbelow(2**512))) n = p * q e = 65537 phi = (p - 1)*(q - 1) d = int(pow(e, -1, phi)) d_len = len(str(d)) print("encrypted ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/blockchain/GlacierCoin/solve-pow.py
ctfs/Glacier/2023/blockchain/GlacierCoin/solve-pow.py
import hashlib,random x = 100000000+random.randint(0,200000000000) for i in range(x,x+20000000000): m = hashlib.sha256() ticket = str(i) m.update(ticket.encode('ascii')) digest1 = m.digest() m = hashlib.sha256() m.update(digest1 + ticket.encode('ascii')) if m.hexdigest().startswith('0000000'): print(i) break...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/blockchain/The_Council_of_Apes/solve-pow.py
ctfs/Glacier/2023/blockchain/The_Council_of_Apes/solve-pow.py
import hashlib,random x = 100000000+random.randint(0,200000000000) for i in range(x,x+20000000000): m = hashlib.sha256() ticket = str(i) m.update(ticket.encode('ascii')) digest1 = m.digest() m = hashlib.sha256() m.update(digest1 + ticket.encode('ascii')) if m.hexdigest().startswith('0000000'): print(i) break...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/blockchain/GlacierVault/solve-pow.py
ctfs/Glacier/2023/blockchain/GlacierVault/solve-pow.py
import hashlib,random x = 100000000+random.randint(0,200000000000) for i in range(x,x+20000000000): m = hashlib.sha256() ticket = str(i) m.update(ticket.encode('ascii')) digest1 = m.digest() m = hashlib.sha256() m.update(digest1 + ticket.encode('ascii')) if m.hexdigest().startswith('0000000'): print(i) break...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/blockchain/ChairLift/solve-pow.py
ctfs/Glacier/2023/blockchain/ChairLift/solve-pow.py
import hashlib,random x = 100000000+random.randint(0,200000000000) for i in range(x,x+20000000000): m = hashlib.sha256() ticket = str(i) m.update(ticket.encode('ascii')) digest1 = m.digest() m = hashlib.sha256() m.update(digest1 + ticket.encode('ascii')) if m.hexdigest().startswith('0000000'): print(i) break...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/misc/Avatar/chall.py
ctfs/Glacier/2023/misc/Avatar/chall.py
print("You get one chance to awaken from the ice prison.") code = input("input: ").strip() whitelist = """gctf{"*+*(=>:/)*+*"}""" # not the flag if any([x not in whitelist for x in code]) or len(code) > 40000: print("Denied!") exit(0) eval(eval(code, {'globals': {}, '__builtins__': {}}, {}), {'globals': {...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/misc/Silent_Snake/chall/repl.py
ctfs/Glacier/2023/misc/Silent_Snake/chall/repl.py
#!/usr/bin/env python3 import os import sys import code DEBUG = os.environ.get("DEBUG", "0") == "1" cpipe = os.fdopen(int(sys.argv[1]), "w", buffering=1) devnull = open("/dev/null", mode="w") print(""" Welcome to silent-snake, the blind REPL! You've got a single ls that you can redeem using `run_command('ls <direc...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/misc/Silent_Snake/chall/silent_snake.py
ctfs/Glacier/2023/misc/Silent_Snake/chall/silent_snake.py
#!/usr/bin/env python3 import os import random import subprocess import time DEBUG = os.environ.get("DEBUG", "0") == "1" def drop_to_unprivileged(uid: int, gid: int): # Drop to a unprivileged user and group. assert uid != 0 and gid != 0 os.setresgid(uid, uid, uid) os.setresuid(gid, gid, gid) def dro...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/pwn/flipper/utils/add-debug/elf/enum-print.py
ctfs/Glacier/2023/pwn/flipper/utils/add-debug/elf/enum-print.py
import sys, re from optparse import OptionParser def read_toks(): data = sys.stdin.read() while data: data = data.lstrip() if data.startswith("//") or data.startswith("#"): data = data.split("\n",1)[1] elif data.startswith("/*"): data = data.split("*/",1)[1] ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/crypto/Missing_Bits/encode_file.py
ctfs/Glacier/2023/crypto/Missing_Bits/encode_file.py
from Crypto.PublicKey import RSA from Crypto.Util.number import bytes_to_long from Crypto.Util.number import long_to_bytes content = open("2048_key_original.priv", "rb").read() key = RSA.import_key(content) filecontent = open("plaintext_message", "rb").read() ct = pow(bytes_to_long(filecontent), key.e, key.n) open(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/crypto/Glacier_Spirit/challenge.py
ctfs/Glacier/2023/crypto/Glacier_Spirit/challenge.py
#!/usr/bin/env python3 import ascon import secrets from secret import FLAG BLOCK_SIZE = 16 def xor(a, b): return bytes([x ^ y for x, y in zip(a, b)]) def split_blocks(message): return [message[i:i + BLOCK_SIZE] for i in range(0, len(message), BLOCK_SIZE)] def mac_creation(key, message): assert len(me...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/crypto/SLCG/encrypt.py
ctfs/Glacier/2023/crypto/SLCG/encrypt.py
from __future__ import annotations import os FLAG = b"gctf{???????}" class LCG: def __init__(self, mod: int, mult: int, add: int, seed: int): self.mod = mod self.mult = mult self.add = add self.value = seed def __next__(self) -> int: self.value = (self.value * self.m...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/crypto/ARISAI/chall.py
ctfs/Glacier/2023/crypto/ARISAI/chall.py
from Crypto.Util.number import bytes_to_long from Crypto.Util.number import getPrime PRIME_LENGTH = 24 NUM_PRIMES = 256 FLAG = b"gctf{redacted}" N = 1 e = 65537 for i in range(NUM_PRIMES): prime = getPrime(PRIME_LENGTH) N *= prime ct = pow(bytes_to_long(FLAG), e, N) print(f"{N=}") print(f"{e=}") print(f"{...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/web/Peak/admin-simulation/admin.py
ctfs/Glacier/2023/web/Peak/admin-simulation/admin.py
#!/usr/bin/env python3 import sys, requests import os from time import sleep from bs4 import BeautifulSoup from datetime import datetime from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.chrom...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/web/Glacier_Exchange/server.py
ctfs/Glacier/2023/web/Glacier_Exchange/server.py
from flask import Flask, render_template, request, send_from_directory, jsonify, session from flask_restful import Api from src.coin_api import get_coin_price_from_api from src.wallet import Wallet import os import secrets app = Flask(__name__) api = Api(app) app.secret_key = os.urandom(64) wallets = {} def get_wall...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/web/Glacier_Exchange/src/wallet.py
ctfs/Glacier/2023/web/Glacier_Exchange/src/wallet.py
import threading class Wallet(): def __init__(self) -> None: self.balances = { "cashout": 1000, "glaciercoin": 0, "ascoin": 0, "doge": 0, "gamestock": 0, "ycmi": 0, "smtl": 0 } self.lock = threading.Lock();...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2023/web/Glacier_Exchange/src/coin_api.py
ctfs/Glacier/2023/web/Glacier_Exchange/src/coin_api.py
import time import random def get_coin_price_from_api(coin: str): coins = coin.split('/') if(len(coins) != 2): return [] seed = coins[0] + coins[1] if coins[0] < coins[1] else coins[1] + coins[0] is_reverse = coins[0] < coins[1] random.seed(seed) end_timestamp = int(time.time()) * 1000 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2022/crypto/ChaCha60/chacha60.py
ctfs/Glacier/2022/crypto/ChaCha60/chacha60.py
#!/usr/bin/env python3 from Crypto.Cipher import ChaCha20 import numpy as np import os from binascii import hexlify with np.load('matrices.npz') as f: m1 = f.get('m1') m2 = f.get('m2') m3 = f.get('m3') if __name__ == '__main__': key = np.unpackbits(bytearray(os.urandom(8)), bitorder='little') k1 =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2022/crypto/CryptoShop/store.py
ctfs/Glacier/2022/crypto/CryptoShop/store.py
from typing import Union from typing import Set # pip install pycryptodome import Crypto from Crypto.PublicKey import RSA SHOP_ITEMS = { "USB Rubber Ducky": 1, "Malduino": 2, "WIFI Deauther": 3, "Bluetooth Jammer": 5, "GSM Jammer": 7, "Bad USB": 10, "CTF-Flag": 1000, } FLAG = 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/Glacier/2022/crypto/Unpredictable/src.py
ctfs/Glacier/2022/crypto/Unpredictable/src.py
from Crypto.Util.number import bytes_to_long from secret import flag, roll_faster, a, b, m import random texts = open("txt.txt", "rb").readlines() def roll(x, y): for _ in range(y): x = (a*x + b) % m return x print("Im not evil, have some paramteres") print(f"{a = }") print(f"{b = }") print(f"{m = }"...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2022/web/GlacierTopNews/challenge/setup.py
ctfs/Glacier/2022/web/GlacierTopNews/challenge/setup.py
from setuptools import setup setup()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2022/web/GlacierTopNews/challenge/glacier_webserver/api.py
ctfs/Glacier/2022/web/GlacierTopNews/challenge/glacier_webserver/api.py
import multiprocessing import os import platform from urllib import urlopen import psutil from flask import request from glacier_webserver.config import app from glacier_webserver.utils import Filter from glacier_webserver.utils import require_jwt def get_system_info(): _, _, load15 = psutil.getloadavg() cpu...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2022/web/GlacierTopNews/challenge/glacier_webserver/_main.py
ctfs/Glacier/2022/web/GlacierTopNews/challenge/glacier_webserver/_main.py
import logging import os import random import sqlite3 import string import glacier_webserver.api import glacier_webserver.config import glacier_webserver.routes import glacier_webserver.utils import jwt from glacier_webserver.config import app from glacier_webserver.utils import Database def prepair_environment(): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2022/web/GlacierTopNews/challenge/glacier_webserver/utils.py
ctfs/Glacier/2022/web/GlacierTopNews/challenge/glacier_webserver/utils.py
import sqlite3 from functools import wraps import os import flask from flask import redirect from flask import render_template from flask import request from glacier_webserver.config import app class Filter: BAD_URL_SCHEMES = ['file', 'ftp', 'local_file'] BAD_HOSTNAMES = ["google", "twitter", "githubusercont...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2022/web/GlacierTopNews/challenge/glacier_webserver/config.py
ctfs/Glacier/2022/web/GlacierTopNews/challenge/glacier_webserver/config.py
from flask import Flask app = Flask(__name__) # app.config['EXPLAIN_TEMPLATE_LOADING'] = True
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2022/web/GlacierTopNews/challenge/glacier_webserver/__init__.py
ctfs/Glacier/2022/web/GlacierTopNews/challenge/glacier_webserver/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Glacier/2022/web/GlacierTopNews/challenge/glacier_webserver/routes.py
ctfs/Glacier/2022/web/GlacierTopNews/challenge/glacier_webserver/routes.py
import os import flask from flask.templating import TemplateNotFound from config import app from flask import render_template from flask import send_from_directory from glacier_webserver.utils import render_template_with_wrapper from glacier_webserver.utils import require_jwt @app.errorhandler(404) @app.errorhandler...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2024/misc/From_4_to_7/Hamming.py
ctfs/Junior.Crypt/2024/misc/From_4_to_7/Hamming.py
import numpy as np from random import randint from secret import FLAG mess = FLAG mess = mess.encode().hex() inp = [bin(int(h,16))[2:].zfill(4) for h in mess] inp = [[int(b) for b in c] for c in inp] imatr = np.array(inp) print (imatr) Gen = np.array([[0,1,1,1,0,0,0], [1,0,1,0,1,0,0], ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2024/steg/Stego_in_code/StegoInCode.py
ctfs/Junior.Crypt/2024/steg/Stego_in_code/StegoInCode.py
#============================================================================# #============================ARCANE CALCULATOR===============================# #============================================================================# import hashlib from cryptography.fernet import Fernet import base64 # GLOBA...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2024/rev/Random_cipher/code_terror.py
ctfs/Junior.Crypt/2024/rev/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/Junior.Crypt/2024/rev/Mutated_Caesar/Caesare.py
ctfs/Junior.Crypt/2024/rev/Mutated_Caesar/Caesare.py
from random import randint from hashlib import md5 from secret import flag hash = md5(flag.encode()).hexdigest() n1, n2 = randint(0x20, 0x41), randint(0x7d, 0x7e) CN = {chr(i+n1): i for i in range(0, n2-n1+1)} NC = {i: chr(i+n1) for i in range(0, n2-n1+1)} N = len(CN.keys()) key = randint(0,N) cipher = "".join([NC[...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2024/crypto/Unrevealed_secret/one-time_pad.py
ctfs/Junior.Crypt/2024/crypto/Unrevealed_secret/one-time_pad.py
import random def generate_string(length): # This function generates a random string of the specified length byte_list = [(random.randint(0, 127) + 256)//2 for _ in range(length)] byte_string = bytes(byte_list) utf8_string = byte_string.decode('utf-8', errors='replace') return utf8_string def xor_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2024/crypto/Reliable_key/fernet_key.py
ctfs/Junior.Crypt/2024/crypto/Reliable_key/fernet_key.py
from base64 import b64encode from cryptography.fernet import Fernet from secret import x, flag n = 105305013148297378743386138736504981711146273323076139944194077886348615620833223992747067288516137830386128329347996814667046484686595043062945572870106791350962812927886259472046898230096135130360594446861634004963890...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2024/crypto/Electronic_voting/vote.py
ctfs/Junior.Crypt/2024/crypto/Electronic_voting/vote.py
# pip install lightphe from lightphe import LightPHE import pickle from random import randint # build a cryptosystem cs = LightPHE(algorithm_name = 'Paillier') with open(f'vote/cs.pickle', 'wb') as f: pickle.dump(cs, f, protocol=pickle.HIGHEST_PROTOCOL) N = 250 # number of voting participants k = 8 kand...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/misc/ZKP_with_Hint/zkp9052.py
ctfs/Junior.Crypt/2025/misc/ZKP_with_Hint/zkp9052.py
# for Users #! /usr/bin/python3 -u from random import randint from Crypto.Util.number import getPrime # Конфигурация FLAG = 'CTF{zkp_basic_secret_123}' ROUNDS = 2 # Параметры протокола p = getPrime(512) # Простое число g = 2 # Генератор группы Zp* x = randint(1,p-2) # Секрет (g^x mod p = y) y = pow...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/misc/Broken_ZKP._I/zkp9050.py
ctfs/Junior.Crypt/2025/misc/Broken_ZKP._I/zkp9050.py
#! /usr/bin/python3 -u from random import randint from Crypto.Util.number import getPrime # Конфигурация FLAG = 'CTF{zkp_basic_secret_123}' ROUNDS = 5 # Параметры протокола p = getPrime(512) # Простое число g = 2 # Генератор x = randint(1,p-2) # Секрет (g^x mod p = y) y = pow(g, x, p) # y r = r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/misc/ZKP_9+/zkp9049.py
ctfs/Junior.Crypt/2025/misc/ZKP_9+/zkp9049.py
from random import randint FLAG = 'REDACTED_FLAG' ROUNDS = 3 # Параметры протокола p = 23 # Простое число g = 5 # Генератор x = randint(1,p-2) # Секрет (g^x mod p = y) y = pow(g, x, p) # y def main(): print(f"\n=== Zero-Knowledge Proof: Prove You Know x ===") prin...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/misc/Homomorphic_Fraud/Paillier9054.py
ctfs/Junior.Crypt/2025/misc/Homomorphic_Fraud/Paillier9054.py
from Crypto.Util.number import getPrime, bytes_to_long import random # Генерация ключей Paillier def generate_keypair(bits=512): p = getPrime(bits) q = getPrime(bits) n = p * q g = n + 1 # Стандартный выбор для g в Paillier lambda_ = (p - 1) * (q - 1) mu = pow(lambda_, -1, n) return (n, g)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/misc/Error_another_error_.../chall_9057.py
ctfs/Junior.Crypt/2025/misc/Error_another_error_.../chall_9057.py
from random import randint, shuffle from copy import copy def hamming_encode_7_4(data_bits): """Кодирование 4 бит данных в 7-битный код Хэмминга (7,4) Args: data_bits: str - строка из 4 бит (например, '1101') Returns: str: 7-битная закодированная строка """ if len(data_bits) != 4 or not all(bit...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/misc/Homomorphic_weak/chall_9055.py
ctfs/Junior.Crypt/2025/misc/Homomorphic_weak/chall_9055.py
from Crypto.Util.number import getPrime, isPrime, bytes_to_long import random from math import gcd def generate_keys(bit_length=512, max_diff=10000): """Генерирует параметры криптосистемы""" while True: p = getPrime(bit_length // 2) q = p + random.randint(1, max_diff) if isPrime(q) and ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/rev/Dynamic_Key/chall_dynamic_key.py
ctfs/Junior.Crypt/2025/rev/Dynamic_Key/chall_dynamic_key.py
import time def dynamic_key(): return ((int(time.time()) % 256) ^ 0xFF) & 0x7F def encrypt(s, key): return bytes([(c + key) ^ (i * 2) for i, c in enumerate(s.encode())]) def check_flag(flag: str) -> bool: if not flag.startswith("grodno{") or not flag.endswith("}"): return False middle = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/rev/Turing_Award/chall_Turing_Award.py
ctfs/Junior.Crypt/2025/rev/Turing_Award/chall_Turing_Award.py
def check_flag(flag): enc = [0x6e, 0x49, 0x60, 0x9, 0x78, 0x75, 0x1, 0x3f, 0x58, 0x68, 0x4f] key = b"MYSECRETKEY" if not flag.startswith("grodno{") or not flag.endswith("}") or len(flag) != 30: return False middle = flag[7:-1] for i in range(11): if (ord(middle[i*2]) ^ ord(middl...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/rev/Hybrid_Encryption/chall_hibrid_enc.py
ctfs/Junior.Crypt/2025/rev/Hybrid_Encryption/chall_hibrid_enc.py
import base64 def encrypt(flag: str) -> str: if not flag.startswith("grodno{") or not flag.endswith("}"): return "" encoded = bytes([ord(c) ^ 0xAA for c in flag[7:-1]]) return base64.b64encode(encoded).decode() def check_flag(flag: str) -> bool: return encrypt(flag) == "np2Z3p2c3s6YmZ3ezs2ZmM...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/rev/Reverse_Puzzle/chall_rev_puzzle.py
ctfs/Junior.Crypt/2025/rev/Reverse_Puzzle/chall_rev_puzzle.py
def puzzle(s: str, step: int) -> str: return s if step == 0 else puzzle(s[::2] + s[1::2], step - 1) def check_flag(flag: str) -> bool: return False if not flag.startswith("grodno{") or not flag.endswith("}") else puzzle(flag[7:-1], 5) == '789603251257384214725442633' flag = input("Enter flag: ") print("Corre...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/ppc/Randomized_Flag/server_9047.py
ctfs/Junior.Crypt/2025/ppc/Randomized_Flag/server_9047.py
from random import getrandbits with open("flag.txt","rb") as f: flag = f.read() for i in range(2**64): print(getrandbits(32) + flag[getrandbits(32) % len(flag)]) a = input() # 1 - I known flag, else - next number if a == '1': ans = input('Flag is: ') if ans == flag.decode(): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/ppc/100_percent_Robust_PRNG/server_9046.py
ctfs/Junior.Crypt/2025/ppc/100_percent_Robust_PRNG/server_9046.py
import time import random import math flag = "FAKE_FLAG" m = random.getrandbits(31) a = 2**10 b = 2**30 rand_numbers = [] d = """ Попробуем взломать генератор псевдослучайных чисел (ПСЧ) Python. Считаем, что ПСЧ создаются функцией getrandbits(31) стандартной библиотеки random. Вы можете попросить несколько последо...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/ppc/LCG_hack/server_9042.py
ctfs/Junior.Crypt/2025/ppc/LCG_hack/server_9042.py
import math import time flag = "FAKE_FLAG" m=math.ceil(time.time()*1000000) a=2**15-1 b=2**51-1 x = m rand_numbers = [x,] for i in range(1,50): x = (a*x + b) % m rand_numbers.append(x) d = """ Попробуем взломать Линейный Конгруэнтный Генератор псевдослучайных чисел (ПСЧ). Его формула: Xn+1 = (A * Xn + ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/ppc/Robust_PRNG_in_Python/server_9045.py
ctfs/Junior.Crypt/2025/ppc/Robust_PRNG_in_Python/server_9045.py
import time import random import math flag = "FAKE_FLAG" m=math.ceil(time.time()*1000000) a = 2**10 b = 2**30 random.seed(m) rand_numbers = [] d = """ Попробуем взломать генератор псевдослучайных чисел (ПСЧ) Python. Считаем, что ПСЧ создаются функцией getrandbits(31) стандартной библиотеки random. Вы можете попрос...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/ppc/Python_PRNG_hack/server_9043.py
ctfs/Junior.Crypt/2025/ppc/Python_PRNG_hack/server_9043.py
import time import random import math flag = "FAKE_FLAG" m=math.ceil(time.time()*1000000) a = 2**10 b = 2**30 random.seed(m) rand_numbers = [] d = """ Попробуем взломать генератор псевдослучайных чисел (ПСЧ) Python. Считаем, что ПСЧ создаются функцией randint стандартной библиотеки random. Вы можете попросить неск...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/crypto/OTP_with_shift_register/OTP_LFSR.py
ctfs/Junior.Crypt/2025/crypto/OTP_with_shift_register/OTP_LFSR.py
# Key generation def lfsr(state, mask): #Генерация нового бита и обновление состояния LFSR bit = (state & 1) # Младший бит (стандартный для right-shift LFSR) state = state >> 1 # Сдвиг вправо if bit: state ^= mask # Применяем маску обратной связи return state, bit # Известные п...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/crypto/Grey_Box_Hacking/chall_9058.py
ctfs/Junior.Crypt/2025/crypto/Grey_Box_Hacking/chall_9058.py
def lfsr(state, mask): # Generating a new bit and updating the state LFSR feedback = (state & 1) # Least bit (standard for right-shift LFSR) state = state >> 1 # Right shift if feedback: state ^= mask # Using a feedback mask return state, feedback initial_state = 0x???? # 16-bi...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/crypto/Signature_ECDSA/chall_ECDSA.py
ctfs/Junior.Crypt/2025/crypto/Signature_ECDSA/chall_ECDSA.py
from ecdsa import SECP256k1 import hashlib from random import randint from mySecret import d # d in range(1,n) - my Private Key # ============================================= # 0. Elliptic Curve SECP256k1 Parameters # ============================================= curve = SECP256k1 G = curve.generator # Base Point n...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/crypto/Very_Obfuscated_Crypto/Obfuscated.py
ctfs/Junior.Crypt/2025/crypto/Very_Obfuscated_Crypto/Obfuscated.py
import numpy as _ __ = 257 ___ = 3 def ____(_____, ______): _______ = int(round(_.linalg.det(_____))) % ______; ________ = pow(_______, -1, ______); _________ = _.round(_______ * _.linalg.inv(_____)).astype(int) ;__________ = (________ * _________) % ______; return __________.astype(int) def ___________(____________: b...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/crypto/Bitflip_RSA/BitflipRSA.py
ctfs/Junior.Crypt/2025/crypto/Bitflip_RSA/BitflipRSA.py
from Crypto.Util.number import getPrime, bytes_to_long flag = "grodno{REDACTED}" p = getPrime(1024) q = getPrime(1024) n = p * q e = 65537 c = pow(bytes_to_long(flag.encode()), e, n) xor = p ^ int(bin(q)[2:][::-1], 2) print(f"RSA module (n): {n}") print(f"Ciphertext (c): {c}") print(f"XOR: {xor}")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Junior.Crypt/2025/crypto/Amount_of_his_dreams/Homo_RSA.py
ctfs/Junior.Crypt/2025/crypto/Amount_of_his_dreams/Homo_RSA.py
from mySecret import leak, e, n # leak = {n1: sign1, n2: sign2, ... } print ("Private RSA-key, 1024 bits") print (f"n = {n}") print (f"e = {e}\n") # Vasily's Dream Sum s = 5199988471129825627913948376450062552455594755832468356529321522386086143936586924501655680894606937621023420805188990547342830709933526619855666...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/ESCAPE/2023/Quals/crypto/Bunker_Escape/prob.py
ctfs/ESCAPE/2023/Quals/crypto/Bunker_Escape/prob.py
from Crypto.Util.number import bytes_to_long, long_to_bytes, getPrime from gmpy2 import invert class Cipher: def __init__(self): self.n = 1085069517367933364906838802568558462480836847416944664613361823484174111767810239578253888188440364957516338765998107984369547901149842799391722598864628514389549590319...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MetaRed/2021/crypto/Crypto_101/challenge.py
ctfs/MetaRed/2021/crypto/Crypto_101/challenge.py
from Crypto.Util.number import * from binascii import hexlify import gmpy from flag import FLAG flag = FLAG data = b'potatoespotatoespotatoes' BITS = 512 flag = int(flag.hex(), 16) data = int(data.hex(), 16) p = getStrongPrime(BITS) q = getStrongPrime(BITS) r = getStrongPrime(BITS) n1 = p * q n2 = q * r e = 65537 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MetaRed/2021/crypto/dogogram/app/web/utils.py
ctfs/MetaRed/2021/crypto/dogogram/app/web/utils.py
from PIL import Image, ImageChops from hashlib import md5 from uuid import uuid4 import sqlite3 def compareJPG(file1, file2): img1 = Image.open(file1) img2 = Image.open(file2) equal_size = img1.height == img2.height and img1.width == img2.width equal_content = not ImageChops.difference( img1....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MetaRed/2021/crypto/dogogram/app/web/server.py
ctfs/MetaRed/2021/crypto/dogogram/app/web/server.py
from flask import Flask, request, render_template, redirect, abort, url_for from hashlib import md5 from utils import * app = Flask(__name__) app.config['MAX_CONTENT_LENGTH'] = 1 * 1000 * 1000 @app.route("/") def index(): return render_template('index.html') @app.route('/upload', methods=['POST']) def upload_fil...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MetaRed/2021/crypto/dogogram/app/web/wsgi.py
ctfs/MetaRed/2021/crypto/dogogram/app/web/wsgi.py
from server import app if __name__ == "__main__": app.run()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MetaRed/2021/web/Repeated_Lock/app.py
ctfs/MetaRed/2021/web/Repeated_Lock/app.py
from flask import Flask, render_template, render_template_string, request import os import utils app = Flask(__name__) app.config['SECRET_KEY'] = 'CTFUA{REDACTED}' @app.route('/', methods=['GET', 'POST']) def home(): return render_template('home.html') @app.route('/admin', methods=['GET', 'POST']) def admin()...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/MetaRed/2024/rev/This_will_make_you_ANGRy/script.py
ctfs/MetaRed/2024/rev/This_will_make_you_ANGRy/script.py
import angr import #Find the library that allows to create symbolic variables # Load the binary project = angr.Project('/paht/to/angry binary', auto_load_libs=False) # Length of the argument argument_length = #Complete with the length of the argument # Create a symbolic variable of size argument_length for argume...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Paradigm/2023/misc/Hello_World/challenge.py
ctfs/Paradigm/2023/misc/Hello_World/challenge.py
from eth_launchers.pwn_launcher import PwnChallengeLauncher from eth_launchers.team_provider import get_team_provider PwnChallengeLauncher( project_location="project", provider=get_team_provider(), ).run()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Paradigm/2023/misc/Cosmic_Radiation/solve.py
ctfs/Paradigm/2023/misc/Cosmic_Radiation/solve.py
import yaml from eth_launchers.koth_solver import KothChallengeSolver from eth_launchers.solver import TicketedRemote from eth_launchers.utils import solve from web3 import Web3 class Solver(KothChallengeSolver): def launch_instance(self): with TicketedRemote() as r: r.recvuntil(b"?") ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Paradigm/2023/misc/Cosmic_Radiation/challenge.py
ctfs/Paradigm/2023/misc/Cosmic_Radiation/challenge.py
from typing import List from web3 import Web3 from anvil_server.database import UserData from anvil_server.socket import ( CreateInstanceRequest, CreateInstanceResponse, UnixClient, UpdateMetadataRequest, ) from eth_launchers.koth_launcher import KothChallengeLauncher from eth_launchers.launcher import ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Paradigm/2023/misc/Dropper/challenge.py
ctfs/Paradigm/2023/misc/Dropper/challenge.py
from anvil_server.database import UserData from anvil_server.socket import ( CreateInstanceRequest, CreateInstanceResponse, GetInstanceRequest, UnixClient, UpdateMetadataRequest, ) from eth_abi import abi from eth_launchers.koth_launcher import KothChallengeLauncher from eth_launchers.launcher impor...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Paradigm/2023/misc/Free_Real_Estate/watcher.py
ctfs/Paradigm/2023/misc/Free_Real_Estate/watcher.py
import asyncio import json import random import sys import time from typing import List from anvil_server.database import UserData from anvil_server.socket import GetInstanceRequest, UnixClient, UpdateMetadataRequest from eth_abi import abi from eth_account.signers.local import LocalAccount from eth_launchers.daemon i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Paradigm/2023/misc/Free_Real_Estate/challenge.py
ctfs/Paradigm/2023/misc/Free_Real_Estate/challenge.py
import json from typing import List from anvil_server.database import UserData from anvil_server.socket import ( CreateInstanceRequest, CreateInstanceResponse, UnixClient, ) from eth_launchers.koth_launcher import KothChallengeLauncher from eth_launchers.launcher import ETH_RPC_URL from eth_launchers.score...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Paradigm/2023/pwn/100/challenge.py
ctfs/Paradigm/2023/pwn/100/challenge.py
from eth_launchers.pwn_launcher import PwnChallengeLauncher from eth_launchers.team_provider import get_team_provider PwnChallengeLauncher( project_location="project", provider=get_team_provider(), ).run()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Paradigm/2023/pwn/Grains_of_Sand/challenge.py
ctfs/Paradigm/2023/pwn/Grains_of_Sand/challenge.py
from anvil_server.socket import ( CreateInstanceRequest, CreateInstanceResponse, UnixClient, ) from eth_launchers.launcher import ETH_RPC_URL from eth_launchers.pwn_launcher import PwnChallengeLauncher from eth_launchers.team_provider import get_team_provider from foundry.anvil import LaunchAnvilInstanceArg...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false