from hashlib import sha256 s="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" t="5d755ec7addaff634907855979bc02d0c279ab60ce736754faa895a81938b3c9" R="EsHH8BQQsfIMp7gC" assertlen(R)==16 assertlen(t)==64 for i1 in s: for i2 in s: for i3 in s: for i4 in s: XXXX=i1+i2+i3+i4 if sha256((XXXX+R).encode()).hexdigest()==t: print (XXXX)
最终我还是手速加快,迅速地得到了许许多多组数据… …,其中一组输出提示:flag mod 9c7f17669e90b219 (in hex) : 3316d33a70b0a941。
加上程序的核心代码可知,输出提示mod后买你的那个数字是质数
1 2 3 4 5
if choice == b"1": module = getPrime(64) self.send(("flag mod {} (in hex) : {}".format( hex(module)[2:], hex(m % module)[2:])).encode()) continue
from Crypto.Util.number import * from MsandAs import m,a defEX_GCD(a,b,arr): #扩展欧几里得 if b == 0: arr[0] = 1 arr[1] = 0 return a g = EX_GCD(b, a % b, arr) t = arr[0] arr[0] = arr[1] arr[1] = t - (a // b) * arr[1] return g defModReverse(a,n): #ax=1(mod n) 求a模n的乘法逆x arr = [0,1,] gcd = EX_GCD(a,n,arr) if gcd == 1: return (arr[0] % n + n) % n else: return -1 arr = [0,1,]
# FUNCTION MAIN# piM=1 for i inrange(40): piM*=m[i] print(piM) t =[0for _ inrange(40)] M =[0for _ inrange(40)] for i inrange(40): M[i]=piM//m[i] for i inrange(40): t[i]=ModReverse(M[i],m[i]) B=0#B为所有atM之积的和 for i inrange(40): B+=a[i]*t[i]*M[i] B%=piM print(B) print(long_to_bytes(B))
from pwn import * from hashlib import sha256 from Crypto.Util.number import * defgetyanzhengma(s16len,s64len): LTSNMS="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" assertlen(s16len)==16andlen(s64len)==64 for i1 in LTSNMS: for i2 in LTSNMS: for i3 in LTSNMS: for i4 in LTSNMS: if sha256((i1+i2+i3+i4+s16len).encode()).hexdigest()==s64len: return i1+i2+i3+i4 sh=remote("49.235.239.97",10001) while(True): str1=sh.recvline(keepends=False) if(str1[0:6]=="sha256"): break yanzhengma=(getyanzhengma(str1[12:28],str1[33:97])) sh.send(yanzhengma) print("[NOTE]SENT YANZHENGMA") e,n,c=1,1,1 str2=sh.recvline(keepends=False) e=str2[18:] str2=sh.recvline(keepends=False) n=str2[4:] str2=sh.recvline(keepends=False) c=str2[4:] e,n,c=int(e),int(n),int(c) print("[NOTE]F=GOT enc") L,R,Clk=0,n,1 while L<=R: if(Clk%50==0): print(L,R,Clk) M=(L+R)//2 for i inrange(3): str3=sh.recvline(keepends=False) sh.send(b"1") a=(c*pow(2,e*Clk,n))%n sh.send(str(hex(a))[2:].encode()) recnum=sh.recvline(keepends=False) recnum=int(recnum[-1]) if recnum==1or recnum==3: L=M+1 if recnum==0or recnum==2: R=M-1 Clk+=1 print(L) print(long_to_bytes(L))