2025年4月2日 星期三

Sqlite3加密方案

SQLite Encryption Extension (SEE)
https://sqlite.org/com/see.html

sqlcipher
https://www.zetetic.net/sqlcipher/
https://github.com/zhouchangsheng/sqlcipher
apt install -y sqlcipher

sqlite-encrypt
https://github.com/jingqi/sqlite-encrypt/blob/master/README.md

SQLiteCrypt
https://www.sqlite-crypt.com/ 

2025年4月1日 星期二

Debian 12 NoVNC

安裝
apt install -y novnc apache2 php

Apache Module 設定
a2enmod rewrite
a2enmod headers

Apache VirtualHost <Directory> or <Location>設定
Header set Cache-Control "no-cache"

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]

index.php 內容
<?php
$NOVNC = "/usr/share/novnc/vnc.html";
$NOVNC = "/usr/share/novnc/v.html";
$NOVNC_DIR = dirname($NOVNC);

if($_SERVER["SCRIPT_URL"]=="/xxx") {
  if($_REQUEST['host']!='') exit();
  header("Content-Type: text/html");
  readfile($NOVNC);
  exit();
}

//novnc file_exists
$_t = $NOVNC_DIR . $_SERVER["SCRIPT_URL"];
if(file_exists($_t)) {
  switch(pathinfo($_t, PATHINFO_EXTENSION)){
    case "":
    case "htm":
    case "html":
    case "pl":
    case "md":  exit(); break;
    case "css": $x = "text/css"; break;
    case "js" : $x = "text/javascript"; break;
    default:    $x = (new finfo(FILEINFO_MIME_TYPE))->file($_t);
  }
  header("Content-Type: $x");
  readfile($_t);
  exit();
}
?>

隱藏 Clipboard Connection Controls 
修改 /usr/share/novnc/vnc.html
 <!-- Clipboard -->
            <input type="hidden" alt="Clipboard" src="app/images/clipboard.svg"
                id="noVNC_clipboard_button" class="noVNC_button"

<!-- Connection Controls -->
            <input type="hidden" alt="Disconnect" src="app/images/disconnect.svg"
                id="noVNC_disconnect_button" class="noVNC_button"
                title="Disconnect">

PHP取得MIME類型

<?php
$f = "1.woff";

$fi = new finfo(FILEINFO_MIME_TYPE);
$mime_type = $fi->file($f);
echo $mime_type;

echo (new finfo(FILEINFO_MIME_TYPE))->file($f);
?>