How to Use phpBB2 to configure a Secure Linux Forum (below)

Source: Internet
Author: User
Article Title: how to configure a Secure Linux Forum (below) with phpBB2 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   Ii. Clear Security Vulnerabilities and upgrade Forum Versions
  
1. php
  
BB2.0.11 Security Vulnerability Analysis and Removal Methods:
  
PhpBB2 is a forum written in php scripting language. A serious vulnerability in versions earlier than 2.0.11 is that viewtopic. php allows remote command execution. Viewtopic. php is a script file in the phpBB2 forum for viewing the post content. Attackers can run any code on the service. Net-Worm.Perl.Santy.a is a worm that uses perl script code to write a virus, through the phpBB2 vulnerability remote execution of system commands invade into the host, once the invasion is successful and get running, began to send a request to google, search for hosts that can be intruded. If you use phpBB2 earlier than 2.0.11, you need to clear the worm.
  
(1) steps to clear viruses:
  
Open the viewtopic. php file and add a line before the following code: $ topic_id = $ post_id = false;
  
If (isset ($ HTTP_GET_VARS [POST_TOPIC_URL])
{
$ Topic_id = intval ($ HTTP_GET_VARS [POST_TOPIC_URL]);
}
Else if (isset ($ HTTP_GET_VARS ['topic '])
{
$ Topic_id = intval ($ HTTP_GET_VARS ['topic ']);
}
  
In addition, the following code is added to the viewtopic. php file:
  
$ Join_ SQL _table = (! Isset ($ post_id ))? '':", ". POSTS_TABLE." p, ". POSTS_TABLE." p2 ";
$ Join_ SQL = (! Isset ($ post_id ))? "T. topic_id = $ topic_id ":" p. post_id = $ post_id AND t. topic_id = p. topic_id AND p2.topic _ id = p. topic_id AND p2.post _ id <= $ post_id ";
$ Count_ SQL = (! Isset ($ post_id ))? '':", COUNT (p2.post _ id) AS prev_posts ";
  
$ Order_ SQL = (! Isset ($ post_id ))? '':" Group by p. post_id, t. topic_id, t. topic_title, t. topic_status, t. topic_replies, t. topic_time, t. topic_type, t. topic_vote, t. topic_last_post_id, f. forum_name, f. forum_status, f. forum_id, f. auth_view, f. auth_read, f. auth_post, f. auth_reply, f. auth_edit, f. auth_delete, f. auth_sticky, f. auth_announce, f. auth_pollcreate, f. auth_vote, f. auth_attachments order by p. post_id ASC ";
  
Replace:
  
$ Join_ SQL _table = (empty ($ post_id ))? '':", ". POSTS_TABLE." p, ". POSTS_TABLE." p2 ";
$ Join_ SQL = (empty ($ post_id ))? "T. topic_id = $ topic_id ":" p. post_id = $ post_id AND t. topic_id = p. topic_id AND p2.topic _ id = p. topic_id AND p2.post _ id <= $ post_id ";
$ Count_ SQL = (empty ($ post_id ))? '':", COUNT (p2.post _ id) AS prev_posts ";
  
$ Order_ SQL = (empty ($ post_id ))? '':" Group by p. post_id, t. topic_id, t. topic_title, t. topic_status, t. topic_replies, t. topic_time, t. topic_type, t. topic_vote, t. topic_last_post_id, f. forum_name, f. forum_status, f. forum_id, f. auth_view, f. auth_read, f. auth_post, f. auth_reply, f. auth_edit, f. auth_delete, f. auth_sticky, f. auth_announce, f. auth_pollcreate, f. auth_vote, f. auth_attachments order by p. post_id ASC ";
  
Click "start"-"Search"-"file or folder", enter "m1h020f" in the file name, and delete all files. So far, no variants have been updated for this worm. We have achieved great control.
  
2. phpBB2.0.12 security vulnerability analysis and solution:
  
PhpBB 2.0.12 has two security vulnerabilities, one of which is very serious. This vulnerability allows any user to obtain management permissions. Another vulnerability may cause server path leakage. The first vulnerability exists in schemdes/sessions. in the PHP file, there is a problem with the type and comparison operations of the $ sessiondata ['autologinid'] variable. Remote attackers can forge special variable values and use operations to determine the user's validity to always return true results, in this way, any user can successfully authenticate as an administrator without knowing the password. The second vulnerability is in the viewtopic. php file. Due to insufficient message filtering, path leakage is possible. Remote attackers can exploit this vulnerability to obtain management permissions. Solution: Upgrade the version to 2.0.14.
  
Steps:
  
1. Database Backup:
  
PhpBB2 can back up its own data. Click "normal management"-"database tool management: Backup"-"select overall backup option" on the forum administrator control panel of phpBB2 ", you can complete the overall backup of Forum data, as shown in figure-4.
    
Figure-4 data backup for the phpBB2 Forum
  
The backup file is phpbb_db_backup. SQL. It can be seen that it is an SQL file.
  
2. Use the network to back up mysql Data:
  
PhpBB2 itself does not support network backup. You can use the Mysql DATA export and import tool mysqldump.
  
(1) local backup:
  
Using mysqldump for backup is very simple. to back up the database "phpbb_db_backup", run the following command:
  
# Mysqldump? U-p phpbb_db_backup>/usr/backups/mysql/phpbb_db_backup.2005.5.6
  
You can also use the gzip command to compress the backup file:
  
# Mysqldump phpbb_db_backup | gzip>/usr/backups/mysql/phpbb_db_backup.2005.5.6. Gz
  
Run the following command to restore data:
  
# Mysql? U-p phpbb_db_backup </usr/backups/mysql/phpbb_db_backup.2005-5-6
  
(2) network backup
  
It is insecure to store mysql data on one computer. Therefore, you should back up the data to other computers in the LAN. Assume that the IP address of the Mysql server is 192.168.1.3. The IP address of the remote computer in Linux is 192.168.1.17, And the IP address of the remote computer in Windows is 192.168.1.18.
  
To back up MYSQL Data to a remote computer using Linux, you must install the Network File System on both ends. After installing the NFS protocol on the remote NFS computer, you must modify the configuration File:/etc/exports, add a row:
  
/Usr/backups/mysql/192.168.1.17 (rw, no_root_squash)
  
Share the/usr/backups/mysql/directory. This directory has the read and write permissions of the remote root user. Save the NFS configuration file and run the following command:
  
# Exportfs-? R
  
Then restart the NFS service:
  
# Service nfsd start
  
After the remote computer is set, create a backup_share directory under the MYSQL server/mnt directory:
  
# Mkdir/mnt/backup_share
  
Mount the/usr/backups/mysql/directory of the remote Linux computer to the/mnt/backup_share directory of the MYSQL server:
  
# Mount-t nfs 192.168.1.17:/usr/backups/mysql/mnt/backup_share
  
After mounting the directory, you only need to enter the/mnt/backup_share Directory, which is equal to the/usr/backups/mysql directory of the NFS computer whose IP address is 192.168.1.7. The following uses mysqldump to back up "phpbb_db_backup" to a remote computer:
  
# Mysqldump phpbb_db_backup>/mnt/backup_share/phpbb_db_backup.2005-5-6
  
To back up MYSQL Data to a remote computer using Windows, you must install the Samab protocol on Linux. Create a directory (/arc) on a Windows computer and share it with you to grant it read and write permissions. Similarly, create a backup_share1 directory under the MYSQL server/mnt directory and mount it:
  
# Mount-t smbfs-o username = csung, password = XXXX // 192.168.1.18/arc/mnt/backup_share
  
Run the following command to back up the data:
  
# Mysqldump phpbb_db_backup>/mnt/backup_share/phpbb_db_backup.2005-5-6
  
3. Upgrade the latest phpBB2 Forum version:
  
Download the latest phpBB-2.0.14 decompress to a temporary directory, first back up the original data, and then the original config. the php file overwrites the config. php: Delete the original phpBB2 installation directory and move the latest phpBB2 version to the/var/www/html/directory:
  
# Mv phpBB2/var/www/html/phpbb2
  
Then, enter http: // localhost/phpbb2/install/update_to_2014.php in the browser. If the system displays figure-5, the upgrade is successful:
  
Figure-5 phpBB2 version upgrade page
  
After the upgrade, you also need to delete the installation files (to prevent others from using these files to modify system information ),
  
# Chmod 644 config. php
# Rm-rf install
# Rm-rf contrib
  
Then, recover the data. Click "normal management"-"database tool management: Recovery" on the forum administrator control panel of phpBB2 to restore the data in the Forum.
  
2. Other security measures
  
1. administrator permissions
  
The system administrator of phpBB2 has the maximum permission, and this permission may conflict with the permissions of other board owners and cause unexpected errors. Therefore, it is best not to have the system administrator as the moderator. In addition, it is not safe to run MYSQL with the root permission. We recommend that you run MYSQL with other users. The method is:
  
# Mysql-u root-p
Enter password: xxxxxxxxx
.........
Mysql> update user set user = "cao" where user = "root ";
Mysql> flush privileges;
Mysql> quit
Bye
  
You will need to access the mysql database through the cao account later.
  
2. security settings of the php configuration file:
  
The phpinfo and get_cmd_var functions are mainly used to debug whether the program is normal. When LAMP is installed, disable it. Edit the php. ini file and add a line :〕
  
Disable_functions = phpinfo, get_assist_var
  
This prevents system service information leakage. About php and Apache other security measures can view the author: teach you how to use PHP to develop a secure application, link: http://tech.ccidnet.com/pub/article/c1113_a239881_p1.html
  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.