HTB - Bank heist

2020. 7. 2. 10:060x0D Crypto

728x90

문제 설명
You get to the scene of a bank heist and find that you have caught one person. Under further analysis of the persons flip phone you see a message that seems suspicious. Can you figure out what the message to put this guy in jail?

내가 생각해본 키워드

Key word : flip phone , message 

숫자이지만, 아스키코드 범위를 초과하는 녀석들이 많이 보이기 때문에 다른 방법으로 풀어야 한다.

상기에 flip phone을 떠올려 보면 쉽게 감을 잡을 수 있다.

root@kali:/home/HTB/crypto# cat solve.py 
import sys
'''
2 : ABC
3 : DEF
4 : GHI
5 : JKL 
6 : MNO 
7 : PQRS
8 : TUV
9 : WXYZ
'''

#test="444332" # length(7) / index(0-6)
def decrypt(data):
    cnt = 0
    _len = len(data)
    lastindex = _len-1
    for i in range(0,_len):
        if(i==0):
            cnt+=1
        else:
            if(data[i-1] == data[i]):
                cnt+=1
            if(data[i] != data[i-1]):
                keypad.append(data[i-1])
                val.append(cnt-1)
                cnt = 1
            if(i==lastindex and data[lastindex-1] != data[lastindex] ):
                keypad.append(data[lastindex])
                val.append(cnt-1)
        
            if(i==lastindex and data[lastindex-1] == data[lastindex] ):
                keypad.append(data[lastindex])
                val.append(cnt-1)

msg = ""
flip_phone = {}
f = open("./bank_heist_message.txt","r")
ch = 0x44
flip_phone[2] = ['A','B','C']

for i in range(3,10):

    flip_phone[i] =  [f"{chr(ch)}"]
    ch+=1
    flip_phone[i] +=  [f"{chr(ch)}"]
    ch+=1
    flip_phone[i] +=  [f"{chr(ch)}"]
    ch+=1

    if(i==7 or i==9):
        flip_phone[i] +=  [f"{chr(ch)}"]
        ch+=1

print(f"phone keypad : {flip_phone}")

key_data = str(f.readlines()).replace("\\n","").replace(".","").replace("'","").replace(",","").replace(":","").replace("!","").replace("[","").replace("]","")

chat=key_data.split(" ")

print("")
tmp = []
for a in chat:
    if(not a):
        pass
    else:
        tmp.append(a)
print("===============")
keypad = []
flag=0
val = []
#test : 4443334


if __name__ == "__main__":

    for enc in tmp:
        decrypt(enc)

        for k,v in zip(keypad, val):
            msg += flip_phone[int(k)][int(v)]
        keypad =[]
        val = []
        msg += " "
    print(msg)


    # Another Encrypt Data 

 

'0x0D Crypto' 카테고리의 다른 글

HackCTF Classic Cipher -3  (0) 2022.03.13
HTB ke  (0) 2020.07.03
Math Study Journey  (0) 2020.06.14
Math  (0) 2020.06.10
Rootme Prob. SHA 2-  (0) 2020.02.02