init from 4 old repositories

This commit is contained in:
2019-08-05 16:07:57 +03:00
parent c750e17675
commit fa1425a67b
20 changed files with 378 additions and 2 deletions

View File

@@ -0,0 +1,4 @@
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://192.168.1.127/$1 [R,L]
Options +Indexes

View 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/ )

View File

@@ -0,0 +1,2 @@
# User privilege specification
www-data ALL=(ALL) /usr/bin/veracrypt, /usr/bin/phpreboot, /usr/bin/phphalt

View 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";
?>

View 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>

View File

@@ -0,0 +1,6 @@
<?php
$p = "vcmnt.sh ".$_GET["pass"];
echo exec($p);
?>

View 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";
?>

View 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;
?>

View 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;
}

View 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;
}

View 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