Skip to content

Instantly share code, notes, and snippets.

View hellman's full-sized avatar
🍊

Aleksei Udovenko hellman

🍊
View GitHub Profile
@hellman
hellman / lacucara.py
Last active June 6, 2024 20:15
Codegate 2024 Quals - LACUCARA_VM (Reverse) - black-box solution
'''
Turns out that the output.txt contains images of the 8-byte chunks of the flag under a fixed affine map.
We can interpolate the map from a bunch of samples and then simply invert the real flag's output.
'''
from sage.all import *
import re
from binteger import Bin # pip install binteger
# need to use script log, since the program requires a console
'''
@hellman
hellman / benchmark_mult_modp.c
Created May 28, 2024 20:28
Multiplication modulo 2^64-257
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
int main() {
uint64_t a = 0x6dc06dabb8fb11a7ull;
uint64_t b = 0x661f975dc51abe17ull;
// uint64_t a = 1ull << 63;
// uint64_t b = 1ull << 63;
@hellman
hellman / CRC32-extend.ipynb
Created May 7, 2024 11:58
Extending CRC32
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hellman
hellman / decision_tree.ipynb
Last active March 17, 2024 18:37
Decision Tree of a Boolean function in $O(n3^n)$
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hellman
hellman / Benchmark_is_cyclic.ipynb
Created February 18, 2024 11:51
Benchmark isogeny.is_cyclic
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hellman
hellman / dice_rejected.py
Last active May 21, 2024 04:59
DiceCTF 2021 - rejected
from sage.all import *
from rejected import LFSR, taps
from binteger import Bin
from sock import Sock
n = 64
N = 2**30 + 2**29
f = Sock("mc.ax 31669")
f.send_line(str(N))
@hellman
hellman / dice_psych.py
Last active February 6, 2022 22:08
DiceCTF 2022 - psych (crypto 500)
from sage.all import ZZ, GF, EllipticCurve, proof
from hashlib import scrypt
from sock import Sock
from psych import sidh, xor, G, H
proof.all(False)
def ser(*args):
@hellman
hellman / 0raccoon.ipynb
Last active July 3, 2021 05:20
CTFZone 2021 - Raccoon
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hellman
hellman / write.ipynb
Last active February 28, 2021 14:46
AeroCTF 2021 - Horcrux (Crypto)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hellman
hellman / coll.py
Last active January 14, 2021 08:44
HXP CTF 2020 - Octothorpe (Crypto Hard)
'''
The idea is to reach a state consisting of 00 and FF bytes.
Because of the independence of shifts values, if the message block is the same 32-byte part repeated 2 times,
the state is preserved. We then can change the 32 byte part arbitrarily and keep the hash value unchanged.
To do this we first craft a 32x2 message block that lands on such state after 2nd round (1st round does nothing).
We have 32 bytes of freedom (-charset constraints), so this is reasonable and can be done with 1 byte guess and propagation.
One caveat is that the initial state is rather symmetric and and it's not always easy to land on a desired state,
so we prepend random block first to randomize the state.