This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2014 by Stephen Bradshaw | |
# | |
# SHA1 and SHA2 generation routines from SlowSha https://code.google.com/p/slowsha/ | |
# which is: Copyright (C) 2011 by Stefano Palazzo | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! coding:utf-8 | |
import os | |
from PIL import Image | |
from hashlib import sha1 | |
from Crypto.Util.number import long_to_bytes as n2s | |
def sha1_collision(image1,image2) : | |
''' | |
Usage: input two image, open in bytes or just a string path | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cube_root(c, q): | |
F = FiniteField(q) | |
R.<x> = PolynomialRing(F,'x') | |
while 1: | |
a = F.random_element() | |
b = F.random_element() | |
fx = x**3 - a*x**2 + b*x - c | |
fc = list(factor(fx)) | |
if len(fc) <= 1: | |
root = pow(x, (q**2+q+1)//3, fx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def partial_p(p0, kbits, n): | |
PR.<x> = PolynomialRing(Zmod(n)) | |
nbits = n.nbits() | |
f = 2^kbits*x + p0 | |
f = f.monic() | |
roots = f.small_roots(X=2^(nbits//2-kbits), beta=0.3) # find root < 2^(nbits//2-kbits) with factor >= n^0.3 | |
if roots: | |
x0 = roots[0] | |
p = gcd(2^kbits*x0 + p0, n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Find P with only knowning 50% of LSB (least significant bit)" | |
def recover_msb(n, p, known_bits, debug=False) : | |
beta = 0.5 | |
epsilon = beta^2/7 | |
PR.<x> = PolynomialRing(Zmod(n)) | |
f = x*(2^kbits) + p | |
f = f.monic() | |
x = f.small_roots(X=2^(pbits-kbits), beta=0.3)[0] # find root < 2^kbits with factor >= n^0.3 | |
return x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script is from https://latticehacks.cr.yp.to/ntru.html | |
import math | |
import numpy as np | |
from sympy.abc import x | |
from sympy import ZZ, Poly | |
from Crypto.Util.number import long_to_bytes | |
n = 71 | |
d = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from sympy.solvers import solve | |
from sympy import Symbol | |
# This is comes from https://github.com/sourcekris/RsaCtfTool/blob/master/wiener_attack.py | |
# A reimplementation of pablocelayes rsa-wiener-attack | |
# https://github.com/pablocelayes/rsa-wiener-attack/ | |
class WienerAttack(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sage | |
# This code is taken from https://github.com/mimoo/RSA-and-LLL-attacks | |
import time | |
############################################ | |
# Config | |
########################################## | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract DelegateCaller { | |
uint public n; | |
address public sender; | |
function delegatecallSetN(address _e, uint _n) { | |
_e.delegatecall(bytes4(keccak256("setN(uint256)")), _n); // D's storage is set, E is not modified | |
} | |
} | |
contract OuterContract { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.18; | |
contract GuessNumber{ | |
struct Player { | |
address addr; | |
uint number; | |
} | |
Player[2] private players; | |
NewerOlder