Skip to content

Instantly share code, notes, and snippets.

View hellman's full-sized avatar
🍊

Aleksei Udovenko hellman

🍊
View GitHub Profile
@hellman
hellman / sharingan_solver.py
Created October 10, 2016 15:36
HITCON QUALS 2016 - Sharingan (Misc 100)
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from sock import Sock
f = Sock("52.197.160.186 31337")
def read_map():
res = []
print " ", "".join("%2d" % i for i in xrange(19))
@hellman
hellman / rsa_collect.py
Last active January 9, 2021 20:22
HITCON QUALS 2016 - RSA (Crypto 400)
'''
http://www.chesworkshop.org/ches2011/presentations/Session%204/CHES2011_Session4_3.pdf
First part - collecting CRT values.
'''
import subprocess
from sock import Sock
from libnum import gcd, solve_crt
def getHashes(p):
return subprocess.check_output(["./sha1", p]).split()[0]
@hellman
hellman / generate.py
Created October 11, 2016 18:00
HITCON QUALS 2016 - Reverse (Reverse 500)
from binascii import crc32
def lcg_step():
global lcg
lcg = (0x5851F42D4C957F2D * lcg + 0x14057B7EF767814F) % 2**64
return lcg
def extract(val):
res = 32 + val - 95 * ((
((val - (0x58ED2308158ED231 * val >> 64)) >> 1) +
@hellman
hellman / 1_hastad.py
Last active May 13, 2020 02:19
Hack The Vote 2016 - SMTPresident (Crypto 400) - RSA private key partial exposure attack
#-*- coding:utf-8 -*-
"""
Hastad's broadcast attack (CRT + root in integers)
"""
import os, re
from collections import defaultdict
from libnum import *
@hellman
hellman / supercomputer.py
Last active February 28, 2017 13:20
Boston Key Party CTF 2016 - Supercomputer
from sage.all import *
import re
active_bits = [
0, 3, 4, 7, 8, 9, 10, 11, 14, 20, 21, 24, 25, 26,
35, 40, 41, 43, 45, 46, 47,
]
code = """
@hellman
hellman / almost_leet.py
Last active April 9, 2017 22:12
ASIS CTF Quals 2017 - Almost leet
from sage.all import *
from itertools import product
def frombin(v):
return int("".join(map(str, v)), 2 )
def l33tize(s, eight=False):
ms = GL(8 if eight else 6, GF(2))
while 1:
@hellman
hellman / bivariate_polynomial_modulo_N.py
Created April 24, 2017 13:53
PlaidCTF 2017 - Common (Crypto 600)
'''
Common-prime (in group order!) RSA with low private exponent.
p = 2ga + 1
q = 2gb + 1
N = p * q
phi(N) = 2gab
'''
from sage.all import *
@hellman
hellman / rsa_timing_attack_d_Montgomery.py
Created May 1, 2017 12:23
DEF CON 2017 Quals - Godzilla (Reverse/Crypto)
#-*- coding:utf-8 -*-
'''
DEF CON 2017 Quals - Godzilla (Reverse)
Timing attack on RSA decryption.
Based on http://www.cs.jhu.edu/~fabian/courses/CS600.624/Timing-full.pdf
Another solutions:
https://gist.github.com/nneonneo/367240ae2d8e705bb9173a49a7c8b0cd by b2xiao
https://gist.github.com/Riatre/caac24840b176cf843b3f66ad9a5eeaf by riatre
@hellman
hellman / Flag.java
Last active June 19, 2017 09:34
Google CTF 2017 Quals - Bleichenbacher’s Lattice Task - Insanity Check
/**
* Print a Flag.
* @author Daniel Bleichenbacher
*/
package blt;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.security.GeneralSecurityException;
@hellman
hellman / 0solve.py
Last active September 3, 2017 16:22
Google CTF 2017 Quals - Introspective CRC
'''
CRC is affine.
CRC(x) = L(x) + C, where L is linear.
We want CRC(x) = L(x) + C = x.
Write as L(x)+x = C.
Solve matrix equation.
'''
from sage.all import *