SHA2017 - Write up Crypto 200
Welcome to my blog.
Today, I will write up for SHA2017 CTF.
First, write for Crypto 200:
The challenge give me source code: source
If we want to get flag we must send to server signed of text start with ''ticket:admin|root|' :
We know $a^d*b^d = (a*b)^d$ then i had a good idea:
If we have some text start with '\xff' and multiple of they is 'ticket:admin|root|'+pading we can solve this challenge.
we have one code brute force to find some text start with '\xff' and multiple of they is 'ticket:admin|root|'+pading :
when we had two signed is number a and b we calculate (pow(a,201)*b)%n and send this to server and get the flag.
The challenge is finish!!!!
Today, I will write up for SHA2017 CTF.
First, write for Crypto 200:
The challenge give me source code: source
If we want to get flag we must send to server signed of text start with ''ticket:admin|root|' :
if ticket.startswith('ticket:admin|root|'):
self.request.sendall("Here you go!\n")
self.request.sendall(flag + "\n")
break
else:
self.request.sendall("Sorry that function is only available to admin user root\n")
In the server provide 3 services:Welcome to the secure login server, make your choice from the following options:
1. Register yourself as a user.
2. Collect flag
3. Sign a message
4. Exit
In the "Sign a message": We send to server one text in hex format, and server send to our sign of this text pading one more '\xff' in the beginning of text.We know $a^d*b^d = (a*b)^d$ then i had a good idea:
If we have some text start with '\xff' and multiple of they is 'ticket:admin|root|'+pading we can solve this challenge.
we have one code brute force to find some text start with '\xff' and multiple of they is 'ticket:admin|root|'+pading :
key = 'ticket:admin|root|' found = False i = 210 while not found: a = int((key + '\x00'*i).encode('hex'), 16) b = int((key + '\xff'*i).encode('hex'), 16) for j in range(200, i): if hex(int(a/pow(0xff, j)))[2:4] == 'ff' and hex(int(b/pow(0xff, j)))[2:4] == 'ff': print "i = %s and j = %s" %(i, j) rs = (int(a/pow(0xff, j))+int(b/pow(0xff, j)))/2 print hex(rs) print pow(0xff, j)*rs > a print pow(0xff, j)*rs < b found = True break
i = 210 and j = 201 0xffa7878ccbd0bcba3a98d8cd75778e1d733a0af8af6aa0bbdd1058L True True
after run this code we have:
'ticket:admin|root|'+ pading = pow(0xff,201) * 0xffa7878ccbd0bcba3a98d8cd75778e1d733a0af8af6aa0bbdd1058LWe send null to server to get signed of ff and send a7878ccbd0bcba3a98d8cd75778e1d733a0af8af6aa0bbdd1058 to get signed of it.
when we had two signed is number a and b we calculate (pow(a,201)*b)%n and send this to server and get the flag.
The challenge is finish!!!!
anh ơi có thể viết writeup bài for01 whitehat chall 04 vừa rồi không ạ ? ( nếu anh có chơi, team BigBear? )
ReplyDelete