題目鏈接:
n次base64 200
依然是base64不過。。。編碼次數(shù)有點多請用python解吧~
地址:密文地址
分析:
沒有疑問 , 題目中提示已經(jīng)說明了一切
使用Python寫一個循環(huán)來解密
這里筆者將Base64的遞歸解密封裝成了一個函數(shù) , 以后如果需要就可以直接拿來用
# coding:utf8
import base64
def repeatedb64decode(ciphertext, times):
'''
功能 :
指定次數(shù)解密Base64
參數(shù) :
ciphertext : 密文
times : 次數(shù)
返回 :
返回將密文解密times次得到的明文
備注 :
當用戶輸入次數(shù)大于密文加密次數(shù)時候 , 只會解密到最終的明文 , 而不會一直進行解密
'''
for i in range(times):
try:
ciphertext = base64.b64decode(ciphertext)
except Exception:
return ciphertext
return ciphertext
def recursive64decode(ciphertext):
'''
功能 :
遞歸解密Base64
參數(shù) :
ciphertext : 密文
返回 :
返回徹底解密得到的明文
'''
while True:
try:
ciphertext = base64.b64decode(ciphertext)
except Exception:
return ciphertext
def repeatedb64encode(plaintext , times):
'''
功能 :
指定次數(shù)加密Base64
參數(shù) :
plaintext : 明文
times : 密文
返回 :
將plaintext加密times次得到的密文
備注 :
加密不存在異常拋出的問題
'''
for i in range(times):
plaintext = base64.b64encode(plaintext)
return plaintext
ciphertext = ""
print recursive64decode(ciphertext)
答案:
nctf{please_use_python_to_decode_base64}
知識點:
- Python
- Base64