php漏洞对策
其实从编程的角度来讲PHP是没什么问题的,主要是使用PHP这种语言编出来的东西是否涉及安全了.
PHP的运行,是靠它的语言解释器来完成的,在NT或WIN9X下也就是PHP.EXE,PHP.EXE是一个解释器,它的作用是解释后缀为.PHP或.PHP3或.PHTML或其它的文件,根据里边定义的程序来访问数据库,读写文件或执行外部命令.并将执行的结果组织成STRING返回给WEB SERVER然后当作HTML格式的文件发送给浏览器.
知道了它工作的过程我们就可以探讨其SECURITY问题了,上述文件中我们提到过 PHP.EXE,提到过读取文件,和执行外部命令,其实这些都是安全隐患只所在,在MS-DOS下可以使用PHP.EXE读任何文件的内容,因为它本身的工作机制也就是读文件内容,把该解释的解释,该过滤的过滤.所以我们就可以利用它的这一特性通过WEB读任何我们想读文件的内容,当然这不是这么简单,这需要WEB SERVER的配合,这是后话,我们以后在讲.
PHP的第二个特性是读取文件的内容,有很多CGI漏洞就是由此特性造成的,很简单的一段程序:它的任务就是读变量$file的内容,程序员在程序调用中可能会天真的想,我就读A文件http://shabi.com/index.php3?file=a.txt 它没有对FILE这个变量做严格的限制,就导致安全问题的产生,我想稍微有点安全知识的人也知道把A.TXT修改为:/etc/passwd或NT下的../../../../../winnt/repair/sam._了
PHP的第三个特性是执行外部命令,在UNIX下比较多见:ls,echo等等,其实这是最容易出问题的,大家都知道SHELL可以连续的执行命令,用管道符|:或者~都可以,在这里我就顺便说个想法让大家和我一起探讨,这是关于WEB MAIL的,当然也和WEB编程有关,一般来说我们申请一个MAIL需要注册,而注册的时候,大都对姓名有限制,如长度等等,不过对密码的限制不严格,长度也大些,而MAIL程序可能需要调用SHELL命令来执行用户的添加,比如叫:ADD USER吧,参数是用户名和密码.add user lovehacker 1234567那如果我的密码为:a|reboot会怎么样呢?嘿嘿如果它没有把密码加密,而且添加用户使用的权限够大的话,哈哈就会让它从新启动COMPUTER,当然如果它要加密的话也行,比如用MD5或DES我们都可以写段程序让加密后的STRING为:rf -rm /*当然这只是个想法啦,我还没实践过:_)工作太忙了!当然通过我以上的想法你也可以看出执行SHELL命令而不做严格的判断有多么的严重!

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
