Schwachstellenseite unter Debian einrichten: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Zeile 72: Zeile 72:
 
<head><title>VulnSite</title></head>
 
<head><title>VulnSite</title></head>
 
<body>
 
<body>
   <h1>Schwachstellendemo</h1>
+
   <h1>Schwachstellen Demos</h1>
  
   <h2>Command Injection</h2>
+
   <h2>Gebe den FQDN ein ich zeige dir die IP</h2>
 
   <form action="cmd.php" method="GET">
 
   <form action="cmd.php" method="GET">
 
     <input name="cmd" placeholder="whoami"><input type="submit">
 
     <input name="cmd" placeholder="whoami"><input type="submit">
 
   </form>
 
   </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>
 
</html>
 
</pre>
 
</pre>
  
* 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:
+
 
 +
=Die Dateien=
 +
;cmd.php
 
<pre>
 
<pre>
 
<?php
 
<?php
 
if (isset($_GET['cmd'])) {
 
if (isset($_GET['cmd'])) {
   system($_GET['cmd']);
+
   $input = $_GET['cmd'];
}
+
  echo "<pre>";
?>
+
   system("host " . $input);
</pre>
+
   echo "</pre>";
 
 
* Inhalt für sqli.php:
 
<pre>
 
<?php
 
$id = $_GET['id'] ?? '';
 
echo "Sie haben Benutzer-ID: $id eingegeben.";
 
?>
 
</pre>
 
 
 
* Inhalt für xss.php:
 
<pre>
 
<?php
 
$q = $_GET['q'] ?? '';
 
echo "<p>Ergebnis für: $q</p>";
 
?>
 
</pre>
 
 
 
* Inhalt für lfi.php:
 
<pre>
 
<?php
 
$file = $_GET['file'] ?? '';
 
if ($file) {
 
   include($file);
 
}
 
?>
 
</pre>
 
 
 
* Inhalt für upload.php:
 
<pre>
 
<?php
 
if (!empty($_FILES['upload'])) {
 
  move_uploaded_file($_FILES['upload']['tmp_name'], "uploads/" . basename($_FILES['upload']['name']));
 
   echo "Datei hochgeladen.";
 
 
}
 
}
 
?>
 
?>
 
</pre>
 
</pre>
 
+
                                                                                                                                                                                                               
* Inhalt für header.php:
+
~
<pre>
 
<?php
 
$redirect = $_GET['redirect'] ?? '';
 
header("Location: $redirect");
 
?>
 
</pre>
 
 
 
* Inhalt für info.php:
 
<pre>
 
<?php
 
phpinfo();
 
?>
 
</pre>
 

Version vom 12. Mai 2025, 19:51 Uhr

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

Datenbank „tuxmen“ vorbereiten

  • Als root anmelden:
mysql -u root
  • Datenbank anlegen:
CREATE DATABASE tuxmen;
USE tuxmen;

Tabelle „mitarbeiter“ erstellen

  • Tabelle erzeugen:
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

  • Testdaten hinzufü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');
  • Sitzung beenden:
EXIT

Umsetzung

  • index.html erstellen:
nano index.html
  • Inhalt einfügen:
<!DOCTYPE html>
<html>
<head><title>VulnSite</title></head>
<body>
  <h1>Schwachstellen Demos</h1>

  <h2>Gebe den FQDN ein ich zeige dir die IP</h2>
  <form action="cmd.php" method="GET">
    <input name="cmd" placeholder="whoami"><input type="submit">
  </form>
</html>


Die Dateien

cmd.php
<?php
if (isset($_GET['cmd'])) {
  $input = $_GET['cmd'];
  echo "<pre>";
  system("host " . $input);
  echo "

";

} ?>

~