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/AmateursCTF/2023/algo/gcd-query-v1/main.py
ctfs/AmateursCTF/2023/algo/gcd-query-v1/main.py
#!/usr/local/bin/python from flag import flag from math import gcd from Crypto.Util.number import getRandomInteger for i in range(10): x = getRandomInteger(2048) for i in range(1412): try: n, m = map(int, input("n m: ").split()) assert m > 0 print(gcd(x + n, m)) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/algo/gcd-query-v2/main.py
ctfs/AmateursCTF/2023/algo/gcd-query-v2/main.py
#!/usr/local/bin/python from flag import flag from math import gcd from Crypto.Util.number import getRandomInteger x = getRandomInteger(128) for i in range(16): try: n, m = map(int, input("n m: ").split()) assert m > 0 print(gcd(x + n, m)) except: print("bad input. you *die*") ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/crypto/OwO_time_pad/main.py
ctfs/AmateursCTF/2023/crypto/OwO_time_pad/main.py
import os import random from Crypto.Util.strxor import strxor from math import gcd with open('secret.txt', 'rb') as f: plaintext = f.read() keylength = len(plaintext) while gcd(keylength, len(plaintext)) > 1: keylength = random.randint(10, 100) key = os.urandom(keylength) key = key * len(pl...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/crypto/Poly_Fractions/main.py
ctfs/AmateursCTF/2023/crypto/Poly_Fractions/main.py
#!/usr/local/bin/python import random import math from flag import flag, text a = 1 b = random.randint(-10, 10) b2 = random.randint(-10, 10) numcoefficients = [a, b] denomcoefficients = [a, b2] query = 0 for i in flag: sign = random.randint(0, 1) if sign == 0: sign -= 1 numcoefficients.append(sign ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/crypto/Lottery/main.py
ctfs/AmateursCTF/2023/crypto/Lottery/main.py
#!/usr/local/bin/python from Crypto.Util.number import * from Crypto.Cipher import AES from math import ceil import os import random from flag import flag xyz = len(flag) fullkey = "" for i in range(128): key = "" for j in range(128): key += str(random.randint(0, 1)) for j in range(10): ke...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/crypto/You_get_extra_information_2/main.py
ctfs/AmateursCTF/2023/crypto/You_get_extra_information_2/main.py
from Crypto.Util.number import * from flag import flag p = getPrime(512) q = getPrime(512) n = p*q e = 0x10001 extra_information = (n**2)*(p**3 + 5*(p+1)**2) + 5*n*q + q**2 ptxt = bytes_to_long(flag) c = pow(ptxt, e, n) with open('output.txt', 'w') as f: f.write(f"n: {n}\nc: {c}\ne: {e}\nextra_information: {extra...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/crypto/You_get_extra_information_1/main.py
ctfs/AmateursCTF/2023/crypto/You_get_extra_information_1/main.py
from Crypto.Util.number import * from flag import flag p = getPrime(512) q = getPrime(512) n = p*q p = p + q e = 0x10001 extra_information = p + q ptxt = bytes_to_long(flag) c = pow(ptxt, e, n) with open('output.txt', 'w') as f: f.write(f"n: {n}\nc: {c}\ne: {e}\nextra_information: {extra_information}")
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/crypto/Minimalaestic/main.py
ctfs/AmateursCTF/2023/crypto/Minimalaestic/main.py
# based on https://github.com/boppreh/aes/blob/master/aes.py from flag import flag, key import copy KEY_SIZE = 2 ROUNDS = 100 def sub_bytes(s): for i in range(2): s[i][0] = sbox[s[i][0]] def final_sub(s): for i in range(2): s[i][1] = sbox[s[i][1]] sbox = [0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/crypto/Weak_Primes/main.py
ctfs/AmateursCTF/2023/crypto/Weak_Primes/main.py
from Crypto.Util.number import * from flag import flag def phi(p, q): if p == q: return (p-1)*p else: return (p-1)*(q-1) def getModPrime(modulus): p = 2**2047 + getPrime(128) p += (modulus - p) % modulus p += 1 iters = 0 while not isPrime(p): p += modulus retu...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/crypto/The_Vault_2/main.py
ctfs/AmateursCTF/2023/crypto/The_Vault_2/main.py
#!/usr/local/bin/python from flag import flag import sys sys.set_int_max_str_digits(13337) a = input("a: ") b = input("b: ") c = input("c: ") x = input("x: ") y = input("y: ") z = input("z: ") try: a, b, c, x, y, z = list(map(int, [a,b,c,x,y,z])) except: print("Invalid input") exit(0) for i in [a,b,c,x...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/crypto/Non-Quadratic_Residues/main.py
ctfs/AmateursCTF/2023/crypto/Non-Quadratic_Residues/main.py
from Crypto.Util.number import * from flag import flag def getModPrime(modulus): p = getPrime(1024) p += (modulus - p) % modulus p += 1 iters = 0 while not isPrime(p): p += modulus return p difficulty = 210 flag = bytes_to_long(flag) # no cheeses here! b = getModPrime(difficulty**1...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/crypto/lce_cream_generator/main.py
ctfs/AmateursCTF/2023/crypto/lce_cream_generator/main.py
#!/usr/local/bin/python from Crypto.Util.number import * from os import urandom from flag import flag class lcg: def __init__(self, p): while (a:=bytes_to_long(urandom(16))) > p: pass while (b:=bytes_to_long(urandom(16))) > p: pass self.a, self.b, self.p = a, b, p ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AmateursCTF/2023/web/funny_factorials/app.py
ctfs/AmateursCTF/2023/web/funny_factorials/app.py
from flask import Flask, render_template, request import sys app = Flask(__name__) def factorial(n): if n == 0: return 1 else: try: return n * factorial(n - 1) except RecursionError: return 1 def filter_path(path): # print(path) path = path.replace("../...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KnightCTF/2022/crypto/Tony_Stark_Needs_Help_Again/encryptor.py
ctfs/KnightCTF/2022/crypto/Tony_Stark_Needs_Help_Again/encryptor.py
import base64 str1 = input("Enter text to encrypt: ") arr1 = [] l_c = ''.join(chr(c) for c in range (97,123)) u_c = ''.join(chr(c) for c in range (65,91)) l_e = l_c[13:] + l_c[:13] u_e = u_c[13:] + u_c[:13] so = "" for c in str1: if c in l_c: so = so + l_e[l_c.find(c)] elif c in u_c: so = so +...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KnightCTF/2022/crypto/Tony_Stark_Needs_Help/encryptor.py
ctfs/KnightCTF/2022/crypto/Tony_Stark_Needs_Help/encryptor.py
secret = input("Enter your string to encrypt: ") key = input("Enter the key: ") secarr = [] keyarr = [] x = 0 def keyfunc(key,keyarr,x): for character in key: keyarr.append(ord(character)) for i in keyarr: x += i def secretfucn(secret,secarr,key,x): for character in secret: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KnightCTF/2022/crypto/Jumble/enc.py
ctfs/KnightCTF/2022/crypto/Jumble/enc.py
def f(t): c = list(t) for i in range(len(t)): for j in range(i, len(t) - 1): c[j], c[j+1] = c[j+1], c[j] return "".join(c) if __name__ == "__main__": flag = open("flag", "r").read() open("ciphertext", "w").write(f(flag))
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KnightCTF/2022/crypto/Feistival/enc.py
ctfs/KnightCTF/2022/crypto/Feistival/enc.py
m, n = 21, 22 def f(word, key): out = "" for i in range(len(word)): out += chr(ord(word[i]) ^ key) return out flag = open("flag.txt", "r").read() L, R = flag[0:len(flag)//2], flag[len(flag)//2:] x = "".join(chr(ord(f(R, m)[i]) ^ ord(L[i])) for i in range(len(L))) y = f(R, 0) L, R = y, x x = "".jo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Zh3r0/2021/pwn/javascript_for_dummies_part_2/build/release/connect.py
ctfs/Zh3r0/2021/pwn/javascript_for_dummies_part_2/build/release/connect.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') EOF = 'zh3r0-CTF' MAX_SIZE = 10000 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Zh3r0/2021/pwn/javascript_for_dummies_part_1/build/release/connect.py
ctfs/Zh3r0/2021/pwn/javascript_for_dummies_part_1/build/release/connect.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') EOF = 'zh3r0-CTF' MAX_SIZE = 10000 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Zh3r0/2021/crypto/twist_and_shout/challenge.py
ctfs/Zh3r0/2021/crypto/twist_and_shout/challenge.py
from secret import flag import os import random state_len = 624*4 right_pad = random.randint(0,state_len-len(flag)) left_pad = state_len-len(flag)-right_pad state_bytes = os.urandom(left_pad)+flag+os.urandom(right_pad) state = tuple( int.from_bytes(state_bytes[i:i+4],'big') for i in range(0,state_len,4) ) random.setst...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Zh3r0/2021/crypto/chaos/challenge.py
ctfs/Zh3r0/2021/crypto/chaos/challenge.py
from secret import flag def ROTL(value, bits, size=32): return ((value % (1 << (size - bits))) << bits) | (value >> (size - bits)) def ROTR(value, bits, size=32): return ((value % (1 << bits)) << (size - bits)) | (value >> bits) def pad(pt): pt+=b'\x80' L = len(pt) to_pad = 60-(L%64) if L%64 <= 60...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Zh3r0/2021/crypto/real_mersenne/challenge.py
ctfs/Zh3r0/2021/crypto/real_mersenne/challenge.py
import random from secret import flag from fractions import Fraction def score(a,b): if abs(a-b)<1/2**10: # capping score to 1024 so you dont get extra lucky return Fraction(2**10) return Fraction(2**53,int(2**53*a)-int(2**53*b)) total_score = 0 for _ in range(2000): try: x = rando...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Zh3r0/2021/crypto/alice_bob_dave/chall.py
ctfs/Zh3r0/2021/crypto/alice_bob_dave/chall.py
from Crypto.Util.number import * from secret import msg_a,msg_b e=65537 p,q,r=[getStrongPrime(1024,e) for _ in range(3)] pt_a=bytes_to_long(msg_a) pt_b=bytes_to_long(msg_b) n_a=p*q n_b=p*r phin_a=(p-1)*(q-1) phin_b=(p-1)*(r-1) d_a=inverse(e,phin_a) d_b=inverse(e,phin_b) ct_a=pow(pt_a,e,n_a) ct_b=pow(pt_b,e,n_b) pri...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Zh3r0/2021/crypto/import_numpy_as_MT/challenge.py
ctfs/Zh3r0/2021/crypto/import_numpy_as_MT/challenge.py
import os from numpy import random from Crypto.Cipher import AES from Crypto.Util.Padding import pad from secret import flag def rand_32(): return int.from_bytes(os.urandom(4),'big') flag = pad(flag,16) for _ in range(2): # hate to do it twice, but i dont want people bruteforcing it random.seed(rand_32()...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Zh3r0/2021/crypto/1n_jection/challenge.py
ctfs/Zh3r0/2021/crypto/1n_jection/challenge.py
from secret import flag def nk2n(nk): l = len(nk) if l==1: return nk[0] elif l==2: i,j = nk return ((i+j)*(i+j+1))//2 +j return nk2n([nk2n(nk[:l-l//2]), nk2n(nk[l-l//2:])]) print(nk2n(flag)) #25977495199845200181935389149727440287807670673732106338434418929108307497492776311825...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/pwn/wyze_guy/webserver.py
ctfs/K3RN3L/2021/pwn/wyze_guy/webserver.py
import SocketServer import BaseHTTPServer import CGIHTTPServer class ThreadingCGIServer(SocketServer.ThreadingMixIn,BaseHTTPServer.HTTPServer): pass import sys server = ThreadingCGIServer(('', 4444), CGIHTTPServer.CGIHTTPRequestHandler) # try: while 1: sys.stdout.flush() server.handle_request...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Beecryption/beecryption.py
ctfs/K3RN3L/2021/crypto/Beecryption/beecryption.py
#!/usr/bin/env python3 # # Polymero # # Imports import os class BeeHive: """ Surrounding their beehive, the bees can feast on six flower fields with six flowers each. """ def __init__(self, key): """ Initialise the bee colony. """ self.fields = self.plant_flowers(key) self.nectar = No...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Vietas_Poly/template.py
ctfs/K3RN3L/2021/crypto/Vietas_Poly/template.py
from pwn import * context.log_level = 'debug' #will print all input and output for debugging purposes conn = remote("server",port) #enter the address and the port here as strings. For example nc 0.0.0.0 5000 turns into remote('0.0.0.0', 5000) def get_input(): #function to get one line from the netcat input = conn.r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Objection/objection.py
ctfs/K3RN3L/2021/crypto/Objection/objection.py
#!/usr/bin/env python3 # # Polymero # # Imports import hashlib, secrets, json from Crypto.PublicKey import DSA # Local imports with open('flag.txt','rb') as f: FLAG = f.read() f.close() class CCC: """ Certified Certificate Certifier. (It's just DSA...) """ def __init__(self, p, q, g): "...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Pascal_RSA/main.py
ctfs/K3RN3L/2021/crypto/Pascal_RSA/main.py
triangle =[[1]] flag = open('flag.txt','rb').read() from Crypto.Util.number import getPrime,bytes_to_long from math import gcd p = getPrime(20) while len(triangle[-1]) <= p: r = [1] for i in range(len(triangle[-1]) - 1): r.append(triangle[-1][i] + triangle[-1][i+1]) r.append(1) triangle.append(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Cozzmic_Dizzcovery/pandorascomb.py
ctfs/K3RN3L/2021/crypto/Cozzmic_Dizzcovery/pandorascomb.py
#!/usr/bin/env python3 # Imports import os # Local imports with open('flag.txt','rb') as f: FLAG = f.read() f.close() HDR = r"""| | | 15 26 | \ 17 18 19 20 / | 14 16 \ | | | | / 21 25 | \ | \| | | |/ ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/1-800-758-6237/1-800-758-6237.py
ctfs/K3RN3L/2021/crypto/1-800-758-6237/1-800-758-6237.py
#!/usr/bin/env python3 # # Polymero # # Imports from Crypto.Cipher import AES import os, time, random # Local imports with open('flag.txt', 'rb') as f: FLAG = f.read() f.close() def leak(drip): rinds = sorted(random.sample(range(len(drip)+1), 16)) for i in range(len(rinds)): ind = rinds[i] + i*len(b'*drip*'...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/3in1/AES.py
ctfs/K3RN3L/2021/crypto/3in1/AES.py
from Crypto.Cipher import AES from Crypto.Hash import SHA256 f = open('progress.txt', 'r') password = ("abda") hash_obj = SHA256.new(password.encode('utf-8')) hkey = hash_obj.digest() def encrypt(info): msg = info BLOCK_SIZE = 16 PAD = "{" padding = lambda s: s + (BLOCK_SIZE - len(s) % B...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/United_Trees_Of_America/main.py
ctfs/K3RN3L/2021/crypto/United_Trees_Of_America/main.py
import random import math from Crypto.Util.number import * def isPrime(p): for i in range(2,int(math.sqrt(p))+1): if p%i==0: return False return True flag = bytes_to_long(open('flag.txt','rb').read()) p = int(input('Enter a prime: ')) assert 10<p, 'Prime too small' assert p<250, 'Prime too big' assert i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/HADIOR/hadior.py
ctfs/K3RN3L/2021/crypto/HADIOR/hadior.py
#!/usr/bin/env python3 # # Polymero # # Imports from Crypto.Util.number import inverse, getPrime, isPrime from secrets import randbelow from base64 import urlsafe_b64encode, urlsafe_b64decode from hashlib import sha256 import json, os, time # Local imports with open('flag.txt','rb') as f: FLAG = f.read() f.cl...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Non-Square_Freedom_1/nonsquarefreedom_easy.py
ctfs/K3RN3L/2021/crypto/Non-Square_Freedom_1/nonsquarefreedom_easy.py
#!/usr/bin/env python3 # # Polymero # # Imports from Crypto.Util.number import getPrime import os # Local imports with open('flag.txt','rb') as f: FLAG = f.read() f.close() # Key gen P = getPrime(512//8) Q = getPrime(256) R = getPrime(256) N = P**8 * Q * R E = 0x10001 def pad_easy(m): m <<= (512//8) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Game_of_Secrets/gameofsecrets.py
ctfs/K3RN3L/2021/crypto/Game_of_Secrets/gameofsecrets.py
#!/usr/bin/env python3 # # Polymero # # Imports import os, base64 from hashlib import sha256 # Local imports with open('flag.txt','rb') as f: FLAG = f.read() f.close() class GoS: def __init__(self, key=None, spacing=12): self.spacing = spacing if type(key) == str: try: key ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Non-Square_Freedom_2/nonsquarefreedom_hard.py
ctfs/K3RN3L/2021/crypto/Non-Square_Freedom_2/nonsquarefreedom_hard.py
#!/usr/bin/env python3 # # Polymero # # Imports from Crypto.Util.number import getPrime import os # Local imports with open('flag.txt','rb') as f: FLAG = f.read() f.close() # Key gen P = getPrime(512//8) Q = getPrime(256) R = getPrime(256) N = P**8 * Q * R E = 0x10001 def pad_hard(m): m <<= (512//2) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Total_Encryption/ltet.py
ctfs/K3RN3L/2021/crypto/Total_Encryption/ltet.py
#!/usr/bin/env python3 # # Polymero # # Imports import os, time, base64 from Crypto.Util.number import getPrime, inverse, GCD, long_to_bytes # Shorthand def b64enc(x): return base64.urlsafe_b64encode(long_to_bytes(x)).rstrip(b'=') class LTET: """ Layered Totally Encrypted Terminal. """ def __init__(self,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/MathyOracle/main.py
ctfs/K3RN3L/2021/crypto/MathyOracle/main.py
print('Find my number N, and I will give you the flag.') def f(N,k): while min(N,k)>0: if k>N: N,k = k,N N%=k return max(N,k) import random N = random.getrandbits(512) for i in range(600): print(f"Try #{i+1}: ") k = input(f'Enter k: ') l = input(f'Enter l: ') try: k= int(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Poly-Proof/polyproof.py
ctfs/K3RN3L/2021/crypto/Poly-Proof/polyproof.py
#!/usr/bin/env python3 # # Polymero # # Imports import os # Local imports with open('flag.txt','rb') as f: FLAG = f.read() f.close() HDR = r"""| | ________ ________ ___ ___ ___ ________ ________ ________ ________ ________ | |\ __ \|\ __ \|\ \ |\ \ / /| |\ ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Aint_No_Mountain_High_Enough/mountaincipher.py
ctfs/K3RN3L/2021/crypto/Aint_No_Mountain_High_Enough/mountaincipher.py
#!/usr/bin/env python3 # # Polymero # #------------------------------------------------------------------------------- # IMPORTS #------------------------------------------------------------------------------- import os from Crypto.Util.number import long_to_bytes, bytes_to_long, inverse #----------------------------...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Aint_No_Mountain_High_Enough/server.py
ctfs/K3RN3L/2021/crypto/Aint_No_Mountain_High_Enough/server.py
#!/usr/bin/env python3 # # Polymero # # Local imports from mountaincipher import * with open('flag.txt','rb') as f: FLAG = f.read() f.close() # Encryption parameters N = 5 P = 251 VERSION = '1.0' HDR_3 = r"""| | | ___ ___ ___ _________ _ | ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Shrine_of_the_Sweating_Buddha/pravrallier.py
ctfs/K3RN3L/2021/crypto/Shrine_of_the_Sweating_Buddha/pravrallier.py
#!/usr/bin/env python3 # # Polymero # # Imports import random from Crypto.Util.number import GCD, inverse, bytes_to_long, long_to_bytes, getPrime from time import sleep class Pravrallier: def __init__(self): # Keygen while True: p, q = getPrime(512), getPrime(512) if GCD(p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Mowhock/mowhock.py
ctfs/K3RN3L/2021/crypto/Mowhock/mowhock.py
#!/usr/bin/env python3 # # Nika Soltas # # Imports import os from hashlib import sha256 # Local imports with open('flag.txt','rb') as f: FLAG = f.read() f.close() class Map: def __init__(self, maptype, params): """Initialise map object""" if maptype.lower() in ['l','lm','logic']: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Fractional_Fractions/main.py
ctfs/K3RN3L/2021/crypto/Fractional_Fractions/main.py
from Crypto.Util.number import bytes_to_long flag = str(bytes_to_long(open('flag.txt','rb').read())) from fractions import Fraction enc = Fraction(0/1) for c in flag: enc += Fraction(int(c)+1) enc = 1/enc print(enc) #7817806454609461952471483475242846271662326/63314799458349217804506955537187514185318043
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Pryby/main.py
ctfs/K3RN3L/2021/crypto/Pryby/main.py
from Crypto.Util.number import bytes_to_long def f(n): q=[True]*(n + 1) r=2 while r**2<=n: if q[r]: for i in range(r**2,n+1,r):q[i] = False r += 1 return [p for p in range(2,n+1) if q[p]] class G: def __init__(self, f): self.f = f self.state = 1 def m...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/K3RN3L/2021/crypto/Tick_Tock/ticktock.py
ctfs/K3RN3L/2021/crypto/Tick_Tock/ticktock.py
#!/usr/bin/env python3 # # Polymero # # Imports from Crypto.Util.number import getPrime, isPrime from Crypto.Util.Padding import pad from Crypto.Cipher import AES from random import randint from hashlib import sha256 # Local imports with open('flag.txt','rb') as f: FLAG = f.read() f.close() assert len(FLAG)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/1753CTF/2025/crypto/Update/update_update.py
ctfs/1753CTF/2025/crypto/Update/update_update.py
#!/usr/bin/env python3 import json from Crypto.Hash import CMAC from Crypto.Cipher import AES from Crypto.PublicKey import RSA from Crypto.Signature import pkcs1_15 from secret import FLAG, CMAC_KEY, PUBKEY_TAG, try_read_cmac_key def mac(msg): cmac = CMAC.new(CMAC_KEY, ciphermod=AES) cmac.oid = '2.16.840.1.1...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2024/crypto/sym_signin/task_utils.py
ctfs/D3CTF/2024/crypto/sym_signin/task_utils.py
import hashlib import struct S = [0xc, 0x5, 0x6, 0xb, 0x9, 0x0, 0xa, 0xd, 0x3, 0xe, 0xf, 0x8, 0x4, 0x7, 0x1, 0x2] P = [0, 8, 16, 24, 1, 9, 17, 25, 2, 10, 18, 26, 3, 11, 19, 27, 4, 12, 20, 28, 5, 13, 21, 29, 6, 14, 22, 30, 7, 15, 23, 31] def S_16bit(x: int) -> int: result = 0 for i in range(4): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2024/crypto/sym_signin/task.py
ctfs/D3CTF/2024/crypto/sym_signin/task.py
import random from secret import secret_KEY, flag from task_utils import * plain = read_from_binary_file('plain') cipher = [] for i in range(len(plain)): x = encrypt(message=plain[i], key=secret_KEY, ROUND=8192) cipher.append(x) write_to_binary_file(cipher, 'cipher') plain_flag = bytes_to_uint32_list(flag) e...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2024/crypto/myRSA/task.py
ctfs/D3CTF/2024/crypto/myRSA/task.py
from random import randint from gmpy2 import * from Crypto.Util.number import * from secret import flag class LFSR: def __init__(self, seed, length): self.mask = 0b10000100100100100100100100100100100100100100100100100100100100100100100100100100100100110 self.length = length self.lengthmask...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2024/crypto/S0DH/challenge.py
ctfs/D3CTF/2024/crypto/S0DH/challenge.py
from sage.all import * from Crypto.Util.number import bytes_to_long from secret import flag import hashlib flag_start = b'd3ctf{' assert flag.startswith(flag_start) flag = flag[len(flag_start):-1] assert len(flag) == 32 a = 38 b = 25 p = 2**a * 3**b - 1 assert is_prime(p) Fp = GF(p) Fpx = PolynomialRing(Fp, "x") x...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2024/crypto/enctwice/enctwice.py
ctfs/D3CTF/2024/crypto/enctwice/enctwice.py
import os import secret from random import seed, choice from Crypto.Cipher import ChaCha20,AES from Crypto.Util.number import * from string import ascii_letters, digits from hashlib import sha256 D3 = 300 def proof_of_work(): seed(os.urandom(8)) proof = ''.join([choice(ascii_letters + digits) for _ in range(2...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2023/crypto/d3bdd/util.py
ctfs/D3CTF/2023/crypto/d3bdd/util.py
from Crypto.Util.number import * class PRNG: def __init__(self , seed): self.state = bytes_to_seedlist(seed) self.m = 738136690439 # f = [randint(0 , m) for _ in range(16)] self.f = [172726532595, 626644115741, 639699034095, 505315824361, 372926623247, 517574605128, 1851886...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2023/crypto/d3bdd/task.py
ctfs/D3CTF/2023/crypto/d3bdd/task.py
from util import * from hashlib import * import os from secret import flag from Crypto.Util.number import * assert flag[:9] == b'antd3ctf{' and flag[-1:] == b'}' and len(flag) == 64 assert sha256(flag).hexdigest() == '8ea9f4a9de94cda7a545ae8e7c7c96577c2e640b86efe1ed738ecbb5159ed327' seed = sha256(b"welcome to D3CTF"...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2023/crypto/d3sys/server.py
ctfs/D3CTF/2023/crypto/d3sys/server.py
from Crypto.Util.number import long_to_bytes,bytes_to_long,getPrime,inverse from gmssl.SM4 import CryptSM4,SM4_ENCRYPT,xor from hashlib import sha256 from secret import secret import signal import time import json import os FLAG = b'ant' + secret banner = br""" :::::::::::::::::::::::::::::::::::::::::::::::::::::::...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2023/crypto/d3sys/gmssl/SM4.py
ctfs/D3CTF/2023/crypto/d3sys/gmssl/SM4.py
# -*-coding:utf-8-*- # https://github.com/duanhongyi/gmssl import copy from random import choice xor = lambda a, b:list(map(lambda x, y: x ^ y, a, b)) rotl = lambda x, n:((x << n) & 0xffffffff) | ((x >> (32 - n)) & 0xffffffff) get_uint32_be = lambda key_data:((key_data[0] << 24) | (key_data[1] << 16) | (key_data[2] ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2023/crypto/d3noisy/task.py
ctfs/D3CTF/2023/crypto/d3noisy/task.py
from Crypto.Util.number import * from random import shuffle from sympy import nextprime def getKey(): p = getPrime(1024) q = getPrime(1024) n = p * q N = [getRandomNBitInteger(3211) for _ in range(15)] d = 0 for _ in N: d = d ^ _ d = nextprime(d) e = inverse(d,(p-1)*(q-1)) r...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2023/web/EscapePlan/challenge/app.py
ctfs/D3CTF/2023/web/EscapePlan/challenge/app.py
import base64 from flask import Flask, request app = Flask(__name__) @app.route('/', methods=['GET', 'POST']) def challenge_3(): cmd = request.form.get("cmd", "") if not cmd: return """<pre> import requests, base64 exp = '' requests.post("", data={"cmd": base64.b64encode(exp.encode())}).text </pre> "...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2022/pwn/d3guard/run.py
ctfs/D3CTF/2022/pwn/d3guard/run.py
import os, subprocess import random def main(): try: ret = subprocess.call([ "qemu-system-x86_64", "-m", f"{256+random.randint(0, 512)}", "-drive", f"if=pflash,format=raw,file=OVMF.fd", "-drive", "file=fat:rw:contents,format=raw", "-net", "none", ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2022/rev/d3thon/main.py
ctfs/D3CTF/2022/rev/d3thon/main.py
import byte_analizer as ba with open("bcode.lbc", "r") as fi: statmts = fi.read().split("\n") for i in statmts: ba.analize(i)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2022/crypto/d3bug/task.py
ctfs/D3CTF/2022/crypto/d3bug/task.py
from Crypto.Util.number import * from secret import flag assert flag.startswith("D3CTF{") assert flag.endswith("}") message = bytes_to_long(flag[6:-1]) assert message < 2**64 mask = 0b1010010000001000000010001001010010100100000010000000100010010100 def lfsr_MyCode(R,mask): output = (R << 1) & 0xffffffffffffffff ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2022/crypto/d3qcg/babyqcg_d93b0b026b8855bd98709388883c98c7.py
ctfs/D3CTF/2022/crypto/d3qcg/babyqcg_d93b0b026b8855bd98709388883c98c7.py
from Crypto.Util.number import * import random from random import randint from gmpy2 import * from secret import flag import hashlib assert b'd3ctf' in flag Bits = 512 UnKnownBits = 146 class QCG(): def __init__(self,bit_length): p = getPrime(bit_length) a = randint(0,p) c = randint(0,p) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2022/crypto/equivalent/task.py
ctfs/D3CTF/2022/crypto/equivalent/task.py
from collections import namedtuple from Crypto.Util import number from Crypto.Random import random PublicKey = namedtuple('PublicKey', ['a']) SecretKey = namedtuple('SecretKey', ['s', 'e', 'p']) def keygen(sbit, N): s_ = [random.getrandbits(sbit) | 1 for _ in range(N)] pbit = sum(s_).bit_length() + 1 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/D3CTF/2022/crypto/d3factor/d3factor.py
ctfs/D3CTF/2022/crypto/d3factor/d3factor.py
from Crypto.Util.number import bytes_to_long, getPrime from secret import msg from sympy import nextprime from gmpy2 import invert from hashlib import md5 flag = 'd3ctf{'+md5(msg).hexdigest()+'}' p = getPrime(256) q = getPrime(256) assert p > q n = p * q e = 0x10001 m = bytes_to_long(msg) c = pow(m, e, n) N = pow(p, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2023/misc/MAnaGerfAker/verifier.py
ctfs/AzureAssassinAlliance/2023/misc/MAnaGerfAker/verifier.py
from secret import flag import os, subprocess, tempfile from base64 import b64decode hash_mod = 1 << 32 hash_mask = hash_mod - 1 def sign_ext(val): if val >= 0x80: return val - 256 + hash_mod return val def calc_hash(data): assert len(data) == 0x33b, "Bad length" base_hash = 1 for v in dat...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2023/misc/SLM/service/service.py
ctfs/AzureAssassinAlliance/2023/misc/SLM/service/service.py
import socketserver import threading import sys import hashlib import string import random import socket import subprocess import requests import os import time import json from termcolor import colored HOST, PORT = "0.0.0.0", 9999 SHOST, SPORT = XXX, XXX NUMBER = 4 POW_DIFFICULTY = 21 TIMEOUT = 60 * 5 POST_TIMEOUT...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2023/misc/SLM/server/server.py
ctfs/AzureAssassinAlliance/2023/misc/SLM/server/server.py
import os from flask import Flask, jsonify, request import threading import signal import socket import multiprocessing from langchain.chains import PALChain from langchain.llms.rwkv import RWKV model_path = "/data/model.pth" tokenizer_path = "/data/tokenizer.json" model = None HOST, PORT = "0.0.0.0", 19999 SECRET =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2023/misc/SLM/server/test.py
ctfs/AzureAssassinAlliance/2023/misc/SLM/server/test.py
import os from flask import Flask, jsonify, request import threading import signal import socket import multiprocessing from langchain.chains import PALChain from langchain.llms.rwkv import RWKV model_path = "/data/model.pth" tokenizer_path = "/data/tokenizer.json" model = None HOST, PORT = "0.0.0.0", XXX SECRET = o...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2023/rev/Tree/server.py
ctfs/AzureAssassinAlliance/2023/rev/Tree/server.py
import os import uuid import signal remote_ip_addr = os.getenv("REMOTE_HOST", "localhost") identifier = remote_ip_addr + '_' + str(uuid.uuid4()) temp_file = "tmp_{}.cpp".format(identifier) try: signal.alarm(20) print('Give me your source code with no header. Input "EOF" to end:', flush=True) codes = [] ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2023/crypto/claw_crane/task.py
ctfs/AzureAssassinAlliance/2023/crypto/claw_crane/task.py
#!/usr/bin/env python3 from Crypto.Util.number import ( bytes_to_long, long_to_bytes ) from hashlib import md5 import os, signal import sys import random BITS = 128 class ClawCrane(object): def __init__(self) -> None: self.seed = bytes_to_long(os.urandom(BITS//8)) self.bless = 0 self.s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2023/crypto/mt_speed_run/server.py
ctfs/AzureAssassinAlliance/2023/crypto/mt_speed_run/server.py
import random, os, hashlib, base64, signal from secret import FLAG sys_rng = random.SystemRandom() def rand_magic(): while True: value = sys_rng.getrandbits(32) if 10 <= bin(value).count('1') <= 22: return value MAGIC_A = rand_magic() MAGIC_B = rand_magic() MAGIC_C = rand_magic() MAGIC...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2023/crypto/EasyRSA/task.py
ctfs/AzureAssassinAlliance/2023/crypto/EasyRSA/task.py
from secret import flag from Crypto.Util.number import * def genKey(nbits, dbits): bbits = (nbits // 2 - dbits) // 2 while True: a = getRandomNBitInteger(dbits) b = getRandomNBitInteger(bbits) c = getRandomNBitInteger(bbits) p1 = a * b * c + 1 if isPrime(p1): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2023/crypto/CRCRC/CRCRC.py
ctfs/AzureAssassinAlliance/2023/crypto/CRCRC/CRCRC.py
from base64 import * def crc128(data, poly = 0x883ddfe55bba9af41f47bd6e0b0d8f8f): crc = (1 << 128) - 1 for b in data: crc ^= b for _ in range(8): crc = (crc >> 1) ^ (poly & -(crc & 1)) return crc ^ ((1 << 128) - 1) with open('./flag.txt','r') as f: flag = f.readline() Your...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2023/crypto/MidRSA/task.py
ctfs/AzureAssassinAlliance/2023/crypto/MidRSA/task.py
from secret import flag from Crypto.Util.number import * def genKey(nbits, dbits): bbits = (nbits // 2 - dbits) // 2 while True: a = getRandomNBitInteger(dbits) b = getRandomNBitInteger(bbits) c = getRandomNBitInteger(bbits) p1 = a * b * c + 1 if isPrime(p1): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2023/web/easy_latex/vip-service/app.py
ctfs/AzureAssassinAlliance/2023/web/easy_latex/vip-service/app.py
from flask import Flask, request from Crypto.Cipher import DES from hashlib import md5 import os PORT = int(os.environ.get('PORT', '5000')) app = Flask(__name__) invitation_codes = [] def new_invitation_code(): return os.urandom(8).hex() def check_invitation_code(username:str, code:str): des = DES.new(md5(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2023/web/story/app.py
ctfs/AzureAssassinAlliance/2023/web/story/app.py
from flask import Flask, render_template_string, jsonify, request, session, render_template, redirect import random from utils.captcha import Captcha, generate_code from utils.minic import * app = Flask(__name__) app.config['SECRET_KEY'] = '' @app.route('/', methods=['GET', 'POST']) def index(): username = session...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2023/web/story/utils/captcha.py
ctfs/AzureAssassinAlliance/2023/web/story/utils/captcha.py
# coding: utf-8 import os import random import typing as t from PIL.Image import new as createImage, Image, QUAD, BILINEAR from PIL.ImageDraw import Draw, ImageDraw from PIL.ImageFilter import SMOOTH from PIL.ImageFont import FreeTypeFont, truetype from io import BytesIO import time ColorTuple = t.Union[t.Tuple[int, i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2023/web/story/utils/minic.py
ctfs/AzureAssassinAlliance/2023/web/story/utils/minic.py
import random rule = [ ['\\x','[',']','.','getitem','print','request','args','cookies','values','getattribute','config'], # rule 1 ['(',']','getitem','_','%','print','config','args','values','|','\'','\"','dict',',','join','.','set'], # rule 2 ['\'','\"','dict',',','config','...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/secure_connection/client.py
ctfs/AzureAssassinAlliance/2022/crypto/secure_connection/client.py
from socket import socket import socketserver import argparse from core import connection_engine, connection_handle_socket import socket def banner(): print(''' ___ ___ ___ _ _ _ __ ___ ___ ___ _ __ _ __ / __|/ _ \/ __| | | | '__/ _ \/ __/ _ \| '_ \| '_ \ \__ \ __/ (__| |_| | | | __/ (_| ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/secure_connection/core.py
ctfs/AzureAssassinAlliance/2022/crypto/secure_connection/core.py
import base64 from dataclasses import dataclass from enum import Enum from Crypto.Cipher import AES import random from telnetlib import SE import libscrc def bytes_xor_16(bytes1, bytes2): v1 = int.from_bytes(bytes1, 'big') v2 = int.from_bytes(bytes2, 'big') v3 = v1 ^ v2 return (v3).to_bytes(16, 'big')...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/RSA_LEAK/task.py
ctfs/AzureAssassinAlliance/2022/crypto/RSA_LEAK/task.py
from sage.all import * from secret import flag from Crypto.Util.number import bytes_to_long def leak(a, b): p = random_prime(pow(2, 64)) q = random_prime(pow(2, 64)) n = p*q e = 65537 print(n) print((pow(a, e) + pow(b, e) + 0xdeadbeef) % n) def gen_key(): a = randrange(0, pow(2,256)) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/casino/players.py
ctfs/AzureAssassinAlliance/2022/crypto/casino/players.py
from qunetsim.components import Host from qunetsim.objects import Qubit from qunetsim.objects import Logger from Crypto.Util.number import long_to_bytes from Crypto.Cipher import AES from casino import WIN_MSG, LOSE_MSG from secret import flag import sys import math import base64 import random import os # Logger.DISA...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/casino/main.py
ctfs/AzureAssassinAlliance/2022/crypto/casino/main.py
#!/usr/bin/env python3 import sys import signal import random, string, hashlib def proof_of_work(): proof = ''.join([random.choice(string.ascii_letters+string.digits) for _ in range(20)]) digest = hashlib.sha256(proof.encode()).hexdigest() print("sha256(XXXX+%s) == %s" % (proof[4:], digest)) x = inpu...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/casino/casino.py
ctfs/AzureAssassinAlliance/2022/crypto/casino/casino.py
CASINO_DESCRIPTION = \ "==========================================================================\n" \ "| Hey gambler! Welcome to AAA casino, here you are going to bet with me.\n" \ "| Hope you can win a lot of money.\n" \ "| If you are outstanding enough, I will give you flag.\n" \ ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/casino/secret.py
ctfs/AzureAssassinAlliance/2022/crypto/casino/secret.py
flag = 'ACTF{this_is_a_local_flag-please_connect_to_the_remote_server_to_get_true_flag}'
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/casino/backend.py
ctfs/AzureAssassinAlliance/2022/crypto/casino/backend.py
from qunetsim import Network def exchange_key(aaa, tbd, qubits_n): network = Network.get_instance() nodes = [aaa.host.host_id, tbd.host.host_id] network.start(nodes) network.delay = 0.0 network.add_host(aaa.host) network.add_host(tbd.host) t1 = aaa.host.run_protocol(aaa.exchange_key...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/crypto_note/blockchain_service.py
ctfs/AzureAssassinAlliance/2022/crypto/crypto_note/blockchain_service.py
""" A "solo" consensus ledger endorsed during bookkeeping """ from json import loads, dumps from secret import flag, alice_pub, bob_priv, bob_pub, carol_priv, carol_pub from abc import abstractmethod from ring_signature import serialize2json, deserialize4json, transaction_curve, OTRS, H as Hv, prng, Hp E, G = transac...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/crypto_note/signed_message_verifier.py
ctfs/AzureAssassinAlliance/2022/crypto/crypto_note/signed_message_verifier.py
from gmssl import sm2, sm3, func # gmssl==3.2.1 from binascii import a2b_hex from json import load from secret import bob_pub class SM2(sm2.CryptSM2): def __init__(self, private_key, public_key): ecc_table = { 'n': '1000000000000000000000000000000014DEF9DEA2F79CD65812631A5CF5D3ED', ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/crypto_note/ring_signature.py
ctfs/AzureAssassinAlliance/2022/crypto/crypto_note/ring_signature.py
from sage.all import * from Crypto.Hash import keccak from Crypto.Util.number import long_to_bytes, bytes_to_long from struct import unpack from random import SystemRandom from json import loads, dumps prng = SystemRandom() def n2s(n): buf = long_to_bytes(n) return len(buf).to_bytes(8, 'big') + buf def s2n(s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/crypto_note/secret.py
ctfs/AzureAssassinAlliance/2022/crypto/crypto_note/secret.py
# This is a sample file for secret.py. alice_priv = 0xa42d6d662afa3114ccf2678f766048faca568bb804de9e0ba17ee18e6af7565 alice_pub = (0x53f9f8c1226769b84fcf8564c2521f87849f8b993ee8fc9784f3a900d896a730, 0x489b81283080f4db6db6c1635a839b89a5eefe8442fd2bced94c39c8cb6470b5) # Every secret number in the real secret.py is repl...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/crypto_note/range_proof_verifier.py
ctfs/AzureAssassinAlliance/2022/crypto/crypto_note/range_proof_verifier.py
from ring_signature import proof_curve, RangeProof, OTRS, deserialize4json, proof_H E, G = proof_curve() H = proof_H(E) rp = RangeProof(OTRS(E, G), H) with open("range_proof_from_carol.json", "r") as f: json = f.read() C, proof = deserialize4json(E, json) print("verfied" if rp.verify(C, 256, proof) else "FAKE P...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/crypto_note/hint1/carol_range_proof_generate.py
ctfs/AzureAssassinAlliance/2022/crypto/crypto_note/hint1/carol_range_proof_generate.py
from ring_signature import proof_curve, RangeProof, OTRS, serialize2json, proof_H E, G = proof_curve() H = proof_H(E) rp = RangeProof(OTRS(E, G), H) Ct = rp.generate_commitment(__import__('secret').carol_pub[0]) x, r, C = Ct proof = rp.prove(Ct, 256) assert rp.verify(C, 256, proof) with open("range_proof_from_carol.j...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/crypto_note/hint1/bob_signed_generate.py
ctfs/AzureAssassinAlliance/2022/crypto/crypto_note/hint1/bob_signed_generate.py
from json import dump from signed_message_verifier import SM2, get_bob_sign_pub from secret import bob_priv text = 'Bob: Do you remember the 1 token I lent you? Pay off that loan, now!' signer = SM2(public_key=get_bob_sign_pub(), private_key=hex(bob_priv)[2:].zfill(64)) sign = signer.sign_with_sm3(text.encode()) dump...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/crypto/impossible_RSA/server.py
ctfs/AzureAssassinAlliance/2022/crypto/impossible_RSA/server.py
from Crypto.Util.number import * from Crypto.PublicKey import RSA e = 65537 flag = b'ACTF{...}' while True: p = getPrime(1024) q = inverse(e, p) if not isPrime(q): continue n = p * q; public = RSA.construct((n, e)) with open("public.pem", "wb") as file: file.write(public.export...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/AzureAssassinAlliance/2022/web/ToLeSion/src/app.py
ctfs/AzureAssassinAlliance/2022/web/ToLeSion/src/app.py
#!/usr/bin/env python # -*- coding:utf-8 - from flask import Flask, request, redirect from flask_session import Session from io import BytesIO import memcache import pycurl import random import string app = Flask(__name__) app.debug = True app.secret_key = ''.join(random.choice(string.ascii_uppercase + string.digits) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WRECKCTF/2022/rev/hopper/hopper.py
ctfs/WRECKCTF/2022/rev/hopper/hopper.py
#!/usr/local/bin/python import os def do_hop(state): hopper = state['hopper'] line = state['line'] hops = [ (hopper - 4, hopper >= 4), (hopper - 1, hopper % 4 != 0), (hopper + 1, hopper % 4 != 3), (hopper + 4, hopper < 12), ] hoppees = { line[hop]: hop for hop, l...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WRECKCTF/2022/rev/reverser/program.py
ctfs/WRECKCTF/2022/rev/reverser/program.py
#!/usr/local/bin/python import os def check_license(license): characters = set('0123456789abcdef') s = [9] for c in license: if c not in characters: return False s.append((s[-1] + int(c, 16)) % 16) target = '51c49a1a00647b037f5f3d5c878eb656' return ''.join(f'{c:x}' for ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/WRECKCTF/2022/crypto/baby-rsa/challenge.py
ctfs/WRECKCTF/2022/crypto/baby-rsa/challenge.py
import os from Crypto.Util.number import bytes_to_long from Crypto.Util.number import getPrime flag = os.environ.get('FLAG', 'no flag provided...') flag = bytes_to_long(flag.encode()) p = getPrime(1024) q = getPrime(1024) n = p * q e = 65537 c = pow(flag, e, n) print(f'n = {n}') print(f'p = {p}') print(f'c = {c}')
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false