文件内容
脚本如下
BASE = 62
CHARSET_DEFAULT = '9876543210qwertyuiopasdfghjklzxcvbnmMNBVCXZLKJHGFDSAPOIUYTREWQ'
str1 = "7dFRjPItGFkeXAALp6GMKE9Y4R4BuNtIUK1RECFlU4f3PomCzGnfemFvO"
def _value(ch, charset):
try:
return charset.index(ch)
except ValueError:
raise ValueError("base62: Invalid character (%s)" % ch)
def decode(encoded, charset=CHARSET_DEFAULT):
if encoded.startswith("0z"):
encoded = encoded[2:]
l, i, v = len(encoded), 0, 0
for x in encoded:
v += _value(x, charset=charset) * (BASE ** (l - (i + 1)))
i += 1
return v
def decodebytes(encoded, charset=CHARSET_DEFAULT):
decoded = decode(encoded, charset=charset)
buf = bytearray()
while decoded > 0:
buf.append(decoded & 0xFF)
decoded //= 256
buf.reverse()
return bytes(buf)
print(decodebytes(str1))
运行得到flag
标签:decoded,ch,DEFAULT,charset,misc999,CTF,2022,encoded,buf From: https://blog.csdn.net/hzhfhsq/article/details/144567033