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/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_python_api.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_python_api.py
from ctypes import * import unittest, sys from test import support ################################################################ # This section should be moved into ctypes\__init__.py, when it's ready. from _ctypes import PyObj_FromPtr ################################################################ from sys imp...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_returnfuncptrs.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_returnfuncptrs.py
import unittest from ctypes import * import _ctypes_test class ReturnFuncPtrTestCase(unittest.TestCase): def test_with_prototype(self): # The _ctypes_test shared lib/dll exports quite some functions for testing. # The get_strchr function returns a *pointer* to the C strchr function. dll =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_as_parameter.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_as_parameter.py
import unittest from ctypes import * from ctypes.test import need_symbol import _ctypes_test dll = CDLL(_ctypes_test.__file__) try: CALLBACK_FUNCTYPE = WINFUNCTYPE except NameError: # fake to enable this test on Linux CALLBACK_FUNCTYPE = CFUNCTYPE class POINT(Structure): _fields_ = [("x", c_int), ("y...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_errno.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_errno.py
import unittest, os, errno import threading from ctypes import * from ctypes.util import find_library class Test(unittest.TestCase): def test_open(self): libc_name = find_library("c") if libc_name is None: raise unittest.SkipTest("Unable to find C library") libc = CDLL(libc_nam...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_functions.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_functions.py
""" Here is probably the place to write the docs, since the test-cases show how the type behave. Later... """ from ctypes import * from ctypes.test import need_symbol import sys, unittest try: WINFUNCTYPE except NameError: # fake to enable this test on Linux WINFUNCTYPE = CFUNCTYPE import _ctypes_test d...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_objects.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_objects.py
r''' This tests the '_objects' attribute of ctypes instances. '_objects' holds references to objects that must be kept alive as long as the ctypes instance, to make sure that the memory buffer is valid. WARNING: The '_objects' attribute is exposed ONLY for debugging ctypes itself, it MUST NEVER BE MODIFIED! '_object...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_macholib.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_macholib.py
import os import sys import unittest # Bob Ippolito: # # Ok.. the code to find the filename for __getattr__ should look # something like: # # import os # from macholib.dyld import dyld_find # # def find_lib(name): # possible = ['lib'+name+'.dylib', name+'.dylib', # name+'.framework/'+name] # for dylib i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_loading.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_loading.py
from ctypes import * import os import sys import unittest import test.support from ctypes.util import find_library libc_name = None def setUpModule(): global libc_name if os.name == "nt": libc_name = find_library("c") elif sys.platform == "cygwin": libc_name = "cygwin1.dll" else: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_random_things.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_random_things.py
from ctypes import * import unittest, sys def callback_func(arg): 42 / arg raise ValueError(arg) @unittest.skipUnless(sys.platform == "win32", 'Windows-specific test') class call_function_TestCase(unittest.TestCase): # _ctypes.call_function is deprecated and private, but used by # Gary Bishp's readlin...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_sizes.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_sizes.py
# Test specifically-sized containers. from ctypes import * import unittest class SizesTestCase(unittest.TestCase): def test_8(self): self.assertEqual(1, sizeof(c_int8)) self.assertEqual(1, sizeof(c_uint8)) def test_16(self): self.assertEqual(2, sizeof(c_int16)) self.assertEq...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_unaligned_structures.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_unaligned_structures.py
import sys, unittest from ctypes import * structures = [] byteswapped_structures = [] if sys.byteorder == "little": SwappedStructure = BigEndianStructure else: SwappedStructure = LittleEndianStructure for typ in [c_short, c_int, c_long, c_longlong, c_float, c_double, c_ushort, c_uint...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_pickling.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_pickling.py
import unittest import pickle from ctypes import * import _ctypes_test dll = CDLL(_ctypes_test.__file__) class X(Structure): _fields_ = [("a", c_int), ("b", c_double)] init_called = 0 def __init__(self, *args, **kw): X.init_called += 1 self.x = 42 class Y(X): _fields_ = [("str", c_char...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_keeprefs.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_keeprefs.py
from ctypes import * import unittest class SimpleTestCase(unittest.TestCase): def test_cint(self): x = c_int() self.assertEqual(x._objects, None) x.value = 42 self.assertEqual(x._objects, None) x = c_int(99) self.assertEqual(x._objects, None) def test_ccharp(sel...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_funcptr.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_funcptr.py
import unittest from ctypes import * try: WINFUNCTYPE except NameError: # fake to enable this test on Linux WINFUNCTYPE = CFUNCTYPE import _ctypes_test lib = CDLL(_ctypes_test.__file__) class CFuncPtrTestCase(unittest.TestCase): def test_basic(self): X = WINFUNCTYPE(c_int, c_int, c_int) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/__main__.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/__main__.py
from ctypes.test import load_tests import unittest unittest.main()
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_refcounts.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_refcounts.py
import unittest from test import support import ctypes import gc MyCallback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int) OtherCallback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_ulonglong) import _ctypes_test dll = ctypes.CDLL(_ctypes_test.__file__) class RefcountTestCase(unittest.TestCase): @sup...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_checkretval.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_checkretval.py
import unittest from ctypes import * from ctypes.test import need_symbol class CHECKED(c_int): def _check_retval_(value): # Receives a CHECKED instance. return str(value.value) _check_retval_ = staticmethod(_check_retval_) class Test(unittest.TestCase): def test_checkretval(self): ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_strings.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_strings.py
import unittest from ctypes import * from ctypes.test import need_symbol class StringArrayTestCase(unittest.TestCase): def test(self): BUF = c_char * 4 buf = BUF(b"a", b"b", b"c") self.assertEqual(buf.value, b"abc") self.assertEqual(buf.raw, b"abc\000") buf.value = b"ABCD"...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_internals.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_internals.py
# This tests the internal _objects attribute import unittest from ctypes import * from sys import getrefcount as grc # XXX This test must be reviewed for correctness!!! # ctypes' types are container types. # # They have an internal memory block, which only consists of some bytes, # but it has to keep references to ot...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_parameters.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_parameters.py
import unittest from ctypes.test import need_symbol import test.support class SimpleTypesTestCase(unittest.TestCase): def setUp(self): import ctypes try: from _ctypes import set_conversion_mode except ImportError: pass else: self.prev_conv_mode =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_pointers.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_pointers.py
import unittest, sys from ctypes import * import _ctypes_test ctype_types = [c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong, c_double, c_float] python_types = [int, int, int, int, int, int, int, int, int, int, float, float] class PointersT...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_callbacks.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_callbacks.py
import functools import unittest from ctypes import * from ctypes.test import need_symbol import _ctypes_test class Callbacks(unittest.TestCase): functype = CFUNCTYPE ## def tearDown(self): ## import gc ## gc.collect() def callback(self, *args): self.got_args = args return ar...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_prototypes.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_prototypes.py
from ctypes import * from ctypes.test import need_symbol import unittest # IMPORTANT INFO: # # Consider this call: # func.restype = c_char_p # func(c_char_p("123")) # It returns # "123" # # WHY IS THIS SO? # # argument tuple (c_char_p("123"), ) is destroyed after the function # func is called, but NOT before ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/__init__.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/__init__.py
import os import unittest from test import support # skip tests if _ctypes was not built ctypes = support.import_module('ctypes') ctypes_symbols = dir(ctypes) def need_symbol(name): return unittest.skipUnless(name in ctypes_symbols, '{!r} is required'.format(name)) def load_tests(*...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_repr.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_repr.py
from ctypes import * import unittest subclasses = [] for base in [c_byte, c_short, c_int, c_long, c_longlong, c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong, c_float, c_double, c_longdouble, c_bool]: class X(base): pass subclasses.append(X) class X(c_char): pass # This test check...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_bitfields.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_bitfields.py
from ctypes import * from ctypes.test import need_symbol import unittest import os import _ctypes_test class BITS(Structure): _fields_ = [("A", c_int, 1), ("B", c_int, 2), ("C", c_int, 3), ("D", c_int, 4), ("E", c_int, 5), ("F", c_int...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_struct_fields.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_struct_fields.py
import unittest from ctypes import * class StructFieldsTestCase(unittest.TestCase): # Structure/Union classes must get 'finalized' sooner or # later, when one of these things happen: # # 1. _fields_ is set. # 2. An instance is created. # 3. The type is used as field of another Structure/Union. ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_delattr.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_delattr.py
import unittest from ctypes import * class X(Structure): _fields_ = [("foo", c_int)] class TestCase(unittest.TestCase): def test_simple(self): self.assertRaises(TypeError, delattr, c_int(42), "value") def test_chararray(self): self.assertRaises(TypeError, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_values.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_values.py
""" A testcase which accesses *values* in a dll. """ import unittest import sys from ctypes import * import _ctypes_test class ValuesTestCase(unittest.TestCase): def test_an_integer(self): # This test checks and changes an integer stored inside the # _ctypes_test dll/shared lib. ctdll = ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_simplesubclasses.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_simplesubclasses.py
import unittest from ctypes import * class MyInt(c_int): def __eq__(self, other): if type(other) != MyInt: return NotImplementedError return self.value == other.value class Test(unittest.TestCase): def test_compare(self): self.assertEqual(MyInt(3), MyInt(3)) self.a...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_varsize_struct.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_varsize_struct.py
from ctypes import * import unittest class VarSizeTest(unittest.TestCase): def test_resize(self): class X(Structure): _fields_ = [("item", c_int), ("array", c_int * 1)] self.assertEqual(sizeof(X), sizeof(c_int) * 2) x = X() x.item = 42 x....
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_structures.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_structures.py
import platform import sys import unittest from ctypes import * from ctypes.test import need_symbol from struct import calcsize import _ctypes_test import test.support class SubclassesTest(unittest.TestCase): def test_subclass(self): class X(Structure): _fields_ = [("a", c_int)] class ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_libc.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_libc.py
import unittest from ctypes import * import _ctypes_test lib = CDLL(_ctypes_test.__file__) def three_way_cmp(x, y): """Return -1 if x < y, 0 if x == y and 1 if x > y""" return (x > y) - (x < y) class LibTest(unittest.TestCase): def test_sqrt(self): lib.my_sqrt.argtypes = c_double, lib.my...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_array_in_pointer.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_array_in_pointer.py
import unittest from ctypes import * from binascii import hexlify import re def dump(obj): # helper function to dump memory contents in hex, with a hyphen # between the bytes. h = hexlify(memoryview(obj)).decode() return re.sub(r"(..)", r"\1-", h)[:-1] class Value(Structure): _fields_ = [("val", ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_incomplete.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_incomplete.py
import unittest from ctypes import * ################################################################ # # The incomplete pointer example from the tutorial # class MyTestCase(unittest.TestCase): def test_incomplete_example(self): lpcell = POINTER("cell") class cell(Structure): _fields_...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_byteswap.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_byteswap.py
import sys, unittest, struct, math, ctypes from binascii import hexlify from ctypes import * def bin(s): return hexlify(memoryview(s)).decode().upper() # Each *simple* type that supports different byte orders has an # __ctype_be__ attribute that specifies the same type in BIG ENDIAN # byte order, and a __ctype_l...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_frombuffer.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_frombuffer.py
from ctypes import * import array import gc import unittest class X(Structure): _fields_ = [("c_int", c_int)] init_called = False def __init__(self): self._init_called = True class Test(unittest.TestCase): def test_from_buffer(self): a = array.array("i", range(16)) x = (c_int *...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_win32.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_win32.py
# Windows specific tests from ctypes import * import unittest, sys from test import support import _ctypes_test # Only windows 32-bit has different calling conventions. @unittest.skipUnless(sys.platform == "win32", 'Windows-specific test') @unittest.skipUnless(sizeof(c_void_p) == sizeof(c_int), ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_find.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_find.py
import unittest import os.path import sys import test.support from ctypes import * from ctypes.util import find_library # On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode. class Test_OpenGL_libs(unittest.TestCase): @classmethod def setUpClass(cls): lib_gl = lib_glu = lib_gle = N...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_init.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_init.py
from ctypes import * import unittest class X(Structure): _fields_ = [("a", c_int), ("b", c_int)] new_was_called = False def __new__(cls): result = super().__new__(cls) result.new_was_called = True return result def __init__(self): self.a = 9 sel...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_pep3118.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/test/test_pep3118.py
import unittest from ctypes import * import re, sys if sys.byteorder == "little": THIS_ENDIAN = "<" OTHER_ENDIAN = ">" else: THIS_ENDIAN = ">" OTHER_ENDIAN = "<" def normalize(format): # Remove current endian specifier and white space from a format # string if format is None: retur...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/macholib/dylib.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/macholib/dylib.py
""" Generic dylib path manipulation """ import re __all__ = ['dylib_info'] DYLIB_RE = re.compile(r"""(?x) (?P<location>^.*)(?:^|/) (?P<name> (?P<shortname>\w+?) (?:\.(?P<version>[^._]+))? (?:_(?P<suffix>[^._]+))? \.dylib$ ) """) def dylib_info(filename): """ A dylib name can take one of the ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/macholib/__init__.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/macholib/__init__.py
""" Enough Mach-O to make your head spin. See the relevant header files in /usr/include/mach-o And also Apple's documentation. """ __version__ = '1.0'
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/macholib/dyld.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/macholib/dyld.py
""" dyld emulation """ import os from ctypes.macholib.framework import framework_info from ctypes.macholib.dylib import dylib_info from itertools import * __all__ = [ 'dyld_find', 'framework_find', 'framework_info', 'dylib_info', ] # These are the defaults as per man dyld(1) # DEFAULT_FRAMEWORK_FALLBACK = [ ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/macholib/framework.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/ctypes/macholib/framework.py
""" Generic framework path manipulation """ import re __all__ = ['framework_info'] STRICT_FRAMEWORK_RE = re.compile(r"""(?x) (?P<location>^.*)(?:^|/) (?P<name> (?P<shortname>\w+).framework/ (?:Versions/(?P<version>[^/]+)/)? (?P=shortname) (?:_(?P<suffix>[^_]+))? )$ """) def framework_info(filename):...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/http/client.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/http/client.py
r"""HTTP/1.1 client library <intro stuff goes here> <other stuff, too> HTTPConnection goes through a number of "states", which define when a client may legally make another request or fetch the response for a particular request. This diagram details these state transitions: (null) | | HTTPConnection(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
true
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/http/cookiejar.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/http/cookiejar.py
r"""HTTP cookie handling for web clients. This module has (now fairly distant) origins in Gisle Aas' Perl module HTTP::Cookies, from the libwww-perl library. Docstrings, comments and debug strings in this code refer to the attributes of the HTTP cookie system as cookie-attributes, to distinguish them clearly from Pyt...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
true
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/http/cookies.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/http/cookies.py
#### # Copyright 2000 by Timothy O'Malley <timo@alum.mit.edu> # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software # and its documentation for any purpose and without fee is hereby # granted, provided that the above copyright notice appear in all # copies and that bot...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/http/__init__.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/http/__init__.py
from enum import IntEnum __all__ = ['HTTPStatus'] class HTTPStatus(IntEnum): """HTTP status codes and reason phrases Status codes from the following RFCs are all observed: * RFC 7231: Hypertext Transfer Protocol (HTTP/1.1), obsoletes 2616 * RFC 6585: Additional HTTP Status Codes * RF...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/http/server.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/python3.7/lib/python3.7/http/server.py
"""HTTP server classes. Note: BaseHTTPRequestHandler doesn't implement any HTTP request; see SimpleHTTPRequestHandler for simple implementations of GET, HEAD and POST, and CGIHTTPRequestHandler for CGI scripts. It does, however, optionally implement HTTP/1.1 persistent connections, as of version 0.3. Notes on CGIHTT...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
true
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/TyphoonCon/2022/pwn/beautifier_player/server/serve.py
ctfs/TyphoonCon/2022/pwn/beautifier_player/server/serve.py
#!/usr/bin/env python from operator import truediv from aiohttp import web from PIL import Image, ImageEnhance from io import BytesIO as buffio from base64 import b64encode as b64 from os import remove, getenv, makedirs, path from filelock import FileLock from time import time application = web.Application() routes =...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/Rohald/RoHaLd_ECC.py
ctfs/Crypto/2021/Rohald/RoHaLd_ECC.py
#!/usr/bin/env sage from Crypto.Util.number import * from secret import flag, Curve def ison(C, P): c, d, p = C u, v = P return (u**2 + v**2 - c**2 * (1 + d * u**2*v**2)) % p == 0 def teal(C, P, Q): c, d, p = C u1, v1 = P u2, v2 = Q assert ison(C, P) and ison(C, Q) u3 = (u1 * v2 + v1 * u2) * inverse(c * (1 +...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/hyper_normal/hyper_normal.py
ctfs/Crypto/2021/hyper_normal/hyper_normal.py
#!/usr/bin/env python3 import random from flag import FLAG p = 8443 def transpose(x): result = [[x[j][i] for j in range(len(x))] for i in range(len(x[0]))] return result def vsum(u, v): assert len(u) == len(v) l, w = len(u), [] for i in range(l): w += [(u[i] + v[i]) % p] return w def sprod(a, u): w = [] ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/linda/linda.py
ctfs/Crypto/2021/linda/linda.py
#!/usr/bin/env python3 from Crypto.Util.number import * from math import gcd from flag import flag def keygen(p): while True: u = getRandomRange(1, p) if pow(u, (p-1) // 2, p) != 1: break x = getRandomRange(1, p) w = pow(u, x, p) while True: r = getRandomRange(1, p-1) if gcd(r, p-1) == 1: y = x * in...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/improved/improved.py
ctfs/Crypto/2021/improved/improved.py
#!/usr/bin/env python3 from Crypto.Util.number import * from gmpy2 import gcd from random import randint import sys, hashlib from flag import flag def lcm(a, b): return (a * b) // gcd(a,b) def gen_params(nbit): p, q = [getPrime(nbit) for _ in range(2)] n, f, g = p * q, lcm(p-1, q-1), p + q e = pow(g, f, n**2) u...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/salt_pepper/salt_pepper.py
ctfs/Crypto/2021/salt_pepper/salt_pepper.py
#!/usr/bin/env python3 from hashlib import md5, sha1 import sys from secret import salt, pepper from flag import flag assert len(salt) == len(pepper) == 19 assert md5(salt).hexdigest() == '5f72c4360a2287bc269e0ccba6fc24ba' assert sha1(pepper).hexdigest() == '3e0d000a4b0bd712999d730bc331f400221008e0' def auth_check(s...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/Wolf/Wolf.py
ctfs/Crypto/2021/Wolf/Wolf.py
#!/usr/bin/env python3 from Cryptodome.Cipher import AES import os, time, sys, random from flag import flag passphrase = b'HungryTimberWolf' def encrypt(msg, passphrase, niv): msg_header = 'EPOCH:' + str(int(time.time())) msg = msg_header + "\n" + msg + '=' * (15 - len(msg) % 16) aes = AES.new(passphrase, AES.MOD...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/double_miff/double_miff.py
ctfs/Crypto/2021/double_miff/double_miff.py
#!/usr/bin/env python3 from Crypto.Util.number import * from secret import a, b, p, P, Q from flag import flag def onmiff(a, b, p, G): x, y = G return (a*x*(y**2 - 1) - b*y*(x**2 - 1)) % p == 0 def addmiff(X, Y): x_1, y_1 = X x_2, y_2 = Y x_3 = (x_1 + x_2) * (1 + y_1*y_2) * inverse((1 + x_1*x_2) * (1 - y_1*y_2)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/TRUNC/trunc.py
ctfs/Crypto/2021/TRUNC/trunc.py
#!/usr/bin/env python3 from Crypto.Util.number import * from hashlib import sha256 import ecdsa from flag import FLAG E = ecdsa.SECP256k1 G, n = E.generator, E.order cryptonym = b'Persian Gulf' def keygen(n, G): privkey = getRandomRange(1, n-1) pubkey = privkey * G return (pubkey, privkey) def sign(msg, keypair...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/Triplet/Triplet.py
ctfs/Crypto/2021/Triplet/Triplet.py
#!/usr/bin/env python3 from Crypto.Util.number import * from random import randint import sys from flag import FLAG def die(*args): pr(*args) quit() def pr(*args): s = " ".join(map(str, args)) sys.stdout.write(s + "\n") sys.stdout.flush() def sc(): return sys.stdin.readline().strip() def main(): border = "+...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/DoRSA/DoRSA.py
ctfs/Crypto/2021/DoRSA/DoRSA.py
#!/usr/bin/env python3 from Crypto.Util.number import * from math import gcd from flag import FLAG def keygen(nbit, dbit): assert 2*dbit < nbit while True: u, v = getRandomNBitInteger(dbit), getRandomNBitInteger(nbit // 2 - dbit) p = u * v + 1 if isPrime(p): while True: x, y = getRandomNBitInteger(dbit...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/hamul/hamul.py
ctfs/Crypto/2021/hamul/hamul.py
#!/usr/bin/env python3 from Crypto.Util.number import * from flag import flag nbit = 64 while True: p, q = getPrime(nbit), getPrime(nbit) P = int(str(p) + str(q)) Q = int(str(q) + str(p)) PP = int(str(P) + str(Q)) QQ = int(str(Q) + str(P)) if isPrime(PP) and isPrime(QQ): break n = PP * QQ m = bytes_to_long(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/maid/maid.py
ctfs/Crypto/2021/maid/maid.py
#!/usr/bin/python3 from Crypto.Util.number import * from gmpy2 import * from secret import * from flag import flag global nbit nbit = 1024 def keygen(nbit): while True: p, q = [getStrongPrime(nbit) for _ in '01'] if p % 4 == q % 4 == 3: return (p**2)*q, p def encrypt(m, pubkey): if GCD(m, pubkey) != 1 or m...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/tiny_ecc/tiny_ecc.py
ctfs/Crypto/2021/tiny_ecc/tiny_ecc.py
#!/usr/bin/env python3 # In the name of Allah from mini_ecdsa import * from Crypto.Util.number import * from flag import flag def tonelli_shanks(n, p): if pow(n, int((p-1)//2), p) == 1: s = 1 q = int((p-1)//2) while True: if q % 2 == 0: q = q // 2 s += 1 else: break if s == 1: ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/tiny_ecc/mini_ecdsa.py
ctfs/Crypto/2021/tiny_ecc/mini_ecdsa.py
#Elliptic curve basics, tools for finding rational points, and ECDSA implementation. #Brendan Cordy, 2015 from fractions import Fraction from math import ceil, sqrt from random import SystemRandom, randrange from hashlib import sha256 from time import time #Useful constant. The order of the subgroup defined in the se...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/lower/lower.py
ctfs/Crypto/2021/lower/lower.py
#!/usr/bin/env python3 from Crypto.Util.number import * import sys from flag import flag flag = flag.lstrip('CCTF{').rstrip('}') def query(n, X, E, p): assert n == len(X) > len(E) C = [getRandomRange(0, p) for _ in range(n)] e = E[getRandomRange(0, len(E))] S = e for _ in range(n): S += X[_] * C[_] S %= p ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/Tuti/tuti.py
ctfs/Crypto/2021/Tuti/tuti.py
#!/usr/bin/env python3 from Crypto.Util.number import * from flag import flag l = len(flag) m_1, m_2 = flag[: l // 2], flag[l // 2:] x, y = bytes_to_long(m_1), bytes_to_long(m_2) k = ''' 000bfdc32162934ad6a054b4b3db8578674e27a165113f8ed018cbe9112 4fbd63144ab6923d107eee2bc0712fcbdb50d96fdf04dd1ba1b69cb1efe 71af7ca08...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/elegant_curve/elegant_curve.py
ctfs/Crypto/2021/elegant_curve/elegant_curve.py
#!/usr/bin/env python3 from Crypto.Util.number import * import sys from flag import flag def tonelli_shanks(n, p): if pow(n, int((p-1)//2), p) == 1: s = 1 q = int((p-1)//2) while True: if q % 2 == 0: q = q // 2 s += 1 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/Rima/rima.py
ctfs/Crypto/2021/Rima/rima.py
#!/usr/bin/env python from Crypto.Util.number import * from flag import FLAG def nextPrime(n): while True: n += (n % 2) + 1 if isPrime(n): return n f = [int(x) for x in bin(int(FLAG.hex(), 16))[2:]] f.insert(0, 0) for i in range(len(f)-1): f[i] += f[i+1] a = nextPrime(len(f)) b = ne...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/frozen/frozen_server.py
ctfs/Crypto/2021/frozen/frozen_server.py
#!/usr/bin/env python3 from Crypto.Util.number import * from gmpy2 import * import sys, random, string from flag import FLAG def genrandstr(N): return ''.join(random.choice(string.ascii_uppercase + string.digits + string.ascii_lowercase) for _ in range(N)) def paramaker(nbit): p = getPrime(nbit) r = getRandomR...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2021/keybase/keybase.py
ctfs/Crypto/2021/keybase/keybase.py
#!/usr/bin/env python3 from Crypto.Util import number from Crypto.Cipher import AES import os, sys, random from flag import flag def keygen(): iv, key = [os.urandom(16) for _ in '01'] return iv, key def encrypt(msg, iv, key): aes = AES.new(key, AES.MODE_CBC, iv) return aes.encrypt(msg) def decrypt(enc, iv, key)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2023/Risk/risk.py
ctfs/Crypto/2023/Risk/risk.py
#!/usr/bin/env python3 from Crypto.Util.number import * from secret import m, flag def genPrime(m, nbit): assert m >= 2 while True: a = getRandomNBitInteger(nbit // m) r = getRandomNBitInteger(m ** 2 - m + 2) p = a ** m + r if isPrime(p): return (p, r) def genkey(m, nbit): p, r = genPrime(m, nbit // 2)...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2023/Resuction/resuction.py
ctfs/Crypto/2023/Resuction/resuction.py
#!/usr/bin/env python3 from Crypto.Util.number import * from flag import flag from decimal import * def keygen(nbit, r): while True: p, q = [getPrime(nbit) for _ in '__'] d, n = getPrime(64), p * q phi = (p - 1) * (q - 1) if GCD(d, phi) == 1: e = inverse(d, phi) N = bin(n)[2:-r] E = bin(e)[2:-r] ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2023/Trex/trex.py
ctfs/Crypto/2023/Trex/trex.py
#!/usr/bin/env python3 import random import sys from flag import flag def die(*args): pr(*args) quit() def pr(*args): s = " ".join(map(str, args)) sys.stdout.write(s + "\n") sys.stdout.flush() def sc(): return sys.stdin.buffer.readline() def check_inputs(a, b, c): if not all(isinstance(x, int) 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/Crypto/2023/Bertrand/Bertrand.py
ctfs/Crypto/2023/Bertrand/Bertrand.py
#!/usr/bin/env python3 import sys import math import functools from PIL import Image from random import randint import string from secret import flag, key, n def pad(s, l): while len(s) < l: s += string.printable[randint(0, 61)] return s def sox(n, d): x, y, t = 0, 0, d for s in range(n - 1): u = 1 & t // 2 ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2023/ASIv2/ASIv2.py
ctfs/Crypto/2023/ASIv2/ASIv2.py
#!/usr/bin/env python3 from Crypto.Util.number import * from flag import flag def base(n, l): D = [] while n > 0: n, r = divmod(n, l) D.append(r) return ''.join(str(d) for d in reversed(D)) or '0' def asiv_prng(seed): l = len(seed) _seed = base(bytes_to_long(seed), 3) _l = len(_seed) ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2023/Blue_Office/blue_office.py
ctfs/Crypto/2023/Blue_Office/blue_office.py
#!/usr/bin/enc python3 import binascii from secret import seed, flag def gen_seed(s): i, j, k = 0, len(s), 0 while i < j: k = k + ord(s[i]) i += 1 i = 0 while i < j: if (i % 2) != 0: k = k - (ord(s[i]) * (j - i + 1)) else: k = k + (ord(s[i]) * (j - i + 1)) k = k % 2147483647 i += 1...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2023/Vinefruit/vinefruit.py
ctfs/Crypto/2023/Vinefruit/vinefruit.py
#!/usr/bin/env python3 import sys import random import binascii from flag import flag def die(*args): pr(*args) quit() def pr(*args): s = " ".join(map(str, args)) sys.stdout.write(s + "\n") sys.stdout.flush() def sc(): return sys.stdin.buffer.readline() def vinefruit(msg, mod, flag = 0): P = [16777619, 1099...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2023/Derik/Derik.py
ctfs/Crypto/2023/Derik/Derik.py
#!/usr/bin/env python3 from Crypto.Util.number import * from secret import C, e, d, p, q, r, flag O = [1391526622949983, 2848691279889518, 89200900157319, 31337] assert isPrime(e) and isPrime(d) and isPrime(p) and isPrime(q) and isPrime(r) assert C[0] * p - C[1] * q >= 0 assert C[2] * q - C[3] * r >= 0 assert C[4] *...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2023/Blobfish/blobfish.py
ctfs/Crypto/2023/Blobfish/blobfish.py
#!/usr/bin/env python3 import os from hashlib import md5 from Crypto.Cipher import AES from Crypto.Random import get_random_bytes from PIL import Image from PIL import ImageDraw from flag import flag key = get_random_bytes(8) * 2 iv = md5(key).digest() cipher = AES.new(key, AES.MODE_CFB, iv=iv) enc = cipher.encrypt(...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2023/Roldy/Roldy.py
ctfs/Crypto/2023/Roldy/Roldy.py
#!/usr/bin/env python3 from Crypto.Util.number import * from pyope.ope import OPE as enc from pyope.ope import ValueRange import sys from secret import key, flag def die(*args): pr(*args) quit() def pr(*args): s = " ".join(map(str, args)) sys.stdout.write(s + "\n") sys.stdout.flush() def sc(): return sys.std...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2023/Suction/suction.py
ctfs/Crypto/2023/Suction/suction.py
#!/usr/bin/env python3 from Crypto.Util.number import * from flag import flag def keygen(nbit, r): while True: p, q = [getPrime(nbit) for _ in '__'] e, n = getPrime(16), p * q phi = (p - 1) * (q - 1) if GCD(e, phi) == 1: N = bin(n)[2:-r] E = bin(e)[2:-r] PKEY = N + E pkey = (n, e) return PKEY,...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2023/Did_it/did.py
ctfs/Crypto/2023/Did_it/did.py
#!/usr/bin/env python3 from random import randint import sys from flag import flag def die(*args): pr(*args) quit() def pr(*args): s = " ".join(map(str, args)) sys.stdout.write(s + "\n") sys.stdout.flush() def sc(): return sys.stdin.buffer.readline() def did(n, l, K, A): A, K = set(A), set(K) R = [pow(_, 2...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/fiercest/fiercest.py
ctfs/Crypto/2022/fiercest/fiercest.py
#!/usr/bin/env python3 from Crypto.Util.number import * import sys from flag import flag def diff(a, b): assert a.bit_length() == b.bit_length() w, l = 0, a.bit_length() for _ in range(l): if bin(a)[2:][_] != bin(b)[2:][_]: w += 1 return w def die(*args): pr(*args) quit() def pr(*args): s = " ".join(map(st...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/313_loyal/313loyal.py
ctfs/Crypto/2022/313_loyal/313loyal.py
#!/usr/bin/env python3 from Crypto.Util.number import * from random import * import sys from flag import flag def keygen(nbit): p, q = [getPrime(nbit) for _ in '__'] n, phi = p * q, (p - 1) * (q - 1) // 2 while True: g = getRandomRange(2, n ** 2) if GCD(g, n) == 1: w = (pow(g, phi, n ** 2) - 1) // n if G...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/sidestep/sidestep.py
ctfs/Crypto/2022/sidestep/sidestep.py
#!/usr/bin/env python3 from Crypto.Util.number import * import random, sys from flag import flag def pow_d(g, e, n): t, r = 0, 1 for _ in bin(e)[2:]: if r == 4: t += 1 r = pow(r, 2, n) if _ == '1': r = r * g % n return t, r def ts(m, p): m = m % p return pow(m, (p - 1) // 2, p) == 1 def die(*args): pr(*...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/oak_land/oak_land.py
ctfs/Crypto/2022/oak_land/oak_land.py
#!/usr/bin/env python3 from Crypto.Util.number import * from flag import flag p = 7389313481223384214994762619823300589978423075857540712007981373887018860174846208000957230283669342186460652521580595183523706412588695116906905718440770776239313669678685198683933547601793742596023475603667 e = 31337 f = 7236042467316...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/jeksign/jeksign.py
ctfs/Crypto/2022/jeksign/jeksign.py
#!/usr/bin/env python3 from Crypto.Util.number import * from secret import gensol, nbit_gensol from flag import flag m = bytes_to_long(flag.encode('utf-8')) print(m) a = 1337 b = 31337 def die(*args): pr(*args) quit() def pr(*args): s = " ".join(map(str, args)) sys.stdout.write(s + "\n") sys.stdout.flush() d...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/shaim/shaim.py
ctfs/Crypto/2022/shaim/shaim.py
#!/usr/bin/env python3 from Crypto.Util.number import * from Crypto.Cipher import DES from hashlib import sha256 import sys, string from flag import flag def shaim(msg): SBOX = [ 0xbe, 0xc5, 0x0f, 0x83, 0xb2, 0x77, 0xa8, 0x40, 0x4c, 0x53, 0x65, 0xd6, 0x27, 0xa7, 0x7c, 0x48, 0x1a, 0x60, 0x30, 0x17, 0xf3, 0x80, 0...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/resign/resign.py
ctfs/Crypto/2022/resign/resign.py
#!/usr/bin/env python3 from Crypto.Util.number import * from hashlib import sha1 import sys from flag import flag def die(*args): pr(*args) quit() def pr(*args): s = " ".join(map(str, args)) sys.stdout.write(s + "\n") sys.stdout.flush() def sc(): return sys.stdin.readline().strip() def main(): border = "|" ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/sparse/sparse.py
ctfs/Crypto/2022/sparse/sparse.py
#!/usr/bin/env python3 from Crypto.Util.number import * from flag import flag def sparse(p, k): nbit = p.bit_length() while True: CF = [getRandomRange(-1, 1) for _ in '_' * k] XP = [getRandomRange(3, nbit - 3) for _ in '_' * k] A = sum([CF[_] * 2 ** XP[_] for _ in range(0, k)]) q = p + A if isPrime(q) * A...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/persian_cat/persian_cat.py
ctfs/Crypto/2022/persian_cat/persian_cat.py
#!/usr/bin/env python3 import random, sys from secret import skey, flag Omega = [ 0x4e, 0x96, 0xfd, 0x7d, 0x8d, 0xf6, 0xdb, 0x33, 0x1e, 0x16, 0x9b, 0x6a, 0xe2, 0xc9, 0xa9, 0xe0, 0x34, 0xe6, 0x86, 0xd6, 0x52, 0x02, 0x25, 0x1f, 0x23, 0xdf, 0xd5, 0x12, 0x45, 0x6b, 0x6f, 0x4d, 0x31, 0x77, 0x09, 0xbf, 0x93, 0xca, ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/cantilever/cantilever.py
ctfs/Crypto/2022/cantilever/cantilever.py
#!/usr/bin/env python3 from Crypto.Util.number import * from flag import flag def gen_primes(nbit, imbalance): p = 2 FACTORS = [p] while p.bit_length() < nbit - 2 * imbalance: factor = getPrime(imbalance) FACTORS.append(factor) p *= factor rbit = (nbit - p.bit_length()) // 2 while True: r, s = [getPrime...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/baphomet/baphomet.py
ctfs/Crypto/2022/baphomet/baphomet.py
#!/usr/bin/env python3 from base64 import b64encode from flag import flag def encrypt(msg): ba = b64encode(msg.encode('utf-8')) baph, key = '', '' for b in ba.decode('utf-8'): if b.islower(): baph += b.upper() key += '0' else: baph += b.lower() key += '1' baph = baph.encode('utf-8') key = int(k...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/infinity_castle/infinity_castle.py
ctfs/Crypto/2022/infinity_castle/infinity_castle.py
#!/usr/bin/env python3 from Crypto.Util.number import * from os import urandom class TaylorSeries(): def __init__(self, order): self.order = order def coefficient(self, n): i = 0 coef = 1 while i < n: i += 1 coef *= (coef * (1/2-i+1)) / i return coef def find(self, center): sum = 0 center ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/faonsa/faonsa.py
ctfs/Crypto/2022/faonsa/faonsa.py
#!/usr/bin/env python3 from Crypto.Util.number import * from math import gcd import sys from flag import flag def diff(a, b): assert a.bit_length() == b.bit_length() w, l = 0, a.bit_length() for _ in range(l): if bin(a)[2:][_] != bin(b)[2:][_]: w += 1 return w def sign_esa(pubkey, x, m): g, p, y = pubkey whi...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/watery_soup/watery_soup.py
ctfs/Crypto/2022/watery_soup/watery_soup.py
#!/usr/bin/env python3 from Crypto.Util.number import * import sys from flag import flag flag = bytes_to_long(flag) assert 256 < flag.bit_length() < 512 def die(*args): pr(*args) quit() def pr(*args): s = " ".join(map(str, args)) sys.stdout.write(s + "\n") sys.stdout.flush() def sc(): return sys.stdin.readlin...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/mino/mino.py
ctfs/Crypto/2022/mino/mino.py
#!/usr/bin/env python3 import sys from flag import flag def die(*args): pr(*args) quit() def pr(*args): s = " ".join(map(str, args)) sys.stdout.write(s + "\n") sys.stdout.flush() def sc(): return sys.stdin.readline().strip() def main(): border = "|" pr(border*72) pr(border, "Hi crypto programmers! I'm loo...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/aniely/aniely.py
ctfs/Crypto/2022/aniely/aniely.py
#!/usr/bin/env python3 from struct import * from os import * from secret import passphrase, flag def aniely_stream(passphrase): def mixer(u, v): return ((u << v) & 0xffffffff) | u >> (32 - v) def forge(w, a, b, c, d): for i in range(2): w[a] = (w[a] + w[b]) & 0xffffffff w[d] = mixer(w[a] ^ w[d], 16 // (i...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false
sajjadium/ctf-archives
https://github.com/sajjadium/ctf-archives/blob/129a3a9fe604443211fa4d493a49630c30689df7/ctfs/Crypto/2022/keydream/keydream.py
ctfs/Crypto/2022/keydream/keydream.py
#!/usr/bin/env python3 from Crypto.Util.number import * import string from flag import flag def randstr(l): rstr = [(string.printable[:62] + '_')[getRandomRange(0, 62)] for _ in range(l)] return ''.join(rstr) def encrypt(msg, l): while True: rstr = 'CCTF{it_is_fake_flag_' + randstr(l) + '_90OD_luCk___!!}' p ...
python
MIT
129a3a9fe604443211fa4d493a49630c30689df7
2026-01-05T01:34:13.869332Z
false