奇怪的文件名——write up

来源:互联网 发布:手机免费炒股软件 编辑:程序博客网 时间:2024/06/11 12:22

0x00 思路

题目链接:
http://sec.hdu.edu.cn/questionLibrary/questionTerminal?questionCategory=cipher&orderType=default&qid=1050
压缩包链接:http://sec.hdu.edu.cn/resource/upload/question/1050/misc1.zip

下载题目的压缩包,打开发现文件名均为md5加密
这里写图片描述

随意选两个文件名,发现解密后均为数字,将文件名遍历并md5解密,得到结果:
27 6 33 36 35 19 24 28 30 23 21 9 26 32 11 29 18 17 25 7 20 15 38 37 4 14 22 31 12 1 13 16 2 8 0 10 39 34 5 3
看到这串数字十分的无语,完全不知道下一步。
打开每个文件,发现里面是16进制的数。同时发现文件名的数字没有重复,因此将提取文件内容,同时将内容按照文件名排序,得到如下内容:
66 6c 61 67 69 73 7b 30 32 63 65 66 37 65 65 62 37 35 66 64 64 39 64 66 63 36 37 63 30 64 63 31 65 33 65 32 35 35 62 7d
将16进制转换为字符串,得到答案:
flagis{02cef7eeb75fdd9dfc67c0dc1e3e255b}

0x01 代码

def filter():    m2 = hashlib.md5()    key_arr =[]    dic = {}    for i in range(0,100):        str = '%d' %i        t = hashlib.md5(str.encode("utf-8")).hexdigest()        key_arr.append(t)    encode_str = ""    result = ""    for parent,dirnames,filenames in os.walk('misc/'):         for filename in filenames:            for ind in range(0,100):                if filename == key_arr[ind]:                    encode_str += "%d " %ind                    dic[ind] = filename    sortBKs = sorted(dic.items(),key=lambda t:t[0])     for d,x in sortBKs:        f = open('misc/'+ x,'r')        line = f.readline()        result =result + line + " "        f.close()    result = result.replace(" ","")    re = bytes.fromhex(result).decode('utf-8')    print(re)filter()
原创粉丝点击