Debian 13 support, PHP 8.4/8.5, security hardening, install script
- Debian 13 (Trixie) compatibility: - Build uw-imap c-client from source (removed from trixie) - Fix OpenSSL 3 include paths for c-client - Split libnginx-mod-http-brotli package name - Add -lgomp and -std=c++17 to PHP CXXFLAGS - Fix Dovecot 2.4 config syntax in setup - Use 127.0.0.1 for DB (works in FPM chroot) - PHP version updates: - Add PHP 8.5.4 and 8.4.19 - Remove PHP 8.1 (EOL) - Update igbinary to master, imagick to 3.8.1, brotli to 0.18.3 - Remove php-rar (unmaintained, incompatible with 8.4+) - setup.php uses DEFAULT_PHP_VERSION for FPM sockets - Users can switch PHP version from dashboard - Security hardening: - CSRF tokens use bin2hex(random_bytes(32)) - Admin password uses password_hash/password_verify - Session regeneration on login - All output escaped with htmlspecialchars - Nginx rewrite rules validated (flag whitelist, reject injection) - Path traversal protection in FileManager - SQL injection fix in password change - Security headers (CSP script-src:none, X-Frame-Options, etc) - Onion private keys encrypted at rest (libsodium) - SFTP password encrypted in session with expiry - Admin brute-force rate limiting - CSRF token on login form - Zero JavaScript - all pages work without JS - mt_rand replaced with random_int - Cookie secure flag precedence fix - PDO ERRMODE_EXCEPTION - Generic login error messages (no username enumeration) - FileManager rename validation - Self-bootstrapping install.sh: - Auto-clones repo if run standalone (curl | bash support) - Interactive prompts or --non-interactive flag - Optional vanity .onion generation via mkp224o - Password generation or custom input - Credentials saved to /root/hosting-credentials.txt
This commit is contained in:
1 parent
71dd2804fb
commit
229ce3a0dc
10 files changed
+873
-96
No files matched your search
+48
-15
@@ -127,22 +127,20 @@ if(isset($_POST['action']) && $_POST['action']==='del_domain_2' && !empty($_POST
|
||||
}
|
||||
del_user_domain($user['id'], $_POST['domain']);
|
||||
}
|
||||
if(isset($_REQUEST['action']) && isset($_REQUEST['onion']) && $_REQUEST['action']==='edit_onion'){
|
||||
if(isset($_POST['action']) && isset($_POST['onion']) && $_POST['action']==='edit_onion'){
|
||||
if($error=check_csrf_error()){
|
||||
die($error);
|
||||
}
|
||||
//$stmt=$db->prepare('SELECT onions.version, onions.instance FROM onions INNER JOIN users ON (users.id=onions.user_id) WHERE onions.onion = ? AND users.id = ? AND onions.enabled IN (0, 1);');
|
||||
$stmt=$db->prepare('SELECT onions.version, onions.instance, onions.description FROM onions INNER JOIN users ON (users.id=onions.user_id) WHERE onions.onion = ? AND users.id = ? AND onions.enabled IN (0, 1);');
|
||||
$description = trim($_POST['description'] ?? $_REQUEST['description'] ?? '');
|
||||
$description = mb_substr($description, 0, 50); // Limit 50
|
||||
|
||||
$stmt->execute([$_REQUEST['onion'], $user['id']]);
|
||||
$stmt=$db->prepare('SELECT onions.version, onions.instance, onions.description FROM onions INNER JOIN users ON (users.id=onions.user_id) WHERE onions.onion = ? AND users.id = ? AND onions.enabled IN (0, 1);');
|
||||
$description = trim($_POST['description'] ?? '');
|
||||
$description = mb_substr($description, 0, 50);
|
||||
|
||||
$stmt->execute([$_POST['onion'], $user['id']]);
|
||||
if($onion=$stmt->fetch(PDO::FETCH_ASSOC)){
|
||||
//$stmt=$db->prepare('UPDATE onions SET enabled = ?, enable_smtp = ?, num_intros = ?, max_streams = ? WHERE onion = ?;');
|
||||
$stmt=$db->prepare('UPDATE onions SET enabled = ?,enable_smtp = ?,num_intros = ?,max_streams = ?,description = ?WHERE onion = ?;');
|
||||
$enabled = isset($_REQUEST['enabled']) ? 1 : 0;
|
||||
$enable_smtp = isset($_REQUEST['enable_smtp']) ? 1 : 0;
|
||||
$num_intros = intval($_REQUEST['num_intros']);
|
||||
$enabled = isset($_POST['enabled']) ? 1 : 0;
|
||||
$enable_smtp = isset($_POST['enable_smtp']) ? 1 : 0;
|
||||
$num_intros = intval($_POST['num_intros']);
|
||||
if($num_intros<3){
|
||||
$num_intros = 3;
|
||||
}elseif($onion['version']==2 && $num_intros>10){
|
||||
@@ -150,17 +148,37 @@ if(isset($_REQUEST['action']) && isset($_REQUEST['onion']) && $_REQUEST['action'
|
||||
}elseif($num_intros>20){
|
||||
$num_intros = 20;
|
||||
}
|
||||
$max_streams = intval($_REQUEST['max_streams']);
|
||||
$max_streams = intval($_POST['max_streams']);
|
||||
if($max_streams<0){
|
||||
$max_streams = 0;
|
||||
}elseif($max_streams>65535){
|
||||
$max_streams = 65535;
|
||||
}
|
||||
//$stmt->execute([$enabled, $enable_smtp, $num_intros, $max_streams, $_REQUEST['onion']]);
|
||||
$stmt->execute([$enabled,$enable_smtp,$num_intros,$max_streams,$description,$_REQUEST['onion']]);
|
||||
$stmt->execute([$enabled,$enable_smtp,$num_intros,$max_streams,$description,$_POST['onion']]);
|
||||
enqueue_instance_reload($onion['instance']);
|
||||
}
|
||||
}
|
||||
if(isset($_POST['action']) && $_POST['action']==='change_php'){
|
||||
if($error=check_csrf_error()){
|
||||
die($error);
|
||||
}
|
||||
$new_php = intval($_POST['php']);
|
||||
if($new_php === 0 || array_key_exists($new_php, PHP_VERSIONS)){
|
||||
$stmt=$db->prepare('UPDATE users SET php = ? WHERE id = ?;');
|
||||
$stmt->execute([$new_php, $user['id']]);
|
||||
$user['php'] = $new_php;
|
||||
$stmt=$db->prepare('SELECT instance FROM onions WHERE user_id = ?;');
|
||||
$stmt->execute([$user['id']]);
|
||||
$instances = [];
|
||||
while($row=$stmt->fetch(PDO::FETCH_ASSOC)){
|
||||
$instances[$row['instance']] = true;
|
||||
}
|
||||
foreach(array_keys($instances) as $instance){
|
||||
rewrite_php_config($instance);
|
||||
}
|
||||
rewrite_nginx_config();
|
||||
}
|
||||
}
|
||||
if(isset($_REQUEST['action']) && isset($_POST['domain']) && $_POST['action']==='edit_domain'){
|
||||
if($error=check_csrf_error()){
|
||||
die($error);
|
||||
@@ -192,7 +210,7 @@ while($onion=$stmt->fetch(PDO::FETCH_ASSOC)){
|
||||
++$count_onions;
|
||||
echo "<form action=\"home.php\" method=\"post\"><input type=\"hidden\" name=\"csrf_token\" value=\"$_SESSION[csrf_token]\"><input type=\"hidden\" name=\"onion\" value=\"$onion[onion]\"><tr><td><a href=\"http://$onion[onion].onion\" target=\"_blank\">$onion[onion].onion</a></td><td>";
|
||||
if(isset($_REQUEST['show_priv'])){
|
||||
echo "<pre>$onion[private_key]</pre>";
|
||||
echo '<pre>'.htmlspecialchars(decrypt_private_key($onion['private_key']), ENT_QUOTES, 'UTF-8').'</pre>';
|
||||
}else{
|
||||
echo '<a href="home.php?show_priv=1">'._('Show private key').'</a>';
|
||||
}
|
||||
@@ -286,6 +304,21 @@ if($count_dbs<MAX_NUM_USER_DBS){
|
||||
?>
|
||||
<p><a href="password.php?type=sql"><?php echo _('Change MySQL password'); ?></a></p>
|
||||
<p><?php printf(_('You can use <a href="/phpmyadmin/" target="_blank">PHPMyAdmin</a> and <a href="/adminer/?username=%s" target="_blank">Adminer</a> for web based database administration.'), rawurlencode($user['mysql_user'])); ?></p>
|
||||
<h3><?php echo _('PHP Version'); ?></h3>
|
||||
<form action="home.php" method="post">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token']; ?>">
|
||||
<select name="php">
|
||||
<option value="0"<?php echo $user['php'] == 0 ? ' selected' : ''; ?>><?php echo _('None'); ?></option>
|
||||
<?php
|
||||
foreach(PHP_VERSIONS as $key => $version){
|
||||
echo "<option value=\"$key\"";
|
||||
echo $user['php'] == $key ? ' selected' : '';
|
||||
echo ">PHP $version</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<button type="submit" name="action" value="change_php"><?php echo _('Save'); ?></button>
|
||||
</form>
|
||||
<h3><?php echo _('System Account'); ?></h3>
|
||||
<table border="1">
|
||||
<tr><th><?php echo _('Username'); ?></th><th><?php echo _('Host'); ?></th><th><?php echo _('SFTP Port'); ?></th><th><?php echo _('POP3 Port'); ?></th><th><?php echo _('IMAP Port'); ?></th><th><?php echo _('SMTP port'); ?></th></tr>
|
||||
|
||||
Reference in new issue
Block a user