Skip to content

Instantly share code, notes, and snippets.

View hellman's full-sized avatar
🍊

Aleksei Udovenko hellman

🍊
View GitHub Profile
# matrix from the `a^i` generator basis to the `a^(-2^i)` normal basis
to_normal = [0x7f50f7fd, 0x95ecaead, 0x495ffebe, 0x90618596, 0x6e0d0395, 0x527b6ec5, 0x563d1cac, 0x1ee02779,
0x287efd13, 0x5a66f53c, 0xdf3df773, 0xa0d25f82, 0x79357a5b, 0xe5c59050, 0x15508e51, 0x498da844,
0xcaf65756, 0x4830c2cb, 0xa93db762, 0x8f7013bc, 0x2d337a9e, 0x50692fc1, 0x72e2c828, 0x24c6d422,
0xa4186165, 0x47b809de, 0xa83497e0, 0x12636a11, 0x23dc04ef, 0x8931b508, 0x4498da84, 0xffffffff]
# inverse of to_normal
from_normal = [0xdb710641, 0x6d930ac3, 0x6d3d2d4d, 0x6567cb95, 0xd7125358, 0x5b358fd3, 0x2e9bb40b, 0x12a59a49,
0x8df9403d, 0x5139de12, 0xba340226, 0x29c45641, 0x12fbc105, 0xecd30c55, 0x3755ebd8, 0x24ee460c,
0x23783fcf, 0x479933fc, 0xa39442a5, 0x9ea0056d, 0xf42608f6, 0x20cacf04, 0x2a0cf83d, 0xeffd8645,
0x2a39a67d, 0x640ebd82, 0x9dfd8792, 0x277402ab, 0xad31bc4f, 0x31536354, 0x5ea35fca, 0x52b55e39]
@maple3142
maple3142 / example.sage
Last active May 1, 2024 09:50
LLL/CVP utilities
from lll_cvp import *
from functools import partial
def example1():
# copied from https://github.com/rkm0959/Inequality_Solving_with_CVP/blob/main/Example%20Challenge%204%20-%20HITCON%20CTF%202019%20Quals%20-%20not%20so%20hard%20RSA/solve_challenge_4.sage
## Example 4 : HITCON CTF 2019 Quals not so hard RSA
## d is 465 bits
@maple3142
maple3142 / flatter.sage
Last active September 10, 2023 13:18
trying https://github.com/keeganryan/flatter for faster lattice reduction than LLL
from subprocess import check_output, DEVNULL, CalledProcessError
import itertools
import IPython
import time
def to_fplll_format(M):
m, n = M.dimensions()
ret = ""
s = "["
@sasdf
sasdf / solve.cpp
Last active November 29, 2021 06:18
DragonCTF 2021 CRC Recursive Challenge
// g++ -O3 solve.cpp -fopenmp && ./a.out
//
// Credits:
// Algorithm: @utaha1228
// Optimization: @sasdf
#include "table.h" // Generated by python3 solve.py
#include <omp.h>
#include <cstdint>
#include <cstdio>
@33eyes
33eyes / commit_jupyter_notebooks_code_to_git_and_keep_output_locally.md
Last active May 10, 2024 03:14
How to commit jupyter notebooks without output to git while keeping the notebooks outputs intact locally
  1. Add a filter to git config by running the following command in bash inside the repo:
git config filter.strip-notebook-output.clean 'jupyter nbconvert --ClearOutputPreprocessor.enabled=True --to=notebook --stdin --stdout --log-level=ERROR'  
  1. Create a .gitattributes file inside the directory with the notebooks

  2. Add the following to that file:

*.ipynb filter=strip-notebook-output  
@msjyryxdzzj
msjyryxdzzj / sol.sage
Last active January 14, 2024 15:33
RWCTF 3rd - Crypto - Old Curse solve script
from Crypto.Util.number import *
PR.<qr>=PolynomialRing(ZZ)
def calc_params(e,N):
delta = 0.1
gama = 0.05
beta = log(e,N).n()
alpha = 0.25
return alpha,beta,delta,gama
@rekkusu
rekkusu / sharsable.sage
Last active October 19, 2020 06:51
SECCON 2020 Online CTF sharsable author writeup
# Overview
# This challenge is based on May's version of Wiener's Attack
# (https://www.math.uni-frankfurt.de/~dmst/teaching/WS2015/Vorlesung/Alex.May.pdf)
# But the attack can't be apply to the challenge because it has 2 exponents,
# so you have to extend the method of May.
# After LLL, choose 2 shortest vectors and reconstruct polynomial.
# then pick coefficients and decrypt ciphertext
import json
from binascii import unhexlify
@gaulinmp
gaulinmp / nopromotedtweets.js
Created October 6, 2020 17:26
Tampermonkey script to remove promoted tweets
// ==UserScript==
// @name Twitter Promoted
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Get rid of stupid promoted tweets
// @author Mac Gaulin
// @match http*://twitter.com/*
// @grant none
// ==/UserScript==
@birdg0
birdg0 / solve.c
Last active September 27, 2020 09:25
Official solution for "Shoplifters" of 0CTF/TCTF 2020 Finals
/*
gcc -m64 -nostdlib -Os -mrtm -fno-toplevel-reorder -static -Wno-multichar solve.c -o solve.elf
objcopy -Obinary -j .text solve.elf solve.bin
Reference https://github.com/Alberts-Coffee-Hours/Mastik/blob/master/src/l1.c,
https://github.com/vusec/ridl/blob/master/exploits/shadow/leak.c
and https://github.com/oranav/ctf-writeups/blob/master/gctf19/RIDL/solve.c
*/
#include <stdio.h>
#include <stdlib.h>
@ruan777
ruan777 / MultipleMultiply.ipynb
Created June 2, 2020 06:50
RCTF2020 Crypto solution
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.