mirror of
http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/blog-contributions.git
synced 2025-07-02 06:36:40 +00:00
new tutorial + fix the index files
This commit is contained in:
parent
3b1d671775
commit
81b9522893
5 changed files with 666 additions and 11 deletions
|
@ -7,7 +7,7 @@
|
|||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
<link rel="shortcut icon" href="../../../../../assets/img/favicon.png">
|
||||
<title>OPSEC: Privacy, Anonymity and Plausible Deniability Tutorials</title>
|
||||
<title>OPSEC: Privacy, Anonymity and Deniability Tutorials</title>
|
||||
<link href="../assets/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="../assets/css/main.css" rel="stylesheet">
|
||||
|
||||
|
@ -38,8 +38,8 @@
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2">
|
||||
<a href="../index.html">Previous Page</a></br></br><h1>OPSEC: Privacy, Anonymity and Plausible Deniability</h1>
|
||||
<p> Tutorials to show how to achieve Privacy, Anonymity and Plausible Deniability online.
|
||||
<a href="../index.html">Previous Page</a></br></br><h1>OPSEC: Privacy, Anonymity and Deniability</h1>
|
||||
<p> Tutorials to show how to achieve Privacy, Anonymity and Deniability online.
|
||||
I have <a href="tutorial/index.html">a quality standard</a> as to how i do these tutorials, if there are any improvements i can do on them please let me know.</p>
|
||||
|
||||
<img src="opsec4levels/0.png" class="imgRz">
|
||||
|
@ -289,7 +289,7 @@
|
|||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2">
|
||||
|
||||
<h2><img src="de0.png"> <b>OPSEC LEVEL 3: Plausible Deniability </b></h2>
|
||||
<h2><img src="de0.png"> <b>OPSEC LEVEL 3: Deniability </b></h2>
|
||||
<!--<div style="float: left; width: 50%;">-->
|
||||
<div class="indexcontainer">
|
||||
|
||||
|
@ -344,7 +344,7 @@
|
|||
<p>🧅 Serverside - High Availability for Deniability (⚠️ <a href="sensitiveremotevshome/index.html">Remote Hosting = Safer!</a>)</p>
|
||||
<ol>
|
||||
<li><a href="high_availability/index.html">✅ Why is High Availability Important for Deniability ?</a><img src="logos/HA.png" class="logo"></li>
|
||||
<li><a href="http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/blog-contributions/issues/187">❌ How to setup a basic NGINX / PHP / MySQL app</a><img src="logos/nginx.png" class="logo"><img src="logos/php.png" class="logo"><img src="logos/mysql.png" class="logo"></li>
|
||||
<li><a href="tornginxphpmysql/index.html">✅ How to setup a basic NGINX / PHP / MySQL app</a><img src="logos/nginx.png" class="logo"><img src="logos/php.png" class="logo"><img src="logos/mysql.png" class="logo"></li>
|
||||
<li><a href="http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/blog-contributions/issues/188">❌ How to setup a MySQL Master-Master replication over Tor</a><img src="logos/mysql.png" class="logo"><img src="logos/Tor.png" class="logo"><img src="logos/HA.png" class="logo"></li>
|
||||
<li><a href="http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/blog-contributions/issues/207">❌ OnionBalance for .onion domains load balancing</a><img src="logos/Tor.png" class="logo"><img src="logos/HA.png" class="logo"></li>
|
||||
<li><a href="endgame/index.html">🟠 Endgame V3 (.onion service Anti DDOS / Load Balancer / WAF + Captcha) ⭐</a><img src="logos/endgame.png" class="logo"></li>
|
||||
|
@ -392,11 +392,9 @@
|
|||
<h2><b> Inspirations</b></h2>
|
||||
|
||||
<ol>
|
||||
<li><a href="https://git.hackliberty.org/hackliberty.org/Hack-Liberty-Resources">Hack Liberty Resources</a></li>
|
||||
<li><a href="https://privacyguides.net">Privacy Guides</a></li>
|
||||
<li><a href="https://simplifiedprivacy.com">Simplified Privacy</a></li>
|
||||
<li><a href="https://anonymousplanet.org/guide.html">The Hitchhiker's guide to Anonymity</a></li>
|
||||
</ol></br></br>
|
||||
<li><a href="https://git.hackliberty.org/hackliberty.org/Hack-Liberty-Resources">Hack Liberty Resources</a></li>
|
||||
</ol></br>
|
||||
<h2><b>Non-KYC VPS providers</b></h2> </br> </br>
|
||||
<p>Current services used:</p>
|
||||
<ol>
|
||||
|
@ -406,7 +404,7 @@
|
|||
</br>
|
||||
<p>Previous services:</p>
|
||||
<ol>
|
||||
<li><a href="https://kycnot.me/service/incognet">Incognet (both registrar and cloud provider)</a></li>
|
||||
<li><a href="https://kycnot.me/service/incognet">Incognet (both registrar and cloud provider)</a> warning: they suck at handling support tickets</li>
|
||||
<li><a href="https://kycnot.me/service/hostiko">Hostiko (cloud provider)</a></li>
|
||||
<li><a href="https://kycnot.me/search?q=hosting&type=service">Other Non-KYC Cloud Providers</a></li>
|
||||
|
||||
|
|
BIN
opsec/tornginxphpmysql/0.png
Normal file
BIN
opsec/tornginxphpmysql/0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
BIN
opsec/tornginxphpmysql/1.png
Normal file
BIN
opsec/tornginxphpmysql/1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 204 KiB |
657
opsec/tornginxphpmysql/index.html
Normal file
657
opsec/tornginxphpmysql/index.html
Normal file
|
@ -0,0 +1,657 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
<link rel="shortcut icon" href="../../../../../../assets/img/favicon.png">
|
||||
|
||||
<title>How to setup a basic NGINX / PHP / MySQL app</title>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link href="../../assets/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="../../assets/css/xt256.css" rel="stylesheet">
|
||||
|
||||
|
||||
|
||||
<!-- Custom styles for this template -->
|
||||
<link href="../../assets/css/main.css" rel="stylesheet">
|
||||
|
||||
|
||||
|
||||
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- Static navbar -->
|
||||
<div class="navbar navbar-inverse-anon navbar-static-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand-anon" href="\index.html">The Nihilism Blog</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
|
||||
<li><a href="/about.html">About</a></li>
|
||||
<li><a href="/blog.html">Categories</a></li>
|
||||
<li><a href="https://blog.nowhere.moe/donate.html">Donate</a></li>
|
||||
<li><a href="/contact.html">Contact</a></li>
|
||||
</ul>
|
||||
</div><!--/.nav-collapse -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- +++++ Posts Lists +++++ -->
|
||||
<!-- +++++ First Post +++++ -->
|
||||
<div id="anon2">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2">
|
||||
<a href="../index.html">Previous Page</a></br></br><p><img src="../../assets/img/user.png" width="50px" height="50px"> <ba>oxeo0 - 2025 / 02 / 01</ba></p>
|
||||
<h1>How to setup a basic NGINX / PHP / MySQL app</h1>
|
||||
<img src="0.png" class="imgRz">
|
||||
<p> </p>
|
||||
|
||||
</div>
|
||||
</div><!-- /row -->
|
||||
</div> <!-- /container -->
|
||||
</div><!-- /grey -->
|
||||
|
||||
<!-- +++++ Second Post +++++ -->
|
||||
<div id="anon3">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2">
|
||||
<h2><b>Introduction</b></h2>
|
||||
<p>
|
||||
After generating your <a href="../torwebsite/index.html">vanity address</a>, you might consider hosting something more advanced on the Tor network. If users need to interact with your website by registering an account, making a purchase, or uploading files, you will likely need functionality that updates data dynamically and stores changes persistently.
|
||||
</p>
|
||||
<p>
|
||||
Today, many websites use JavaScript to fetch and store data via APIs, dynamically rendering content in real-time. However, most hidden services hosted on Tor take a more conservative approach when building interactive websites. These services typically use PHP scripts rendered on the server side, which are then returned to users as HTML documents. This method minimizes the use of client-side JavaScript, which is often used for browser fingerprinting.
|
||||
</p>
|
||||
<p>
|
||||
The main drawback of this approach is that website content can only be updated by reloading the page since each page is server-side rendered using a PHP interpreter.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div><!-- /row -->
|
||||
</div> <!-- /container -->
|
||||
</div><!-- /white -->
|
||||
|
||||
<div id="anon2">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2">
|
||||
<h2><b>Overview</b></h2>
|
||||
|
||||
<p>
|
||||
In this guide, we will set up a <b>LEMP</b> stack (<b>L</b>inux + <b>E</b>ngine-X + <b>M</b>ySQL + <b>P</b>HP) and expose a vegetable store website via a Tor hidden service. Nginx will act as a reverse proxy, passing requests to the PHP-FPM socket and returning an HTTP response back to the user. The PHP-FPM interpreter will execute the necessary PHP script to render the page and pass it to Nginx.
|
||||
</p>
|
||||
<p>
|
||||
We will also configure a MySQL-compatible database that the PHP scripts can access to store data persistently. By default on Debian systems, Nginx communicates with the PHP-FPM interpreter via a Unix socket located at <b>/var/run/php/php-fpm.sock</b>.
|
||||
</p>
|
||||
<p>
|
||||
Here is the diagram illustrating how our service will look like at the end of this guide. You can refer back to it anytime if you get lost in the steps below.
|
||||
</p>
|
||||
|
||||
<img src="1.png" class="imgRz">
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div><!-- /row -->
|
||||
</div> <!-- /container -->
|
||||
</div><!-- /white -->
|
||||
|
||||
<div id="anon1">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2">
|
||||
<h2><b>Prerequisites</b></h2>
|
||||
<p>
|
||||
To follow this guide you need to have up-to-date <a href="../linux/index.html">Debian (or derivative) system running</a> with root access. I will be using <b>sudo</b> to run commands that require root privileges.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Ensure you have Tor installed and onion domain generated as explained <a href="../torwebsite/index.html">here</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Next, install the required software:
|
||||
<ul>
|
||||
<li>Nginx</li>
|
||||
<li>PHP</li>
|
||||
<li>PHP-FPM</li>
|
||||
<li>MariaDB (MySQL compatible database)</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<pre><code class="nim">oxeo@galaxy:~$ sudo apt update
|
||||
oxeo@galaxy:~$ sudo apt install nginx php php-fpm php-mysql mariadb-server
|
||||
</code></pre>
|
||||
|
||||
<p>
|
||||
We will be using <a href="https://mariadb.org/">MariaDB</a> since it's available in Debian repositories. It's a fully open source fork of MySQL created when the former was acquired by Oracle.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div><!-- /row -->
|
||||
</div> <!-- /container -->
|
||||
</div><!-- /white -->
|
||||
|
||||
<div id="anon2">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2">
|
||||
<h2><b>Database Setup</b></h2>
|
||||
|
||||
<p>
|
||||
We will start by generating a secure root password for MariaDB database.
|
||||
</p>
|
||||
|
||||
<pre><code class="nim">oxeo@galaxy:~$ tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 12 && echo
|
||||
ln8qXH64tjDi
|
||||
</code></pre>
|
||||
|
||||
<p>
|
||||
From now on, you should replace every <b>YOU_SHOULD_GENERATE_THIS</b> string with the output of this command.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
There is a special <b>mysql_secure_installation</b> command we need to run to configure database security settings. This includes changing the database root account password to the one you generated.
|
||||
</p>
|
||||
|
||||
<pre><code class="nim">oxeo@galaxy:~$ sudo mysql_secure_installation
|
||||
|
||||
Enter current password for root (enter for none):
|
||||
[...]
|
||||
|
||||
Switch to unix_socket authentication [Y/n] n
|
||||
[...]
|
||||
|
||||
Change the root password? [Y/n] Y
|
||||
New password: YOU_SHOULD_GENERATE_THIS
|
||||
Re-enter new password: YOU_SHOULD_GENERATE_THIS
|
||||
[...]
|
||||
|
||||
Remove anonymous users? [Y/n] Y
|
||||
[...]
|
||||
|
||||
Disallow root login remotely? [Y/n] Y
|
||||
[...]
|
||||
|
||||
Remove test database and access to it? [Y/n] Y
|
||||
[...]
|
||||
|
||||
Reload privilege tables now? [Y/n] Y
|
||||
[...]
|
||||
|
||||
All done! If you've completed all of the above steps, your MariaDB
|
||||
installation should now be secure.
|
||||
|
||||
Thanks for using MariaDB!
|
||||
</code></pre>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<p>
|
||||
After that, we log into the database and execute SQL commands to create the required tables and fill them with data.
|
||||
</p>
|
||||
|
||||
<pre><code class="nim">oxeo@galaxy:~$ sudo mysql
|
||||
</code></pre>
|
||||
|
||||
<p>
|
||||
Here are all commands to prepare the database for our app:
|
||||
</p>
|
||||
|
||||
<pre><code class="nim">CREATE DATABASE veggie_shop;
|
||||
USE veggie_shop;
|
||||
|
||||
CREATE TABLE products (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
price DECIMAL(10, 2) NOT NULL,
|
||||
quantity INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE users (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
balance DECIMAL(10, 2) NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO products (name, price, quantity) VALUES
|
||||
('Apple', 0.50, 25),
|
||||
('Banana', 0.30, 40),
|
||||
('Orange', 0.45, 30);
|
||||
|
||||
INSERT INTO users (balance) VALUES (20.00);
|
||||
</code></pre>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<p>
|
||||
Now, here is an explanation of each command and the output you should get. You can skip this section if you are already familiar with SQL.
|
||||
</p>
|
||||
|
||||
<pre><code class="nim">MariaDB [(none)]> CREATE DATABASE veggie_shop;
|
||||
Query OK, 1 row affected (0.000 sec)
|
||||
|
||||
MariaDB [(none)]> USE veggie_shop;
|
||||
Database changed
|
||||
MariaDB [veggie_shop]>
|
||||
</code></pre>
|
||||
|
||||
<p>
|
||||
This creates a new database called <b>veggie_shop</b>. Then with <b>USE veggie_shop</b>, we specify which database we want to execute commands on.
|
||||
</p>
|
||||
|
||||
<pre><code class="nim">MariaDB [veggie_shop]> CREATE TABLE products (
|
||||
-> id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
-> name VARCHAR(100) NOT NULL,
|
||||
-> price DECIMAL(10, 2) NOT NULL,
|
||||
-> quantity INT NOT NULL
|
||||
-> );
|
||||
Query OK, 0 rows affected (0.006 sec)
|
||||
|
||||
MariaDB [veggie_shop]> CREATE TABLE users (
|
||||
-> id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
-> balance DECIMAL(10, 2) NOT NULL
|
||||
-> );
|
||||
Query OK, 0 rows affected (0.007 sec)
|
||||
</code></pre>
|
||||
|
||||
<p>
|
||||
Now we add two tables - one for <b>products</b> and one for <b>users</b> and defining their schemas. Each <b>product</b> has an id, name (up to 100 characters long), price and quantity. Every <b>user</b> has an id and balance. For this demo, we will only have one user with id=1.
|
||||
</p>
|
||||
|
||||
<pre><code class="nim">MariaDB [veggie_shop]> INSERT INTO products (name, price, quantity) VALUES
|
||||
-> ('Apple', 0.50, 25),
|
||||
-> ('Banana', 0.30, 40),
|
||||
-> ('Orange', 0.45, 30);
|
||||
Query OK, 3 rows affected (0.008 sec)
|
||||
Records: 3 Duplicates: 0 Warnings: 0
|
||||
|
||||
MariaDB [veggie_shop]> INSERT INTO users (balance) VALUES (20.00);
|
||||
Query OK, 1 row affected (0.002 sec)
|
||||
|
||||
MariaDB [veggie_shop]> \q
|
||||
</code></pre>
|
||||
|
||||
<p>
|
||||
Finally, we can fill the tables with products and create one user. Now the user has initial balance set to 20$.
|
||||
<br>
|
||||
To exit the MariaDB shell we can use <b>\q</b>.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div><!-- /row -->
|
||||
</div> <!-- /container -->
|
||||
</div><!-- /white -->
|
||||
|
||||
|
||||
<div id="anon1">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2">
|
||||
<h2><b>PHP Scripting</b></h2>
|
||||
|
||||
<p>
|
||||
First, create a directory to put our php scripts.
|
||||
</p>
|
||||
|
||||
<pre><code class="nim">oxeo@galaxy:~$ sudo mkdir -p /srv/shop
|
||||
</code></pre>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<p>
|
||||
Then create the config file under <b>/srv/shop/config.php</b> and remember to replace <b>YOU_SHOULD_GENERATE_THIS</b> password with the one you generated earlier.
|
||||
<br>
|
||||
Here, we connect to the database running at localhost using <b>mysqli</b> function. The database name is <b>veggie_shop</b> which we created before.
|
||||
</p>
|
||||
|
||||
<pre><code class="nim"><?php
|
||||
$db_host = 'localhost';
|
||||
$db_user = 'root';
|
||||
$db_pass = 'YOU_SHOULD_GENERATE_THIS';
|
||||
$db_name = 'veggie_shop';
|
||||
|
||||
$conn = new mysqli($db_host, $db_user, $db_pass, $db_name);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<p>
|
||||
Now, put the main website content in <b>/srv/shop/index.php</b>. It will be executed every time a user accesses the main page of the website. In our case, this will be the entire content of our vegetable store.
|
||||
<br>
|
||||
I left some vague comments in the code, but I don't have the space to explain all of it here. If you want to learn the basics of PHP, I recommend the <a href="https://www.phptutorial.net/">phptutorial</a> website.
|
||||
</p>
|
||||
|
||||
<pre><code class="nim"><?php
|
||||
require_once 'config.php';
|
||||
|
||||
// fetch available products from the database
|
||||
$products_query = "SELECT * FROM products WHERE quantity > 0";
|
||||
$products_result = $conn->query($products_query);
|
||||
|
||||
// read the balance of user with ID=1
|
||||
// we only have this one user for demonstration purposes
|
||||
$balance_query = "SELECT balance FROM users WHERE id = 1";
|
||||
$balance_result = $conn->query($balance_query);
|
||||
$user_balance = $balance_result->fetch_assoc()['balance'];
|
||||
|
||||
// post request means user wants to buy something (form is submitted)
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$success = true;
|
||||
$total_cost = 0;
|
||||
$updates = [];
|
||||
|
||||
// calculate cost of selected products
|
||||
foreach ($_POST['quantity'] as $product_id => $quantity) {
|
||||
if ($quantity > 0) {
|
||||
$product_query = "SELECT price, quantity FROM products WHERE id = ?";
|
||||
$stmt = $conn->prepare($product_query);
|
||||
$stmt->bind_param("i", $product_id);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$product = $result->fetch_assoc();
|
||||
|
||||
if ($quantity > $product['quantity']) {
|
||||
$success = false;
|
||||
$error = "Not enough items in stock!";
|
||||
break;
|
||||
}
|
||||
|
||||
$total_cost += $product['price'] * $quantity;
|
||||
$updates[$product_id] = $quantity;
|
||||
}
|
||||
}
|
||||
|
||||
// check if user has enough funds
|
||||
if ($total_cost > $user_balance) {
|
||||
$success = false;
|
||||
$error = "Insufficient funds!";
|
||||
}
|
||||
|
||||
// process the purchase
|
||||
if ($success && !empty($updates)) {
|
||||
$conn->begin_transaction();
|
||||
try {
|
||||
// update products in the database
|
||||
foreach ($updates as $product_id => $quantity) {
|
||||
$update_query = "UPDATE products SET quantity = quantity - ? WHERE id = ?";
|
||||
$stmt = $conn->prepare($update_query);
|
||||
$stmt->bind_param("ii", $quantity, $product_id);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
// calculate and set the user's balance after the purchase
|
||||
$update_balance = "UPDATE users SET balance = balance - ? WHERE id = 1";
|
||||
$stmt = $conn->prepare($update_balance);
|
||||
$stmt->bind_param("d", $total_cost);
|
||||
$stmt->execute();
|
||||
|
||||
$conn->commit();
|
||||
$message = "Purchase successful!";
|
||||
|
||||
// load the new balance from the database
|
||||
$balance_result = $conn->query($balance_query);
|
||||
$user_balance = $balance_result->fetch_assoc()['balance'];
|
||||
|
||||
// load products from the database
|
||||
$products_result = $conn->query($products_query);
|
||||
} catch (Exception $e) {
|
||||
// something went wrong, display failed message
|
||||
$conn->rollback();
|
||||
$error = "Transaction failed!";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Vegetable Shop</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif; color: #fff;
|
||||
background-color: #111;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
.product { margin: 10px 0; padding: 10px; border: 1px solid #ddd; }
|
||||
.message { color: #0c3; }
|
||||
.error { color: #c33; }
|
||||
.balance { font-size: 1.2em; margin-bottom: 20px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Vegetable Shop</h1>
|
||||
|
||||
<div class="balance">Your balance: $<?php echo number_format($user_balance, 2); ?></div>
|
||||
|
||||
<?php if (isset($message)): ?>
|
||||
<div class="message"><?php echo $message; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (isset($error)): ?>
|
||||
<div class="error"><?php echo $error; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post">
|
||||
<?php while ($product = $products_result->fetch_assoc()): ?>
|
||||
<div class="product">
|
||||
<strong><?php echo htmlspecialchars($product['name']); ?></strong>
|
||||
<br>
|
||||
Price: $<?php echo number_format($product['price'], 2); ?>
|
||||
<br>
|
||||
Available: <?php echo $product['quantity']; ?>
|
||||
<br>
|
||||
Purchase quantity:
|
||||
<input type="number" name="quantity[<?php echo $product['id']; ?>]"
|
||||
min="0" max="<?php echo $product['quantity']; ?>" value="0">
|
||||
</div>
|
||||
<?php endwhile; ?>
|
||||
|
||||
<input type="submit" value="Purchase">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
</code></pre>
|
||||
|
||||
</div>
|
||||
</div><!-- /row -->
|
||||
</div> <!-- /container -->
|
||||
</div><!-- /white -->
|
||||
|
||||
<div id="anon2">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2">
|
||||
<h2><b>Nginx Configuration</b></h2>
|
||||
|
||||
<p>
|
||||
Just like <a href="../torwebsite/index.html">last time</a>, we need to create a new nginx site. Put the following in <b>/etc/nginx/sites-available/veggie-shop.conf</b>.
|
||||
</p>
|
||||
|
||||
<pre><code class="nim">server {
|
||||
listen 4440;
|
||||
server_name kxnxuxyi72umpstd7h5btkzyx43o6o5xynjcndpl6xotx65ulwa7crqd.onion;
|
||||
root /srv/shop/;
|
||||
index index.php;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
include snippets/fastcgi-php.conf;
|
||||
fastcgi_pass unix:/var/run/php/php-fpm.sock;
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
<p>
|
||||
The main new thing is the <b>\.php$</b> location matcher which will pass all requests ending with <b>.php</b> to the <b>PHP-FPM</b> interpreter. When a user requests the root of our website, it is served with <b>index.php</b> file we created earlier.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Now, we can enable the site by linking <b>available</b> to <b>enabled</b> and validate nginx configuration.
|
||||
</p>
|
||||
|
||||
<pre><code class="nim">oxeo@galaxy:~$ sudo ln -s /etc/nginx/sites-available/veggie-shop.conf /etc/nginx/sites-enabled/veggie-shop.conf
|
||||
oxeo@galaxy:~$ sudo nginx -t
|
||||
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
|
||||
nginx: configuration file /etc/nginx/nginx.conf test is successful
|
||||
</code></pre>
|
||||
|
||||
<p>
|
||||
Finally, configure the hidden service by adding these lines to your torrc. Don't forget to put your onion domain keys in the <b>/var/lib/tor/veggie_service</b> as explained <a href="../torwebsite/index.html">here</a>.
|
||||
</p>
|
||||
|
||||
<pre><code class="nim">HiddenServiceDir /var/lib/tor/veggie_service/
|
||||
HiddenServicePort 80 127.0.0.1:4440
|
||||
</code></pre>
|
||||
|
||||
</div>
|
||||
</div><!-- /row -->
|
||||
</div> <!-- /container -->
|
||||
</div><!-- /white -->
|
||||
|
||||
<div id="anon1">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2">
|
||||
<h2><b>Almost there</b></h2>
|
||||
|
||||
<p>
|
||||
You can now restart nginx and tor to reload their configurations and enable required services to start at boot.
|
||||
</p>
|
||||
|
||||
<pre><code class="nim">oxeo@galaxy:~$ sudo systemctl restart nginx tor php8.2-fpm mariadb
|
||||
oxeo@galaxy:~$ sudo systemctl enable nginx tor php8.2-fpm mariadb
|
||||
</code></pre>
|
||||
|
||||
<p>
|
||||
Now, go to your onion domain and verify the vegetable shop is accessible on the Tor network.
|
||||
</p>
|
||||
|
||||
<img src="0.png" class="imgRz">
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<p>
|
||||
If you encounter any issues, you may look for appropriate log entries using <b>journalctl</b>.
|
||||
</p>
|
||||
|
||||
<pre><code class="nim">oxeo@galaxy:~$ sudo journalctl -xe
|
||||
Feb 01 16:44:28 galaxy Tor[1754]: Opening Control listener on /run/tor/control
|
||||
Feb 01 16:44:28 galaxy Tor[1754]: Opened Control listener connection (ready) on /run/tor/control
|
||||
Feb 01 16:44:28 galaxy Tor[1754]: Bootstrapped 10% (conn_done): Connected to a relay
|
||||
Feb 01 16:44:28 galaxy Tor[1754]: Bootstrapped 14% (handshake): Handshaking with a relay
|
||||
[...]
|
||||
</code></pre>
|
||||
|
||||
</div>
|
||||
</div><!-- /row -->
|
||||
</div> <!-- /container -->
|
||||
</div><!-- /white -->
|
||||
|
||||
<div id="anon2">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2">
|
||||
<h2><b>Closing Remarks</b></h2>
|
||||
|
||||
<p>
|
||||
<b>Congratulations!</b> - You have successfully deployed an interactive website on the Tor network.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Running more complicated websites on the <b>"Dark Web"</b> requires a lot of experience. Every simple mistake can have <a href="https://doingfedtime.com/helsinki-darknet-markets-security-failures-ip-leak-info-disclosure-etc-still-live/">devastating consequences</a> for your service's anonymity.
|
||||
<br>
|
||||
Here are some important things to consider:
|
||||
|
||||
<ul>
|
||||
<li><b>Database User</b> - For this demo, we were running our app with <b>root access</b> to the database. Ideally, you should create a separate MariaDB user and restrict their permissions.</li><br>
|
||||
|
||||
<li><b>SQL Injection</b> - Until a few years ago, SQL injection was one of the most common web vulnerabilities. It's crucial to sanitize user input to prevent unauthorized access to your SQL database. The <b>mysqli</b> library has the <a href="https://www.w3schools.com/php/func_mysqli_prepare.asp">prepare function</a> designed to prevent such vulnerabilities.</li><br>
|
||||
|
||||
<li><b>Keeping Software Up-to-Date</b> - Over the years, there have been numerous <a href="https://bugs.php.net/search.php?limit=30&order_by=id&direction=DESC&cmd=display&status=Open&bug_type=All&phpver=8.0&project=PHP">bugs found in PHP</a>. Regularly update your packages to patch vulnerabilities that may cause deanonymization of your hidden service.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div><!-- /row -->
|
||||
</div> <!-- /container -->
|
||||
</div><!-- /white -->
|
||||
|
||||
<!-- +++++ Footer Section +++++ -->
|
||||
|
||||
<div id="anonb">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-4">
|
||||
<h4>Nihilism</h4>
|
||||
<p>
|
||||
Until there is Nothing left.</p></br></br><p>Creative Commons Zero: <a href="../../../../opsec/runtheblog/index.html">No Rights Reserved</a></br><img src="\CC0.png">
|
||||
|
||||
</p>
|
||||
</div><!-- /col-lg-4 -->
|
||||
|
||||
<div class="col-lg-4">
|
||||
<h4>My Links</h4>
|
||||
<p>
|
||||
|
||||
<a target="_blank" rel="noopener noreferrer" href="http://blog.nowhere.moe/rss/feed.xml">RSS Feed</a><br/><a target="_blank" rel="noopener noreferrer" href="https://simplex.chat/contact#/?v=2-7&smp=smp%3A%2F%2FL5jrGV2L_Bb20Oj0aE4Gn-m5AHet9XdpYDotiqpcpGc%3D%40nowhere.moe%2FH4g7zPbitSLV5tDQ51Yz-R6RgOkMEeCc%23%2F%3Fv%3D1-3%26dh%3DMCowBQYDK2VuAyEAkts5T5AMxHGrZCCg12aeKxWcpXaxbB_XqjrXmcFYlDQ%253D&data=%7B%22type%22%3A%22group%22%2C%22groupLinkId%22%3A%22c3Y-iDaoDCFm6RhptSDOaw%3D%3D%22%7D">SimpleX Chat</a><br/>
|
||||
|
||||
</p>
|
||||
</div><!-- /col-lg-4 -->
|
||||
|
||||
<div class="col-lg-4">
|
||||
<h4 class="readable">About nihilist</h4>
|
||||
<p style="word-wrap: break-word;"><u>Donate XMR:</u>
|
||||
8AUYjhQeG3D5aodJDtqG499N5jXXM71gYKD8LgSsFB9BUV1o7muLv3DXHoydRTK4SZaaUBq4EAUqpZHLrX2VZLH71Jrd9k8
|
||||
</p></br>
|
||||
<p style="word-wrap: break-word;"><u>Donate XMR to the author:</u>
|
||||
862Sp3N5Y8NByFmPVLTPrJYzwdiiVxkhQgAdt65mpYKJLdVDHyYQ8swLgnVr8D3jKphDUcWUCVK1vZv9u8cvtRJCUBFb8MQ</p>
|
||||
<p class="readable"><u>Contact:</u> nihilist@contact.nowhere.moe (<a
|
||||
href="https://nowhere.moe/nihilist.pubkey">PGP</a>)</p>
|
||||
</div><!-- /col-lg-4 -->
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Bootstrap core JavaScript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -38,7 +38,7 @@
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2">
|
||||
<a href="../index.html">Previous Page</a></br></br><h1>Productivity Tutorials</h1>
|
||||
<a href="../index.html">Previous Page</a></br></br><h1>Productivity: Health and Work Organisation</h1>
|
||||
<img src="productivity.png" class="imgRz">
|
||||
<p>Making sure that your Body and Mind are not getting in the way of your work, and making sure that you are working as efficiently as possible.</p>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue