init from 4 old repositories
This commit is contained in:
4
controlserverwebpage/.htaccess
Normal file
4
controlserverwebpage/.htaccess
Normal file
@@ -0,0 +1,4 @@
|
||||
RewriteEngine On
|
||||
RewriteCond %{SERVER_PORT} 80
|
||||
RewriteRule ^(.*)$ https://192.168.1.127/$1 [R,L]
|
||||
Options +Indexes
|
||||
17
controlserverwebpage/README.md
Normal file
17
controlserverwebpage/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
### controlserverwebpage
|
||||
|
||||
Web page and scripts for basic control of server with Veracrypt/Truecrypt storage
|
||||
|
||||
This software is released under the DWTW license.
|
||||
|
||||
Warning! Use only https connection for sending passwords via this page.
|
||||
|
||||
Change /etc/sudoers for adding root previlegies to www-data.
|
||||
Compile phphalt.c and phpreboot.c in /usr/bin:
|
||||
|
||||
```
|
||||
gcc -Wall phphalt.c -o phphalt
|
||||
gcc -Wall phpreboot.c -o phpreboot
|
||||
```
|
||||
|
||||
( https://stackoverflow.com/questions/24100055/ )
|
||||
2
controlserverwebpage/etc/sudoers
Normal file
2
controlserverwebpage/etc/sudoers
Normal file
@@ -0,0 +1,2 @@
|
||||
# User privilege specification
|
||||
www-data ALL=(ALL) /usr/bin/veracrypt, /usr/bin/phpreboot, /usr/bin/phphalt
|
||||
8
controlserverwebpage/halt.php
Normal file
8
controlserverwebpage/halt.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
if ($_GET["pass"] == "simplepass") {
|
||||
shell_exec('echo www-data-password | sudo -S /usr/bin/phphalt');
|
||||
echo "Shutdown...please wait";
|
||||
} else echo "wrong password";
|
||||
|
||||
?>
|
||||
91
controlserverwebpage/index.html
Normal file
91
controlserverwebpage/index.html
Normal file
@@ -0,0 +1,91 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>Control page</title>
|
||||
</head>
|
||||
<body>
|
||||
Status: <b id="status"></b>
|
||||
<br><br>
|
||||
<input type="button" onclick="checkStatus();" value="Check status"/>
|
||||
<input id="pwdButton" type="button" onclick="password();" value="Enter password"/>
|
||||
<input type="button" onclick="rebootS();" value="Reboot"/>
|
||||
<input type="button" onclick="haltS();" value="Shutdown"/>
|
||||
<script type="text/javascript">
|
||||
|
||||
var waitState = "false";
|
||||
|
||||
function checkStatus() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'status.php');
|
||||
xhr.send(null);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
|
||||
xhr.responseText.split('\n').forEach(function(line) {
|
||||
if (waitState == "true") { document.getElementById("status").innerHTML = "<font color=red>wait ... </font>" + line }
|
||||
else { document.getElementById("status").innerHTML = line; }
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function password() {
|
||||
var answer = prompt('Enter password', '');
|
||||
if (!((answer == null) || (answer == ''))) {
|
||||
document.getElementById("pwdButton").disabled = true;
|
||||
document.getElementById("status").innerHTML = "<font color=red>wait</font>";
|
||||
waitState = "true";
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'password.php?pass=' + answer);
|
||||
xhr.send(null);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
|
||||
xhr.responseText.split('\n').forEach(function(line) {
|
||||
document.getElementById("status").innerHTML = line;
|
||||
document.getElementById("pwdButton").disabled = false;
|
||||
waitState = "false";
|
||||
})
|
||||
}
|
||||
document.getElementById("status").innerHTML = "";
|
||||
document.getElementById("pwdButton").disabled = false;
|
||||
waitState = "false";
|
||||
checkStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function rebootS() {
|
||||
var answerpw = prompt('Enter password for reboot', '');
|
||||
if (!((answerpw == null) || (answerpw == ''))) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'reboot.php?pass=' + answerpw);
|
||||
xhr.send(null);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
|
||||
xhr.responseText.split('\n').forEach(function(line) {
|
||||
document.getElementById("status").innerHTML = line;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function haltS() {
|
||||
var answerpw = prompt('Enter password for sutdown', '');
|
||||
if (!((answerpw == null) || (answerpw == ''))) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'halt.php?pass=' + answerpw);
|
||||
xhr.send(null);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
|
||||
xhr.responseText.split('\n').forEach(function(line) {
|
||||
document.getElementById("status").innerHTML = line;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
6
controlserverwebpage/password.php
Normal file
6
controlserverwebpage/password.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
$p = "vcmnt.sh ".$_GET["pass"];
|
||||
echo exec($p);
|
||||
|
||||
?>
|
||||
8
controlserverwebpage/reboot.php
Normal file
8
controlserverwebpage/reboot.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
if ($_GET["pass"] == "simplepass") {
|
||||
echo "Rebooting...";
|
||||
shell_exec('echo www-data-password | sudo -S /usr/bin/phpreboot');
|
||||
} else echo "wrong password";
|
||||
|
||||
?>
|
||||
12
controlserverwebpage/status.php
Normal file
12
controlserverwebpage/status.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
$mountCheck = "ls /media/veracrypt/check/";
|
||||
// if file 'accept' exists, then disk is mounted
|
||||
if (exec($mountCheck) == 'accept') $mountStatus = "mounted";
|
||||
else $mountStatus = "dismounted";
|
||||
|
||||
$result = $mountStatus;
|
||||
|
||||
echo $result;
|
||||
|
||||
?>
|
||||
10
controlserverwebpage/usr/bin/phphalt.c
Normal file
10
controlserverwebpage/usr/bin/phphalt.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
setuid(0);
|
||||
char *command = "/sbin/shutdown";
|
||||
execl(command, command, NULL);
|
||||
return 0;
|
||||
}
|
||||
10
controlserverwebpage/usr/bin/phpreboot.c
Normal file
10
controlserverwebpage/usr/bin/phpreboot.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
setuid(0);
|
||||
char *command = "/sbin/reboot";
|
||||
execl(command, command, NULL);
|
||||
return 0;
|
||||
}
|
||||
7
controlserverwebpage/usr/bin/stmnt.sh
Executable file
7
controlserverwebpage/usr/bin/stmnt.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo www-data-password | sudo -S veracrypt -t -v --non-interactive --mount /tmp/crypt_container.dat /media/veracrypt/ -p $1
|
||||
sleep 1
|
||||
echo www-data-password | sudo -S echo "there some another command"
|
||||
|
||||
exit
|
||||
Reference in New Issue
Block a user