


Introduction to common PHP vulnerabilities in CTF (graphic summary)
This article brings you an introduction to common PHP vulnerabilities in CTF (picture and text summary)). It has certain reference value. Friends in need can refer to it. I hope it will help You helped.
I usually encounter a lot of questions like this. It’s easy to forget if you have a bad memory, so I’ll summarize them carefully to deepen my memory! ! !
1. md5() vulnerability, PHP will use "!=" or "==" when processing hash strings. Comparing hash values, it interprets every hash value starting with "0E" as 0, so if two different passwords are hashed, and their hash values both start with "0E", then PHP They will be considered the same, both are 0.
Here are a few examples that start with 0e after md5 processing;
s878926199a
0e545993274517709034328855841020
s155964671a
0e342768416822451524974117254469
s 214587387a
0e848240448830537924465865611904
s214587387a
0e848240448830537924465865611904
Let’s try an experiment:
The result. . . As we expected
# Therefore, when the md5-encrypted string is controllable (that is, the input can be controlled), it may cause a vulnerability! ! !
Of course, what’s more interesting is that md5 cannot handle arrays. The following is also an experiment:
We pass in two different arrays:
You will find that although there is a warning, it can still be bypassed (Just add the @ symbol in front if you don’t want a warning):
However, I don’t know what will be returned when processing the array, so try it out:
var_dump():
is empty! ! ! Note that when processing an array, a NULL value will be returned.
There are many bypass methods for md5(str)==0; to summarize:
starts with 0 or 0e to bypass
Array
As long as there is no number at the beginning after processing by the md5 function, for example, "c9f0f895fb98ab9159f51fd0297e236d"==0 is established! ! ! , used to convert strings into integers! ! ! , if there is no number at the beginning, it can only be converted to 0! !
2.strcmp() function vulnerability,
strcmp() function is used to compare two strings,
strcmp( string$ str1, string$ str2);
Parameter str1 is the first string. str2 is the second string. If str1 is less than str2, return 0; If they are equal, return 0. (Note the feature of equal return 0)
But if this function If there is an illegal parameter (object, array, etc.) in the parameter, an error will be reported and 0 will be returned! ! ! (This vulnerability applies to php before 5.3. I tried it on this machine. I found that it couldn't be fixed. I don't know what happened.)
The following is an example of a question audited with BUGKU code:
As shown in the figure , according to the strcmp vulnerability, try passing in an array:
Passing in the array will cause strcmp error and return, so it is bypassed! ! !
There is another function strcasecmp(), which is the same as strcmp(). strcmp() is case-sensitive, but strcasecmp() is not, and can be bypassed in the same way.
The above is the detailed content of Introduction to common PHP vulnerabilities in CTF (graphic summary). For more information, please follow other related articles on the PHP Chinese website!

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



Alipay PHP...

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,

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...
