|
Yusa的日常生活—美国大选- from Crypto.Util.number import *
- from secret import p,q
- def gcd(a, b):
- while b:
- a, b = b, a%b
- return a
-
- flag='DASCTF{********************************}'
- e=3
- phi = (p-1)*(q-1)
- assert gcd(e,phi)==1
- d = inverse(e,phi)
- print r"Form of vote:{voter}:{votee}! eg: "
- print "Yusa:Trump!"
- vote = pow(bytes_to_long("Yusa:Trump!"),d,p*q)
- print "vote:",vote
- try:
- yusa = int(raw_input("Your vote: "))
- vote = long_to_bytes(pow(yusa,e,p*q)).split(":")
- print vote
- if vote[-1] == "Trump!":
- print flag[:10]
- elif vote[-1] == "Biden!":
- print flag[10:]
- except Exception as e:
- print str(e)
- exit()
复制代码
|
|