Schwachstellenseite unter Debian einrichten
Apache vorbereiten
- Apache und PHP installieren:
apt update apt install -y apache2 php libapache2-mod-php
- PHP aktivieren und Apache starten:
systemctl enable apache2 systemctl start apache2
- Verzeichnis für Testseite anlegen:
mkdir -p /var/www/html/ cd /var/www/html/
MariaDB vorbereiten
- MariaDB und PHP-MySQL-Modul installieren:
apt install -y mariadb-server php-mysql
- MariaDB starten und beim Boot aktivieren:
systemctl enable mariadb systemctl start mariadb
- Zugriff als root:
mysql -u root
Datenbank und Tabelle einrichten
- Als root anmelden:
mysql -u root
- Datenbank anlegen:
CREATE DATABASE tuxmen; USE tuxmen;
- Tabelle erstellen:
CREATE TABLE mitarbeiter (
id INT PRIMARY KEY AUTO_INCREMENT, username VARCHAR(50), password VARCHAR(50), fullname VARCHAR(100), email VARCHAR(100), notes TEXT
);
- Beispieldaten einfügen:
INSERT INTO mitarbeiter (username, password, fullname, email, notes) VALUES ('admin', 'admin123', 'Karl Rootmann', 'admin@tuxmen.local', 'Zugang zu allen Systemen'), ('alice', 'alicepw', 'Alice Liddell', 'alice@tuxmen.local', 'Team Marketing, Urlaub bis 22. Mai'), ('bob', 'bobpw', 'Bob Baumeister', 'bob@tuxmen.local', 'Serverraum: Türcode 1234'), ('charlie', 'charliepw', 'Charlie Foxtrot', 'charlie@tuxmen.local', 'Entwicklungstools: VSCode, Docker'), ('dora', 'dorapw', 'Dora Explorer', 'dora@tuxmen.local', 'VPN-Probleme gemeldet'), ('eve', 'evepw', 'Evelyn Mallory', 'eve@tuxmen.local', 'Audit-Team, Zugang GVM'), ('frank', 'frankpw', 'Frank Underroot', 'frank@tuxmen.local', 'Sudo-Zugang beantragt'), ('grace', 'gracepw', 'Grace Hopper', 'grace@tuxmen.local', 'Legacy-Projekt „COBOL Revival“'), ('hans', 'hanspw', 'Hans Hacker', 'hans@tuxmen.local', 'Kali-Linux Testumgebung'), ('irene', 'irenepw', 'Irene Adler', 'irene@tuxmen.local', 'Zuständig für LDAP und Mailserver');
EXIT
Umesetzung=
- index.html erstellen:
nano index.html
- Inhalt einfügen:
<!DOCTYPE html>
<html>
<head><title>VulnSite</title></head>
<body>
<h1>Schwachstellendemo</h1>
<h2>Command Injection</h2>
<form action="cmd.php" method="GET">
<input name="cmd" placeholder="whoami"><input type="submit">
</form>
<h2>SQL Injection</h2>
<form action="sqli.php" method="GET">
<input name="id" placeholder="1 OR 1=1"><input type="submit">
</form>
<h2>XSS</h2>
<form action="xss.php" method="GET">
<input name="q" placeholder="Suchbegriff"><input type="submit">
</form>
<h2>LFI</h2>
<form action="lfi.php" method="GET">
<input name="file" placeholder="/etc/passwd"><input type="submit">
</form>
<h2>Upload</h2>
<form action="upload.php" method="POST" enctype="multipart/form-data">
<input type="file" name="upload"><input type="submit">
</form>
<h2>Redirect</h2>
<form action="header.php" method="GET">
<input name="redirect" placeholder="http://example.com"><input type="submit">
</form>
<p><a href="info.php">PHP Info</a></p>
<p><a href="config.txt">Offene Konfigdatei</a></p>
<p><a href="uploads/">Upload-Verzeichnis</a></p>
</body>
</html>
- PHP-Dateien erstellen:
touch cmd.php sqli.php xss.php lfi.php upload.php header.php info.php mkdir uploads echo "dbpass = admin" > config.txt chmod 777 uploads
- Inhalt für cmd.php:
<?php
if (isset($_GET['cmd'])) {
system($_GET['cmd']);
}
?>
- Inhalt für sqli.php:
<?php $id = $_GET['id'] ?? ''; echo "Sie haben Benutzer-ID: $id eingegeben."; ?>
- Inhalt für xss.php:
<?php $q = $_GET['q'] ?? ''; echo "<p>Ergebnis für: $q</p>"; ?>
- Inhalt für lfi.php:
<?php
$file = $_GET['file'] ?? '';
if ($file) {
include($file);
}
?>
- Inhalt für upload.php:
<?php
if (!empty($_FILES['upload'])) {
move_uploaded_file($_FILES['upload']['tmp_name'], "uploads/" . basename($_FILES['upload']['name']));
echo "Datei hochgeladen.";
}
?>
- Inhalt für header.php:
<?php
$redirect = $_GET['redirect'] ?? '';
header("Location: $redirect");
?>
- Inhalt für info.php:
<?php phpinfo(); ?>