[GXYCTF2019]gakki


先binwalk分离图片的压缩包:

得到的压缩包有密码,尝试爆破。

看到flag.txt有很多字符,想到字符频率,用脚本或者HxD查看都可以。


附上解题脚本:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: UTF-8 -*-
def processLine(line, CharacterCounts):
for character in line:
#if ord(character) in range(97, 123):
if ord(character) in range(32,126):
CharacterCounts[character] += 1

#创建字母字典
def createCharacterCounts(CharacterCounts):
#for i in range(97, 123):
for i in range(32, 126):
CharacterCounts[chr(i)] = 0

def main():
#用户输入一个文件名
# filename = input("enter a filename:").strip()
filename = "flag.txt"
infile = open(filename, "r")

#建立用于计算词频的空字典
CharacterCounts = {}
#初始化字典键值
createCharacterCounts(CharacterCounts)
for line in infile:
#processLine(line.lower(), CharacterCounts)
processLine(line, CharacterCounts)

#从字典中获取数据对
pairs = list(CharacterCounts.items())

#列表中的数据对交换位置,数据对排序
items = [[x,y] for (y,x) in pairs]
items.sort(reverse=True)

#输出count个数词频结果
for i in range(len(items)):
#print(items[i][1]+"\t"+str(items[i][0]))
print(items[i][1],end='')

infile.close()

if __name__ == '__main__':
main()

#
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×