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 flask import Flask, render_template, request, make_response, redirect | |
import random | |
import string | |
from base64 import b64decode, b64encode | |
from Crypto.Cipher import AES | |
from hashlib import md5 | |
from Crypto.Hash import HMAC | |
import gzip | |
BLOCK_SIZE = 16 |
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 random | |
import string | |
from base64 import b64decode, b64encode | |
from Crypto.Cipher import AES | |
from hashlib import md5 | |
from Crypto.Hash import HMAC | |
from gzip import * | |
BLOCK_SIZE = 16 | |
pad = lambda s: s + bytearray(((BLOCK_SIZE - len(s) % BLOCK_SIZE) * chr(BLOCK_SIZE - len(s) % BLOCK_SIZE)).encode("utf-8")) |
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 Crypto.Util.number import * | |
from Crypto.PublicKey import RSA | |
def get_n_e(pub_key): | |
key = RSA.importKey(pub_key) | |
return (key.n,key.e) | |
def copper(pubkey, c, msg): | |
n,e = get_n_e(pub_key) | |
msg = msg.replace('X','\x00') |
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
''' | |
sage: tmp.nbits() | |
1024 | |
sage: p = next_prime(1337*tmp + randint(2, 2**512)) | |
sage: q = next_prime(7331*tmp + randint(2, 2**512)) | |
sage: n = p * q | |
''' | |
n = 139713689065649193238602077859960857468098993135221000039102730899547298927683962573562384690733560045229965690142223836971463635696618075169874035306125645096696682021038045841133380609849851790395591047968701652975799368468556274243238594974251982826875184190103880810901174411829635180158201629467635591810569775155092318675639049754541256014635438864801255760305914815607547032463796789980267388517787537827413511219215383011915710116907720461035152786018808394261912036183662986050428253151429051345333273081222126466016921456969903177087878715836995228953335073770833282613911892360743789453583070756075529298371748549 | |
e = 65537 |
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 Crypto.Util.number import * | |
# Fermat Factorisation | |
def fermat(n,e,c): | |
print '-------------------------------Starting Fermat factorisation ...--------------------------------' | |
a = ceil(sqrt(n)) | |
b2 = a^2 - n | |
while not is_square(b2): | |
a += 1 | |
b2 = a^2 - n | |
print 'Factoring successful' |
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 Crypto.Util.number import * | |
n = 139713689065649193238602077859960857468098993135221000039102730899547298927683962573562384690733560045229965690142223836971463635696618075169874035306125645096696682021038045841133380609849851790395591047968701652975799368468556274243238594974251982826875184190103880810901174411829635180158201629467635591810569775155092318675639049754541256014635438864801255760305914815607547032463796789980267388517787537827413511219215383011915710116907720461035152786018808394261912036183662986050428253151429051345333273081222126466016921456969903177087878715836995228953335073770833282613911892360743789453583070756075529298371748549 | |
e = 65537 | |
c = 12468572013728608797463708345483170133996629380442289308559627038940585561940415652074376692937328786810653829958942403878304319433456024381264056159265220036837611561124789123763503235210237526645548600470735521347212790573469514127249385805737895181235784053540315569179888625488285946891206657367500646451826352698299724912115852055157625844877 |
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/python2 | |
from Crypto.Cipher import AES | |
import hmac, hashlib | |
import os | |
import sys | |
menu = """Choose one: | |
1. encrypt data | |
2. decrypt data | |
3. quit |
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 telnetlib import * | |
import string | |
r = Telnet('localhost', 32323) | |
#r = Telnet('localhost', 32323) | |
def enc_data(prefix,suffix): | |
r.read_until('3. quit') | |
r.write('1\n') | |
r.read_until('prefix: ') | |
r.write(prefix+'\n') | |
r.read_until('suffix: ') |
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
c = '1d14273b1c27274b1f10273b05380c295f5f0b03015e301b1b5a293d063c62333e383a20213439162e0037243a72731c22311c2d261727172d5c050b131c433113706b6047556b6b6b6b5f72045c371727173c2b1602503c3c0d3702241f6a78247b253d7a393f143e3224321b1d14090c03185e437a7a607b52566c6c5b6c034047'.decode('hex') | |
import string | |
import itertools | |
alpha = string.ascii_uppercase + string.ascii_lowercase | |
possible_keys = [''.join(i) for i in itertools.product(alpha,repeat = 2)] | |
def xor(s1,s2): | |
return ''.join(chr(ord(a) ^ ord(b)) for a,b in zip(s1,s2)) |
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 Crypto.Util.number import * | |
import random | |
flag = 'Hidden' | |
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) |