for i inrange(307): s = f x = 0 flag = 'f' for j in cipher[1:]: s = (s + 3 * (x + i) ** 2 + 3 * (x + i) + 2) % 307 flag += chr(s % 307 ^ j) x += 1 if flag.startswith('flag'): print(flag) break
n = 91199296749700640866861970843221921564137544261129053887425392932988391945347109139916771807692421337876348836994210858876263910655470768762350727999480618878134421267998392984933961329385719026483517450921019470754415144029155942372395138271661480657908744441177122383316627111414388193786640150788888530603
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from pwn import * import gmpy2 import re
context.log_level = 'debug' sh = remote('47.96.253.167', 10001)
defsolve_param(): # Show me the answer: # 2^(2^15564589) mod 121681006663891030353125079362654646150164550749728886750112000021783884995766049892447002069598160684689219206863221050719168669576003627002300521823506368946026163175585544560064152737971271228176382282388743375550175972802243965592596093473434521220152129320759007520132577637100332218758770863084824561257 # You have 10 seconds. gogogo! # Your answer: _param = sh.recvuntil(b'Your answer: ').decode() a, b, p, n, _ = list(map(int, re.findall(r"\d+", _param))) return gmpy2.powmod(a, 2 ** p, n)
defsolve(): ans = solve_param() sh.sendline(str(ans).encode()) sh.recvline() flag = sh.recvline() print(flag)
int _p = atoi(argv[1]); constchar* _n = argv[2]; mpz_t a, p, n, ans; mpz_init_set_ui(a, 2); mpz_inits(p, n, ans, NULL); mpz_set_str(n, _n, 10); mpz_pow_ui(p, a, _p); mpz_powm(ans, a, p, n); gmp_printf("%Zd\n", ans);
from Crypto.Util.number import * from gmpy2 import * from sympy import *
N = 74800532075026000381837181416244620595735832084449587543298943677432459925226779465012047327503889744860523742208172886216379540864590422182548917267328318002568353149060053351303844576292098647505525745870477873483633887953229529381991915277382594791671160580866806786630969504851192001076830016106043571009 a = iroot(N, 2)[0] whileTrue: if iroot(abs(a ** 2 - N), 2)[1]: x = iroot(abs(a ** 2 - N), 2)[0] p = symbols('p') q = symbols('q') ans = solve([p * q - N, p - q - 2 * x], [p, q])[0] p = abs(ans[0]) q = abs(ans[1]) print(p, q) break a += 1
分解N之后就基本上解决了
1 2 3 4 5 6 7 8 9 10 11 12 13
from Crypto.Util.number import * from gmpy2 import *
P, Q = 8648730084528363889079256703102451885638502646326789467433028151231988147282102518446568939251174824284022886978974447762450602661673263195651063256419309, 8648730084528363889079256703102451885638502646326789467433028151231988147950513953027745544103648427529036056091995954088466858748986415929861782517451301 c = 43523864567514744915966689535281796032938848285272379114823034307386872487132537558002098315139078417494456662422159972154875552286129585227356449706489220730274914478951912475004304175148219692251592494173776801031153513926834828210101453328096936742697439995490235629532386225637438572176601752800221641207 e = 65537 n = 74800532075026000381837181416244620595735832084449587543298943677432459925226779465012047327503889744860523742208172886216379540864590422182548917267328318002568353149060053351303844576292098647505525745870477873483633887953229529381991915277382594791671160580866806786630969504851192001076830016106043571009
phi = (P - 1) * (Q - 1) d = invert(e, phi) m = pow(c, d, n) flag = long_to_bytes(m) print(flag)