一次简单的CTF
工具脚本
- 凯撒密码
1
2
3
4
5
6
7def caesar_offset(s, i):
if not -25 <= i <= 25:
return False
origin = map(lambda c: chr((ord(c) - 65 + i) % 26 + 65) if 65 <= ord(c) <= 90
else chr((ord(c) - 97 + i) % 26 + 97) if 97 <= ord(c) <= 122
else c, s)
return ''.join(origin) - base64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21def b64de(s):
print(" B64 start ".center(64, '-'))
r = ""
deb64 = base64.b64decode(s)
try:
print("try:utf-8 decode")
print(deb64.decode("utf-8"))
except:
print("\nCantdecode UTF-8")
print()
for i in deb64:
print(('%02x' % i).upper(), end=' ')
print()
print("try:chr decode")
for i in deb64:
print(chr(i), end='')
r += chr(i)
print()
print(" B64 stop ".center(64, '-'))
return r - 二进制字符串转ASCII
1
2
3
4
5
6
7
8def binToASCII(bin_str):
bin_str = bin_str.replace('\n', '').replace(' ', '')
r = ""
print(len(bin_str))
for i in range(len(bin_str) // 8):
byte_str = bin_str[i * 8:i * 8 + 8]
r += chr(int(byte_str, 2)) if byte_str != '00000000' else ''
return r - 黑白图转二进制字符串
1
2
3
4
5
6
7
8
9
10
11
12
13
14def imgToBin(path, mode='B0W1'):
im = Image.open(path)
im = im.convert("1")
bin_str = ""
black, white = ('0', '1') if mode == 'B0W1' else ('1', '0') if mode == 'B1W0' else ('0', '0')
for j in range(im.size[1]):
for i in range(im.size[0]):
if im.getpixel((i, j)) >= 128:
bin_str += white
else:
bin_str += black
return bin_str
源
+
图片隐写术
=
1 |
|
ks6w
凯撒+6
1 |
|
base64 -d 解出
1 |
|
base91.decode(s)解出
1 |
|
下载到文件33.7z 密码b1Wzb6bp9o0f
解压出33.wav
Rot36 decode 出二维码
扫得
1 |
|
base91.decode(s)解出
1 |
|
下载到文件321.7z 密码Sc3885s38z
解压出321.png
扫得
1 |
|
凯撒+3
1 |
|
一次简单的CTF
https://siltal.github.io/2022/01/21/一次简单的CTF/