22-12-21-UNknown

Figure out 2 tasks.

One is for crypto, and the other is for misc.

Both of them are easy.

poem

reference: [ACTF新生赛2020]base64隐写

  • base64stego
  • caeser cipher

base64stego

poem.txt

Make sure that the end of each line. This ending is \r\n

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import base64
"""
base64stego
"""
b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
with open('poem.txt', 'rb') as f:
bin_str = ''
# print(f.readlines())
for line in f.readlines():
stegb64 = str(line, 'utf-8').strip('\r\n') # edit
# print(stegb64)
row64 = str(base64.b64encode(base64.b64decode(stegb64)), 'utf-8').strip('\n')
offset = abs(b64chars.index(stegb64.replace('=', '')[-1]) - b64chars.index(row64.replace('=', '')[-1]))
equalnum = stegb64.count('=')
if equalnum:
bin_str += bin(offset)[2:].zfill(equalnum * 2)
output = [chr(int(bin_str[i:i + 8], 2)) for i in range(0, len(bin_str), 8)]
flag = ''.join(output)
print(flag)

caeser cipher

Just crack!

key is 13.

Alex2Bob

Alex2Bob

  • ARCHPR-mask
  • PNG-header
  • PNG-crack width
  • LSB

ARCHPR-mask

Known the end of the key is kitty.

This is the mask attack. We don’t know the length of the key, so we try some possibilities.

Until we try to set unknown length is 4, we get the key.

PNG-header

Use the winhex and analyze the png. We find that the file header is wrong, so we should edit the file header 88 -> 89.

Still can’t open the picture or see the content.

PNG-crack width

Crack the true width, and we will get the width is 0x260.

Edit the width by winhex or 010Editor, and we will get the real picture.

LSB

Two ways to get the information embedded in LSB.

  • stegsolve-original
  • zsteg

The cipher is ZmxhZ3tsb3ZlX3JhZ2RvbGxfY2F0fQ==, and base64 decode.

-------------THE END-------------