• About
  • Policy
  • Contact

Phan Anh Buổi Sáng

  • Home
  • Kiến thức IT
    • PSD
    • Blogger
  • Translate
Google
Custom Search
Trang chủ » Security » TUTORIALS » Tips bảo mật cho webserver apache nền linux sf

Tips bảo mật cho webserver apache nền linux sf

Unknown Labels: Security, TUTORIALS Leave A Comment 06:00
Ở bài viết hôm nay mình sẽ giới thiệu 1 vài cách bảo mật webserver chạy php cho các sysadmin.

Điều kiện : CÓ root access . và tập trung nói ở file security của apache /etc/php.d/security.ini ( file này tự tạo nhé )

Trước hết hãy đề cập đến các lỗi thường bị khai thác bây giờ để tìm ra cách chống đỡ
Phổ biến và nguy hiểm nhất là XSS,SQL injection,File upload,file includes, hàm eval(),csrf,etc nhiều lắm các bạn tự biết nhé

Mình sẽ demo config tại 1 server sạch chưa cài gì
Phần 1 :

1> Tìm cách module không cần thiết và xóa bỏ bớt đi
Code:
[root@www2047uc ~]# php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
ereg
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
imap
json
libxml
mbstring
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
tokenizer
xml
zip
zlib
[Zend Modules] 
ở ví dụ này mình thấy sqlite,readline là k cần lắm nên có để disable hoặc xóa

rm /etc/php.d/sqlite3.ini
(readline)
hoặc
v /etc/php.d/sqlite3.ini /etc/php.d/sqlite3.disabl
e (readline)

Hoặc thay vì xóa thì cài bản php chỉ có những module mình cần
ví dụ

[./configure --with-libdir=lib64 --with-gd --with-mysql --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --cache-file=../config.cache --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-fastcgi --enable-force-cgi-redirect[/code]
cái này mình cài luôn fastcgi
2. Fake http banner (http://junookyo.blogspot.com/2012/03/fake-apache-banner-va-php-x-powered-by.html)

3.Log tất cả các lỗi phát sinh của PHP

Mở /etc/php.d/security.ini thêm vào
Code:

display_errors=Off
log_errors=On
error_log=/var/log/httpd/php_scripts_error.log
4. Tốt nhất là dis luôn upload :
vẫn sửa trong file kia nha file_uploads=Off hoặc nếu cho thì hoặc set max upload
file_uploads=On# user can only upload upto 1MB via php
upload_max_filesize=1M

5. bật sql safe mode
sql.safe_mode=On
Khi set cái này mysql_connect() và mysql_pconnect() sẽ không nhận bất thì đối số nào được truyền tới chúng.
cái này mà dùng wp là xịt đấy
và gợi ý nữa là thay vì dùng magic_quotes thì dùng mysql_escape_string() (các pro đã chứng minh em k dám cãi )

6. Dis các hàm nguy hiểm
disable_functions =exec,passthru,shell_exec,system,proc_open,popen,c url_exec,curl_multi_exec,parse_ini_file,show_sourc e

7.Cài fastcgi
FastCGI giảm hiệu suất của server tuy nhiên lại làm tăng tốc độ của PHP. và giúp ngăn chặn việc gọi shell trực tiếp qua cgi.force_redirect
cgi.force_redirect=On
8. Bảo vệ Apache, PHP, and, MySQL Configuration Files
thay vì dùng chmod ở đây mình dùng chattr
dùng ở các file sau

# chattr +i /etc/php.ini
# chattr +i /etc/php.d/*
# chattr +i /etc/my.ini
# chattr +i /etc/httpd/conf/httpd.conf
# chattr +i /etc/



Bài viết liên quan

← Bài đăng mới hơn Bài đăng cũ hơn → Trang chủ
Powered by Blogger.

Các Bình Luận Gần Đây

Bài đăng phổ biến

  • Ảnh bìa chế Phía sau một cô gái - Soobin Hoàng Sơn - Zoy Thủ Thuật #Zoy
    Đôi lúc em tránh ánh mắt của anh. vì dường như lúc nào em cũng hiểu thấu lòng anh Demo Cover Download PSD loading...
  • PSD - Người & Ta
    DOWNLOAD PSD
  • Share CMND Nữ Cho Anh Em Để Unlock & Report
    COPYRIGHT : MINH HAKU IT                                               
  • [PHP] Get list username - vBulletin
    <?php // GET user function duyk_get_all_usr($link, $total_usr) { $max_page = $total_usr/100; $ma...
  • Wordpress Plugins Spotlight Your Upload Vulnerability
    ___________.__ _________ _________ \__ ___/| |__ ____ \_ ___ \______ ...
  • Owasp Xelenium - XSS Scanner
    XSS scanner, Xelenium. It is a nice security testing tool that can be used to test and find security vulnerabilities in websites and web a...
  • Hướng dẫn "Hack lại Keylogger"
    Hướng dẫn: Hack lại Keylogger Công cụ: Sniff Pass http://www.nirsoft.net/utils/password_sniffer.html Tutorial by Juno_okyo GhostClub's T...
  • Tội phạm lừa đảo - Phần VI: Đánh cắp nhận dạng
    Bạn làm việc chăm chỉ cần mẫn hàng ngày chỉ với mong muốn kiếm sống nuôi lấy bản thân. Bạn phải hết sức dè sẻn trong chi tiêu hàng ngày, và...
  • Phemail.py: Phishing EMail Social Engineering Tool
    Social Engineering is defined as the process of inducing people into giving away access or confidential information. From a security consu...
  • [TUT] - Upload Shell qua ACP của NukeViet
    Victim : http://dansodaklak.gov.vn Bước 1: Đăng nhập với quyền quản trị   http://dansodaklak.gov.vn/admin/index.php   Bước 2: Upload Themes...

Pageviews from the past week

Chuyên mục

Bài đăng phổ biến

  • Ảnh bìa chế Phía sau một cô gái - Soobin Hoàng Sơn - Zoy Thủ Thuật #Zoy
    Ảnh bìa chế Phía sau một cô gái - Soobin Hoàng Sơn - Zoy Thủ Thuật #Zoy
    Đôi lúc em tránh ánh mắt của anh. vì dường như lúc nào em cũng hiểu thấu lòng anh Demo Cover Download PSD loading...
  • PSD - Người & Ta
    PSD - Người & Ta
    DOWNLOAD PSD
  • Share CMND Nữ Cho Anh Em Để Unlock & Report
    Share CMND Nữ Cho Anh Em Để Unlock & Report
    COPYRIGHT : MINH HAKU IT                                               
  • [PHP] Get list username - vBulletin
    <?php // GET user function duyk_get_all_usr($link, $total_usr) { $max_page = $total_usr/100; $ma...
  • Wordpress Plugins Spotlight Your Upload Vulnerability
    ___________.__ _________ _________ \__ ___/| |__ ____ \_ ___ \______ ...
  • Owasp Xelenium - XSS Scanner
    XSS scanner, Xelenium. It is a nice security testing tool that can be used to test and find security vulnerabilities in websites and web a...
  • Hướng dẫn "Hack lại Keylogger"
    Hướng dẫn "Hack lại Keylogger"
    Hướng dẫn: Hack lại Keylogger Công cụ: Sniff Pass http://www.nirsoft.net/utils/password_sniffer.html Tutorial by Juno_okyo GhostClub's T...
  • Tội phạm lừa đảo - Phần VI: Đánh cắp nhận dạng
    Bạn làm việc chăm chỉ cần mẫn hàng ngày chỉ với mong muốn kiếm sống nuôi lấy bản thân. Bạn phải hết sức dè sẻn trong chi tiêu hàng ngày, và...
  • Phemail.py: Phishing EMail Social Engineering Tool
    Social Engineering is defined as the process of inducing people into giving away access or confidential information. From a security consu...
  • [TUT] - Upload Shell qua ACP của NukeViet
    Victim : http://dansodaklak.gov.vn Bước 1: Đăng nhập với quyền quản trị   http://dansodaklak.gov.vn/admin/index.php   Bước 2: Upload Themes...
Google
Custom Search
Support: Facebook | Twitter | Google+ | Giới thiệu
Copyright © 2015 • Phan Anh Buổi Sáng • All Right Reserved. Template by Template Việt