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 long_to_bytes as l2b | |
from sage.all_cmdline import * | |
n = 140376049134934822153964243403031201922239588054133319056483413311963385321279682186354948441840374124640187894619689719746347334298621083485494086361152915457458004998419817456902929318697902819798254427945343361548635794308362823239150919240307072688623000747781103375481834571274423004856276841225675241863 | |
c = 46735962204857190520476434898881001530665718155698898882603422023484998388668858692912250418134186095459060506275961050676051693220280588047233628259880712415593039977585805890920089318643002597837000049626154900908543384761210358835843974072960080857150727010985827690190496793207012355214605393036388807616 | |
e = 7621 | |
def factorize(e, dp): | |
for i in range(2, e): | |
p = (e * dp - 1 + i) // i |
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 sage.modules.free_module_integer import IntegerLattice | |
from random import randint | |
import sys | |
from itertools import starmap | |
from operator import mul | |
# from sage.all_cmdline import * | |
# Babai's Nearest Plane algorithm | |
# from: http://mslc.ctf.su/wp/plaidctf-2016-sexec-crypto-300/ | |
# https://hackmd.io/@hakatashi/B1OM7HFVI |
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
''' | |
ref form https://sasdf.github.io/ctf/writeup/2020/google/crypto/oracle/ & | |
https://github.com/sasdf/ctf/blob/master/writeup/2020/google/crypto/oracle/_files/solve.py | |
''' | |
import aegis | |
import base64 | |
import sys | |
import aes | |
import itertools | |
import re |
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 string | |
import itertools | |
import hashlib | |
HOST = '123.57.4.93' | |
PORT = 45216 | |
# HOST = '127.0.0.1' | |
# PORT = 20009 |
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
''' | |
https://ctftime.org/task/2108 | |
In the challenge, We’re trying a new mac here at BKP—HMAC-CRC. | |
The hmac (with our key) of “zupe zecret” is ‘0xa57d43a032feb286’. | |
What’s the hmac of “BKPCTF”? | |
''' | |
from sage.all import * |
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 send_num(num): | |
p.sendline('god') | |
p.sendline(str(num).strip('L')) | |
return int(p.recvuntil()) | |
def get_flag(num): | |
p.sendline('bless') | |
p.sendline(str(num).strip('L')) | |
return p.recvuntil() |
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
# author: badmonkey | |
from Crypto.Util.number import * | |
x1 = 123702839015756050884261730350882737708358949223717439499184803586403380580917033774031115610745320766887583414238651786366942713037837183155670218651008201659397071753885966029204756119524199815830117337679903000409946531282131341544499373725768763177481236458288527526859422459135345981831473247316555618560 | |
x2 = 53924539754438007029501782029367518619266978487508630921932520518338714507664032847344261722536853774745396939590212348751300654791168048424611586167435934594214127893014772880318410947388412139484910911558913354881832668949036424760411326983813389804113790149675585445672972740198653398937213550096612898644 | |
x3 = 63167700157587157707659591399396856546372104423703909698033441469110658576803656359757694321232303912965997844863919208184964899691086676221424510238937996039639020372184420079106454203010811220417415790732729673830907444478937628707872186593129029778616120328244635824580198884662150104071084993653737914022 | |
x4 = 60900060027375388502 |
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 sage.all_cmdline import * | |
from gmpy2 import iroot, invert, is_prime | |
from Crypto.Util.number import long_to_bytes | |
from random import shuffle | |
s = pow(2, 790-256) | |
primes = [6703903964971298549787012499102923063739682910296196688861780721860882015036773488400937149083451713845015929093243025426876941405973284973216824503118559, 6703903964971298549787012499102923063739682910296196688861780721860882015036773488400937149083451713845015929093243025426876941405973284973216824503126443, 6703903964971298549787012499102923063739682910296196688861780721860882015036773488400937149083451713845015929093243025426876941405973284973216824503193349, 6703903964971298549787012499102923063739682910296196688861780721860882015036773488400937149083451713845015929093243025426876941405973284973216824503562289, 6703903964971298549787012499102923063739682910296196688861780721860882015036773488400937149083451713845015929093243025426876941405973284973216824503734189, 6703903964971298549787012499102923063739682910296196688861780721860 |
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 gmpy2 import * | |
h= mpz(h) | |
A= mpz(A) | |
B= mpz(B) | |
p= mpz(p) | |
q= mpz(q) | |
c1= mpz(c1) | |
c2= mpz(c2) |
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 GCD, long_to_bytes | |
from hashlib import sha1 | |
from tqdm import * | |
n = 26318358382258215770827770763384603359524444566146134039272065206657135513496897321983920652242182112479484135343436206815722605756557098241887233837248519031879444740922789351356138322947108346833956405647578838873425658405513192437479359531790697924285889505666769580176431360506227506064132034621123828090480606055877425480739950809109048177976884825589023444901953529913585288143291544181183810227553891973915960951526154469344587083295640034876874318610991153058462811369615555470571469517472865469502025030548451296909857667669963720366290084062470583318590585472209798523021029182199921435625983186101089395997 | |
m = 262754933207060261441969663988861968338151704138077058052877634130131009628317037746403327655038380874349048356579882760646603044278029616091859979646654408674169007111285178592675046576271605987002486897380452431421114891796733758193087795352472146606942116987994610443543522009503093923218610219209682 |
NewerOlder