English [HackIM 2016] [Crypto 400 – Crypto question 3] Write Up

Description

Crypto Question 3 400 pts

After entring the luxurious condomium,you get the feel that you are in home of a yester Star. the extravagant flooring and furnishings shows the richness of this star. But where is she? There she is, lying peacefuly on her couch. See what Envy has done to her…with a perfectly well maintained attractive body she still looks sex diva, except for her face beyond recogniton. Her identity is crucial to know who killed her and why? In absence of any personal data around there is only a file. with a cryptic text in it. Preity sure she has used her own name to XOR encrypt the file. And challenge is to know her name.

Resolution

This challenge were maybe the most complicated of the crypto category.
It’s a XOR with an unknown key with an unknown length.
This little handmade program solve this kind of XOR task using frequency analysis.

with open('cipher','rb') as f:
 message = f.read()

T = []
cur = -1
for i in range(len(message)):
 if i%12==0:
 T.append('')
 cur = cur+1
 T[cur] = T[cur]+("%02x" % message[i])

for i in range(len(T[cur])//2,12):
 T[cur] = T[cur]+'00'

englishLetterFreq = {' ': 15,'E': 12.70, 'T': 9.06, 'A': 8.17, 'O': 7.51, 'I': 6.97, 'N': 6.75, 'S': 6.33, 'H': 6.09, 'R': 5.99, 'D': 4.25, 'L': 4.03, 'C': 2.78, 'U': 2.76, 'M': 2.41, 'W': 2.36, 'F': 2.23, 'G': 2.02, 'Y': 1.97, 'P': 1.93, 'B': 1.29, 'V': 0.98, 'K': 0.77, 'J': 0.15, 'X': 0.15, 'Q': 0.10, 'Z': 0.07}
for i in range(10):
 englishLetterFreq.update({str(i):1.5})
for i in range(ord('a'),ord('z')):
 englishLetterFreq.update({chr(i):englishLetterFreq[chr(i-ord('a')+ord('A'))]})

print(englishLetterFreq)


key = ''
ar = ['']*len(T)
for letter in range(0,len(T[10]),2):
 goodLetter = 0
 doIt = input("Do it with hands ?")
 max = 0
 for letterValue in range(256):
 score = 0
 score2 = 0
 temp = ''
 
 for i in range(len(T)):
 a = letterValue^int(T[i][letter:letter+2],16)
 temp = temp+' '+chr(a)
 if (a>=ord('A') and a<=ord('Z')) or (a>=ord('a') and a<=ord('z')) or (a>=ord('0') and a<=ord('9')) or a==ord(' '):
 score = score+1
 score2 = score2+englishLetterFreq.get(chr(a),0)
 
 if score>9 and doIt == '1':
 print("We had a good letter to xor with : "+str(letterValue))
 print("We obtained "+temp)
 replace = input("Replace current ?")
 if replace=='1':
 goodLetter = letterValue
 
 if score2>max and doIt != '1':
 print("We had a good letter to xor with : "+str(letterValue))
 print("We obtained "+temp)
 goodLetter = letterValue
 max = score2
 
 key = key+format(goodLetter,'02x')
 for i in range(len(T)):
 ar[i] = ar[i]+chr(goodLetter^int(T[i][letter:letter+2],16))
 
 print("Current state :")
 print("Key = "+key)
 for i in ar:
 print(i)
 print()

We obtain :

 julie And St
eve's Sex li
fE doeSn't g
oing tHe way
 they Want t
o be, They w
ant to know 
how thEy can
 add mOre an
d pure pleas
ure on their
 sex lIfe. S
o they go to
 the lIbrary
 where they 
rEAd A book 
about AnciEn
t secrEts of
 the KAma Su
trA, dUrINg 
rEAdinG thEy
 uniNtEntion
ally vIsIt a
ncieNt India
 where they 
mEet A mIstr
ess. THe mis
tress GuIdEs
 Julie and S
tEve ANd tEa
ches tHem Ka
ma SutRa sEc
rEts ANd lEa
ds theM to m
any plAces w
hEre tHey me
et manY peop
lE who pract
icAlly teach
 them Many m
ore KAMa Sut
ra secRets.*
- WritTen by
 JeaNnA Fine
 
anna

Now we know her name as asked 🙂

Flag was “Jeanna Fine

Leave a Reply

Your email address will not be published.