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/DownUnderCTF/2023/crypto/hhhhh/hhhhh.py
ctfs/DownUnderCTF/2023/crypto/hhhhh/hhhhh.py
#!/usr/bin/env python3 from os import getenv as hhhhhhh from hashlib import md5 as hhhhh def hhhhhh(hhh): h = hhhhh() hh = bytes([0] * 16) for hhhh in hhh: h.update(bytes([hhhh])) hh = bytes([hhhhhhh ^ hhhhhhhh for hhhhhhh, hhhhhhhh in zip(hh, h.digest())]) return hh print('hhh hhh hhh...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/complementary/complementary.py
ctfs/DownUnderCTF/2023/crypto/complementary/complementary.py
flag = open('./flag.txt', 'rb').read().strip() m1 = int.from_bytes(flag[:len(flag)//2]) m2 = int.from_bytes(flag[len(flag)//2:]) n = m1 * m2 print(n)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/apbq_rsa_ii/apbq-rsa-ii.py
ctfs/DownUnderCTF/2023/crypto/apbq_rsa_ii/apbq-rsa-ii.py
from Crypto.Util.number import getPrime, bytes_to_long from random import randint p = getPrime(1024) q = getPrime(1024) n = p * q e = 0x10001 hints = [] for _ in range(3): a, b = randint(0, 2**312), randint(0, 2**312) hints.append(a * p + b * q) FLAG = open('flag.txt', 'rb').read().strip() c = pow(bytes_to_l...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/encrypted_mail/crypto.py
ctfs/DownUnderCTF/2023/crypto/encrypted_mail/crypto.py
import hashlib, secrets, random from gmpy2 import powmod # faster than pow() pow = lambda a, b, c: int(powmod(a, b, c)) g = 3 p = 14670369266027569336674932500849620716463328273662826844368368921998778319905860341355750895821950519350637430769511014383282484107857082780306911477632963673038747122470632072818906606817...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/encrypted_mail/bot_users.py
ctfs/DownUnderCTF/2023/crypto/encrypted_mail/bot_users.py
from crypto import g, p, Messenger from secrets import randbelow import os class Bots: def __init__(self, db): self.db = db def setup(self): self.admin_privkey = randbelow(p) self.flag_haver_privkey = randbelow(p) self.admin_pubkey = pow(g, self.admin_privkey, p) self...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/encrypted_mail/db.py
ctfs/DownUnderCTF/2023/crypto/encrypted_mail/db.py
from collections import defaultdict from time import time class Database: def __init__(self): self.users = {} self.inboxes = defaultdict(list) self.current_user = None def add_user(self, username, pubkey): self.users[username] = pubkey def user_exists(self, username): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/encrypted_mail/server.py
ctfs/DownUnderCTF/2023/crypto/encrypted_mail/server.py
#!/usr/bin/env python3 from collections import defaultdict import os, time, re from db import Database from bot_users import Bots from crypto import Authenticator, Encryptor, p def menu(): print('[R]egister') print('[L]ogin') print('[S]end message') print('[V]iew inbox') return input('> ')[0].lo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/handshake/generate.py
ctfs/DownUnderCTF/2023/crypto/handshake/generate.py
from Crypto.PublicKey import ECC from Crypto.Signature import DSS from Crypto.Hash import SHA256 def get_signed_certificate(subject_name, pubkey, ca_privkey): signer = DSS.new(ca_privkey, 'fips-186-3') tbs = f'SUBJECT={subject_name}\n{pubkey.export_key(format="PEM")}' signature = signer.sign(SHA256.new(tbs...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/handshake/server.py
ctfs/DownUnderCTF/2023/crypto/handshake/server.py
#!/usr/bin/env python3 from Crypto.PublicKey import ECC from Crypto.Signature import DSS from Crypto.Protocol.KDF import HKDF from Crypto.Hash import SHA256 from Crypto.Cipher import AES from Crypto.Util.Padding import pad from Crypto.Util.number import long_to_bytes import os cwd = os.path.dirname(__file__) ca_pubke...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/fnv/fnv.py
ctfs/DownUnderCTF/2023/crypto/fnv/fnv.py
#!/usr/bin/env python3 import os def fnv1(s): h = 0xcbf29ce484222325 for b in s: h *= 0x00000100000001b3 h &= 0xffffffffffffffff h ^= b return h TARGET = 0x1337133713371337 print("Welcome to FNV!") print(f"Please enter a string in hex that hashes to 0x{TARGET:016x}:") s = bytearray.fromhex(input()) if fnv1...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/flag_art/flag-art.py
ctfs/DownUnderCTF/2023/crypto/flag_art/flag-art.py
message = open('./message.txt', 'rb').read() + open('./flag.txt', 'rb').read() palette = '.=w-o^*' template = list(open('./mask.txt', 'r').read()) canvas = '' for c in message: for m in [2, 3, 5, 7]: while True: t = template.pop(0) if t == 'X': canvas += palette[c %...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/apbq_rsa_i/apbq-rsa-i.py
ctfs/DownUnderCTF/2023/crypto/apbq_rsa_i/apbq-rsa-i.py
from Crypto.Util.number import getPrime, bytes_to_long from random import randint p = getPrime(1024) q = getPrime(1024) n = p * q e = 0x10001 hints = [] for _ in range(2): a, b = randint(0, 2**12), randint(0, 2**312) hints.append(a * p + b * q) FLAG = open('flag.txt', 'rb').read().strip() c = pow(bytes_to_lo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/crypto/randomly_chosen/randomly-chosen.py
ctfs/DownUnderCTF/2023/crypto/randomly_chosen/randomly-chosen.py
import random random.seed(random.randrange(0, 1337)) flag = open('./flag.txt', 'r').read().strip() out = ''.join(random.choices(flag, k=len(flag)*5)) print(out)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/crossed_monkes/monkestorage/main.py
ctfs/DownUnderCTF/2023/web/crossed_monkes/monkestorage/main.py
from flask import Flask, request, render_template, send_from_directory, abort, redirect, session from functools import wraps from werkzeug.security import safe_join from werkzeug.utils import secure_filename from pymongo import MongoClient from bson.objectid import ObjectId from datetime import datetime from cairosvg i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/crossed_monkes/monkestorage/config.py
ctfs/DownUnderCTF/2023/web/crossed_monkes/monkestorage/config.py
import os STORAGE_PATH='/storage' ALLOWED_FILE_TYPES = ['.jpeg', '.jpg', '.svg', '.png', '.gif'] ALLOWED_MIME_TYPES = [ 'image/jpeg', 'image/jpg', 'image/svg+xml', 'image/png', 'image/gif' ] MONGODB_CONFIG = { 'host': 'mongodb', 'port': 27017, 'username': 'monkeuser', 'password': ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/crossed_monkes/monkebot/main.py
ctfs/DownUnderCTF/2023/web/crossed_monkes/monkebot/main.py
from flask import Flask, render_template, request import urllib.parse as urlparse import monkebot import threading app = Flask(__name__, static_folder='static/', static_url_path='/') threading.Thread(target=monkebot.monke_worker, daemon=True).start() @app.route("/", methods=["GET"]) def index(): return render_te...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/crossed_monkes/monkebot/monkebot.py
ctfs/DownUnderCTF/2023/web/crossed_monkes/monkebot/monkebot.py
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC import logging, os, time from queue import Queue monke_queue = Queue(maxsize=5) monkestorage_host = os.environ.get("MONKE...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/0day_blog/adminbot/adminbot.py
ctfs/DownUnderCTF/2023/web/0day_blog/adminbot/adminbot.py
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.service import Service import logging, os, time from queue import Queue USERNAME = "ghostccamm" # Password is different on challenge instance PASSWORD = "hmmmm idk what would be good for a passw0rd..." DRUPAL_HOST...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/0day_blog/adminbot/main.py
ctfs/DownUnderCTF/2023/web/0day_blog/adminbot/main.py
from flask import Flask, render_template, request import urllib.parse as urlparse import adminbot import threading app = Flask(__name__, static_folder='static/', static_url_path='/') threading.Thread(target=adminbot.worker, daemon=True).start() @app.route("/", methods=["GET"]) def index(): return render_template...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/grades_grades_grades/run.py
ctfs/DownUnderCTF/2023/web/grades_grades_grades/run.py
from src import create_app app = create_app() if __name__ == '__main__': app.run(host='0.0.0.0', debug=False)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/grades_grades_grades/src/__init__.py
ctfs/DownUnderCTF/2023/web/grades_grades_grades/src/__init__.py
from flask import Flask from src.routes import api from src import auth def create_app(): app = Flask(__name__) app.auth = auth app.register_blueprint(api) return app
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/grades_grades_grades/src/routes.py
ctfs/DownUnderCTF/2023/web/grades_grades_grades/src/routes.py
from flask import request, jsonify, Blueprint, current_app, make_response, render_template, redirect, url_for from src.auth import requires_token, is_authenticated, token_value, requires_teacher, is_teacher_role import random api = Blueprint('api', __name__) def ran_g(): grades = ['A', 'B', 'C', 'D', 'E', 'F'] ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/grades_grades_grades/src/auth.py
ctfs/DownUnderCTF/2023/web/grades_grades_grades/src/auth.py
import jwt from flask import request, jsonify, current_app, make_response from functools import wraps import secrets SECRET_KEY = secrets.token_hex(32) def create_token(data): token = jwt.encode(data, SECRET_KEY, algorithm='HS256') return token def token_value(token): decoded_token = jwt.decode(token, SE...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/static_file_server/app.py
ctfs/DownUnderCTF/2023/web/static_file_server/app.py
from aiohttp import web async def index(request): return web.Response(body=''' <header><h1>static file server</h1></header> Here are some files: <ul> <li><img src="/files/ductf.png"></img></li> <li><a href="/files/not_the_flag.txt">not the flag</a></li> </ul>...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/manage.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/manage.py
#!/usr/bin/env python """Django's command-line utility for administrative tasks.""" import os import sys def main(): """Run administrative tasks.""" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'secureblog.settings') try: from django.core.management import execute_from_command_line except I...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/admin.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/admin.py
from django.contrib import admin from app.models import Article, Flag @admin.register(Article) class ArticleAdmin(admin.ModelAdmin): pass @admin.register(Flag) class FlagAdmin(admin.ModelAdmin): pass
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/__init__.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/tests.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/tests.py
from django.test import TestCase # Create your tests here.
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/apps.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/apps.py
from django.apps import AppConfig class AppConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'app'
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/serializers/article.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/serializers/article.py
from rest_framework import serializers from app.models import Article class ArticleSerializer(serializers.ModelSerializer): """ Article serializer """ author = serializers.CharField(source='created_by.username') class Meta: model = Article fields = ('title', 'body', 'author')
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/serializers/__init__.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/serializers/__init__.py
from app.serializers.article import ArticleSerializer
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/models/article.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/models/article.py
from django.db import models from django.contrib.auth.models import User class Article(models.Model): """ Test Article model """ title = models.CharField(max_length=255) body = models.TextField() created_by = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self) -> str: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/models/__init__.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/models/__init__.py
from app.models.article import Article from app.models.flag import Flag
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/models/flag.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/models/flag.py
from django.db import models class Flag(models.Model): """ Flag model """ flag = models.CharField(max_length=255) def __str__(self) -> str: return "Top Secret Flag"
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/utils/hash.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/utils/hash.py
from django.contrib.auth.hashers import PBKDF2PasswordHasher class PBKDF2LowIterationHasher(PBKDF2PasswordHasher): """ Custom password hasher to make password cracking doable in a reasonable time period """ iterations = 1000
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/utils/__init__.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/utils/__init__.py
from app.utils.hash import PBKDF2LowIterationHasher
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/views/article.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/views/article.py
from rest_framework.views import APIView from rest_framework.request import Request from rest_framework.response import Response from app.models import Article from app.serializers import ArticleSerializer class ArticleView(APIView): """ View for Articles """ def get(self, request: Request, format...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/views/__init__.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/views/__init__.py
from app.views.article import ArticleView
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/migrations/0002_flag.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/migrations/0002_flag.py
# Generated by Django 4.2.2 on 2023-06-29 02:00 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('app', '0001_initial'), ] operations = [ migrations.CreateModel( name='Flag', fields=[ ('id', models....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/migrations/0001_initial.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/migrations/0001_initial.py
# Generated by Django 4.2.2 on 2023-06-29 01:50 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] ope...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/migrations/__init__.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/app/migrations/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/asgi.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/asgi.py
""" ASGI config for secureblog project. It exposes the ASGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ """ import os from django.core.asgi import get_asgi_application os.environ.setdefault('DJANGO_SE...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/settings.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/settings.py
""" Django settings for secureblog project. Generated by 'django-admin startproject' using Django 4.2.2. For more information on this file, see https://docs.djangoproject.com/en/4.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.2/ref/settings/ """ from path...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/__init__.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/__init__.py
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/wsgi.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/wsgi.py
""" WSGI config for secureblog project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SE...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/urls.py
ctfs/DownUnderCTF/2023/web/secure_blog/djangoapp/secureblog/urls.py
""" URL configuration for secureblog project. The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/4.2/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='h...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/pwn/rw.py/rw.py
ctfs/DownUnderCTF/2025/pwn/rw.py/rw.py
#!/usr/bin/env python3 import ctypes a = [{}, (), [], "", 0.0] while True: try: inp = input("> ") cmd, idx, *val = inp.split() idx = int(idx) match cmd: case "r": print(a[idx]) case "w": ctypes.cast( id(a) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/pwn/fakeobj.py/fakeobj.py
ctfs/DownUnderCTF/2025/pwn/fakeobj.py/fakeobj.py
#!/usr/bin/env python3 import ctypes obj = {} print(f"addrof(obj) = {hex(id(obj))}") libc = ctypes.CDLL(None) system = ctypes.cast(libc.system, ctypes.c_void_p).value print(f"system = {hex(system or 0)}") fakeobj_data = bytes.fromhex(input("fakeobj: ")) for i in range(72): ctypes.cast(id(obj), ctypes.POINTER(ct...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/rev/bilingual/bilingual.py
ctfs/DownUnderCTF/2025/rev/bilingual/bilingual.py
DATA='eNrtfQt8k0XW96RNei8p0mBBxIDBFhAoTXUrpZpIAk811QotqFza0iY00pu5IChiMa00POb9oS/uerefn6/L8vO3y3qBFnd9U8pKC/LZ8uoK4qtFXU0tusULFFbN9z/zPOmFFvHddfdd1xydOWduZ86cmTlzZpKSvFu3sEjGmBIhGGSsiUlgYOeHPoRRl+wexV6MPTipSWE5OKmg3O7U1jiqVzlKKrWlJVVV1S7tSqvW4a7S2qu0phsXaSury6wzExPjdDKP22q+vGXm6EfjQiHVHhs3Dfjqhx6Ln8HxIzJ+Mv4yjp+KnwxstT...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/crypto/Speak_Friend_and_Enter/server.py
ctfs/DownUnderCTF/2025/crypto/Speak_Friend_and_Enter/server.py
#!/usr/bin/env python3 from Crypto.Hash import CMAC, SHA512 from Crypto.Cipher import AES from Crypto.PublicKey import RSA from Crypto.Util.number import long_to_bytes, bytes_to_long from binascii import unhexlify import random, json, string from cryptosecrets import NIST_SP_800_38B_Appendix_D1_K, flag ## Generated ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/crypto/yet_another_login/chall.py
ctfs/DownUnderCTF/2025/crypto/yet_another_login/chall.py
#!/usr/bin/env python3 from Crypto.Util.number import getPrime, bytes_to_long, long_to_bytes from hashlib import sha256 from secrets import randbits import os FLAG = os.getenv('FLAG', 'DUCTF{FLAG_TODO}') class TokenService: def __init__(self): self.p = getPrime(512) self.q = getPrime(512) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/crypto/certvalidated/certvalidated.py
ctfs/DownUnderCTF/2025/crypto/certvalidated/certvalidated.py
#!/usr/bin/env python3 import base64 from endesive import plain TO_SIGN = 'just a random hex string: af17a1f2654d3d40f532e314c7347cfaf24af12be4b43c5fc95f9fb98ce74601' DUCTF_ROOT_CA = open('./root.crt', 'rb').read() print(f'Sign this! <<{TO_SIGN}>>') content_info = base64.b64decode(input('Your CMS blob (base64): ')) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/crypto/good_game_spawn_point/chal.py
ctfs/DownUnderCTF/2025/crypto/good_game_spawn_point/chal.py
#!/usr/bin/env python3 import os import secrets import hashlib from Crypto.Util.number import getPrime from Crypto.PublicKey import ECC FLAG = os.getenv("FLAG", "DUCTF{testflag}") # https://neuromancer.sk/std/nist/P-256 order = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551 * 0x1 def ec_key(): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/crypto/SH_RSA/sh-rsa.py
ctfs/DownUnderCTF/2025/crypto/SH_RSA/sh-rsa.py
#!/usr/bin/env python3 from Crypto.Util.number import long_to_bytes, bytes_to_long from gmpy2 import mpz, next_prime from hashlib import shake_128 import secrets, signal, os def H(N, m): return shake_128(long_to_bytes(N) + m).digest(8) def sign(N, d, m): return pow(mpz(bytes_to_long(H(N, m))), d, N) def ver...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2025/beginner/hungry_hungry_caterpillar/challenge.py
ctfs/DownUnderCTF/2025/beginner/hungry_hungry_caterpillar/challenge.py
#!/usr/bin/env python3 import os def xor(a, b): return bytes(left ^ right for left, right in zip(a, b)) def main(): flag = open("flag.txt", "rb").read() assert flag[1] == ord("U") flag += os.urandom(len(flag) * 6) keystream = os.urandom(len(flag)) print( f""" In the light o...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/pwn/babypywn/babypywn.py
ctfs/DownUnderCTF/2022/pwn/babypywn/babypywn.py
#!/usr/bin/env python3 from ctypes import CDLL, c_buffer libc = CDLL('/lib/x86_64-linux-gnu/libc.so.6') buf1 = c_buffer(512) buf2 = c_buffer(512) libc.gets(buf1) if b'DUCTF' in bytes(buf2): print(open('./flag.txt', 'r').read())
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/oracle-for-block-cipher-enthusiasts/ofb.py
ctfs/DownUnderCTF/2022/crypto/oracle-for-block-cipher-enthusiasts/ofb.py
#!/usr/bin/env python3 from os import urandom, path from Crypto.Cipher import AES FLAG = open(path.join(path.dirname(__file__), 'flag.txt'), 'r').read().strip() MESSAGE = f'Decrypt this... {urandom(300).hex()} {FLAG}' def main(): key = urandom(16) for _ in range(2): iv = bytes.fromhex(input('iv: ')...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-ii/rsa-interval-oracle-ii.py
ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-ii/rsa-interval-oracle-ii.py
#!/usr/bin/env python3 import signal, time from os import urandom, path from Crypto.Util.number import getPrime, bytes_to_long FLAG = open(path.join(path.dirname(__file__), 'flag.txt'), 'r').read().strip() N_BITS = 384 TIMEOUT = 20 * 60 MAX_INTERVALS = 1 MAX_QUERIES = 384 def main(): p, q = getPrime(N_BITS//2...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-iv/rsa-interval-oracle-iv.py
ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-iv/rsa-interval-oracle-iv.py
#!/usr/bin/env python3 import signal, time from os import urandom, path from Crypto.Util.number import getPrime, bytes_to_long FLAG = open(path.join(path.dirname(__file__), 'flag.txt'), 'r').read().strip() N_BITS = 384 TIMEOUT = 3 * 60 MAX_INTERVALS = 4 MAX_QUERIES = 4700 def main(): p, q = getPrime(N_BITS//2...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-i/rsa-interval-oracle-i.py
ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-i/rsa-interval-oracle-i.py
#!/usr/bin/env python3 import signal, time from os import urandom, path from Crypto.Util.number import getPrime, bytes_to_long FLAG = open(path.join(path.dirname(__file__), 'flag.txt'), 'r').read().strip() N_BITS = 384 TIMEOUT = 20 * 60 MAX_INTERVALS = 384 MAX_QUERIES = 384 def main(): p, q = getPrime(N_BITS/...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/kyber/kyber.py
ctfs/DownUnderCTF/2022/crypto/kyber/kyber.py
#!/usr/bin/env python3 import ctypes MAX_QUERIES = 7681 FLAG = open('flag.txt', 'rb').read().strip() kyber_lib = ctypes.CDLL('./libpqcrystals_kyber512_ref.so') class Kyber: def __init__(self): self.pk_buf = ctypes.c_buffer(800) self.sk_buf = ctypes.c_buffer(1632) kyber_lib.pqcrystals_kybe...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/time-locked/time-locked.py
ctfs/DownUnderCTF/2022/crypto/time-locked/time-locked.py
from hashlib import sha256 from Crypto.Util.Padding import unpad from Crypto.Cipher import AES ct = bytes.fromhex('85534f055c72f11369903af5a8ac64e2f4cbf27759803041083d0417b5f0aaeac0490f018b117dd4376edd6b1c15ba02') p = 275344354044844896633734474527970577743 a = [2367876727, 2244612523, 2917227559, 2575298459, 34084...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/baby-arx/baby-arx.py
ctfs/DownUnderCTF/2022/crypto/baby-arx/baby-arx.py
class baby_arx(): def __init__(self, key): assert len(key) == 64 self.state = list(key) def b(self): b1 = self.state[0] b2 = self.state[1] b1 = (b1 ^ ((b1 << 1) | (b1 & 1))) & 0xff b2 = (b2 ^ ((b2 >> 5) | (b2 << 3))) & 0xff b = (b1 + b2) % 256 sel...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-iii/rsa-interval-oracle-iii.py
ctfs/DownUnderCTF/2022/crypto/rsa-interval-oracle-iii/rsa-interval-oracle-iii.py
#!/usr/bin/env python3 import signal, time from os import urandom, path from Crypto.Util.number import getPrime, bytes_to_long FLAG = open(path.join(path.dirname(__file__), 'flag.txt'), 'r').read().strip() N_BITS = 384 TIMEOUT = 3 * 60 MAX_INTERVALS = 4 MAX_QUERIES = 4700 def main(): p, q = getPrime(N_BITS//2...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/crypto/faulty-arx/faulty_arx.py
ctfs/DownUnderCTF/2022/crypto/faulty-arx/faulty_arx.py
#!/usr/bin/env python3 import os import signal import random FLAG = open(os.path.join(os.path.dirname(__file__), 'flag.txt'), 'r').read().strip() def rol(x, d): return ((x << d) | (x >> (32 - d))) & 0xffffffff def bytes_to_words(B): return [int.from_bytes(B[i:i+4], 'little') for i in range(0, len(B), 4)] ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/web/dyslexxec/getExcelMetadata.py
ctfs/DownUnderCTF/2022/web/dyslexxec/getExcelMetadata.py
import sys import uuid import os import shutil from lxml import etree from openpyxl import load_workbook from zipfile import ZipFile WORKBOOK = "xl/workbook.xml" def getMetadata(filename): properties = [] try: wb = load_workbook(filename) for e in wb.properties.__elements__: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/web/dyslexxec/app.py
ctfs/DownUnderCTF/2022/web/dyslexxec/app.py
from flask import Flask, render_template, request, send_file from werkzeug.utils import secure_filename from getExcelMetadata import getMetadata, extractWorkbook, findInternalFilepath, WORKBOOK import shutil import os import uuid app = Flask(__name__) app.config['MAX_CONTENT_LENGTH'] = 32 * 1024 @app.errorhandler(413...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2022/web/sqli2022/app.py
ctfs/DownUnderCTF/2022/web/sqli2022/app.py
from flask import Flask, request import textwrap import sqlite3 import os import hashlib assert len(os.environ['FLAG']) > 32 app = Flask(__name__) @app.route('/', methods=['POST']) def root_post(): post = request.form # Sent params? if 'username' not in post or 'password' not in post: return...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/DownUnderCTF/2020/pwn-or-web/server.py
ctfs/DownUnderCTF/2020/pwn-or-web/server.py
#!/usr/bin/env python3 import os import sys import subprocess import tempfile MAX_SIZE = 100 * 1024 script_size = int(input("Enter the size of your exploit script (in bytes, max 100KB): ")) assert script_size < MAX_SIZE print("Minify your exploit script and paste it in: ") contents = sys.stdin.read(script_size) tmp ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/small_enigma.py
ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/small_enigma.py
from Enigma.Enigma import Enigma print(''' ──────────────────────────────────────────────────────────────────────────────────────────────────────────── ─██████████████──██████──────────██████──██████████──██████████████──████...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Tests/Tests.py
ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Tests/Tests.py
import random import numpy as np from Enigma_Project.Enigma.Enigma import Enigma def encryptTest(): e = Enigma(["I", "II", "III"], "B", [0,0,0], [0,0,0], "") input = "ABCDEFGHIJKLMNOPQRSTUVWXYZAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBABCDEFGHIJKLMNOPQRSTUVWXYZ" output = "BJELRQZVJWARXSNBXORST...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Plugboard.py
ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Plugboard.py
class Plugboard: def __init__(self, connections): self.wiring = Plugboard.decodePlugboard(connections) def forward(self,c): return self.wiring[c] @staticmethod def identityPlugboard(): return list(range(26)) @staticmethod def decodePlugboard(plugboard=None): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Enigma.py
ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Enigma.py
from Enigma_Project.Enigma.Reflector import Reflector from Enigma_Project.Enigma.Rotor import Rotor from Enigma_Project.Enigma.Plugboard import Plugboard class Enigma: def __init__(self,rotors,reflector,rotorPositions,ringSettings,plugboardConnections): self.leftRotor = Rotor.Create(rotors[0], rotorPos...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Reflector.py
ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Reflector.py
class Reflector: def __init__(self,encoding): self.forwardWiring = Reflector.decodeWiring(encoding) @staticmethod def Create(name): if name == "B": return Reflector("YRUHQSLDPXNGOKMIEBFZCWVJAT") elif name == "C": return Reflector("FVPJIAOYEDRZXWGCTKUQSBNMHL...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Rotor.py
ctfs/KubanCTF/2023/Quals/crypto/we_need_your_help_comrade/Enigma/Rotor.py
class Rotor: def __init__(self, name,encoding, rotorPos, notchPosition, ringSetting): self.name = name self.forwardWiring = Rotor.decodeWiring(encoding) self.backwardWiring = Rotor.inverseWiring(self.forwardWiring) self.rotorPosition = rotorPos self.notchPosition = notchPosit...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PwnMe/2025/Quals/crypto/Vending_Machine/server.py
ctfs/PwnMe/2025/Quals/crypto/Vending_Machine/server.py
#!/usr/bin/env python3 from tinyec.ec import SubGroup, Curve from Crypto.Util.Padding import pad from Crypto.Cipher import AES from json import loads, dumps from hashlib import sha3_256 from random import choice from os import urandom from flag import FLAG import secrets import time class SignatureManager: def __i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PwnMe/2025/Quals/crypto/Mirror_Hash/challenge.py
ctfs/PwnMe/2025/Quals/crypto/Mirror_Hash/challenge.py
import hashlib import struct from secret import FLAG class CustomSHA: def __init__(self, data: bytes): self.data: bytes = data def process(self) -> str: h0 = 0x674523EFCD.to_bytes(5, byteorder='big') h = h0 data = self.preprocess() for i in range(0, len(data), 8): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PwnMe/2022/crypto/ToBasics/encrypt.py
ctfs/PwnMe/2022/crypto/ToBasics/encrypt.py
#!/usr/bin/env python3 from secrets import choice from string import digits FLAG = open("./flag.txt", "r").read() SECRET = choice(digits) * len(FLAG) def encrypt(flag): return [str((ord(v[0]) ^ ord(v[1]))+i) for i, v in enumerate(zip(flag, SECRET))] out = open('./flag-encrypted.txt', 'w') out.write(','.join(enc...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PwnMe/2022/crypto/EncryptedCommunication/chall.py
ctfs/PwnMe/2022/crypto/EncryptedCommunication/chall.py
from Crypto.Util.number import * flag = open('flag.txt', 'rb').read() p, q, s = getPrime(2048), getPrime(2048), getPrime(2048) n1 = p * q n2 = s * p e = 2**16+1 d = pow(e, -1, (p-1)*(q-1)) c1 = pow(bytes_to_long(flag[:20]), e, n1) c2 = pow(bytes_to_long(flag[20:]), e, n2) out = open('output.txt', 'w') out.write(f'{n...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PwnMe/2022/crypto/RsaMadness/chall.py
ctfs/PwnMe/2022/crypto/RsaMadness/chall.py
from Crypto.Util.number import * flag = bytes_to_long(open('flag.txt', 'rb').read()) factors = [getPrime(32) for i in range(32)] n = 1 for factor in factors: n *= factor e = 2**16+1 c = pow(flag, e, n) out = open('output.txt', 'w') out.write(f'{n = }\n') out.write(f'{e = }\n') out.write(f'{c = }\n') out.clos...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/PwnMe/2022/crypto/ExponentialMachine/chall.py
ctfs/PwnMe/2022/crypto/ExponentialMachine/chall.py
from Crypto.Util.number import * LIMIT = 0 a = getPrime(512) x = bytes_to_long(b"PWNME{FAKE_FLAG}") n = getPrime(512) print("You can have the result of whatever operation between multiplication, exponentiation, addition, division and substraction !") print("Also you can choose the value with which you can apply the ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/Gift_Wrapping/solve.py
ctfs/NTUA_H4CK/2024/misc/Gift_Wrapping/solve.py
from pwn import * from json import loads,dumps from hashlib import sha256 context.encoding='ascii' t = remote('localhost',1337) def get_belt(seed:int, n:int) -> list[int]: random.seed(seed) return [random.randint(1,n**2) for _ in range(n)] def solve(belt: list[int],k:int) -> list[int]: return range(len...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/Learn/solver.py
ctfs/NTUA_H4CK/2024/misc/Learn/solver.py
from tqdm import tqdm # Progress bar :) from pwn import * # Import the pwntools module to interact with the server # Set the host and port HOST = '???' PORT = 000 t = remote(HOST, PORT) # Connect to the server t.level = 'debug' # This will print the data sent and received # Recieve until the challenges start t...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/Learn/server.py
ctfs/NTUA_H4CK/2024/misc/Learn/server.py
from secret import FLAG from Crypto.Cipher import AES from random import randint,choice,choices import signal def timeout_handler(signum, frame): print("\nOut of Time 😔") exit() signal.signal(signal.SIGALRM, timeout_handler) signal.alarm(20) # Limit to 20s def rand_str(): charset = 'abcdefghijklmnopqrst...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/Snekbox/server.py
ctfs/NTUA_H4CK/2024/misc/Snekbox/server.py
# unsafe (example of what not to do) def unsafe_eval(): inp = input("> ") eval(inp) # 100% safe BLACKLIST = ["builtins", "import", "=", "flag", ';', "print", "_", "open", "exec", "eval", "help", "br"] def safe_eval(): inp = input("> ") if any(banned in inp for banned in BLACKLIST) or any(ord(c) >= 128 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/na_kopso_glyko/server.py
ctfs/NTUA_H4CK/2024/misc/na_kopso_glyko/server.py
import random import json from secret import FLAG def random_flouri_generator(): m = 10**30 return random.randint(1, m)**11 + 17*random.randint(1, m)**7 - 42*random.randint(1, m)**5 + 1337*random.randint(1, m)*3 + 31337*random.randint(1, m) def check_password(password, your_guess): for i in range(len(pass...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/Backdoored_Calculator/totally_normal_integers.py
ctfs/NTUA_H4CK/2024/misc/Backdoored_Calculator/totally_normal_integers.py
from functools import reduce, partial sum = partial(reduce, lambda a, b: a + b) class Int: def __init__(self, value): self.value = int(value) def __repr__(self): return str(self.value) def __add__(self, other): return Int(3*self.value + 5*other.value) def __sub__(self, ot...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/Backdoored_Calculator/calculator.py
ctfs/NTUA_H4CK/2024/misc/Backdoored_Calculator/calculator.py
from totally_normal_integers import Int, sum from string import digits from secret import FLAG zero = Int(0) class Calculator: def __init__(self): self.ind = 0 self.vals = [zero]*6 self.t = [Int(tval) for tval in [1550, 1548, 8073, 5413, 1411]] def calc(self, a, op, b): re...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/misc/Baby_Prison/server.py
ctfs/NTUA_H4CK/2024/misc/Baby_Prison/server.py
from secret import FLAG as FLAAAAAAAAG from string import ascii_lowercase, digits M = 10 BLACKLIST = ascii_lowercase + digits + "_()" for _ in range(3): inp = input("> ") assert len(inp) < M, "too long" assert all(banned not in inp for banned in BLACKLIST), "that's banned" exec(inp)
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/rev/onelinerev/challenge.py
ctfs/NTUA_H4CK/2024/rev/onelinerev/challenge.py
__import__("pickle").loads(bytes.fromhex("80048c086275696c74696e738c05696e70757493288c0c456e74657220666c61673a207452711a308c086275696c74696e738c0767657461747472937181308c0b5f5f6765746974656d5f5f71a230688128681a8c06656e636f64657452295271753055534a777e5b763551704128425925614b6e7954262a783072392d4f7066467d484e342447553256...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/crypto/Secure_Encryption_Service/server.py
ctfs/NTUA_H4CK/2024/crypto/Secure_Encryption_Service/server.py
from Crypto.Cipher import AES from time import time from hashlib import sha256 from secret import FLAG key = sha256(sha256(str(int(time())).encode() + FLAG).digest() + FLAG).digest() cipher = AES.new(key= key, mode= AES.MODE_CTR, nonce= sha256(FLAG + sha256(FLAG + str(int(time())).encode()).digest()).digest()[:12]) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/crypto/New_Laptop/source.py
ctfs/NTUA_H4CK/2024/crypto/New_Laptop/source.py
from Crypto.Util.number import getPrime, isPrime from secrets import randbelow from secret import FLAG from supercomputer import superfast_product_up_to_x_mod_n # you need to have a supercomputer to use this sorry :/ # superfast_product_up_to_x_mod_n(x, n) returns 0 if x % n == 0, otherwise it calculates the product p...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/crypto/wishcAErdS/source.py
ctfs/NTUA_H4CK/2024/crypto/wishcAErdS/source.py
from Crypto.Cipher import AES from Crypto.Util.Padding import pad import os from secret import FLAG def keygen(keysize): key = os.urandom(2) while len(key) != keysize: key += bytes([(key[-2] + key[-1]) % 256]) return key def aesenc(key, msg): return AES.new(key, AES.MODE_ECB).encrypt(pad(msg, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/crypto/Factoring_Expert/server.py
ctfs/NTUA_H4CK/2024/crypto/Factoring_Expert/server.py
import random from Crypto.Util.number import isPrime from secret import FLAG e = 65537 NUMROUNDS = 7 def get_primes_and_messages(nbits): primes = [] messages = [] ind = 0 while True: num = random.randint(0, 2**nbits - 2) poss_prime = int(f"{(1 << nbits) + num}{ind:04}") if isPr...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/crypto/warmup_rsa/source.py
ctfs/NTUA_H4CK/2024/crypto/warmup_rsa/source.py
from Crypto.Util.number import getPrime, isPrime, bytes_to_long from secret import FLAG def keygen(bitsize): while True: p = getPrime(bitsize) b = getPrime(12) q = p + 42*b**(bitsize//12) + 17*b**(bitsize//24) + 42*b + 1337 if isPrime(q): return p, q SIZE = 384 p, q = k...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/crypto/RSA_se_olous_RSei/source.py
ctfs/NTUA_H4CK/2024/crypto/RSA_se_olous_RSei/source.py
from Crypto.Util.number import getPrime from math import prod from sympy import sieve from secret import FLAG FLAGLEN = 18 assert len(FLAG) == FLAGLEN p = getPrime(2048) q = getPrime(2048) n = p*q e = 3 m = prod(pow(sieve[i], FLAG[FLAGLEN - i], n) for i in range(1, FLAGLEN + 1)) c = pow(m, e, n) print(f"{n = }") prin...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/NTUA_H4CK/2024/crypto/hashmash/source.py
ctfs/NTUA_H4CK/2024/crypto/hashmash/source.py
from hashlib import sha256 from secret import FLAG half = len(FLAG)//2 D1 = [] for i in range(half): D1.append(sha256(FLAG[:i+1]).hexdigest()) print(f"{D1 = }") D2 = [] for i in range(half): D2.append(sha256(FLAG[:half + i+1]).digest()[0]) print(f"{D2 = }") ''' D1 = ['8ce86a6ae65d3692e7305e2c58ac62eebd97d3d...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2021/rev/pickled-onions/chall.py
ctfs/redpwn/2021/rev/pickled-onions/chall.py
__import__('pickle').loads(b'(I128\nI4\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI40\nI140\nI18\nI112\nI105\nI99\nI107\nI108\nI101\nI100\nI104\nI111\nI114\nI115\nI101\nI114\nI97\nI100\nI105\nI115\nI104\nI67\nI65\nI128\nI4\nI99\nI112\nI105\nI99\nI107\nI108\nI101\nI10\nI105\nI111\nI10\nI99\nI105\nI11...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
true
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2021/crypto/scissor/encrypt.py
ctfs/redpwn/2021/crypto/scissor/encrypt.py
import random key = random.randint(0, 25) alphabet = 'abcdefghijklmnopqrstuvwxyz' shifted = alphabet[key:] + alphabet[:key] dictionary = dict(zip(alphabet, shifted)) print(''.join([ dictionary[c] if c in dictionary else c for c in input() ]))
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/redpwn/2021/crypto/yahtzee/server.py
ctfs/redpwn/2021/crypto/yahtzee/server.py
#!/usr/local/bin/python from Crypto.Cipher import AES from Crypto.Util.number import long_to_bytes from random import randint from binascii import hexlify with open('flag.txt','r') as f: flag = f.read().strip() with open('keyfile','rb') as f: key = f.read() assert len(key)==32 ''' Pseudorandom number ge...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false