This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Abschaltung verschiedener PHP-Funktionen auf Ubuntu 20.04.3 LTS mit PHP 7.4.3
#1
Abschaltung verschiedener PHP-Funktionen auf Ubuntu 20.04.3 LTS mit PHP 7.4.3

Einige PHP- Funktionen lassen sich mit der 'disable_functions =' in der php.ini aus Sicherheitsgründen ausschalten.

Ich nutze auf meinem Ubuntu 20.04.3 LTS die PHP Version PHP 7.4.3.

Die Abschaltung verschiedener Funktionen von PHP soll die Sicherheit vom Server weiter erhöhen.

Diese Funktion 'disable_functions =' in der php.ini wird den Angreifer in seinen Möglichkeiten möglicherweise einschränken.

Welches Linux?

sniper@honigbiene:~# lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal


PHP Version abfragen:

sniper@honigbiene:~$ php -v

PHP 7.4.3 (cli) (built: Oct 25 2021 18:20:54) ( NTS )
Copyright © The PHP Group
Zend Engine v3.4.0, Copyright © Zend Technologies
with Zend OPcache v7.4.3, Copyright ©, by Zend Technologies

Wo ist die php.ini Datei?


sudo find / -name php.ini

Ausgabe:

/etc/php/7.4/apache2/php.ini
/etc/php/7.4/cli/php.ini


sniper@ghonigbiene:~$

Diese Datei öffnen und editieren:

sudo nano /etc/php/7.4/apache2/php.ini

Funktionen in der php.ini abschalten:

disable_functions =

Code:

Code:
disable_functions = "exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source,mail,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,
pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare"


exec,- Führt ein externes Programm aus

passthru, - Führt ein externes Programm aus und zeigt dessen Ausgabe an

shell_exec, - Führt einen Befehl auf der Shell aus und liefert die komplette Ausgabe als String

system, - Führt ein externes Programm aus und zeigt dessen Ausgabe an

proc_open,  - Execute a command and open file pointers for input/output

popen, - Opens process file pointer

curl_exec, - Perform a cURL session

curl_multi_exec, - Run the sub-connections of the current cURL handle

parse_ini_file, - Parse a configuration file

show_source, - Alias of highlight_file()

mail, - Mailfunktionen senden

pcntl_alarm, - Set an alarm clock for delivery of a signal

pcntl_fork, - Forks the currently running process

pcntl_waitpid, - Waits on or returns the status of a forked child

pcntl_wait, - Waits on or returns the status of a forked child

pcntl_wifexited, - Checks if status code represents a normal exit

pcntl_wifstopped, - Checks whether the child process is currently stopped

pcntl_wifsignaled, - Checks whether the status code represents a termination due to a signal

pcntl_wifcontinued, - nicht gefunden!

pcntl_wexitstatus, - Lefert den Statuscode

pcntl_wtermsig, - Returns the signal which caused the child to terminate

pcntl_wstopsig,  - Gibt das Signal zurück, welches das Anhalten verursachte

pcntl_signal,  - Richtet eine Signalverarbeitung ein

pcntl_signal_get_handler, - Get the current handler for specified signal

pcntl_signal_dispatch, - Calls signal handlers for pending signals

pcntl_get_last_error, - Retrieve the error number set by the last pcntl function which failed

pcntl_strerror, - Retrieve the system error message associated with the given errno

pcntl_sigprocmask, - Sets and retrieves blocked signals

pcntl_sigwaitinfo, - Waits for signals

pcntl_sigtimedwait, - Waits for signals, with a timeout

pcntl_exec, - Executes specified program in current process space

pcntl_getpriority, - Get the priority of any process

pcntl_setpriority, - Change the priority of any process

pcntl_async_signals,- Enable/disable asynchronous signal handling or return the old setting



Überprüfen:

Pfad:

root@honigbiene:~# cd /var/www/html


Datei erstellen:

root@honigbiene:/var/www/html# touch info.php


Code eintragen und abspeichern:

Code:
<?php
    phpinfo();
?>


Aufrufen:

http://server-ip:port/info.php

   
All done!
Zitieren


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste