Analyse
题目内容:
表 9876543210qwertyuiopasdfghjklzxcvbnmMNBVCXZLKJHGFDSAPOIUYTREWQ
密文 7dFRjPItGFkeXAALp6GMKE9Y4R4BuNtIUK1RECFlU4f3PomCzGnfemFvO
观察其码表发现长度为62,那么这个应该是base62换表,两种解决方式
解题
Solution 1
通过修改base62库中的原始码表,替换为题目的码表
然后正常解base62即可
import base62
import libnum
print(libnum.n2s(base62.decode("7dFRjPItGFkeXAALp6GMKE9Y4R4BuNtIUK1RECFlU4f3PomCzGnfemFvO")))
#flag{cf492422-13cb-4123-8bc5-5495f0349494}
Solution 2
通过常规换表解法,首先我们需要知道base62的常规码表:
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
这里我看网上也有这种类型
经过测试,这种码表解不了这道题
接着通过.translate
和maketrans
进行码表的替换。原理就是对比两个码表,对密文按照两个码表的对应顺序进行替换,得出按照正常base62编码后的密文,接着对该密文进行正常的base62解码即可
import base62
import libnum
chipertext = "7dFRjPItGFkeXAALp6GMKE9Y4R4BuNtIUK1RECFlU4f3PomCzGnfemFvO"
original_form = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
changed_form = "9876543210qwertyuiopasdfghjklzxcvbnmMNBVCXZLKJHGFDSAPOIUYTREWQ"
print("changed_form:\t" + changed_form)
print("original_form:\t" + original_form)
chipertext = chipertext.translate(str.maketrans(changed_form , original_form))
print(chipertext)
print(base62.decodebytes(chipertext))
#b'flag{cf492422-13cb-4123-8bc5-5495f0349494}'