[WUSTCTF2020]レベル4
ステップ
- elfファイル、仮想マシンを実行して一般的な状況を確認し、プロンプト文字に従って
Typing....Struct.....char....*left....*right............emmmmm...OK!
バイナリツリーがあると推測します
。type1とtype2の文字列はフラグに少し似ていることがわかりますが、順序が乱れています。 - 64 ida Loading
type1(byte_601290)、バイナリツリートラバーサル順序:2f0t02T} {hcsiI_SwA__r7Ee
20f0Th} {2tsIS_icArE e7__w:Type2(byte_601290)、バイナリツリーのバイナリツリートラバーサルシーケンス
は、バイナリツリーの原理を理解した後、前に紹介します。決定される注文。冒頭のマニュアル、執筆の途中で、見つけすぎてスクリプトを変更しました
Python3 exp
ソース:https://blog.csdn.net/weixin_41287060/article/details/99400963
#使用中序后序求前序遍历
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def reConstructBinaryTree(self, post, tin):
if len(post) == 0:
return None
root = TreeNode(post[-1])
TinIndex = tin.index(post[-1])
root.left = self.reConstructBinaryTree(post[0:TinIndex], tin[0:TinIndex])
root.right = self.reConstructBinaryTree(post[TinIndex:len(post) - 1], tin[TinIndex + 1:])
return root
def PreTraversal(self, root):
if root != None:
print(root.val,end="")
self.PreTraversal(root.left)
self.PreTraversal(root.right)
strm="2f0t02T{hcsiI_SwA__r7Ee}"
stre="20f0Th{2tsIS_icArE}e7__w"
post = list(stre)#后序
tin = list(strm)#中序
S = Solution()
root = S.reConstructBinaryTree(post, tin)
S.PreTraversal(root)
フラグ{This_IS_A_7reE}