几种防御PHP程序被木马攻击配置详解方法
1,防止跳出web目录
首先修改httpd.conf,如果你只允许你的php脚本程序在web目录里操作,还可以修改httpd.conf文件限制php的操作路径,比如你的web目录是/usr/local/apache/htdocs,那么在httpd.conf里加上这么几行:
php_admin_value open_basedir /usr/local/apache /htdocs
这样,如果脚本要读取/usr/local/apache/htdocs以外的文件将不会被允许,如果错误显示打开的话会提示这样的错误:
warning: open_basedir restriction in effect. file is in wrong directory in /usr/local/apache/htdocs/open.php on line 4 等等.
2、防止php木马执行webshell
打开safe_mode,在,php.ini中设置
disable_functions= passthru,exec,shell_exec,system
二者选一即可,也可都选.
3、防止php木马读写文件目录
在php.ini中的disable_functions= passthru,exec,shell_exec,system,后面加上php处理文件的函数,主要有:
fopen,mkdir,rmdir,chmod,unlink,dir fopen,fread,fclose,fwrite,file_exists closedir,is_dir,readdir.opendir fileperms.copy,unlink,delfile //即成为 disable_functions= passthru,exec,shell_exec,system,fopen,mkdir,rmdir,chmod,unlink,dir fopen,fread,fclose,fwrite,file_exists closedir,is_dir,readdir.opendir fileperms.copy,unlink,delfile
ok,大功告成,php木马拿我们没辙了,遗憾的是这样的话,利用文本数据库教程的那些东西就都不能用了.
如果是在windos平台下搭建的apache我们还需要注意一点,apache默认运行是system权限,这很恐怖,这让人感觉很不爽,那我们就给apache降降权限吧.
net user apache fuckmicrosoft /add net localgroup users apache /del
ok.我们建立了一个不属于任何组的用户apche,我们打开计算机管理器,选服务,点apache服务的属性,我们选择log on,选择this account,我们填入上面所建立的账户和密码,重启apache服务,ok,apache运行在低权限下了.
实际上我们还可以通过设置各个文件夹的权限,来让apache用户只能执行我们想让它能干的事情,给每一个目录建立一个单独能读写的用户,这也是当前很多虚拟主机提供商的流行配置方法,不过这种方法用于防止这里就显的有点大材小用了.
永久链接:
转载随意!带上文章地址吧。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Route management is one of the most critical parts of any web application because they determine how a URL request will be processed and responded to. PHP is a widely used web programming language and many developers use PHP to build their web applications. In this article, we will discuss the best practices for routing management in PHP programs. Using the MVC Framework Many PHP applications are developed using the MVC (Model-View-Controller) framework. In this framework,

How to use GitHubActions for automated packaging and deployment of PHP programs? Introduction With the rise of cloud computing and DevOps, automation and continuous integration of software development have become increasingly important. GitHubActions is a powerful automation tool that can help developers achieve rapid and efficient software development and deployment. In this article, we will focus on how to use GitHubActions for automated packaging and deployment of PHP programs to improve development efficiency. 1. Assume

PHP is a popular programming language that is widely used for website and web application development. However, when PHP applications become more and more complex, performance issues also manifest themselves. Therefore, performance optimization has become an important aspect in PHP development. In this article, we will introduce optimization best practices in PHP programs to help you improve the performance of your applications. 1. Choose the correct PHP version and extensions First, make sure you are using the latest PHP version. New releases usually include performance improvements and bug fixes, as well as

How to package and deploy PHP programs in Ubuntu environment? With the popularity of PHP development and the increase in application scenarios, we often need to package and deploy the developed PHP programs so that they can be easily deployed and run in different environments. This article will introduce how to package and deploy PHP programs in the Ubuntu environment for developers' reference and use. First, we need to install some necessary software and tools to ensure that we can package and deploy smoothly. We need to install the following packages: PHP: Make sure you have

What is PHP? PHP (Hypertext Preprocessor) is a web development language widely used as a server-side scripting language. It allows developers to embed code in HTML files to create dynamic web pages and interact with databases. PHP is known for its simplicity, versatility, and extensive integration capabilities with popular databases. It offers a wide range of extension capabilities and has a large developer community ensuring there is abundant resources and support What are naive algorithms in PHP? TheNaivealgorithm,alsoknownastheBruteForcealgorithm,isasimplepatternsearchingalgorithmus

How to use caching strategies to reduce the memory footprint of PHP programs? Summary: When developing PHP programs, we often encounter the problem of excessive memory usage. In order to solve this problem, we can use caching strategies to reduce the memory footprint of PHP programs. This article will introduce how to use caching strategies to optimize PHP programs and give corresponding code examples. 1. Why you need to use caching strategy In PHP, every time a page is requested, the server will re-execute the PHP script to generate the page content. This means that each request will result in a

How to use cache preheating to improve PHP program performance? Abstract: In PHP development, cache preheating is a commonly used technical means, which can significantly improve the performance and response speed of the program. This article will introduce the concept of cache preheating and provide some specific code examples to help readers better understand and apply this technology to optimize the performance of PHP programs. Keywords: cache preheating, PHP program performance, code examples 1. What is cache preheating? Before understanding cache preheating, let's first understand what cache is. Caching is a way of storing data

What is PHP? PHP stands for Hypertext Preprocessor and is a widely used server-side scripting language mainly used for web development. It provides developers with a powerful and flexible platform to create dynamic web pages and applications. PHP can be embedded in HTML code, allowing for seamless integration of server-side functionality with client-side elements. Its syntax is similar to C and Perl, making it relatively easy to learn and use for programmers familiar with these languages. PHP allows server-side scripts to be executed on a web server, generating dynamic content that can be delivered to the user's browser. It supports a variety of databases and is suitable for developing database-driven websites. Additionally, PHP offers a vast ecosystem of open source libraries and frameworks that facilitate rapid development and enhance code
