Use the new features of php7 to bypass the anti-killing rules
Recently I have been studying webshell anti-virus, and I have come up with a novel point of my experience. The reason is that I suddenly thought that since php7.1 cannot use the assert of variable functions, then use the new features of php7 to bypass the anti-killing rules, and finally bypass a certain shield and "a certain d0g".
The experimental environment is in 7.1.9, and all horses cannot be used in environments below php7.
D Shield Rule Base (latest): 20191227
Because a certain d0g may cause infringement by testing its products, in order to prevent being reported, the picture will not be posted.
Pre-experiment
a certain shield
First the following code
A direct false alarm.
Therefore, it is unrealistic to directly pass parameters into eval.
So next we have to use functions and cooperate with new features of PHP to bypass it.
A certain d0g
As for a certain d0g, as long as the following code
will cause it to report falsely.
Therefore, when writing a horse-free game, the variables in post should not appear in the string in eval. Just like `b` above, although it appears as a variable in `eval`. With this foundation in mind, we can get to the point.
PHP7.0.x
[php manual-php7.0.x new features]( https://www.php.net/manual/zh/migration70.new-features.php )
Return value type declaration
php7 adds support for return value type declaration. Just add a `:type` when defining a function.
For example:
# means that the function return value type must be int. Otherwise, it will be forced to convert or a syntax error will be displayed.
If the anti-virus software with this feature is not updated, this function will not be recognized and it will be bypassed.
For example:
#You can use anti-virus software to test it.
Found not detected.
can use.
null coalescing operator
Due to the large number of situations where ternary expressions and `isset()` are used simultaneously in daily use, the null coalescing operator (*??*) is added. Syntactic sugar. If the variable exists and its value is not **`NULL`**, it will return its own value, otherwise it will return its second operand
Simply put:
How to use `? ? ` symbol, the killing software will not understand this processing process, which may lead to bypass.
Just like the following code, you can bypass a certain d0g
and then use the function call
You can find that you have passed the D shield
Test the usability
The types of parameters and return values can now be nullable by adding a question mark before the type. When this feature is enabled, the parameters passed in or the result returned by the function are either of the given type or null .
There are more features than 7.1 `? `If the function return value is not of the given type, it will be empty. Use the same code:Passed D shield
Short array syntax
The short array syntax ([]) is now a fallback for the list() syntax option, which can be used to assign the value of the array to some variables (including in foreach).
Here, a list of square brackets `[] type` is used for demonstration.
In this way, the values of the array are assigned to ` $c`, `$d`.`$c='a';$d='b' ;`
In this way, you can use this rarely used feature to bypass static killing
First write the simplest one:
Then we passed a certain d0g. Test it yourself.
After that, you can match the function. Like this:
Check it
Test availability
list() now supports key names
Official description: list() and its new [] syntax now support specifying key names within it. This means that it can assign any type of array to some variables (similar to the short array syntax)
This is very confusing, you may understand it after looking at the example.
eg:
You can pass a certain d0g with a little modification (self-test):
Try D Shield
Reported Level 1
Use the custom function again.
Passed D successfully to test the usability.
Support negative string offsets
Official description
Now all string operation functions that support offsets Supports accepting negative numbers as offsets, including operating string subscripts via [] or {}. In this case, a negative offset is understood as an offset from the end of the string.
In versions less than 7.1, negative offsets return an empty string.
eg:
Returns `s` in 7.1.x, but returns ` string(0) "" in previous versions `
Idea: We can split the string so that the rules cannot be recognized. Finally, use the variable variables of PHP:
so that you can pass a certain d0g. But for D shield, splicing characters and variable variables will be recognized. Reporting level 1 `suspicious files`, I have to say that this is really done very well.
End
In fact, there are many features, such as `defining a constant array through define()`, which can also be bypassed by analogy. And not only custom functions, but also classes, variable variables, etc. can be used to bypass static killing.
You can also use the `spaceship operator (combined comparison operator)`, `integer division function intdiv()`, etc. to bypass dynamic killing.
For more related articles, please pay attention to the web server security column of php Chinese website!
The above is the detailed content of Use the new features of php7 to bypass the anti-killing rules. 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

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



How to install the mongo extension in php7.0: 1. Create the mongodb user group and user; 2. Download the mongodb source code package and place the source code package in the "/usr/local/src/" directory; 3. Enter "src/" directory; 4. Unzip the source code package; 5. Create the mongodb file directory; 6. Copy the files to the "mongodb/" directory; 7. Create the mongodb configuration file and modify the configuration.

In php5, we can use the fsockopen() function to detect the TCP port. This function can be used to open a network connection and perform some network communication. But in php7, the fsockopen() function may encounter some problems, such as being unable to open the port, unable to connect to the server, etc. In order to solve this problem, we can use the socket_create() function and socket_connect() function to detect the TCP port.

To resolve the plugin not showing installed issue in PHP 7.0: Check the plugin configuration and enable the plugin. Restart PHP to apply configuration changes. Check the plugin file permissions to make sure they are correct. Install missing dependencies to ensure the plugin functions properly. If all other steps fail, rebuild PHP. Other possible causes include incompatible plugin versions, loading the wrong version, or PHP configuration issues.

Common solutions for PHP server environments include ensuring that the correct PHP version is installed and that relevant files have been copied to the module directory. Disable SELinux temporarily or permanently. Check and configure PHP.ini to ensure that necessary extensions have been added and set up correctly. Start or restart the PHP-FPM service. Check the DNS settings for resolution issues.

How to install and deploy php7.0: 1. Go to the PHP official website to download the installation version corresponding to the local system; 2. Extract the downloaded zip file to the specified directory; 3. Open the command line window and go to the "E:\php7" directory Just run the "php -v" command.

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...

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

Compared with PHP7, PHP8 has some advantages and improvements in terms of performance, new features and syntax improvements, type system, error handling and extensions. However, choosing which version to use depends on your specific needs and project circumstances. Detailed introduction: 1. Performance improvement, PHP8 introduces the Just-in-Time (JIT) compiler, which can improve the execution speed of the code; 2. New features and syntax improvements, PHP8 supports the declaration of named parameters and optional parameters, making functions Calling is more flexible; anonymous classes, type declarations of properties, etc. are introduced.
