Phòng chống tấn công SQL Injection với GreenSQL trên Debian Etch pot

5 388 1
Phòng chống tấn công SQL Injection với GreenSQL trên Debian Etch pot

Đang tải... (xem toàn văn)

Thông tin tài liệu

Phòng chống tấn công SQL Injection với GreenSQL trên Debian Etch GreenSQL (hay greensql-fw) là một firewall cho cơ sở dữ liệu MySQL để cản lọc các cuộc tấn công SQL Injection. Nó làm việc như là một reverse proxy, ví dụ : nó tiếp nhận các query SQL, kiểm tra chúng, chuyển cho MySQL và trả lại kết quả từ cơ sở dữ liệu MySQl. Bạn có thể quản lý GreenSQL thông qua giao diện web trên hệ thống Debian Etch. 1 Lưu ý sơ bộ Tôi đã thử trên máy chủ Debian Etch đã được cài đặt MySQL. Tôi sẽ sử dụng virtual host www.example.com với thiết lập document root /var/www/web1/web để cài đặt giao diện web GreenSQL. 2 Installing greensql-fw Dự án GreenSQL cung cấp gói binary cho Debian Etch tại http://www.greensql.net/public/releases/Debian_Etch/ (bạn có thể tìm các gói cho các bản khác tại http://www.greensql.net/public/releases/). Tải về và cài đặt bản .deb mới nhất như sau: cd /tmp wget http://www.greensql.net/public/releases/Debian_Etch/i386/greensql- fw_0.9.2_i386.deb dpkg -i greensql-fw_0.9.2_i386.deb (Cho hệ thống i386) Bạn sẽ gặp câu hỏi sau: What is the name of the server used to store GreenSQL configuration db (MySQL server)? < localhost What is the database name for the GreenSQL configuration? < greendb Would you like to set up the database and tables automatically? < Yes What is the username of the MySQL administrator? < root Enter the MySQL administrator password < yourrootsqlpassword (replace this with your root MySQL password) Confirm this password < yourrootsqlpassword (replace this with your root MySQL password) What is the GreenSQL db username? < green What is the GreenSQL user password? < greensqlpassword (replace this with a password of your choice for the green MySQL user) Sau khi cài đặt xong greensql-fw sẽ chạy ở địa chỉ 127.0.0.1 trên cổng 3305 (cổng mặc định của MySQl là 3306). Bạn có thể kiểm tra bằng cách chạy netstat -tap | grep greensql server1:~# netstat -tap | grep greensql tcp 0 0 localhost.localdom:3305 *:* LISTEN 4499/greensql-fw server1:~# Để kiểm tra xem greensql-fw hoạt động hay không, hãy thử connect tới MySQL thông qua proxy GreenSQL: mysql -h 127.0.0.1 -P 3305 -u root -p Điền mật khẩu root của MySQL và bạn sẽ đăng nhập vào để sử dụng greensql- fw. Nếu bạn muốn ứng dụng web connect tới MySQL thông qua green-fw, bạn cần sửa lại vài chỗ trong cấu hình MySQL. Ví dụ, nếu bạn có ứng dụng PHP với dòng sau trong tập tin cấu hình (e.g. config.php) [ ] $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); [ ] hãy đổi thành [ ] $link = mysql_connect('127.0.0.1:3305', 'mysql_user', 'mysql_password'); [ ] (Điều này là quan trọng nếu bạn connect tới 127.0.0.1 thay vì localhost bởi greensql-fw hỗ trợ TCP nhưng không hỗ trợ Unix sockets!) 3 Cài đặt greensql-console Giao diện web GreenSQL (greensql-console) có thể tải về tại http://sourceforge.net/project/showfiles.php?group_id=199511&package_id=2 36915. Để cài đặt tại /var/www/web1/web hãy tiến hành như sau: cd /var/www/web1/web wget http://heanet.dl.sourceforge.net/sourceforge/greensql/greensql-console- 0.4.2.tar.gz tar xvfz greensql-console-0.4.2.tar.gz Tạo subdirectory greensql-console trong /var/www/web1/web. Tiếp đó ta cần điều chỉnh cấu hình greensql-console: cd greensql-console vi config.php Trong config.php hãy chắc chắn rằng bạn đã điền đúng mật khẩu cho tài khoản green MySQL (tại dòng $db_pass): # Uncomment the following line to switch to demo version #$demo_version = 1; # greensql version $version = "0.4.0"; # MySQL Database IP address $db_host = "127.0.0.1"; #MySQL Database Port Value. $db_port = 3306; # MySQL database name used to store greensql confiuration and alerts $db_name = "greendb"; # MySQL database user and password $db_user = "green"; $db_pass = "greensqlpassword"; # If you run greensql-fw service on the same computer you can specify # location of it's log file. It will be visible as part of the console. $log_file = "/var/log/greensql.log"; # Number of lines to show when viewing log file. $num_log_lines = 200; # Generated web pages cache $cache_dir = "templates_c"; ?> Sau đó cấp quyền cho thư mục templates_c/ là writable: chmod 777 templates_c/ Mở trình duyệt vào truy cập địa chỉ http://www.example.com/greensql- console. Đăng nhập vào với tài khoản admin và mật khẩu pwd: Trong giao diện web GreenSQL bạn đã có thể thấy truy vấn MySQL nào bị chặn và kết quả, bạn có thể thiết lập whitelist cho truy vấn MySQL, chỉ cho greensql-fw chặn cái gì và cho phép cái gì cho từng database riêng biệt, xem log hoặc đổi mật khẩu admin cho giao diện web GreenSQL: Nếu bạn muốn đổi vị trí kiểm tra cho green-fw, hãy sửa tập tin cấu hình của greensql-fw configuration /etc/greensql/greensql.conf. Sau khi sửa tập tin này bạn cần khởi động lại green-fw: /etc/init.d/greensql-fw stop /etc/init.d/greensql-fw start . Phòng chống tấn công SQL Injection với GreenSQL trên Debian Etch GreenSQL (hay greensql- fw) là một firewall cho cơ sở dữ liệu MySQL để cản lọc các cuộc tấn công SQL Injection. Nó. greensql- fw Dự án GreenSQL cung cấp gói binary cho Debian Etch tại http://www .greensql. net/public/releases /Debian_ Etch/ (bạn có thể tìm các gói cho các bản khác tại http://www .greensql. net/public/releases/) http://heanet.dl.sourceforge.net/sourceforge /greensql/ greensql-console- 0.4.2.tar.gz tar xvfz greensql- console-0.4.2.tar.gz Tạo subdirectory greensql- console trong /var/www/web1/web. Tiếp đó ta cần điều chỉnh cấu hình greensql- console:

Ngày đăng: 14/08/2014, 04:21

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan