Created
September 9, 2024 08:02
-
-
Save peroon/bc73708cb33dcdda6c219b394ed4142c to your computer and use it in GitHub Desktop.
picoCTF 8bytes+8bytes => 16bytesエンコードされたものをデコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://play.picoctf.org/practice/challenge/104 | |
text = "灩捯䍔䙻ㄶ形楴獟楮獴㌴摟潦弸彥ㄴㅡて㝽" | |
# UTF-16エンコーディングでバイト列に変換 010011001010... | |
bytes_text = text.encode('utf-16') | |
# 先端2文字がBOMなので削除 | |
bytes_text = bytes_text[2:] | |
# バイト列を2バイトごとに処理 | |
for i in range(0, len(bytes_text), 2): # 2バイトごとに処理 | |
byte_pair = bytes_text[i:i+2] # 2バイトのペアを取得 | |
# print(byte_pair) # b'pi' などの表示 | |
s = string_text = byte_pair.decode('ascii') # "pi" など | |
s = s[::-1] # ビッグエンディアン、リトルエンディアンによりひっくり返すこともある | |
print(s,end='') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment