Home Operation and Maintenance Linux Operation and Maintenance How to detect and kill Trojans in Linux system

How to detect and kill Trojans in Linux system

Aug 10, 2017 am 11:14 AM
linux system

[导读] 木马和后门的查杀是系统管理员一项长期需要坚持的工作,切不可掉以轻心。以下从几个方面在说明Linux系统环境安排配置防范和木马后门查杀的方法:一、Web Server(以Nginx为例)1、为防止跨站感染,将虚拟主机目

木马和后门的查杀是系统管理员一项长期需要坚持的工作,切不可掉以轻心。以下从几个方面在说明Linux系统环境安排配置防范和木马后门查杀的方法:

一、Web Server(以Nginx为例)

1、为防止跨站感染,将虚拟主机目录隔离(可以直接利用fpm建立多个程序池达到隔离效果)

2、上传目录、include类的库文件目录要禁止代码执行(Nginx正则过滤)

3、path_info漏洞修正:

在nginx配置文件中增加:

if ($request_filename ~* (.*).php) {set $php_url $1;         }if (!-e $php_url.php) {return 404;    }
Copy after login

4、重新编译Web Server,隐藏Server信息

5、打开相关级别的日志,追踪可疑请求,请求者IP等相关信息。

二.改变目录和文件属性,禁止写入

find -type f -name *.php -exec chmod 444 {} ;find -type d -exec chmod 555 {} ;
Copy after login

注:当然要排除上传目录、缓存目录等;

同时最好禁止chmod函数,攻击者可通过chmod来修改文件只读属性再修改文件!

三.PHP配置

修改php.ini配置文件,禁用危险函数:

disable_funcions = dl,eval,exec,passthru,system,popen,shell_exec,proc_open,proc_terminate,curl_exec,curl_multi_exec,show_source,touch,escapeshellcmd,escapeshellarg
Copy after login

四.MySQL数据库账号安全:

禁止mysql用户外部链接,程序不要使用root账号,最好单独建立一个有限权限的账号专门用于Web程序。

五.查杀木马、后门

grep -r –include=*.php  ‘[^a-z]eval($_POST’ . > grep.txtgrep -r –include=*.php  ‘file_put_contents(.*$_POST[.*]);’ . > grep.txt
Copy after login

把搜索结果写入文件,下载下来慢慢分析,其他特征木马、后门类似。有必要的话可对全站所有文件来一次特征查找,上传图片肯定有也捆绑的,来次大清洗。

查找近2天被修改过的文件:

find -mtime -2 -type f -name *.php
Copy after login

注意:攻击者可能会通过touch函数来修改文件时间属性来避过这种查找,所以touch必须禁止

六.及时给Linux系统和Web程序打补丁,堵上漏洞

The above is the detailed content of How to detect and kill Trojans in Linux system. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is Linux actually good for? What is Linux actually good for? Apr 12, 2025 am 12:20 AM

Linux is suitable for servers, development environments, and embedded systems. 1. As a server operating system, Linux is stable and efficient, and is often used to deploy high-concurrency applications. 2. As a development environment, Linux provides efficient command line tools and package management systems to improve development efficiency. 3. In embedded systems, Linux is lightweight and customizable, suitable for environments with limited resources.

Using Docker with Linux: A Comprehensive Guide Using Docker with Linux: A Comprehensive Guide Apr 12, 2025 am 12:07 AM

Using Docker on Linux can improve development and deployment efficiency. 1. Install Docker: Use scripts to install Docker on Ubuntu. 2. Verify the installation: Run sudodockerrunhello-world. 3. Basic usage: Create an Nginx container dockerrun-namemy-nginx-p8080:80-dnginx. 4. Advanced usage: Create a custom image, build and run using Dockerfile. 5. Optimization and Best Practices: Follow best practices for writing Dockerfiles using multi-stage builds and DockerCompose.

What to do if the apache80 port is occupied What to do if the apache80 port is occupied Apr 13, 2025 pm 01:24 PM

When the Apache 80 port is occupied, the solution is as follows: find out the process that occupies the port and close it. Check the firewall settings to make sure Apache is not blocked. If the above method does not work, please reconfigure Apache to use a different port. Restart the Apache service.

How to start apache How to start apache Apr 13, 2025 pm 01:06 PM

The steps to start Apache are as follows: Install Apache (command: sudo apt-get install apache2 or download it from the official website) Start Apache (Linux: sudo systemctl start apache2; Windows: Right-click the "Apache2.4" service and select "Start") Check whether it has been started (Linux: sudo systemctl status apache2; Windows: Check the status of the "Apache2.4" service in the service manager) Enable boot automatically (optional, Linux: sudo systemctl

How to monitor Nginx SSL performance on Debian How to monitor Nginx SSL performance on Debian Apr 12, 2025 pm 10:18 PM

This article describes how to effectively monitor the SSL performance of Nginx servers on Debian systems. We will use NginxExporter to export Nginx status data to Prometheus and then visually display it through Grafana. Step 1: Configuring Nginx First, we need to enable the stub_status module in the Nginx configuration file to obtain the status information of Nginx. Add the following snippet in your Nginx configuration file (usually located in /etc/nginx/nginx.conf or its include file): location/nginx_status{stub_status

How to start monitoring of oracle How to start monitoring of oracle Apr 12, 2025 am 06:00 AM

The steps to start an Oracle listener are as follows: Check the listener status (using the lsnrctl status command) For Windows, start the "TNS Listener" service in Oracle Services Manager For Linux and Unix, use the lsnrctl start command to start the listener run the lsnrctl status command to verify that the listener is started

How to set up a recycling bin in Debian system How to set up a recycling bin in Debian system Apr 12, 2025 pm 10:51 PM

This article introduces two methods of configuring a recycling bin in a Debian system: a graphical interface and a command line. Method 1: Use the Nautilus graphical interface to open the file manager: Find and start the Nautilus file manager (usually called "File") in the desktop or application menu. Find the Recycle Bin: Look for the Recycle Bin folder in the left navigation bar. If it is not found, try clicking "Other Location" or "Computer" to search. Configure Recycle Bin properties: Right-click "Recycle Bin" and select "Properties". In the Properties window, you can adjust the following settings: Maximum Size: Limit the disk space available in the Recycle Bin. Retention time: Set the preservation before the file is automatically deleted in the recycling bin

How to restart the apache server How to restart the apache server Apr 13, 2025 pm 01:12 PM

To restart the Apache server, follow these steps: Linux/macOS: Run sudo systemctl restart apache2. Windows: Run net stop Apache2.4 and then net start Apache2.4. Run netstat -a | findstr 80 to check the server status.

See all articles