Demo entry 6758401

1

   

Submitted by anonymous on Aug 13, 2018 at 17:36
Language: Python. Code size: 4.8 kB.

from pwn import *
s = remote("112.166.114.150", 49374)
context.log_level = 'debug'

def func_word():
    s.recvuntil("!!\n")

    line_1 = s.recvline().replace(" ", "").replace("\n", "")
    line_2 = s.recvline().replace(" ", "").replace("\n", "")
    line_3 = s.recvline().replace(" ", "").replace("\n", "")

    word_list = list()
    check_dic = {'OXOXXX':'#','XOOOOO':'A', 'XOXOOO':'B', 'XXOOOO':'C', 'XXOXOO':'D', 'XOOXOO':'E', 'XXXOOO':'F', 'XXXXOO':'G', 'XOXXOO':'H', 'OXXOOO':'I', 'OXXXOO':'J', 'XOOOXO':'K', 'XOXOXO':'L', 'XXOOXO':'M', 'XXOXXO':'N', 'XOOXXO':'O', 'XXXOXO':'P', 'XXXXXO':'Q', 'XOXXXO':'R', 'OXXOXO':'S', 'OXXXXO':'T', 'XOOOXX':'U', 'XOXOXX':'V', 'OXXXOX':'W', 'XXOOXX':'X', 'XXOXXX':'Y', 'XOOXXX':'Z'}

    send_msg = ""
    for i in range(len(line_1)/2):
        add_str1 = line_1[:2] 
        add_str2 = line_2[:2]
        add_str3 = line_3[:2]
        line_1 = line_1[2:]
        line_2 = line_2[2:]
        line_3 = line_3[2:]

        
        word_list.append(add_str1 + add_str2 + add_str3)
        send_msg += check_dic[word_list[i]]
    
    print(send_msg)
    s.sendline(send_msg)
    s.recv()

def func_num():
    s.recvuntil("!!\n")

    line_1 = s.recvline().replace(" ", "").replace("\n", "")
    line_2 = s.recvline().replace(" ", "").replace("\n", "")
    line_3 = s.recvline().replace(" ", "").replace("\n", "")
    
    num_list = list()
    check_dic = {'OXOXXX':'','XOOOOO':'1', 'XOXOOO':'2', 'XXOOOO':'3', 'XXOXOO':'4', 'XOOXOO':'5', 'XXXOOO':'6', 'XXXXOO':'7', 'XOXXOO':'8', 'OXXOOO':'9', 'OXXXOO':'0'}
    send_msg = ""
    for i in range(len(line_1)/2):
        add_str1 = line_1[:2] 
        add_str2 = line_2[:2]
        add_str3 = line_3[:2]
        line_1 = line_1[2:]
        line_2 = line_2[2:]
        line_3 = line_3[2:]
        num_list.append(add_str1 + add_str2 + add_str3)
        send_msg += check_dic[num_list[i]]
    
    print(send_msg)
    s.sendline(send_msg)
    s.recv()

def func_punc():

    line_1 = s.recvline().replace(" ", "").replace("\n", "")
    line_2 = s.recvline().replace(" ", "").replace("\n", "")
    line_3 = s.recvline().replace(" ", "").replace("\n", "")
    
    punc_list = list()
    check_dic = {'OOXXOX':'.','OOXOOO':',','OOXOXO':';','OOXXOO':':','OOXOXX':'?','OOXXXO':'!','OOOOXO':'\'', 'OOXXXX':'"', 'OXOXOO':'Q', 'OOOXXX':'"', 'OOOXOO':'W', 'XOXOOX':'(','OXOXXO':')','OXOXOX':'E', 'OXOOXO':'/', 'XOOOOX':'\\', 'OOOOXX':'-', 'OOOOOX':'R'}
    send_msg = ""

    for i in range(len(line_1)/2):
        add_str1 = line_1[:2] 
        add_str2 = line_2[:2]
        add_str3 = line_3[:2]
        line_1 = line_1[2:]
        line_2 = line_2[2:]
        line_3 = line_3[2:]
        punc_list.append(add_str1 + add_str2 + add_str3)
        send_msg += check_dic[punc_list[i]]
    
    
    send_msg = send_msg.replace("\'\"","\"").replace("Q?","\"").replace("Q\"","\"").replace("W(","(").replace("W)",")").replace("E/","/").replace("E\\","\\").replace("R-","-")
    print(send_msg)
    s.sendline(send_msg)

def func_finish():
    s.recvuntil("tion\n")

    line_1 = s.recvline().replace(" ", "").replace("\n", "")
    line_2 = s.recvline().replace(" ", "").replace("\n", "")
    line_3 = s.recvline().replace(" ", "").replace("\n", "")
    
    finish_list = list()
    check_dic = {'XOOOOO':'A', 'XOXOOO':'B', 'XXOOOO':'C', 'XXOXOO':'D', 'XOOXOO':'E', 'XXXOOO':'F', 'XXXXOO':'G', 'XOXXOO':'H', 'OXXOOO':'I', 'OXXXOO':'J', 'XOOOXO':'K', 'XOXOXO':'L', 'XXOOXO':'M', 'XXOXXO':'N', 'XOOXXO':'O', 'XXXOXO':'P', 'XXXXXO':'Q', 'XOXXXO':'R', 'OXXOXO':'S', 'OXXXXO':'T', 'XOOOXX':'U', 'XOXOXX':'V', 'OXXXOX':'W', 'XXOOXX':'X', 'XXOXXX':'Y', 'XOOXXX':'Z', 'OOXXOX':'.','OOXOOO':',','OOXOXO':';','OOXXOO':':','OOXOXX':'?','OOXXXO':'!','OOOOXO':'\'', 'OOXXXX':'"', 'OXOXOO':'Q', 'OOOXXX':'"', 'OOOXOO':'W', 'XOXOOX':'(','OXOXXO':')','OXOXOX':'E', 'OXOOXO':'/', 'XOOOOX':'\\', 'OOOOXX':'-', 'OOOOOX':'R'}
    send_msg = ""
    for i in range(len(line_1)/2):
        add_str1 = line_1[:2] 
        add_str2 = line_2[:2]
        add_str3 = line_3[:2]
        line_1 = line_1[2:]
        line_2 = line_2[2:]
        line_3 = line_3[2:]
        finish_list.append(add_str1 + add_str2 + add_str3)
        send_msg += check_dic[finish_list[i]]
    
    send_msg = send_msg.replace("\'\"","\"").replace("Q?","\"").replace("Q\"","\"").replace("W(","(").replace("W)",")").replace("E/","/").replace("E\\","\\").replace("R-","-")
    print(send_msg)
    s.sendline(send_msg)


for i in range(11):
    func_word()


for i in range(10):
    func_num()

cnt = 0
s.recvuntil(".\n\n")
for i in range(10): 
    func_punc()
    if i != 9:
        s.recvuntil("]\n")

for i in range(10):
    func_finish()

s.interactive()

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).