Home
avatar

静静

奇怪的杂项

https://blog.csdn.net/luochen2436/article/details/123376678

图0

一个Python编译文件,运行后什么也没有,先到反编译网站反编译看看。得到如下代码。

#!/usr/bin/env python
# visit https://tool.lu/pyc/ for more information
# Version: Python 3.6

'''Base58 encoding

Implementations of Base58 and Base58Check endcodings that are compatible
with the bitcoin network.
'''
from hashlib import sha256
__version__ = '1.0.3'
alphabet = b'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
if bytes == str:
    
    iseq = lambda s: map(ord, s)
    
    bseq = lambda s: ''.join(map(chr, s))
    
    buffer = lambda s: s
else:
    
    iseq = lambda s: s
    bseq = bytes
    
    buffer = lambda s: s.buffer

def scrub_input(v):
    if isinstance(v, str) and not isinstance(v, bytes):
        v = v.encode('ascii')
    if not isinstance(v, bytes):
        raise TypeError("a bytes-like object is required (also str), not '%s'" % type(v).__name__)


def b58encode_int(i, default_one = (True,)):
    '''Encode an integer using Base58'''
    if not i and default_one:
        return alphabet[0:1]
    string = None
    while i:
        (i, idx) = divmod(i, 58)
        string = alphabet[idx:idx + 1] + string
    return string


def b58encode(v):
    '''Encode a string using Base58'''
    v = scrub_input(v)
    nPad = len(v)
    v = v.lstrip(b'%00')
    nPad -= len(v)
    (p, acc) = (1, 0)
    for c in iseq(reversed(v)):
        acc += p * c
        p = p << 8
    
    result = b58encode_int(acc, False, **('default_one',))
    return alphabet[0:1] * nPad + result


def b58decode_int(v):
    '''Decode a Base58 encoded string as an integer'''
    v = v.rstrip()
    v = scrub_input(v)
    decimal = 0
    for char in v:
        decimal = decimal * 58 + alphabet.index(char)
    
    return decimal


def b58decode(v):
    '''Decode a Base58 encoded string'''
    v = v.rstrip()
    v = scrub_input(v)
    origlen = len(v)
    v = v.lstrip(alphabet[0:1])
    newlen = len(v)
    acc = b58decode_int(v)
    result = []
    while acc > 0:
        (acc, mod) = divmod(acc, 256)
        result.append(mod)
    return b'%00' * (origlen - newlen) + bseq(reversed(result))


def b58encode_check(v):
    '''Encode a string using Base58 with a 4 character checksum'''
    digest = sha256(sha256(v).digest()).digest()
    return b58encode(v + digest[:4])


def b58decode_check(v):
    '''Decode and verify the checksum of a Base58 encoded string'''
    result = b58decode(v)
    result = result[:-4]
    check = result[-4:]
    digest = sha256(sha256(result).digest()).digest()
    if check != digest[:4]:
        raise ValueError('Invalid checksum')

if __name__ == '__main__':
    if b58encode(input()) == b'3sLBBYq91BUxPzp7tRuYNKvUNQ2hedyw6ydjzNbf9rJbYq9Ue6xzr9aL6rEDwUQZRGnZPGGgwM2PspAeVcCCjyrNQqDV5PhvaZpwj5ZMaXaFuGjiXK1gf72U325dx6n1RFKiBF3C9dYRTj86aqxZ5HN53KLaW7oBoXwJjbsNFdci8A2kQM':
        print('flag is coming...')
    else:
        print('There is no problem that your input is wrong.')

图1

解码最后一句话得到: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 解码隐写文件。

wget https://mirror.ghproxy.com/https://github.com/AngelKitty/stegosaurus/releases/download/1.0/stegosaurus

图2

flag{217a5bcecea1be5eeca5028b06427b84}

Misc 编码隐写