day20

一、[MoeCTF 2022]想听点啥

1.使用MuseScore可以打开whatdoyouliketohear.mscz(查了一下是乐谱文件),在乐谱的最后可以看到由音符拼成的一段字串,提示MOECTFI1iKE是密码

image

MOECTFI1iKE

2.密码解压得到一个脚本和一个txt,简单看一下代码,就是一个flag字串,逐位异或,输出字串存到txt中,利用异或的特点,异或回去,写个脚本

image

点击查看代码
flag = 'm'
with open("./flag.txt","rb") as f:
    fl = f.read()
for i in range(len(fl)):
    flag += chr(ord(flag[i]) ^ fl[i])
print(flag)

3.得到flag

moectf{Want_s0me_mor3_mus1c?}

二、[MoeCTF 2022]usb

1.根据特点发现是USB中的键盘流量,先使用UsbKeyboardDataHacker工具,发现无法提取数据

image

2.那就只能使用麻烦一点的方法了,先使用tshark提取其中的data数据

tshark -r usb.pcapng -T fields -e usbhid.data -Y "frame.len == 35" > data1.txt

3.把数据处理一下,0000000000000000和0200000000000000全部删去,否则会报错,使用之前积累的分析脚本和data1.txt,得到flag

点击查看代码
normalKeys = {"04":"a", "05":"b", "06":"c", "07":"d", "08":"e", "09":"f", "0a":"g", "0b":"h", "0c":"i", "0d":"j", "0e":"k", "0f":"l", "10":"m", "11":"n", "12":"o", "13":"p", "14":"q", "15":"r", "16":"s", "17":"t", "18":"u", "19":"v", "1a":"w", "1b":"x", "1c":"y", "1d":"z","1e":"1", "1f":"2", "20":"3", "21":"4", "22":"5", "23":"6","24":"7","25":"8","26":"9","27":"0","28":"<RET>","29":"<ESC>","2a":"<DEL>", "2b":"\t","2c":"<SPACE>","2d":"-","2e":"=","2f":"[","30":"]","31":"\\","32":"<NON>","33":";","34":"'","35":"<GA>","36":",","37":".","38":"/","39":"<CAP>","3a":"<F1>","3b":"<F2>", "3c":"<F3>","3d":"<F4>","3e":"<F5>","3f":"<F6>","40":"<F7>","41":"<F8>","42":"<F9>","43":"<F10>","44":"<F11>","45":"<F12>"}

shiftKeys = {"04":"A", "05":"B", "06":"C", "07":"D", "08":"E", "09":"F", "0a":"G", "0b":"H", "0c":"I", "0d":"J", "0e":"K", "0f":"L", "10":"M", "11":"N", "12":"O", "13":"P", "14":"Q", "15":"R", "16":"S", "17":"T", "18":"U", "19":"V", "1a":"W", "1b":"X", "1c":"Y", "1d":"Z","1e":"!", "1f":"@", "20":"#", "21":"$", "22":"%", "23":"^","24":"&","25":"*","26":"(","27":")","28":"<RET>","29":"<ESC>","2a":"<DEL>", "2b":"\t","2c":"<SPACE>","2d":"_","2e":"+","2f":"{","30":"}","31":"|","32":"<NON>","33":"\"","34":":","35":"<GA>","36":"<","37":">","38":"?","39":"<CAP>","3a":"<F1>","3b":"<F2>", "3c":"<F3>","3d":"<F4>","3e":"<F5>","3f":"<F6>","40":"<F7>","41":"<F8>","42":"<F9>","43":"<F10>","44":"<F11>","45":"<F12>"}

keys = open('data1.txt')
output = ""
for line in keys:
    k = line[1]
    n = line[4:6]
    if k == '0':
        print(normalKeys[n], end='')
    elif k == '2':
        print(shiftKeys[n], end='')

image

4.得到的flag中为大写,为删除,整理一下flag

moectf{Learned_a6ou7_USB_tr@ffic}
posted @ 2023-08-01 17:16  CPYQY_orz  阅读(79)  评论(0编辑  收藏  举报