Discuz, Uchome, and other php programs to scan and kill Trojans

Source: Internet
Author: User

Some time ago, a small station on the server was infected with Trojans. Centos + nginx + php used by the server, and Didcuz and UChome used by the program. This website has no access traffic, and hackers are still eyeing it. Fortunately, backups are generated every day, causing no loss. However, I am very grateful to the hackers for helping me check the server's security vulnerabilities, so as to further strengthen the server's security protection.
I will share some Server Security Protection Information ~~~

1. Security of the server itself

Install denyhost to prevent brute-force SSH cracking. For details about how to install it, see denyhost to prevent brute-force SSH cracking and protect your linux.
Add an I permission to some important files of the system.
For example:
# Chattr + I/etc/passwd
# Chattr + I/etc/group
# Chattr + I/etc/shadow
# Chattr + I/etc/gshadow
# Chattr + I/etc/ssh/sshd_config

2. nginx and php security

(1) restrict php programs to directories Uploaded By discuz/attachments, uchome/attachment, ucenter/data/tmp, and other users. Centos + nginx should be relatively safe. Generally, hackers use webshell to intrude into the system.
Add
Location ~ . *. (Php | php5 )? $ {
.......
#------------------------------------------
Rewrite ^/(uc \ _ client | templates | include | plugins | admin | attachments | images |
Forumdata)/. *. (php | php5 )? $/50x. php last;
#-------------------------------------------
}

(2) Modify php. ini
Search: disable_functions
Find and add after =
Exec, system, passthru, error_log, ini_alter, dl, openlog, syslog, readlink, symlink, link, leak, fsockopen, proc_open,
Popepassthru, chroot, scandir, chgrp, chown, escapeshellcmd, escapeshellarg, shell_exec, proc_get_status, popen
All functions in php are prohibited.

(3) Add the I permission to some important files that do not need to be modified. The method is the same as in section 1. Security of the server itself.


3. How to Find the php Trojan on the server

The most obvious feature of the PHP Trojan is that the eval and base64_decode functions are used, so we can look

Find/var/www/-type f-name "*. php" | xargs grep "eval (" | more

If such words are found, most of them are Trojans.
Eval (base64_decode (..............));

Check whether your server has any Trojans ~~~

Related Article

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.