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/Balsn/2023/misc/Matrix/share/config.py | ctfs/Balsn/2023/misc/Matrix/share/config.py | FLAG = b'BALSN{dummy flag}'
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2023/pwn/ASTRAL_StarryNight/sourcecode/APPLET/assembler.py | ctfs/Balsn/2023/pwn/ASTRAL_StarryNight/sourcecode/APPLET/assembler.py | from pwn import *
def aasm(code):
def check(condition):
if not condition:
print(f'invalid argument on line {lnum + 1} : {origLine}')
exit()
def getReg(rs):
if rs == 'pc':
return 4
elif rs == 'lr':
return 5
elif rs == 'inplen':
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2023/pwn/ASTRAL_StarryNight/sourcecode/APPLET/interpreter.py | ctfs/Balsn/2023/pwn/ASTRAL_StarryNight/sourcecode/APPLET/interpreter.py | def interpret(bcode = [], inp = [], storage = []):
PC = 4
LR = 5
INPLEN = 11
CALLER = 12
FLAG = 13
SP = 14
BP = 15
def translateAddr(addr):
idx = addr>>32
offset = addr&0xffffffff
if idx > 4 or offset > 0x1000:
print(f'invalid addr : {hex(addr)}')
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2023/crypto/Many_Time_QKD/const.py | ctfs/Balsn/2023/crypto/Many_Time_QKD/const.py | KEYLEN = 256
SEEDLEN = KEYLEN * 3
THRESHOLD = 0.1
SUCCESS = 0
FAILED = -1 | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2023/crypto/Many_Time_QKD/main.py | ctfs/Balsn/2023/crypto/Many_Time_QKD/main.py | import sys, socket
from protocol import *
from player import *
DESCRIPTION = """
[Many-Time-QKD]
# Description
Alice and Bob are communicating through a noiseless channel, and you task is to steal their secret!
# Hint
When there are n qubits (quantum bits) being transmitted, you can input a string o... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2023/crypto/Many_Time_QKD/quantum.py | ctfs/Balsn/2023/crypto/Many_Time_QKD/quantum.py | import numpy as np
class Qubit(object):
"A (pure) qubit."
def __init__(self, v:list):
assert len(v) == 2
norm = (abs(v[0])**2 + abs(v[1])**2)**0.5
self.v = np.array(v) / norm
def orthogonal(self):
return Qubit(np.conj([self.v[1], -self.v[0]]))
class Basis(object):
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2023/crypto/Many_Time_QKD/protocol.py | ctfs/Balsn/2023/crypto/Many_Time_QKD/protocol.py | from quantum import *
from const import *
class QKD(object):
def __init__(self, p1, p2):
self.p1 = p1
self.p2 = p2
def run(self):
status = FAILED
while status != SUCCESS:
self.p1.init()
self.p2.init()
self.quantum_protocol()
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2023/crypto/Many_Time_QKD/player.py | ctfs/Balsn/2023/crypto/Many_Time_QKD/player.py | import os
import random
import bitstring
from Crypto.Cipher import AES
from quantum import *
from const import *
class Player(object):
def __init__(self, msg=""):
self.seed = bitstring.BitArray(os.urandom(SEEDLEN//8))
self.key = None
self.basis = None
self.msg = msg
def... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2023/crypto/Geometry_Hash/chall.py | ctfs/Balsn/2023/crypto/Geometry_Hash/chall.py | import secrets
from sympy import N, Float, Point, Triangle
from secret import FLAG
PRECISION = 1337
def main():
import signal
signal.alarm(20)
levels = [
lambda x: x.centroid,
lambda x: x.circumcenter,
lambda x: x.incenter,
]
try:
for level in levels:
challenge(level)
print(FLAG)
except:
print(... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2022/pwn/sentinel/share/instanceManager.py | ctfs/Balsn/2022/pwn/sentinel/share/instanceManager.py | #!/usr/bin/python3
import os
import sys
import subprocess
import string
import uuid
import hashlib
import random
###Boilerplate utils
def printError(errMsg):
print(errMsg)
exit()
def myInput(prompt):
'''
python input prompts to stderr by default, and there is no option to change this afaik
this w... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2022/pwn/flag_market/src/backend/backend.py | ctfs/Balsn/2022/pwn/flag_market/src/backend/backend.py | #!/usr/bin/env python3
import os
from datetime import datetime
from flask import Flask, abort, request
def create_app():
app = Flask(__name__)
@app.errorhandler(Exception)
def help(error):
return "Try to buy a flag!\n"
@app.route("/buy_flag", methods=["SPECIAL_METHOD_TO_BUY_FLAG"])
def ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2022/pwn/Want_my_signature/share/main.py | ctfs/Balsn/2022/pwn/Want_my_signature/share/main.py | #!/usr/bin/env python3
import uuid
import os
import shutil
import tarfile
import time
import re
from flask import Flask, render_template, request
from werkzeug.utils import secure_filename
app = Flask(__name__, template_folder='templates')
app.config['MAX_CONTENT_LENGTH'] = 4 * 1000 * 1000
@app.route("/")
def uploa... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2022/rev/Propaganda/run.py | ctfs/Balsn/2022/rev/Propaganda/run.py | import subprocess
flag = b'BALSN{____this__is______not_a_flag_______}'
answer = [9128846476475241493, 7901709191400900973, 9127969212443560833, 8731519357089725617, 4447363623394058601, 616855300804233277]
output = []
for i in range(0, len(flag), 8):
number = int.from_bytes(flag[i:i+8], 'little')
output.appe... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2022/crypto/LFSR/chall.py | ctfs/Balsn/2022/crypto/LFSR/chall.py | from Crypto.Util.number import *
from Crypto.Util.Padding import pad
from Crypto.Cipher import AES
import os
import base64
from hashlib import sha256
from secret import flag
# LFSR template by Cryptanalyse
class StreamCipher:
def __init__(self, key):
assert len(key) == 128, "Error: the key must be of exact... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2022/crypto/Yet_another_RSA_with_hint/chall.py | ctfs/Balsn/2022/crypto/Yet_another_RSA_with_hint/chall.py | from Crypto.Util.number import *
from secret import flag
p = getPrime(512)
q = getPrime(512)
n = p * q
e = 0x10001
c = pow(bytes_to_long(flag), e, n)
def digitsSum(n, base):
ret = 0
while n:
ret += n % base
n //= base
return ret
hint = [digitsSum(p, i) for i in range(2, 200)]
print(f"{n = }")
print(f"{e = }"... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Balsn/2022/crypto/vss/chall.py | ctfs/Balsn/2022/crypto/vss/chall.py | from Crypto.Util.number import *
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
import os
import random
from hashlib import sha256
from secret import FLAG
class ShareScheme:
def __init__(self, key: bytes):
assert len(key) == 128
self.key1 = bytes_to_long(key[:64])
self.ke... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DanteCTF/2023/crypto/Small_Inscription/SmallInscription.py | ctfs/DanteCTF/2023/crypto/Small_Inscription/SmallInscription.py | #!/usr/bin/env python3
from Crypto.Util.number import bytes_to_long, getPrime
from secret import FLAG
assert len(FLAG) < 30
if __name__ == '__main__':
msg = bytes_to_long(
b'There is something reeeally important you should know, the flag is '+FLAG)
N = getPrime(1024)*getPrime(1024)
e = 3
ct... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DanteCTF/2023/crypto/DIY_enc/DIYenc.py | ctfs/DanteCTF/2023/crypto/DIY_enc/DIYenc.py | #!/usr/bin/env python3
import os
from Crypto.Cipher import AES
from base64 import b64encode
from secret import FLAG
assert len(FLAG) == 19
if __name__ == '__main__':
print('Encrypting flag...')
key = os.urandom(16)
nonce = os.urandom(15)
cipher = AES.new(key, AES.MODE_CTR, nonce=nonce)
# lo... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DanteCTF/2023/crypto/PiedPic/PiedPic.py | ctfs/DanteCTF/2023/crypto/PiedPic/PiedPic.py | #!/usr/bin/env python3
from PIL import Image
from Crypto.Random import get_random_bytes
from io import BytesIO
from base64 import b64encode, b64decode
flag_file = "flag.png"
def encrypt_image(image, key):
perm_table = {0: (0, 1, 2), 1: (0, 2, 1), 2: (1, 0, 2), 3: (1, 2, 0), 4: (2, 0, 1), 5: (2, 1, 0)}
size ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DanteCTF/2023/web/CryptoMarket/challenge/flask/run.py | ctfs/DanteCTF/2023/web/CryptoMarket/challenge/flask/run.py | import time
import secrets
from flask import Flask, session, redirect, jsonify, request, make_response
from utils.db_connection import Connector
from utils.renders import render_template
import jwt
from waitress import serve
app = Flask(__name__)
conn = Connector()
cursor = conn.initMySQL()
token_jwt = secrets.token_b... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DanteCTF/2023/web/CryptoMarket/challenge/flask/secrets.py | ctfs/DanteCTF/2023/web/CryptoMarket/challenge/flask/secrets.py | from random import choice
def token_hex(value):
alphabet = 'abcdef0123456789'
return ''.join(choice(alphabet) for _ in range(5))
def token_bytes(value):
alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
return ''.join(choice(alphabet) for _ in range(value)).encode()
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DanteCTF/2023/web/CryptoMarket/challenge/flask/utils/renders.py | ctfs/DanteCTF/2023/web/CryptoMarket/challenge/flask/utils/renders.py | from flask import render_template_string
def __openTemplate(template):
with open('./templates/'+template, "r") as f:
return f.read()
def render_template(template, **kwargs):
temp = __openTemplate(template).format(**kwargs)
return render_template_string(temp, **kwargs) | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DanteCTF/2023/web/CryptoMarket/challenge/flask/utils/db_connection.py | ctfs/DanteCTF/2023/web/CryptoMarket/challenge/flask/utils/db_connection.py | import mysql.connector
import os
import bcrypt
import hashlib
import secrets
class Connector(object):
def __init__(self):
self.host = os.getenv('MYSQL_DATABASE_HOST')
self.user = os.getenv('MYSQL_DATABASE_USER')
self.password = os.getenv('MYSQL_DATABASE_PASSWORD')
self.db = os.gete... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DanteCTF/2023/web/SecureHashedDb/challenge/app/src/run.py | ctfs/DanteCTF/2023/web/SecureHashedDb/challenge/app/src/run.py | from flask import Flask, render_template, request, session, redirect, jsonify, make_response
from flask_mysqldb import MySQL
from utils.db_connection import db_Connection as cnn
from utils.userUtils import userUtils as utl
from serverRequestHandler import serverHandler as server
from waitress import serve
import os
a... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DanteCTF/2023/web/SecureHashedDb/challenge/app/src/serverRequestHandler.py | ctfs/DanteCTF/2023/web/SecureHashedDb/challenge/app/src/serverRequestHandler.py | import requests as r
import base64
import hashlib
import os
class serverHandler:
requestObject = ''
urllocation = ''
def __init__(self):
self.urllocation = f'http://{os.environ["BACKEND_HOST"]}:1717/index.php'
self.requestObject = 'TzoxMToiTUQ1REJFbmdpbmUiOjI6e3M6MjE6IgBNRDVEQkVuZ2luZQBvY... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DanteCTF/2023/web/SecureHashedDb/challenge/app/src/utils/db_connection.py | ctfs/DanteCTF/2023/web/SecureHashedDb/challenge/app/src/utils/db_connection.py | import os
import re
class db_Connection(object):
def __init__(self, app, mysql, utils) -> None:
self.app = app
self.mysql = mysql
self.utils = utils
# MySQL configurations
self.app.config['MYSQL_USER'] = os.getenv('MYSQL_DATABASE_USER')
self.app.config['MYSQL_PASSW... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DanteCTF/2023/web/SecureHashedDb/challenge/app/src/utils/userUtils.py | ctfs/DanteCTF/2023/web/SecureHashedDb/challenge/app/src/utils/userUtils.py | import bcrypt
import jwt
import secrets
class userUtils:
def __init__(self) -> None:
pass
def hash_verifier(self, password, recoveredPassword):
result = False
exception = False
try:
result = bcrypt.checkpw(password.encode(), recoveredPassword.encode())
ex... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/osuigaming/2024/misc/replayflow/model.py | ctfs/osuigaming/2024/misc/replayflow/model.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class ReplayFlow(nn.Module):
def __init__(self, D=8, W=256):
super(ReplayFlow, self).__init__()
self.linears = nn.ModuleList(
# input: (t, x, y)
[nn.Linear(3, W)] +
[nn.Linear(W, W) for _ in range... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/osuigaming/2024/misc/i_hate_anime_girls/server.py | ctfs/osuigaming/2024/misc/i_hate_anime_girls/server.py | #!/usr/local/bin/python
import base64
import sys
import numpy as np
from PIL import Image
import torch
import torch.nn as nn
import torchvision.transforms as T
from torchvision.models import resnet18
model = resnet18()
model.fc = nn.Linear(model.fc.in_features, 1)
model.load_state_dict(torch.load("model.pt"))
resize... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/osuigaming/2024/pwn/osu_v8/server.py | ctfs/osuigaming/2024/pwn/osu_v8/server.py | import sys
import os
sys.stdout.write("script size:\n")
sys.stdout.flush()
size = int(sys.stdin.readline().strip())
if size > 102400:
sys.stdout.write("No way!\n")
sys.stdout.flush()
sys.exit(1)
sys.stdout.write("script:\n")
sys.stdout.flush()
script = sys.stdin.read(size)
with open(sys.argv[1], 'w') as f:... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/osuigaming/2024/crypto/base727/727.py | ctfs/osuigaming/2024/crypto/base727/727.py | import binascii
flag = open('flag.txt').read()
def encode_base_727(string):
base = 727
encoded_value = 0
for char in string:
encoded_value = encoded_value * 256 + ord(char)
encoded_string = ""
while encoded_value > 0:
encoded_string = chr(encoded_value % base) + encoded_string
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/osuigaming/2024/crypto/no_dorchadas/server.py | ctfs/osuigaming/2024/crypto/no_dorchadas/server.py | from hashlib import md5
from secret import flag, secret_slider
from base64 import b64encode, b64decode
assert len(secret_slider) == 244
dorchadas_slider = b"0,328,33297,6,0,B|48:323|61:274|61:274|45:207|45:207|63:169|103:169|103:169|249:199|249:199|215:214|205:254,1,450.000017166138,6|6,1:1|2:1,0:0:0:0:"
def sign(bea... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/osuigaming/2024/crypto/korean_offline_mafia/server.py | ctfs/osuigaming/2024/crypto/korean_offline_mafia/server.py | from topsecret import n, secret_ids, flag
import math, random
assert all([math.gcd(num, n) == 1 for num in secret_ids])
assert len(secret_ids) == 32
vs = [pow(num, 2, n) for num in secret_ids]
print('n =', n)
print('vs =', vs)
correct = 0
for _ in range(1000):
x = int(input('Pick a random r, give me x = r^2 (mod n... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/osuigaming/2024/crypto/wysi_prime/script.py | ctfs/osuigaming/2024/crypto/wysi_prime/script.py | from Crypto.Util.number import isPrime, bytes_to_long
import random
import os
def getWYSIprime():
while True:
digits = [random.choice("727") for _ in range(272)]
prime = int("".join(digits))
if isPrime(prime):
return prime
# RSA encryption using the WYSI primes
p = getWYSIprime... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/osuigaming/2024/crypto/lucky_roll_gaming/script.py | ctfs/osuigaming/2024/crypto/lucky_roll_gaming/script.py | from Crypto.Util.number import getPrime # https://pypi.org/project/pycryptodome/
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
from random import randrange
from math import floor
def lcg(s, a, b, p):
return (a * s + b) % p
p = getPrime(floor(72.7))
a = randrange(0, p)
b = randrange(0, p)
seed ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/osuigaming/2024/crypto/secret_map/enc.py | ctfs/osuigaming/2024/crypto/secret_map/enc.py | import os
xor_key = os.urandom(16)
with open("flag.osu", 'rb') as f:
plaintext = f.read()
encrypted_data = bytes([plaintext[i] ^ xor_key[i % len(xor_key)] for i in range(len(plaintext))])
with open("flag.osu.enc", 'wb') as f:
f.write(encrypted_data)
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/wtf/2021/crypto/Pr4nK/3ncrypt.py | ctfs/wtf/2021/crypto/Pr4nK/3ncrypt.py | import binascii
import random
flag = ""
fl = int(binascii.hexlify(flag), 16)
p = 1 << 1024
b = random.randint(0, p) | 1
s = random.randint(0, p)
x = pow(b, s, p)
print('p: {}'.format(p))
print('b: {}'.format(b))
print('x: {}'.format(x))
y = int(input('y: '))
z = pow(y, s, p)
Message = fl ^ z
print('Message: {}'.f... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/wtf/2021/crypto/H4ck3r_Vs_C0d3r/encr3pt.py | ctfs/wtf/2021/crypto/H4ck3r_Vs_C0d3r/encr3pt.py | from PIL import Image, ImageDraw
import os
import sys
from random import SystemRandom
random = SystemRandom()
xrange = range
I3 = Image.open
if len(sys.argv) != 2:
exit()
fl = str(sys.argv[1])
O1 = os.path.isfile
O2 = os.path.splitext
if not O1(fl):
exit()
i = I3(fl)
f, e = O2(fl)
O_A = f+"_A.png"
O_B =... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/wtf/2022/rev/A_Tale_of_code/briefcase.py | ctfs/wtf/2022/rev/A_Tale_of_code/briefcase.py | import hashlib
def flagify(f):
fl = str(int(f)**5)
l1 = list(fl)
l2 = [115, 110, 102, 60, 75, 69, 114, 112, 51, 43, 87, 50, 91, 89, 43, 106, 94, 47, 43, 49, 44, 122]
flag = []
for i in range(len(l1)):
flag.append(chr(int(l1[i])+l2[i]))
return "".join(flag)
code = input("Enter the code:... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/wtf/2022/crypto/pixels/encrypt.py | ctfs/wtf/2022/crypto/pixels/encrypt.py | from PIL import Image
im = Image.open("flag.png")
col,row = im.size
pix = im.load()
key = ''
k = []
for i in key:
k.append(ord(i))
enc = Image.new(im.mode,im.size)
out = enc.load()
for i in range(col):
for j in range(row):
ca = (k[0] + k[1]*i) % col
ra = (k[2] + k[3]*j) % row
out[... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/misc/ml_project/encode.py | ctfs/TJCTF/2024/misc/ml_project/encode.py | import torch
flag = open("flag.txt").read().strip()
class Model(torch.nn.Module):
def __init__(self):
super().__init__()
self.f1 = torch.nn.Linear(len(flag), 22)
self.relu = torch.nn.ReLU()
self.f2 = torch.nn.Linear(22, 18)
def forward(self, x):
x = self.relu(self.f1(x... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/misc/roundabout/enc.py | ctfs/TJCTF/2024/misc/roundabout/enc.py | import dataclasses
import re
import secrets
import sys
from pyrage import passphrase # type: ignore
args = sys.argv[1:]
def make_password(num_words):
text = open("amontillado.txt").read()
words = list(set(re.sub("[^a-z]", " ", text.lower()).split()))
return "".join(secrets.choice(words) for _ in range(n... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/misc/golf_harder/golf.py | ctfs/TJCTF/2024/misc/golf_harder/golf.py | #!/usr/local/bin/python3.11
import regex # le duh
import os
import tomllib
from tabulate import tabulate
from importlib import import_module
from itertools import zip_longest as zp
def check_regex(pattern, matches, nonmatches):
try:
re = regex.compile(pattern, flags=regex.V1)
except:
print("... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/misc/golf_hard/golf.py | ctfs/TJCTF/2024/misc/golf_hard/golf.py | #!/usr/local/bin/python3.11
import regex # le duh
import os
import tomllib
from tabulate import tabulate
from importlib import import_module
from itertools import zip_longest as zp
def check_regex(pattern, matches, nonmatches):
try:
re = regex.compile(pattern, flags=regex.V1)
except:
print("... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/rev/pseudo_brainrot/encode.py | ctfs/TJCTF/2024/rev/pseudo_brainrot/encode.py | from PIL import Image
import random
random.seed(42)
lmao = random.randint(12345678,123456789)
random.seed(lmao)
img = Image.open("skibidi.png")
width, height = img.size
flag = open("flag.txt", "rb").read()
st = ""
for i in bytearray(flag):
tmp = bin(i)[2:]
while(len(tmp))<8:
tmp = "0"+tmp
st... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/rev/cagnus_marlsen/endgamemaker.py | ctfs/TJCTF/2024/rev/cagnus_marlsen/endgamemaker.py | import tkinter
global root, myCanvas
root = tkinter.Tk()
myCanvas = tkinter.Canvas(root, bg="white", height=320, width=320)
turn = 0
grid = [0]*64
def selectWhite():
global turn
turn = 1
L3.config(text="Filling white")
def selectBlack():
global turn
turn = 0
L3.config(text="Filling black")
d... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/crypto/hulksmash/main.py | ctfs/TJCTF/2024/crypto/hulksmash/main.py | from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
key = open("key.txt", "rb").read().strip()
flag = pad(open("flag.txt", "rb").read(), 16)
cipher = AES.new(key, AES.MODE_ECB)
open("output.txt", "w+").write(cipher.encrypt(flag).hex())
| python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/crypto/weird_crypto/a.py | ctfs/TJCTF/2024/crypto/weird_crypto/a.py | from math import lcm
from Crypto.Util.number import bytes_to_long, getPrime
with open('flag.txt', 'rb') as f:
flag = bytes_to_long(f.read().strip())
oops = getPrime(20)
p1 = getPrime(512)
p2 = getPrime(512)
haha = (p1-1)*(p2-1)
crazy_number = pow(oops, -1, haha)
discord_mod = p1 * p2
hehe_secret = pow(flag, craz... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/crypto/alkane/main.py | ctfs/TJCTF/2024/crypto/alkane/main.py | schedule = [[117, 30, 102, 114, 82, 127, 125, 85, 59, 122, 117, 107, 29, 103, 27, 120, 26, 26, 80, 7, 39, 74, 88, 47, 30, 62, 100, 113, 62, 13, 1, 50, 6, 1, 41, 91, 42, 79, 20, 70, 41, 62, 38, 114, 111, 113, 123, 93, 62, 117, 17, 75, 73, 46, 109, 112, 119, 2, 109, 95, 113, 88, 27, 63], [44, 1, 36, 119, 73, 7, 121, 62, ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | true |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/crypto/accountleak/server.py | ctfs/TJCTF/2024/crypto/accountleak/server.py | #!/usr/local/bin/python3.10 -u
import time
from Crypto.Util.number import getPrime, getRandomInteger, getRandomNBitInteger
flag = open("flag.txt").read().strip()
p = getPrime(512)
q = getPrime(512)
sub = getRandomInteger(20)
# hehe u cant guess it since its random :P
my_password = getRandomNBitInteger(256)
n = p*q... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/crypto/iodomethane/main.py | ctfs/TJCTF/2024/crypto/iodomethane/main.py | import secrets
flag = open("flag.txt", "r").read().strip()
print(flag)
matrix = [[],[],[]]
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0192834756{}_!@#$%^&*()"
modulus = 15106021798142166691 #len(alphabet)
flag = [alphabet.index(a) for a in flag]
while len(flag) % 3 != 0:
flag.append(sec... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/crypto/lightweight_crypto_guard_system/encode.py | ctfs/TJCTF/2024/crypto/lightweight_crypto_guard_system/encode.py | #!/usr/local/bin/python3.10 -u
from Crypto.Util.number import *
import random
a = getRandomNBitInteger(30)
c = getRandomNBitInteger(15)
m = getPrime(32)
x0 = getRandomNBitInteger(30)
n = random.randint(2**8, 2**10)
flag = open("flag.txt").read().strip()
class Random():
global m, a, c
def __init__(self, x0... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/crypto/tetraethyllead/server.py | ctfs/TJCTF/2024/crypto/tetraethyllead/server.py | #!/usr/local/bin/python3 -u
import secrets
import hashlib
from Crypto.Util.number import bytes_to_long, long_to_bytes
def rrot(word, i):
i %= 32
word = word & ((1 << 32) - 1)
return ((word >> i) | (word << (32 - i))) & ((1 << 32) - 1)
def lrot(word, i):
i %= 32
word = word & ((1 << 32) - 1)
r... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/web/topplecontainer/app.py | ctfs/TJCTF/2024/web/topplecontainer/app.py | from flask import Flask, request, render_template, redirect, make_response, send_file
import uuid
import jwt
from functools import wraps
from datetime import datetime
import os
import json
MAX_SIZE_MB = 0.5
KID = "8c2088dfb37658e01b35aec916b3b085c3cafd5fbf03bbb2735d3f8e63defd6b"
app = Flask(__name__)
app.static_folde... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2024/web/templater/app.py | ctfs/TJCTF/2024/web/templater/app.py | from flask import Flask, request, redirect
import re
app = Flask(__name__)
flag = open('flag.txt').read().strip()
template_keys = {
'flag': flag,
'title': 'my website',
'content': 'Hello, {{name}}!',
'name': 'player'
}
index_page = open('index.html').read()
@app.route('/')
def index_route():
re... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2023/pwn/painter/app.py | ctfs/TJCTF/2023/pwn/painter/app.py | from flask import Flask, render_template, redirect, request
from uuid import uuid4
app = Flask(__name__)
images = {}
@app.route('/')
def index():
return render_template('index.html')
@app.route('/save', methods=['POST'])
def post_image():
img, name = request.json['img'], request.json['name']
id = uuid... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2023/rev/save-trees/server.py | ctfs/TJCTF/2023/rev/save-trees/server.py | #!/usr/local/bin/python3.10 -u
import ast
import sys
import select
from Crypto.Util.number import bytes_to_long
import hashlib
import random
def set_globals():
global edge_lst, cnt, threshold, vals, key, lvs
edge_lst = []
cnt, threshold = 0, 128
vals = [0 for _ in range(threshold*16)]
key = (byt... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2023/rev/scramble/chal.py | ctfs/TJCTF/2023/rev/scramble/chal.py | #first 3 lines are given
import random
seed = 1000
random.seed(seed)
#unscramble the rest
def recur(lst):
l2[i] = (l[i]*5+(l2[i]+n)*l[i])%l[i]
l2[i] += inp[i]
flag = ""
flag+=chr((l4[i]^l3[i]))
return flag
l.append(random.randint(6, 420))
l3[0] = l2[0]%mod
for i in range(1, n):
def decrypt(inp):
for i in range(n):
ass... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2023/rev/div3rev/chal.py | ctfs/TJCTF/2023/rev/div3rev/chal.py | def op1(b):
for i in range(len(b)):
b[i] += 8*(((b[i] % 10)*b[i]+75) & 1)
cur = 1
for j in range(420):
cur *= (b[i]+j) % 420
return b
def op2(b):
for i in range(len(b)):
for j in range(100):
b[i] = b[i] ^ 69
b[i] += 12
return b
def op3(... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2023/crypto/merky-hell/merky-hell.py | ctfs/TJCTF/2023/crypto/merky-hell/merky-hell.py | from math import gcd
import secrets
from Crypto.Util.number import *
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
n = 48
with open('flag.txt', 'rb') as f:
flag = f.read()
def randint(a, b):
return int(secrets.randbelow(int(b-a + 1)) + a)
def makeKey():
W = []
s = 0
for i i... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2023/crypto/iheartrsa/iheartrsa.py | ctfs/TJCTF/2023/crypto/iheartrsa/iheartrsa.py | #!/usr/local/bin/python3.10 -u
import ast
import sys
import select
from Crypto.Util import number
import hashlib
with open('flag.txt') as f:
flag = f.readline()
raw_bin = str(
bin(int('0x'+str(hashlib.sha256(flag.encode('utf-8')).hexdigest()), 16))[2:])
hsh = int('0b1' + '0' * (256 - len(raw_bin)) + raw_bin... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2023/crypto/keysmith/server.py | ctfs/TJCTF/2023/crypto/keysmith/server.py | #!/usr/local/bin/python3.10 -u
from Crypto.Util.number import getPrime
flag = open("flag.txt", "r").read()
po = getPrime(512)
qo = getPrime(512)
no = po * qo
eo = 65537
msg = 762408622718930247757588326597223097891551978575999925580833
s = pow(msg,eo,no)
print(msg,"\n",s)
try:
p = int(input("P:"))
q = int(i... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2023/crypto/squishy/rsa.py | ctfs/TJCTF/2023/crypto/squishy/rsa.py | #!/usr/local/bin/python3.10 -u
import sys
import select
from Crypto.Util.number import bytes_to_long, getPrime
def input_with_timeout(prompt, timeout=10):
sys.stdout.write(prompt)
sys.stdout.flush()
ready, _, _ = select.select([sys.stdin], [], [], timeout)
if ready:
return sys.stdin.buffer.re... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2023/crypto/drm-1/app.py | ctfs/TJCTF/2023/crypto/drm-1/app.py | from flask import Flask
import time
from Crypto.Hash import SHA256
app = Flask(__name__)
hash_key = open("hash_key", "rb").read()[:32]
flag = open("flag.txt", "r").read().strip()
@app.route('/buy/<user>')
def buy(user):
return "No"
@app.route('/song/<user>')
def song(user):
return open("user/"+user+".drms... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2023/web/back-to-the-past/jwt.py | ctfs/TJCTF/2023/web/back-to-the-past/jwt.py | import base64
import json
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization, hashes, hmac
from cryptography.hazmat.primitives.asymmetric import padding
possible_algorithms = ["HS256", "RS256"]
def base64url_encode(value):
return base64.urlsafe_b64e... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2023/web/back-to-the-past/app.py | ctfs/TJCTF/2023/web/back-to-the-past/app.py | from flask import Flask, request, render_template, redirect, make_response
import uuid
import random
import jwt
import secrets
from functools import wraps
u2id = {}
u2year = {}
app = Flask(__name__)
app.static_folder = "static"
flag = open("flag.txt", "r").read()
def login_required():
def _login_required(f):
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2023/web/swill-squill/app.py | ctfs/TJCTF/2023/web/swill-squill/app.py | import html
from flask import Flask, request, render_template, redirect, make_response
import sqlite3
import jwt
import secrets
from functools import wraps
app = Flask(__name__)
app.static_folder = 'static'
flag = open('flag.txt', 'r').read()
def login_required():
def _login_required(f):
@wraps(f)
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2023/web/outdated/app.py | ctfs/TJCTF/2023/web/outdated/app.py | from flask import Flask, request, render_template, redirect
from ast import parse
import re
import subprocess
import uuid
app = Flask(__name__)
app.static_folder = 'static'
app.config['UPLOAD_FOLDER'] = './uploads'
@app.route('/')
def index():
return render_template('home.html')
@app.route('/upload')
def upload(... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2023/web/pay-to-win/app.py | ctfs/TJCTF/2023/web/pay-to-win/app.py | from flask import Flask, request, render_template, redirect, make_response
from base64 import b64encode, b64decode
import hashlib
import random
import json
app = Flask(__name__)
users = {}
def hash(data):
return hashlib.sha256(bytes(data, 'utf-8')).hexdigest()
@app.route('/')
def index():
if request.cookie... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/misc/guess_my_number/chall.py | ctfs/TJCTF/2025/misc/guess_my_number/chall.py | #!/usr/local/bin/python
import random
flag = open("flag.txt").read().strip()
r = random.randint(1, 1000)
guessed = False
for i in range(10):
guess = int(input("Guess a number from 1 to 1000: "))
if guess > r:
print("Too high")
elif guess < r:
print("Too low")
else:
guessed = Tru... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/misc/golf_hardester/golf.py | ctfs/TJCTF/2025/misc/golf_hardester/golf.py | #!/usr/local/bin/python3.11
import regex # le duh
import os
import tomllib
from tabulate import tabulate
from importlib import import_module
from itertools import zip_longest as zp
def check_regex(pattern, matches, nonmatches):
try:
re = regex.compile(pattern, flags=regex.V1)
except:
print("... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/misc/make_groups/calc.py | ctfs/TJCTF/2025/misc/make_groups/calc.py | f = [x.strip() for x in open("chall.txt").read().split('\n')]
n = int(f[0])
a = list(map(int, f[1].split()))
m = 998244353
def factorial(n):
if n==0: return 1
if n==1: return 1
return n * factorial(n-1)
def choose(n, r):
return (factorial(n) // (factorial(r) * factorial(n-r))) % m
ans = 1
for x in a:... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/rev/rubix_cube/rubixcube.py | ctfs/TJCTF/2025/rev/rubix_cube/rubixcube.py | import copy
import random
import numpy as np
class RubiksCube:
def __init__(self):
self.faces = {
'U': [['⬜'] * 3 for _ in range(3)],
'L': [['🟧'] * 3 for _ in range(3)],
'F': [['🟩'] * 3 for _ in range(3)],
'R': [['🟥'] * 3 for _ in range(3)],
'B... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/rev/artifact/main.py | ctfs/TJCTF/2025/rev/artifact/main.py | import sys
from time import perf_counter
from math import pi,sqrt,asin,degrees,radians,sin
circ = 24901
diam = (circ / (2 * pi)) ** 2
rad = sqrt(diam)
spin = 1000
def add_spin(points,time):
ang = time / circ * 360
for i in range(len(points)):
nang = find_ang(points[i]) + ang
points[i] = sin(r... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/crypto/seeds/main.py | ctfs/TJCTF/2025/crypto/seeds/main.py | #!/usr/local/bin/python3.10 -u
import time, sys, select
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
class RandomGenerator:
def __init__(self, seed = None, modulus = 2 ** 32, multiplier = 157, increment = 1):
if seed is None:
seed = time.asctime()
if type(seed) is... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/crypto/theartofwar/main.py | ctfs/TJCTF/2025/crypto/theartofwar/main.py | from Crypto.Util.number import bytes_to_long, getPrime, long_to_bytes
import time
flag = open('flag.txt', 'rb').read()
m = bytes_to_long(flag)
e = getPrime(8)
print(f'e = {e}')
def generate_key():
p, q = getPrime(256), getPrime(256)
while (p - 1) % e == 0:
p = getPrime(256)
while (q - 1) % e == ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/crypto/pseudo_secure/server.py | ctfs/TJCTF/2025/crypto/pseudo_secure/server.py | #!/usr/local/bin/python
import random
import base64
import sys
import select
class User:
def __init__(self, username):
self.username = username
self.key = self.get_key()
self.message = None
def get_key(self):
username = self.username
num_bits = 8 * len(username)
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/crypto/bacon_bits/enc.py | ctfs/TJCTF/2025/crypto/bacon_bits/enc.py | with open('flag.txt') as f: flag = f.read().strip()
with open('text.txt') as t: text = t.read().strip()
baconian = {
'a': '00000', 'b': '00001',
'c': '00010', 'd': '00011',
'e': '00100', 'f': '00101',
'g': '00110', 'h': '00111',
'i': '01000', 'j': '01000',
'k': '01001', 'l': '01010',
'm': '01011', 'n': '01100... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/crypto/double_trouble/enc.py | ctfs/TJCTF/2025/crypto/double_trouble/enc.py | from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
import random
def gen():
myrandom = random.Random(42)
k1 = myrandom.randbytes(8)
choices = list(myrandom.randbytes(6))
k2 = b''
for _ in range(8):
k2 += bytes([choices[random.randint(0, 3)]])
return k1, k2
def enc(data, ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/crypto/close_secrets/encrypt.py | ctfs/TJCTF/2025/crypto/close_secrets/encrypt.py | import random
from random import randint
import sys
from Crypto.Util import number
import hashlib
def encrypt_outer(plaintext_ords, key):
cipher = []
key_offset = key % 256
for val in plaintext_ords:
if not isinstance(val, int):
raise TypeError
cipher.append((val + key_offset) ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/crypto/dotdotdotv2/encode.py | ctfs/TJCTF/2025/crypto/dotdotdotv2/encode.py | import numpy as np
import random
import sys
sys.stdin = open("flag.txt", "r")
sys.stdout = open("encoded.txt", "w")
n = 64
filler = "In cybersecurity, a CTF (Capture The Flag) challenge is a competitive, gamified event where participants, either individually or in teams, are tasked with finding and exploiting vulner... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/crypto/alchemist_recipe/chall.py | ctfs/TJCTF/2025/crypto/alchemist_recipe/chall.py | import hashlib
SNEEZE_FORK = "AurumPotabileEtChymicumSecretum"
WUMBLE_BAG = 8
def glorbulate_sprockets_for_bamboozle(blorbo):
zing = {}
yarp = hashlib.sha256(blorbo.encode()).digest()
zing['flibber'] = list(yarp[:WUMBLE_BAG])
zing['twizzle'] = list(yarp[WUMBLE_BAG:WUMBLE_BAG+16])
glimbo = list(y... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/forensic/album_cover/enc.py | ctfs/TJCTF/2025/forensic/album_cover/enc.py | import wave
from PIL import Image
import numpy as np
#sample_rate = 44100
with wave.open('flag.wav', 'rb') as w:
frames = np.frombuffer(w.readframes(w.getnframes()), dtype=np.int16)
print(w.getnframes())
sampwidth = w.getsampwidth() # 2
nchannels = w.getnchannels() # 1
w.close()
arr = np.array(frame... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2025/web/double_nested/app.py | ctfs/TJCTF/2025/web/double_nested/app.py | from flask import Flask, render_template, request
import re
app = Flask(__name__)
@app.route('/')
def index():
i=request.args.get("i", "double-nested")
return render_template("index.html", i=sanitize(i))
def sanitize(input):
input = re.sub(r"^(.*?=){,3}", "", input)
forbidden = ["script", "http://", ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2022/crypto/cipher-master/cipher.py | ctfs/TJCTF/2022/crypto/cipher-master/cipher.py | from typing import List
import os
sbox1 = [37, 9, 32, 12, 17, 41, 57, 47, 24, 36, 10, 44, 29, 18, 53, 38, 23, 14, 3, 61, 45, 62, 13, 46, 8, 5, 52, 63, 30, 4, 55, 28, 31, 11, 25, 0, 16, 35, 19, 22, 54, 59, 40, 42, 43, 6, 15, 33, 20, 50, 56, 26, 51, 34, 48, 49, 39, 27, 7, 1, 58, 60, 2, 21]
sbox2 = [4, 1, 51, 27, 53, 10,... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2022/crypto/mac-master/server.py | ctfs/TJCTF/2022/crypto/mac-master/server.py | #!/usr/local/bin/python -u
import hashlib
import os
with open("flag.txt") as f:
FLAG = f.read()
QUERIED = set()
KEY = os.urandom(16)
print("Introducing Neil-MAC (NMAC), the future of hash-based message")
print("authentication codes!")
print()
print("No longer susceptible to those pesky length extension attacks!"... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2022/crypto/merkle-master/server.py | ctfs/TJCTF/2022/crypto/merkle-master/server.py | #!/usr/local/bin/python -u
import hashlib
import json
import random
import string
import sys
import os
with open("flag.txt") as f:
FLAG = f.read()
N = 50
M = 1000
print("It's time for a challenge!")
print()
print("I want you to produce a sorted Merkle tree commitment for me: however,")
print("there's a catch. T... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2022/crypto/factor-master/server.py | ctfs/TJCTF/2022/crypto/factor-master/server.py | #!/usr/local/bin/python -u
from Crypto.Util.number import getPrime, isPrime, getRandomInteger
import sys, random
print("Are you truly the master here?")
print()
print("We'll have to find out...")
print()
def fail():
print("You are not the master!")
sys.exit(1)
def challenge1():
p = getPrime(44)
q = ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2022/crypto/copper-master/server.py | ctfs/TJCTF/2022/crypto/copper-master/server.py | #!/usr/local/bin/python -u
from Crypto.Util.number import *
import os
N = 768
e = 3
p = 1
while GCD(e, p - 1) != 1:
p = getPrime(N)
q = 1
while GCD(e, q - 1) != 1:
q = getPrime(N)
n = p * q
d = pow(e, -1, (p - 1) * (q - 1))
def pad(m, n_bits):
# otherwise recovering the message will be a bit of a pai... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2022/crypto/7sckp/server.py | ctfs/TJCTF/2022/crypto/7sckp/server.py | #!/usr/local/bin/python -u
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
import random
from time import time
key = get_random_bytes(16)
flag = open('flag.txt', 'rb').read().strip()
def pad(msg, block_size):
random.seed(seed)
p = b''
pad_len = block_size - (len(msg) % block_siz... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2022/crypto/morph-master/server.py | ctfs/TJCTF/2022/crypto/morph-master/server.py | #!/usr/local/bin/python -u
from Crypto.Util.number import *
N = 1024
p = getPrime(N)
q = getPrime(N)
assert GCD(p * q, (p - 1) * (q - 1)) == 1
n = p * q
s = n ** 2
λ = (p - 1) * (q - 1) // GCD(p - 1, q - 1)
g = getRandomRange(1, s)
L = lambda x : (x - 1) // n
μ = pow(L(pow(g, λ, s)), -1, n)
def encrypt(m):
r = ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2022/web/fleecebook/db.py | ctfs/TJCTF/2022/web/fleecebook/db.py | import sqlite3
from uuid import uuid4
from pathlib import Path
path = Path(__file__).resolve().parent / 'database/db.sqlite3'
def conn_db():
conn = sqlite3.connect(path, check_same_thread=False)
cur = conn.cursor()
return (conn, cur)
if __name__ == '__main__':
path.parent.mkdir(parents=True, exist_... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TJCTF/2022/web/fleecebook/app.py | ctfs/TJCTF/2022/web/fleecebook/app.py | from flask import Flask, request, render_template, render_template_string, redirect, send_from_directory
from db import conn_db
from uuid import uuid4
conn, cur = conn_db()
app = Flask(__name__, static_url_path='')
@app.route('/static/<path:path>')
def static_file(path):
return send_from_directory('static', pat... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/SuSeC/2020/jailbreak/server.py | ctfs/SuSeC/2020/jailbreak/server.py | #!/usr/bin/env python
import ctypes
# We use external library because built-in functions are deleted
# and default 're' will no longer work.
# - https://github.com/kokke/tiny-regex-c
libregex = ctypes.CDLL('./libregex.so')
match = libregex.re_match
match.restype = ctypes.c_int
match.argtypes = [ctypes.c_char_p, ctype... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Hayyim/2022/pwn/AuViel/share/wrapper.py | ctfs/Hayyim/2022/pwn/AuViel/share/wrapper.py | #!/usr/bin/env python3
import os
import sys
import tempfile
def print(s):
sys.stdout.write(s)
sys.stdout.flush()
print("The number of files (max 3): ")
try:
count = int(sys.stdin.readline().strip())
except:
print("invalid input\n")
exit()
if count > 3 or count <= 0:
print("invalid input\n")... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Bucket/2023/crypto/Search-2/search_2_generator.py | ctfs/Bucket/2023/crypto/Search-2/search_2_generator.py | from Crypto.Util.number import getPrime, inverse, bytes_to_long, isPrime
from string import ascii_letters, digits
from random import choice
p = bytes_to_long(open("flag.txt", "rb").read())
m = 0
while not isPrime(p):
p += 1
m += 1
q = getPrime(len(bin(p)))
n = p * q
e = 65537
l = (p-1)*(q-1)
d = inverse(e, l)
... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Bucket/2023/crypto/Search-1/search_1_generator.py | ctfs/Bucket/2023/crypto/Search-1/search_1_generator.py | from Crypto.Util.number import getPrime, inverse, bytes_to_long
from string import ascii_letters, digits
from random import choice
m = open("flag.txt", "rb").read()
p = getPrime(128)
q = getPrime(128)
n = p * q
e = 65537
l = (p-1)*(q-1)
d = inverse(e, l)
m = pow(bytes_to_long(m), e, n)
print(m)
print(n)
leak = (p-2)*... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Bucket/2023/crypto/PsychologyRandom/encoder.py | ctfs/Bucket/2023/crypto/PsychologyRandom/encoder.py | seedKey = [] # set of 4 human random numbers between 0 and 255 inclusive
addKey = humanRandomGenerator(1,10) # human random number between 1 and 10 inclusive
for i in range(4):
seedKey.append(humanRandomGenerator(0, 255))
with open("flag.txt", "rb") as f:
flag = f.read()
encryptedFlag = bytearray()
for i in ... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Bucket/2023/crypto/Search-0/search_0_generator.py | ctfs/Bucket/2023/crypto/Search-0/search_0_generator.py | from Crypto.Util.number import getPrime, inverse, bytes_to_long
from string import ascii_letters, digits
from random import choice
m = open("flag.txt", "rb").read()
p = getPrime(128)
q = getPrime(128)
n = p * q
e = 65537
l = (p-1)*(q-1)
d = inverse(e, l)
m = pow(bytes_to_long(m), e, n)
print(m)
print(n)
p = "{0:b}".... | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
sajjadium/ctf-archives | https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Bucket/2023/crypto/Search-3/search_3_generator.py | ctfs/Bucket/2023/crypto/Search-3/search_3_generator.py | from Crypto.Util.number import getPrime, inverse, bytes_to_long, isPrime
from string import ascii_letters, digits
from random import choice
m = bytes_to_long(open("flag.txt", "rb").read())
p = getPrime(128)
q = getPrime(128)
n = p * p
e = 65537
l = (p-1)*(p-1)
d = inverse(e, l)
m = pow(m, e, n)
print(m)
print(n) | python | MIT | 129a3a9fe604443211fa4d493a49630c30689df7 | 2026-01-05T01:34:13.869332Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.