Created
October 19, 2019 15:47
-
-
Save mkow/420ec189ed1499f61d61b67f74fd2f72 to your computer and use it in GitHub Desktop.
Lost Modulus Again (HITCON Quals 2019, solver by adami)
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
e = 1048583 | |
d = 20899585599499852848600179189763086698516108548228367107221738096450499101070075492197700491683249172909869748620431162381087017866603003080844372390109407618883775889949113518883655204495367156356586733638609604914325927159037673858380872827051492954190012228501796895529660404878822550757780926433386946425164501187561418082866346427628551763297010068329425460680225523270632454412376673863754258135691783420342075219153761633410012733450586771838248239221434791288928709490210661095249658730871114233033907339401132548352479119599592161475582267434069666373923164546185334225821332964035123667137917080001159691927 | |
x = 22886390627173202444468626406642274959028635116543626995297684671305848436910064602418012808595951325519844918478912090039470530649857775854959462500919029371215000179065185673136642143061689849338228110909931445119687113803523924040922470616407096745128917352037282612768345609735657018628096338779732460743 | |
y = 138356012157150927033117814862941924437637775040379746970778376921933744927520585574595823734209547857047013402623714044512594300691782086053475259157899010363944831564630625623351267412232071416191142966170634950729938561841853176635423819365023039470901382901261884795304947251115006930995163847675576699331 | |
t = e*d - 1 | |
while (t % 2) == 0: | |
t= t / 2 | |
# p = 135136928230019073146158752709151576119155564982754768027494878210491711363872928718225319693774548227271767324623087432404412585662574641211148315864508708036871556964386141364368797168619283425834644924573664613109609076319077176698754203574237779054129492453503018443013301394555677417140681949745410143477 | |
# q = 166564961597106229342966450443567005929416288372170308009700499465281616388542030734600089639466922805142577582894052957547174764252067983124558747593344882775630971023610755334859287415681252266825395627416912206349590353878868107848653100299011246746851490276537231636534462821659050996145878589643016881929L | |
def find(phi): | |
# phi = p*q - p - q + 1 | |
a = (phi - 1)*x + 1 | |
b = (phi - 1)*y + 1 | |
n = a*b | |
for g in range(10, 15): | |
p = gcd(int(pow(g, t, n)) - 1, n) | |
if p > 2**1020 and p < 2**1030: | |
print 'prime:', p | |
exit(0) | |
for k in xrange(2, e): | |
a = e*d-1 | |
if a % k == 0: | |
print 'k:', k | |
find(a/k) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment