개발자의 끄적끄적

Apache && PHP 버전 노출 제거 (Ubuntu) [펌] 본문

개발/was & server

Apache && PHP 버전 노출 제거 (Ubuntu) [펌]

효벨 2020. 6. 18. 01:00
728x90
반응형

Apache && PHP 버전 노출 제거 (Ubuntu) [펌]

 

Apache && PHP Header Version 노출

패키지로 설치시 Default로 Apache, PHP Version이 Header에 노출되는 경우가 있다.
노출시 OS, Engine, Version을 통하여 관련된 취약점을 알아볼 수 있으므로 불필요한 정보 노출은 꼭!! 제거해주자.

띠용!!
본글은 Ubuntu 14.04 Server 기반으로 합니다.

Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename : Trusty



[index.html (사진 잘 안보이면 확대해서 보세용)]

단순히 Chrome Browser를 통하여 HTTP Headers 확인할 수 있다.
현재 index.html 페이지에 접속 시 Header에 Server 버전 정보가 노출되어 있는 걸 볼 수 있다.

Server: Apache/2.4.7 (Ubuntu)

여기서 알 수 있는 정보는 Web Engine이 Apache로 구동되고, 버전은 2.4.7를 사용하며 운영체제는 Ubuntu을 사용하여 Web Server을 구동한다는걸 알 수 있다.



[index.php (사진 잘 안보이면 확대해서 보세용)]

이번에는 PHP Page에 접속을 해보았다. html와 다르게 PHP Engine를 통하여 접근시
Server와 X-Powered-BY"가 추가된걸 볼 수 있다. PHP 페이지는 PHP Engine을 사용하므로 Default로 버전이 노출된다.



[Curl Headers]

참고로 Chrome Browser를 통하여 HTTP Headers를 확인하는 방면 Curl을 통하여 CLI로 확인할 수 있다.
물론 Linux curl 이용해도 되고, Windows에 curl.exe를 사용하여 확인할 수 있다.

dongdonge@dongdonge:~$ curl -I http://<IP-Address>




Apache Version Remove

앞에서 Version이 노출되는 걸 확인했으니 이제 본격적으로 버전 노출을 제거하자!!

dongdonge@dongdonge:~$ sudo vim /etc/apache2/conf-available/security.conf

vim으로 security.conf 파일을 수정하자!

# ServerTokens # This directive configures what you return as the Server HTTP response # Header. The default is 'Full' which sends information about the OS-Type # and compiled in modules. # Set to one of: Full | OS | Minimal | Minor | Major | Prod # where Full conveys the most information, and Prod the least. #ServerTokens Minimal ServerTokens OS #ServerTokens Full

Default로 ServerTokens가 OS로 설정되어 있다. 이부분을 Prod로 변경해주자!!

# ServerTokens # This directive configures what you return as the Server HTTP response # Header. The default is 'Full' which sends information about the OS-Type # and compiled in modules. # Set to one of: Full | OS | Minimal | Minor | Major | Prod # where Full conveys the most information, and Prod the least. #ServerTokens Minimal ServerTokens Prod #ServerTokens Full

요렇게!! 변경하자!! 😊

여기서 잠깐!! 6가지 모드가 존재하는데 각각 어떤 차이가 있는지 궁금할 수 있다.
저는 각각 어떤 차이가 있는지 예전에 하나씩 설정하여 결과값을 본적이 있네용... 자 그럼 각 차이를 설명해드리도록 하겠습니다.

Server: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.27

Full

Server: Apache/2.4.7 (Ubuntu)

OS

Server: Apache/2.4.7

Minimal

Server: Apache/2.4

Minor

Server: Apache/2

Major

Server: Apache

Prod

Prod로 설정 시 OS(Ubuntu) 정보와 Apache 버전 정보가 지워지고 "Apache" 단어만 남게 된다.
그러면 또 고민에 빠질 수 밖에 없다. "Apache" 단어까지 제거하고 싶다면 어떻게 처리해야 할까?

아쉽게도 패키지로 Apache를 설치하였다면 제거할 수는 없지만 WAF - Modsecurity를 사용하여 제거할 수 있으며, 컴파일로 설치하였다면 재컴파일 시 Header 부분에 노출된 문자열을 제거 후 컴파일하면 된다.



PHP Version Remove

dongdonge@dongdonge:~$ sudo vim /etc/php5/apache2/php.ini

php.ini 파일은 PHP 설정 값을 변경할 수 있는 파일이다.

; Decides whether PHP may expose the fact that it is installed on the server ; (e.g. by adding its signature to the Web server header). It is no security ; threat in any way, but it makes it possible to determine whether you use PHP ; on your server or not. ; http://php.net/expose-php expose_php = On

Default로 expose_php = On으로 설정되어있다. Off로 변경하자

; Decides whether PHP may expose the fact that it is installed on the server ; (e.g. by adding its signature to the Web server header). It is no security ; threat in any way, but it makes it possible to determine whether you use PHP ; on your server or not. ; http://php.net/expose-php expose_php = Off

요렇게!!!!



Apache Restart

[Apache Restart]dongdonge@dongdonge:~$ sudo service apache2 restart

security.conf 파일과 php.ini의 설정값을 적용하기 위해 Apache를 재시작하자!!

[HTTP Headers]

 

 

출처 : https://blog.d0ngd0nge.xyz/apache_php_version_remove-ubuntu/

반응형
Comments