diff --git a/ht/gemini-domain.php b/ht/gemini-domain.php new file mode 100644 index 0000000..d1f9b02 --- /dev/null +++ b/ht/gemini-domain.php @@ -0,0 +1,78 @@ + + +

+ Ajouter un domaine sur un dossier de site
+ Le domaine doit pointer vers ces adresses IP :
+ IPv4 : 45.13.104.169
+ IPv6 : 2a0b:cbc0:1103:2::106f +

+ +
+
+
+
+ +
+ +
+ + + + diff --git a/ht/gemini-onion.php b/ht/gemini-onion.php new file mode 100644 index 0000000..76c32fa --- /dev/null +++ b/ht/gemini-onion.php @@ -0,0 +1,89 @@ + +

+ Ajouter un accès en .onion sur un dossier +

+ +
+
+ +
+ +
+ +L'adresse de votre capsule Onion Gemini est :
http://" . $onion . "

"; + +} + +?> + + diff --git a/ht/http-onion.php b/ht/http-onion.php index 664358d..b63c543 100644 --- a/ht/http-onion.php +++ b/ht/http-onion.php @@ -55,11 +55,11 @@ if (isset($_POST['dir']) AND isset($_SESSION['username'])) { $torConf = $torConf . "\nHiddenServiceDir /var/lib/tor/niver/" . $_POST['dir'] . "/\nHiddenServicePort 80 [::1]:80"; file_put_contents("/etc/tor/torrc", $torConf); - exec("sudo -u root /root/maniver/target/debug/maniver reload-tor", $output); + exec("sudo -u root " . MANIVER_PATH . " reload-tor", $output); addNiverLog("Tor reloaded by " . $_SESSION['username'], $output); // Copy generated address to a location readable by PHP - exec("sudo -u root /root/maniver/target/debug/maniver export-tor " . $_SESSION['username'] . " " . $_POST['dir'], $output); + exec("sudo -u root " . MANIVER_PATH . " export-tor " . $_SESSION['username'] . " " . $_POST['dir'], $output); addNiverLog("Tor data exported by " . $_SESSION['username'], $output); // Get the address generated by Tor @@ -80,7 +80,7 @@ if (isset($_POST['dir']) AND isset($_SESSION['username'])) { exec("sudo /root/maniver/target/debug/maniver reload-nginx"); // Tell the user their site address - echo "

L'adresse de votre site Onion est :
http://" . $onion . "

"; + echo "

L'adresse de votre site Onion HTTP est :
http://" . $onion . "

"; } diff --git a/ht/https-domain.php b/ht/https-domain.php index 181e976..b7bf693 100644 --- a/ht/https-domain.php +++ b/ht/https-domain.php @@ -1,4 +1,5 @@ +

Ajouter un domaine sur un dossier de site
Le domaine doit pointer vers ces adresses IP :
@@ -64,9 +65,9 @@ if (isset($_POST['domain']) AND isset($_POST['dir']) AND isset($_SESSION['userna $conf = preg_replace("#DIR#", $_POST['dir'], $conf); $conf = preg_replace("#USER#", $_SESSION['username'], $conf); file_put_contents("/etc/nginx/hyper.d/" . $_POST['domain'] . ".conf", $conf); - exec("sudo /root/maniver/target/debug/maniver reload-nginx"); + exec("sudo " . MANIVER_PATH . " reload-nginx"); //certbot certonly --nginx -d testcrabe.atope.art - echo "Accès par domaine ajouté sur ce dossier !"; + echo "Accès HTTP par domaine ajouté sur ce dossier !"; } ?> diff --git a/ht/index.php b/ht/index.php index 5dff417..ade1604 100644 --- a/ht/index.php +++ b/ht/index.php @@ -5,7 +5,11 @@ Accéder à son espace SFTP, pour publier et mettre à jour ses sites

Accès HTTP en Onion

Un site HTML, accessible par Tor, avec une adresse en .onion

Accès HTTPS par DNS

-Des pages HTML, accessible directement, par un nom de domaine +Un site HTML, accessible directement, par un nom de domaine +

Accès Gemini en Onion

+Une capsule Gemini, accessible par Tor, avec une adresse en .onion +

Accès Gemini par DNS

+Une capsule Gemini, accessible directement, par un nom de domaine

Installer un certificat Let's Encrypt sur un domaine

diff --git a/ht/le.php b/ht/le.php index e33efb1..dd5e001 100644 --- a/ht/le.php +++ b/ht/le.php @@ -14,7 +14,7 @@ if (isset($_POST['domain'])) { - exec("sudo /root/maniver/target/debug/maniver le-install " . $_POST['domain'], $output); + exec("sudo " . MANIVER_PATH . " le-install " . $_POST['domain'], $output); echo "
";
   print_r($output);
   echo "
"; diff --git a/ht/sftp.php b/ht/sftp.php index 7a8241b..a3efb26 100644 --- a/ht/sftp.php +++ b/ht/sftp.php @@ -4,7 +4,7 @@ if ($_SESSION['sftp_enabled'] == false) { ?>

Pour que vous puissiez mettre en ligne votre site via SFTP, veuillez définir un mot de passe. -
Il ne pourra pas être modifié. +
Il sera loggué en clair dans le systèmee et il ne pourra pas être modifié.

@@ -19,9 +19,12 @@ if ($_SESSION['sftp_enabled'] == false) { ?> if (isset($_SESSION['username']) AND isset($_POST['password'])) { // Setup SFTP access - exec("sudo /root/maniver/target/debug/maniver setup-user " . $_SESSION['username'] . " " . $_POST['password']); + exec("sudo " . MANIVER_PATH . " setup-user " . $_SESSION['username'] . " " . $_POST['password'], $output); + addNiverLog($_SESSION['username'] . " enabled SFTP on their account", $output); enableSftp($_SESSION['username']); $_SESSION['sftp_enabled'] = true; + header('Location: ' . PREFIX . '/' . SERVICE . '/' . PAGE . '', true, 302); + exit(); } } else if ($_SESSION['sftp_enabled'] == true) { ?> diff --git a/inc/all.inc.php b/inc/all.inc.php index b2b2f81..a70fb23 100644 --- a/inc/all.inc.php +++ b/inc/all.inc.php @@ -10,6 +10,15 @@ function addNiverLog($message, $outputLines) { file_put_contents(ROOT_PATH . "/niver.log", $logs, FILE_APPEND); } +function checkAction($action) { + if ($action === "delete") + return "un"; + else if ($action === "add") + return ""; + else + exit("ERROR: wrong value for action"); +} + function listUserZones($username) { $db = new PDO('sqlite:' . DB_PATH); $usernameArray[0] = $username; diff --git a/inc/format.inc.php b/inc/format.inc.php index 43c5c4c..4b9bd3c 100644 --- a/inc/format.inc.php +++ b/inc/format.inc.php @@ -4,23 +4,23 @@ if (strpos($_SERVER['PHP_SELF'], "inc.php") !== false) function checkIpFormat($ip) { if (!filter_var($ip, FILTER_VALIDATE_IP)) - exit("Erreur : l'adresse IP n'est pas valide"); + exit("ERROR: wrong IP address"); if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) - exit("Erreur : l'adresse IP est dans une plage privée"); + exit("ERROR: IP address is on the private range"); if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) - exit("Erreur : l'adresse IP est dans une plage réservée"); + exit("ERROR: IP address is on the reserved range"); } function checkAbsoluteDomainFormat($domain) { // If the domain must end with a dot if (!filter_var($domain, FILTER_VALIDATE_DOMAIN) OR !preg_match("/^([a-z0-9]{1,63}\.){2,127}$/", $domain)) - exit("Erreur : ce domaine n'est pas valide !"); + exit("ERROR: wrong domain"); } function checkDomainFormat($domain) { // If the domain must end without a dot if (!filter_var($domain, FILTER_VALIDATE_DOMAIN) OR !preg_match("/^([a-z0-9]{1,63}\.){1,126}[a-z0-9]{1,63}$/", $domain)) - exit("Erreur : ce domaine n'est pas valide !"); + exit("ERROR: wrong domain"); } function checkPasswordFormat($password) { diff --git a/inc/html/ttl.ns.inc.php b/inc/html/ttl.ns.inc.php new file mode 100644 index 0000000..f585f26 --- /dev/null +++ b/inc/html/ttl.ns.inc.php @@ -0,0 +1,15 @@ +
+ TTL + +
+ +
+ +
+ +
diff --git a/inc/ns.inc.php b/inc/ns.inc.php index a571d61..22aa0a5 100644 --- a/inc/ns.inc.php +++ b/inc/ns.inc.php @@ -2,8 +2,17 @@ if (strpos($_SERVER['PHP_SELF'], "inc.php") !== false) exit("This file is meant to be included."); -function nsCheckZonePossession($zone) { - checkAbsoluteDomainFormat($zone); +function nsTtl($value, $multiplier) { + $ttl = $value * $multiplier; + + if (!($ttl >= 300 AND $ttl <= 432000)) + exit("Erreur : le TTL doit être compris entre 5 minutes et 5 jours (entre 300 et 432000 secondes)"); + + return $ttl; +} + +function nsCheckZonePossession($submittedZone) { + checkAbsoluteDomainFormat($submittedZone); $db = new PDO('sqlite:' . DB_PATH); $username[0] = $_SESSION['username']; @@ -11,16 +20,13 @@ function nsCheckZonePossession($zone) { $op = $db->prepare('SELECT zone FROM zones WHERE username = ?'); $op->execute($username); - $domain = $op->fetch()['zone']; + $dbZone = $op->fetch()['zone']; - while ($domain != NULL) { - if ($domain === $zone) { - $owned = true; - break; - } - $domain = $op->fetch()['zone']; + while ($dbZone != NULL) { + if ($dbZone === $submittedZone) return; + $dbZone = $op->fetch()['zone']; } - if (!($owned === true)) - exit("Erreur : Vous ne possédez pas ce domaine sur le serveur de noms !"); + // If there is no entry in the database for the user matching the submitted zone + exit("ERROR: You don't own this zone on the nameserver"); } diff --git a/inc/pages.inc.php b/inc/pages.inc.php index 297f761..f40a0a9 100644 --- a/inc/pages.inc.php +++ b/inc/pages.inc.php @@ -22,6 +22,9 @@ switch (SERVICE) { case "txt": $page['title'] = "Enregistrement TXT"; break; + case "caa": + $page['title'] = "Enregistrement CAA"; + break; case "zone": $page['title'] = "Ajouter une zone"; break; @@ -64,6 +67,9 @@ switch (SERVICE) { case "password": $page['title'] = "Changer le mot de passe"; break; + case "logout": + $page['title'] = "Déconnexion"; + break; } break; @@ -73,8 +79,14 @@ switch (SERVICE) { case "mkdir": $page['title'] = "Créer un dossier de site"; break; + case "gemini-onion": + $page['title'] = "Accès Gemini en Onion"; + break; + case "gemini-domain": + $page['title'] = "Accès Gemini par domaine"; + break; case "http-onion": - $page['title'] = "Accès HTTP en .onion"; + $page['title'] = "Accès HTTP en Onion"; break; case "https-domain": $page['title'] = "Accès HTTPS par domaine"; diff --git a/niver.log b/niver.log index 5747ddf..be9241f 100644 --- a/niver.log +++ b/niver.log @@ -12,3 +12,38 @@ status: exit code: 0 stdout: stderr: + +2021-02-27 19:32:34 poule enabled SFTP on their account + status: exit code: 0 + stdout: + stderr: + +2021-02-27 19:45:47 poireau enabled SFTP on their account + status: exit code: 0 + stdout: + stderr: + sent username:password to chpasswd + chpasswd responded with: + status: exit code: 0 + stdout: + stderr: + status: exit code: 0 + stdout: + stderr: + status: exit code: 0 + stdout: + stderr: + +2021-02-27 19:59:45 Tor reloaded by poireau + +2021-02-27 19:59:45 Tor data exported by poireau + status: exit code: 0 + stdout: + stderr: + +2021-02-27 20:06:30 Tor reloaded by poireau + +2021-02-27 20:06:30 Tor data exported by poireau + status: exit code: 0 + stdout: + stderr: diff --git a/ns/caa.php b/ns/caa.php new file mode 100644 index 0000000..def31e8 --- /dev/null +++ b/ns/caa.php @@ -0,0 +1,83 @@ + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ += 0 AND $_POST['flag'] <= 255)) + exit("ERROR: Wrong value for flag"); + + if (!(preg_match("/^[a-z]{1,127}$/", $_POST['tag']))) + exit("ERROR: Wrong value for tag"); + + if (!(preg_match("/^[a-z0-9.-]{1,255}$/", $_POST['value']))) + exit("ERROR: Wrong value for value"); + + nsCheckZonePossession($_POST['zone']); + checkAbsoluteDomainFormat($_POST['domain']); + + $action = checkAction($_POST['action']); + + $ttl = nsTtl($_POST['ttl-value'], $_POST['ttl-multiplier']); + + exec(KNOTC_PATH . " zone-begin " . $_POST['zone']); + exec(KNOTC_PATH . " zone-" . $action . "set " . $_POST['zone'] . " " . $_POST['domain'] . " " . $ttl . " IN CAA " . $_POST['flag'] . " " . $_POST['tag'] . " " . $_POST['value']); + exec(KNOTC_PATH . " zone-commit " . $_POST['zone']); + echo "Enregistrement ajouté"; +} + +?> + + diff --git a/ns/index.php b/ns/index.php index 1e11e2e..c43208a 100644 --- a/ns/index.php +++ b/ns/index.php @@ -16,7 +16,7 @@ Mettre en place DANEEnregistrement SRV Indiquer un serveur pour un domaine -

Enregistrement MX

+

Enregistrement MX

Indiquer le serveur mail pour un domaine

Enregistrement LOC

Indiquer la localisation physique d'un domaine diff --git a/ns/ip.php b/ns/ip.php index 2773f2d..66c5565 100644 --- a/ns/ip.php +++ b/ns/ip.php @@ -67,12 +67,7 @@ if (isset($_POST['domain']) AND isset($_POST['ip']) AND isset($_POST['zone']) AN else exit("Erreur inconnue sur le format de l'IP"); - if ($_POST['action'] == "delete") - $action = "un"; - else if ($_POST['action'] == "add") - $action = ""; - else - exit("ERROR : Wrong value for action"); + $action = checkAction($_POST['action']); exec(KNOTC_PATH . " zone-begin " . $_POST['zone']); exec(KNOTC_PATH . " zone-" . $action . "set " . $_POST['zone'] . " " . $_POST['domain'] . " 3600 " . $record . " " . $_POST['ip']); diff --git a/ns/ns.php b/ns/ns.php index 12c010a..accca00 100644 --- a/ns/ns.php +++ b/ns/ns.php @@ -40,12 +40,7 @@ if (isset($_POST['zone']) AND isset($_POST['domain']) AND isset($_POST['action'] checkAbsoluteDomainFormat($_POST['domain']); checkAbsoluteDomainFormat($_POST['ns']); - if ($_POST['action'] == "delete") - $action = "un"; - else if ($_POST['action'] == "add") - $action = ""; - else - exit("Erreur : valeur invalide pour action"); + $action = checkAction($_POST['action']); exec(KNOTC_PATH . " zone-begin " . $_POST['zone']); exec(KNOTC_PATH . " zone-" . $action . "set " . $_POST['zone'] . " " . $_POST['domain'] . " 3600 IN NS " . $_POST['ns']); diff --git a/ns/txt.php b/ns/txt.php index 5546900..00b5827 100644 --- a/ns/txt.php +++ b/ns/txt.php @@ -42,18 +42,13 @@ if (isset($_POST['zone']) AND isset($_POST['domain']) AND isset($_POST['action'] nsCheckZonePossession($_POST['zone']); checkAbsoluteDomainFormat($_POST['domain']); - if ($_POST['action'] == "delete") - $action = "un"; - else if ($_POST['action'] == "add") - $action = ""; - else - exit("Erreur : valeur invalide pour action"); + $action = checkAction($_POST['action']); $test = ' 3600 IN TXT \"' . $_POST['txt'] . '\"'; echo $test; exec(KNOTC_PATH . " zone-begin " . $_POST['zone']); - exec(KNOTC_PATH . " zone-" . $action . "set " . $_POST['zone'] . " " . $_POST['domain'] . ' 3600 IN TXT \"' . $_POST['txt'] . '\"'); + exec(KNOTC_PATH . " zone-" . $action . "set " . $_POST['zone'] . " " . $_POST['domain'] . ' 3600 IN TXT \"' . $_POST['txt'] . '\"'); exec(KNOTC_PATH . " zone-commit " . $_POST['zone']); echo "Enregistrement ajouté"; } diff --git a/reg/glue.php b/reg/glue.php index d01a36c..99fd39e 100644 --- a/reg/glue.php +++ b/reg/glue.php @@ -58,12 +58,7 @@ if (isset($_POST['action']) AND isset($_POST['subdomain']) AND isset($_POST['suf else exit("Unknown error about IP format"); - if ($_POST['action'] == "delete") - $action = "un"; - else if ($_POST['action'] == "add") - $action = ""; - else - exit("ERROR : Wrong value for action"); + $action = checkAction($_POST['action']); // Remove anything before the first dot and the first dot itself $suffix = regGetSuffix($_POST['suffix']); diff --git a/reg/ns.php b/reg/ns.php index 40d4cb2..dcdcfc9 100644 --- a/reg/ns.php +++ b/reg/ns.php @@ -39,12 +39,7 @@ if (isset($_POST['domain']) AND isset($_POST['action']) AND isset($_POST['ns']) regCheckDomainPossession($_POST['domain']); checkAbsoluteDomainFormat($_POST['ns']); - if ($_POST['action'] == "delete") - $action = "un"; - else if ($_POST['action'] == "add") - $action = ""; - else - exit("Erreur : valeur invalide pour action"); + $action = checkAction($_POST['action']); $suffix = regGetSuffix($_POST['domain']); diff --git a/top.inc.php b/top.inc.php index 3e1f5a8..4564611 100644 --- a/top.inc.php +++ b/top.inc.php @@ -26,6 +26,7 @@ define("PAGE", basename($_SERVER['PHP_SELF'], '.php')); define("DB_PATH", ROOT_PATH . "/db/niver.db"); define("KNOTC_PATH", "/usr/sbin/knotc"); define("KEYMGR_PATH", "/usr/sbin/keymgr"); +define("MANIVER_PATH", "/root/maniver/target/release/maniver"); if (SERVICE != "auth" AND !isset($_SESSION['username'])) { header('Location: ' . PREFIX . '/auth/login?redir=' . SERVICE . "/" . PAGE, true, 302);