Add files via upload
This commit is contained in:
229
server/app-code/install/add_passkey.php
Normal file
229
server/app-code/install/add_passkey.php
Normal file
@@ -0,0 +1,229 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
|
||||
<title>Add passkey</title>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
//js to handle passkey
|
||||
async function createRegistration() {
|
||||
try {
|
||||
|
||||
// check browser support
|
||||
if (!window.fetch || !navigator.credentials || !navigator.credentials.create) {
|
||||
throw new Error('Browser not supported.');
|
||||
}
|
||||
|
||||
// get create args
|
||||
let rep = await window.fetch('/system/insecure_zone/php/create_admin_backend.php?fn=getCreateArgs' + getGetParams(), {method:'GET', cache:'no-cache'});
|
||||
const createArgs = await rep.json();
|
||||
|
||||
// error handling
|
||||
if (createArgs.success === false) {
|
||||
throw new Error(createArgs.msg || 'unknown error occured');
|
||||
}
|
||||
|
||||
// replace binary base64 data with ArrayBuffer. a other way to do this
|
||||
// is the reviver function of JSON.parse()
|
||||
recursiveBase64StrToArrayBuffer(createArgs);
|
||||
|
||||
// create credentials
|
||||
const cred = await navigator.credentials.create(createArgs);
|
||||
|
||||
// create object
|
||||
const authenticatorAttestationResponse = {
|
||||
transports: cred.response.getTransports ? cred.response.getTransports() : null,
|
||||
clientDataJSON: cred.response.clientDataJSON ? arrayBufferToBase64(cred.response.clientDataJSON) : null,
|
||||
attestationObject: cred.response.attestationObject ? arrayBufferToBase64(cred.response.attestationObject) : null
|
||||
};
|
||||
|
||||
// check auth on server side
|
||||
rep = await window.fetch('/system/insecure_zone/php/create_admin_backend.php?fn=processCreate' + getGetParams(), {
|
||||
method : 'POST',
|
||||
body : JSON.stringify(authenticatorAttestationResponse),
|
||||
cache : 'no-cache'
|
||||
});
|
||||
const authenticatorAttestationServerResponse = await rep.json();
|
||||
|
||||
// prompt server response
|
||||
if (authenticatorAttestationServerResponse.success) {
|
||||
reloadServerPreview();
|
||||
window.alert(authenticatorAttestationServerResponse.msg || 'registration success');
|
||||
window.location.href = "end.php";
|
||||
} else {
|
||||
throw new Error(authenticatorAttestationServerResponse.msg);
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
reloadServerPreview();
|
||||
window.alert(err.message || 'unknown error occured');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function queryFidoMetaDataService() {
|
||||
window.fetch('/system/insecure_zone/php/create_admin_backend.php?fn=queryFidoMetaDataService' + getGetParams(), {method:'GET',cache:'no-cache'}).then(function(response) {
|
||||
return response.json();
|
||||
|
||||
}).then(function(json) {
|
||||
if (json.success) {
|
||||
window.alert(json.msg);
|
||||
} else {
|
||||
throw new Error(json.msg);
|
||||
}
|
||||
}).catch(function(err) {
|
||||
window.alert(err.message || 'unknown error occured');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* convert RFC 1342-like base64 strings to array buffer
|
||||
* @param {mixed} obj
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function recursiveBase64StrToArrayBuffer(obj) {
|
||||
let prefix = '=?BINARY?B?';
|
||||
let suffix = '?=';
|
||||
if (typeof obj === 'object') {
|
||||
for (let key in obj) {
|
||||
if (typeof obj[key] === 'string') {
|
||||
let str = obj[key];
|
||||
if (str.substring(0, prefix.length) === prefix && str.substring(str.length - suffix.length) === suffix) {
|
||||
str = str.substring(prefix.length, str.length - suffix.length);
|
||||
|
||||
let binary_string = window.atob(str);
|
||||
let len = binary_string.length;
|
||||
let bytes = new Uint8Array(len);
|
||||
for (let i = 0; i < len; i++) {
|
||||
bytes[i] = binary_string.charCodeAt(i);
|
||||
}
|
||||
obj[key] = bytes.buffer;
|
||||
}
|
||||
} else {
|
||||
recursiveBase64StrToArrayBuffer(obj[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a ArrayBuffer to Base64
|
||||
* @param {ArrayBuffer} buffer
|
||||
* @returns {String}
|
||||
*/
|
||||
function arrayBufferToBase64(buffer) {
|
||||
let binary = '';
|
||||
let bytes = new Uint8Array(buffer);
|
||||
let len = bytes.byteLength;
|
||||
for (let i = 0; i < len; i++) {
|
||||
binary += String.fromCharCode( bytes[ i ] );
|
||||
}
|
||||
return window.btoa(binary);
|
||||
}
|
||||
|
||||
function ascii_to_hex(str) {
|
||||
let hex = '';
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
let ascii = str.charCodeAt(i).toString(16);
|
||||
hex += ('00' + ascii).slice(-2); // Ensure each hex value is 2 characters long
|
||||
}
|
||||
return hex;
|
||||
}
|
||||
/**
|
||||
* Get URL parameter
|
||||
* @returns {String}
|
||||
*/
|
||||
function getGetParams() {
|
||||
let url = '';
|
||||
|
||||
url += '&apple=1';
|
||||
url += '&yubico=1';
|
||||
url += '&solo=1'
|
||||
url += '&hypersecu=1';
|
||||
url += '&google=1';
|
||||
url += 'µsoft=1';
|
||||
url += '&mds=1';
|
||||
|
||||
url += '&requireResidentKey=0';
|
||||
|
||||
url += '&type_usb=1';
|
||||
url += '&type_nfc=1';
|
||||
url += '&type_ble=1';
|
||||
url += '&type_int=1';
|
||||
url += '&type_hybrid=1';
|
||||
|
||||
url += '&fmt_android-key=1';
|
||||
url += '&fmt_android-safetynet=1';
|
||||
url += '&fmt_apple=1';
|
||||
url += '&fmt_fido-u2f=1';
|
||||
url += '&fmt_none=1';
|
||||
url += '&fmt_packed=1';
|
||||
url += '&fmt_tpm=1';
|
||||
|
||||
url += '&rpId=auth.jakach.com';
|
||||
|
||||
url += '&userId=' + encodeURIComponent(ascii_to_hex(document.getElementById('username').value));
|
||||
url += '&userName=' + encodeURIComponent(document.getElementById('username').value);
|
||||
url += '&userDisplayName=' + encodeURIComponent(document.getElementById('username').value);
|
||||
|
||||
url += '&userVerification=discouraged';
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
function reloadServerPreview() {
|
||||
//let iframe = document.getElementById('serverPreview');
|
||||
//iframe.src = iframe.src;
|
||||
}
|
||||
|
||||
function setAttestation(attestation) {
|
||||
let inputEls = document.getElementsByTagName('input');
|
||||
for (const inputEl of inputEls) {
|
||||
if (inputEl.id && inputEl.id.match(/^(fmt|cert)\_/)) {
|
||||
inputEl.disabled = !attestation;
|
||||
}
|
||||
if (inputEl.id && inputEl.id.match(/^fmt\_/)) {
|
||||
inputEl.checked = attestation ? inputEl.id !== 'fmt_none' : inputEl.id === 'fmt_none';
|
||||
}
|
||||
if (inputEl.id && inputEl.id.match(/^cert\_/)) {
|
||||
inputEl.checked = attestation ? inputEl.id === 'cert_mds' : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* force https on load
|
||||
* @returns {undefined}
|
||||
*/
|
||||
window.onload = function() {
|
||||
if (location.protocol !== 'https:' && location.host !== 'localhost') {
|
||||
location.href = location.href.replace('http', 'https');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4>Add a passkey?</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<input type="text" id="username" name="username" value="<?php echo($_GET["username"]); ?>" style="display: none;">
|
||||
<p>You can add a device specific passkey which allows you to login in securely with your fingerprint / hardware key etc.</p>
|
||||
<button type="button" class="btn btn-primary btn-block" onclick="createRegistration()">Add a passkey</button>
|
||||
<br><br>
|
||||
<a href="end.php" class="btn btn-primary btn-block">Skip for now</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
85
server/app-code/install/create_admin.php
Normal file
85
server/app-code/install/create_admin.php
Normal file
@@ -0,0 +1,85 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
|
||||
<title>Change Password</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
include "../api/php/log/add_server_entry.php"; //to log things
|
||||
?>
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4>Add an admin user</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>Please create an initial admin user. This user the can create new users etc.<br>Please use a strong password for this user!</p>
|
||||
<form action="create_admin.php?create=true" method="post">
|
||||
<div class="form-group">
|
||||
<label for="username">Username:</label>
|
||||
<input type="text" class="form-control" id="username" name="username" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Email:</label>
|
||||
<input type="email" class="form-control" id="email" name="email" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" class="form-control" id="password" name="password" required>
|
||||
</div>
|
||||
<br>
|
||||
<button type="submit" class="btn btn-primary btn-block">Create user</button>
|
||||
</form>
|
||||
<?php
|
||||
include "../config.php";
|
||||
if(isset($_GET["create"])){
|
||||
$email=htmlspecialchars($_POST["email"]);
|
||||
$username=htmlspecialchars($_POST["username"]);
|
||||
$password=htmlspecialchars($_POST["password"]);
|
||||
$permissions="11111111111";
|
||||
// Create connection
|
||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
|
||||
|
||||
// Check connection
|
||||
if ($conn->connect_error) {
|
||||
$success=0;
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
//create the unauth user
|
||||
$stmt = $conn->prepare("INSERT INTO users (email, username, password,perms,allow_pw_login,send_login_message,use_2fa) VALUES ('unauth@cyberhex.local', 'not_authenticated_user', 'this_user_does_not_have_a_password', '000000000000000',0,0,0)");
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO users (email, username, password,perms,allow_pw_login,send_login_message,use_2fa) VALUES (?, ?, ?, ?,1,0,0)");
|
||||
$stmt->bind_param("ssss", $email, $username, $hash, $permissions);
|
||||
|
||||
$email=htmlspecialchars($_POST["email"]);
|
||||
$username=htmlspecialchars($_POST["username"]);
|
||||
$password=$_POST["password"];
|
||||
$permissions="11111111111";
|
||||
$hash=password_hash($password, PASSWORD_BCRYPT);
|
||||
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Admin user created successfully! <a href="add_passkey.php?username='.$username.'">Continue installation</a>
|
||||
</div>';
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
469
server/app-code/install/create_db.php
Normal file
469
server/app-code/install/create_db.php
Normal file
@@ -0,0 +1,469 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
|
||||
<title>Cyberhex login page</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4>We are creating the databases used in cyberhex, please stand by</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>If the creation fails, please wait a minute and try again. The database server might still be starting at the time.</p>
|
||||
<br>
|
||||
</div>
|
||||
<?php
|
||||
$success=1;
|
||||
include "../config.php";
|
||||
|
||||
// Create connection
|
||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD);
|
||||
|
||||
// Check connection
|
||||
if ($conn->connect_error) {
|
||||
$success=0;
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Create database
|
||||
$sql = "CREATE DATABASE IF NOT EXISTS $DB_DATABASE";
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Database created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating database: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
|
||||
// Connect to the new database
|
||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
|
||||
|
||||
// Check connection
|
||||
if ($conn->connect_error) {
|
||||
$success=0;
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Create user table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS users (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
username VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
perms VARCHAR(255),
|
||||
password VARCHAR(255),
|
||||
2fa VARCHAR(255),
|
||||
telegram_id VARCHAR(255),
|
||||
user_hex_id VARCHAR(255),
|
||||
credential_id VARBINARY(64),
|
||||
allow_pw_login INT,
|
||||
use_2fa INT,
|
||||
send_login_message INT,
|
||||
public_key TEXT,
|
||||
counter INT
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table users created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table users: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Create log table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS log (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
logtext VARCHAR(500) NOT NULL,
|
||||
loglevel VARCHAR(255) NOT NULL,
|
||||
machine_id VARCHAR(255),
|
||||
time VARCHAR(255)
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table log created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table log: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Create incident table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS incidents (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
status VARCHAR(50) NOT NULL,
|
||||
description VARCHAR(255) NOT NULL,
|
||||
opened VARCHAR(50),
|
||||
closed VARCHAR(50)
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table incidents created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table incidents: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Create todo_items table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS todo_items (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
done INT,
|
||||
done_by INT,
|
||||
belongs_to_list INT,
|
||||
text VARCHAR(500) NOT NULL
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table todo_items created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table todo_items: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Create todo lists table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS todo_lists (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
belongs_to_incident INT,
|
||||
name VARCHAR(255) NOT NULL
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table todo_items created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table todo_items: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Create chat table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS chats (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
belongs_to_incident INT,
|
||||
text TEXT NOT NULL,
|
||||
sent VARCHAR(50),
|
||||
from_userid INT
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table todo_items created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table todo_items: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
|
||||
// Create server log table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS server_log (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
logtext VARCHAR(500) NOT NULL,
|
||||
loglevel VARCHAR(255) NOT NULL,
|
||||
userid INT,
|
||||
time VARCHAR(255)
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table log created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table log: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Create settings table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS settings (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL UNIQUE,
|
||||
value VARCHAR(255) NOT NULL
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table settings created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table settings: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
//user tasks table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS user_tasks (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
task VARCHAR(255) NOT NULL UNIQUE
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table settings created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table settings: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
//system tasks table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS system_tasks (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
task VARCHAR(255) NOT NULL UNIQUE
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table settings created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table settings: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
// Create rtp_included table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS rtp_included (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
path VARCHAR(255) NOT NULL UNIQUE
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table rtp_included created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table rtp_included: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
// Create rtp_excluded table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS rtp_excluded (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
path VARCHAR(255) NOT NULL UNIQUE
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table rtp_excluded created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table rtp_excluded: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Create dissalowed_start table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS disallowed_start (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
path VARCHAR(255) NOT NULL UNIQUE
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table disalowed_start created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table disalowed_start: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Create api table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS api (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
apikey VARCHAR(500) NOT NULL,
|
||||
machine_id VARCHAR(255) NOT NULL
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table api created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table api: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Create secrets table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS secrets (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
cert VARCHAR(500) NOT NULL,
|
||||
machine_id VARCHAR(255) NOT NULL
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table secrets created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table secrets: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Create machine table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS machines (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
machine_name VARCHAR(255) NOT NULL,
|
||||
machine_location VARCHAR(255) NOT NULL,
|
||||
machine_ip VARCHAR(255) NOT NULL
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table machines created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table machines: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Create vir_notify messages table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS vir_notify (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
machine_id VARCHAR(255) NOT NULL,
|
||||
path VARCHAR(255) NOT NULL,
|
||||
hash VARCHAR(255) NOT NULL,
|
||||
action VARCHAR(255) NOT NULL
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table machines created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table machines: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Create sig_ex messages table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS sig_ex (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
signature VARCHAR(255) NOT NULL,
|
||||
description VARCHAR(255) NOT NULL
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table excluded signatures created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table excluded signatures: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Create sig_in messages table
|
||||
$sql = "CREATE TABLE IF NOT EXISTS sig_in (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
signature VARCHAR(255) NOT NULL,
|
||||
description VARCHAR(255) NOT NULL
|
||||
)";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Table included signatures created successfully!
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating table included signatures: ' . $conn->error .'
|
||||
</div>';
|
||||
}
|
||||
|
||||
// Attempt to create the directory where export files will be stored later on
|
||||
/*if (mkdir("/var/www/html/export", 0777, true)) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Created export dir successfully.
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating export dir.
|
||||
</div>';
|
||||
}
|
||||
//Attempt to create the directory where import files will be stored later on
|
||||
if (mkdir("/var/www/html/import", 0777, true)) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Created export dir successfully.
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating export dir.
|
||||
</div>';
|
||||
}
|
||||
|
||||
//Attempt to create the directory where log backup files will be stored later on
|
||||
if (mkdir("/var/www/html/backup", 0777, true)) {
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Created backup dir successfully.
|
||||
</div>';
|
||||
} else {
|
||||
$success=0;
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
Error creating backup dir.
|
||||
</div>';
|
||||
}*/
|
||||
|
||||
if($success!==1){
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
There was an error creating the databases. Please try again or contact support at: <a href="mailto:info.jakach@gmail.com">info.jakach@gmail.com</a>
|
||||
</div>';
|
||||
}else{
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
Database created successfully! <a href="create_admin.php">Continue installation</a>
|
||||
</div>';
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
49
server/app-code/install/end.php
Normal file
49
server/app-code/install/end.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
|
||||
<title>Cyberhex login page</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4>You have installed cyberhex! Thank you for choosing us!</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<a href="end.php?end=true">Finish installation.</a>
|
||||
<?php
|
||||
if(isset($_GET["end"])){
|
||||
$success=1;
|
||||
/* if(!unlink("create_admin.php")){
|
||||
$success=0;
|
||||
}if(!unlink("welcome.php")){
|
||||
$success=0;
|
||||
}if(!unlink("create_db.php")){
|
||||
$success=0;
|
||||
}if(!unlink("add_passkey.php")){
|
||||
$success=0;
|
||||
}*/
|
||||
if($success!==1){
|
||||
echo '<br><div class="alert alert-danger" role="alert">
|
||||
There was an error finishing the installation. Please try again or contact support at: <a href="mailto:info.jakach@gmail.com">info.jakach@gmail.com</a>
|
||||
</div>';
|
||||
}else{
|
||||
echo '<br><div class="alert alert-success" role="alert">
|
||||
All done, you can now start using cyberhex! <a href="/login.php">Go to login page</a>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
30
server/app-code/install/welcome.php
Normal file
30
server/app-code/install/welcome.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
|
||||
<title>Cyberhex login page</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4>Welcome to the Cyberhex Installation</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
<p>The installer will guide you through the installation.</p>
|
||||
<p>If there are any errors during installation or you are stuck, please contatact <a href="mailto:info.jakach@gmail.com">info.jakach@gmail.com</a></p>
|
||||
<a href="create_db.php">Start installation.</a>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user