011 base64stego

题目描述

菜狗经过几天的学习,终于发现了如来十三掌最后一步的精髓

Solution

根据 CTF Wiki ZIP 格式 板块的介绍,我们的切入点可能是:

  • 爆破:穷举所有可能的密码
  • 伪加密:修改标记位
  • 明文攻击:利用已知文件找加密密钥,利用密钥来解锁其它加密文件
  • CRC32:不去爆破密码,而是直接去爆破源文件的内容

我们拿到题目文件,解压会被提示输入密码:

011-1.png

我们首先考虑是不是伪加密,如果不是再采用爆破手段。

我们用 HxD 打开压缩包,搜索十六进制504B0102,可以看到每个加密文件的文件头字段:

011-2.png

然后从50开始,第9、第10个 byte 为加密字段,将其设置为0000即可变成无加密状态:

011-3.png

另一个办法是在 Kali 下使用binwalk -e来绕过伪加密。

解压出来的文件带着大量的 base64 编码字符串。解码出来关于隐写术的介绍:

  1. ┌──(cheeryLaptop)-[~/Desktop]
  2. └─$ cat stego.txt| base64 -d >> decoded.txt
  3. ┌──(cheeryLaptop)-[~/Desktop]
  4. └─$ cat decoded.txt
  5. Steganography is the art and science of writing hidden messages in such a way that no one, apart from the sender and intended recipient, suspects the existence of the message, a form of security through obscurity. The word steganography is ......

根据题目名字“base64stego”,可以猜想本题是一道 base64 隐写题目。我们编写一段 Python 脚本来处理这些 base64 编码字符串:

  1. import re
  2. path = './stego.txt'
  3. b64char = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  4. with open(path, 'r')as f:
  5. cipher = [i.strip() for i in f.readlines()]
  6. plaintext = ''
  7. for i in cipher:
  8. if i[-2] == '=': # There are 4-bit hidden info while end with two '='
  9. bin_message = bin(b64char.index(i[-3]))[2:].zfill(4)
  10. plaintext += bin_message[-4:]
  11. elif i[-1] == '=': # There are 2-bit hidden info while end with one '='
  12. bin_message = bin(b64char.index(i[-2]))[2:].zfill(2)
  13. plaintext += bin_message[-2:]
  14. plaintext = re.findall('.{8}', plaintext) # 8bits/group
  15. plaintext = ''.join([chr(int(i, 2)) for i in plaintext])
  16. print(plaintext)

运行结果如下:

  1. Base_sixty_four_point_five

修改一下格式即可得到 Flag。