
一个Python编译文件,运行后什么也没有,先到反编译网站反编译看看。得到如下代码。
1#!/usr/bin/env python
2# visit https://tool.lu/pyc/ for more information
3# Version: Python 3.6
4
5'''Base58 encoding
6
7Implementations of Base58 and Base58Check endcodings that are compatible
8with the bitcoin network.
9'''
10from hashlib import sha256
11__version__ = '1.0.3'
12alphabet = b'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
13if bytes == str:
14
15 iseq = lambda s: map(ord, s)
16
17 bseq = lambda s: ''.join(map(chr, s))
18
19 buffer = lambda s: s
20else:
21
22 iseq = lambda s: s
23 bseq = bytes
24
25 buffer = lambda s: s.buffer
26
27def scrub_input(v):
28 if isinstance(v, str) and not isinstance(v, bytes):
29 v = v.encode('ascii')
30 if not isinstance(v, bytes):
31 raise TypeError("a bytes-like object is required (also str), not '%s'" % type(v).__name__)
32
33
34def b58encode_int(i, default_one = (True,)):
35 '''Encode an integer using Base58'''
36 if not i and default_one:
37 return alphabet[0:1]
38 string = None
39 while i:
40 (i, idx) = divmod(i, 58)
41 string = alphabet[idx:idx + 1] + string
42 return string
43
44
45def b58encode(v):
46 '''Encode a string using Base58'''
47 v = scrub_input(v)
48 nPad = len(v)
49 v = v.lstrip(b'%00')
50 nPad -= len(v)
51 (p, acc) = (1, 0)
52 for c in iseq(reversed(v)):
53 acc += p * c
54 p = p << 8
55
56 result = b58encode_int(acc, False, **('default_one',))
57 return alphabet[0:1] * nPad + result
58
59
60def b58decode_int(v):
61 '''Decode a Base58 encoded string as an integer'''
62 v = v.rstrip()
63 v = scrub_input(v)
64 decimal = 0
65 for char in v:
66 decimal = decimal * 58 + alphabet.index(char)
67
68 return decimal
69
70
71def b58decode(v):
72 '''Decode a Base58 encoded string'''
73 v = v.rstrip()
74 v = scrub_input(v)
75 origlen = len(v)
76 v = v.lstrip(alphabet[0:1])
77 newlen = len(v)
78 acc = b58decode_int(v)
79 result = []
80 while acc > 0:
81 (acc, mod) = divmod(acc, 256)
82 result.append(mod)
83 return b'%00' * (origlen - newlen) + bseq(reversed(result))
84
85
86def b58encode_check(v):
87 '''Encode a string using Base58 with a 4 character checksum'''
88 digest = sha256(sha256(v).digest()).digest()
89 return b58encode(v + digest[:4])
90
91
92def b58decode_check(v):
93 '''Decode and verify the checksum of a Base58 encoded string'''
94 result = b58decode(v)
95 result = result[:-4]
96 check = result[-4:]
97 digest = sha256(sha256(result).digest()).digest()
98 if check != digest[:4]:
99 raise ValueError('Invalid checksum')
100
101if __name__ == '__main__':
102 if b58encode(input()) == b'3sLBBYq91BUxPzp7tRuYNKvUNQ2hedyw6ydjzNbf9rJbYq9Ue6xzr9aL6rEDwUQZRGnZPGGgwM2PspAeVcCCjyrNQqDV5PhvaZpwj5ZMaXaFuGjiXK1gf72U325dx6n1RFKiBF3C9dYRTj86aqxZ5HN53KLaW7oBoXwJjbsNFdci8A2kQM':
103 print('flag is coming...')
104 else:
105 print('There is no problem that your input is wrong.')

解码最后一句话得到:1 base58(radix58) So you still decompiled me. I’m just a Miscellaneous. Forget it. Look at your hard work. Give you a hint. Flag is in the PyC file. 暗示flag.pyc 本身就是flag,不要解码看python代码,是pyc隐写。
用 stegosaurus 解码隐写文件。
1wget https://mirror.ghproxy.com/https://github.com/AngelKitty/stegosaurus/releases/download/1.0/stegosaurus

flag{217a5bcecea1be5eeca5028b06427b84}

