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 math | |
def egcd(a, b): | |
x,y, u,v = 0,1, 1,0 | |
while a != 0: | |
q, r = b//a, b%a | |
m, n = x-u*q, y-v*q | |
b,a, x,y, u,v = a,r, u,v, m,n | |
gcd = b | |
return gcd, x, y |
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 fractions | |
def egcd(a, b): | |
x,y, u,v = 0,1, 1,0 | |
while a != 0: | |
q, r = b//a, b%a | |
m, n = x-u*q, y-v*q | |
b,a, x,y, u,v = a,r, u,v, m,n | |
gcd = b | |
return gcd, x, y |
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 egcd(a, b): | |
x,y, u,v = 0,1, 1,0 | |
while a != 0: | |
q, r = b//a, b%a | |
m, n = x-u*q, y-v*q | |
b,a, x,y, u,v = a,r, u,v, m,n | |
gcd = b | |
return gcd, x, y | |
def decrypt(p, q, e, ct): |
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
from fractions import Fraction | |
def egcd(a, b): | |
x,y, u,v = 0,1, 1,0 | |
while a != 0: | |
q, r = b//a, b%a | |
m, n = x-u*q, y-v*q | |
b,a, x,y, u,v = a,r, u,v, m,n | |
gcd = b | |
return gcd, x, y |
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 plus(x, y): | |
return (x + y) & 0xffffffff | |
def rotate(x, n): | |
y = x << n | |
z = x >> (32 - n) | |
return (y | z) & 0xffffffff | |
def make_array(s): | |
v = [s[i: i+2] for i in range(0, len(s), 2)] |
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 requests | |
def make_blocks(s): | |
return [s[i:i+16] for i in xrange(0, len(s), 16)] | |
def xor(a, b): | |
return "".join([chr(ord(a[i]) ^ ord(b[i % len(b)])) for i in xrange(len(a))]) | |
def decrypt(target): | |
prefix = "578ae51334b467aa99092c00e57ff977168f922a.4f3a3680afa88ae056e5c56fb67544ff03e5b64f4174f1752ab93ac24a78257fc173ab2f339436453e9163265fd23707" |
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 socket | |
import hashlib | |
import itertools | |
def hash_solve(s): | |
charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" | |
for i in range(5): | |
for j in itertools.product(charset, repeat=i): | |
test = "".join(j) | |
h = hashlib.md5(test).hexdigest().strip() |
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 -*- | |
# 0CTF 2016: RSA? (Crypto 2pt) | |
''' | |
# openssl rsa -in public.pem -pubin -text -modulus | |
Public-Key: (314 bit) | |
Modulus: | |
02:ca:a9:c0:9d:c1:06:1e:50:7e:5b:7f:39:dd:e3: | |
45:5f:cf:e1:27:a2:c6:9b:62:1c:83:fd:9d:3d:3e: | |
aa:3a:ac:42:14:7c:d7:18:8c:53 |
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
# Sharif University CTF 2016: High-speed RSA Keygen [Part2] | |
def egcd(a, b): | |
if (a == 0): | |
return [b, 0, 1] | |
else: | |
g, y, x = egcd(b % a, a) | |
return [g, x - (b // a) * y, y] | |
def modInv(a, m): |
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
# SECCON CTF 2015 Online Quals Find the prime numbers (Crypto 200pt) | |
def egcd(a, b): | |
if (a == 0): | |
return [b, 0, 1] | |
else: | |
g, y, x = egcd(b % a, a) | |
return [g, x - (b // a) * y, y] | |
# Modular multiplicative inverse |
OlderNewer