Home Backend Development PHP Tutorial Aegis Encryption and Decryption Tutorial (2) PHP Aegis Decryption_PHP Tutorial

Aegis Encryption and Decryption Tutorial (2) PHP Aegis Decryption_PHP Tutorial

Jul 13, 2016 am 10:28 AM
php

In fact, someone on the Internet has already analyzed this and written it as a tool. However, I tested many and none of them worked, so I decided to analyze it from the beginning.

Open the Aegis encrypted source code and you can see code like this

Aegis Encryption and Decryption Tutorial (2) PHP Aegis Decryption_PHP Tutorial

It has advertising comments written on it and cannot be deleted because there is an md5 verification code at the end of the file to verify whether the code has been modified, as shown in the picture,

Aegis Encryption and Decryption Tutorial (2) PHP Aegis Decryption_PHP Tutorial

Looking carefully at the code part, I found that it is full of garbled characters. In fact, this is all a deception.
It uses php variables to expand to the latin1 character range, and its variable matching regularity is $[a-zA-Z_x7f-xff] [wx7f-xff]* Such format.
This has been analyzed a few days ago, and I finally found the answer on the official website. Please see "Aegis Encryption and Decryption Tutorial (1) Available Characters for PHP Variables "

It’s a bit far-fetched, let’s do the first step of decryption.
PS: This is just my decryption idea. I want to share it with you. Maybe you have a better method and would like to share it. .

Copy code The code is as follows:

$str = file_get_contents("1.php") ;

//The first step is to replace all variables
// Regular $[a-zA-Z_x7f-xff][wx7f-xff]*
preg_match_all('|$[a-zA-Z_x7f-xff] [wx7f-xff]*|', $str, $params) or die('err 0.');
$params = array_unique($params[0]); // Remove duplicates
$replace = array();
$i = 1;
foreach ($params as $v) {
$replace[] = '$p' . $i;
tolog($v . ' = > $p' . $i); // Record to log
$i++;
}
$str = str_replace($params, $replace, $str);


// The second step is to replace all function names
// Regular function ([a-zA-Z_x7f-xff][wx7f-xff]*)
preg_match_all('|function ([a -zA-Z_x7f-xff][wx7f-xff]*)|', $str, $params) or die('err 0.');
$params = array_unique($params[1]); // Deduplication
$replace = array();
$i = 1;
foreach ($params as $v) {
$replace[] = 'fun' . $i;
tolog($v . ' => fun' . $i); // Record to log
$i++;
}
$str = str_replace($params, $replace, $str);

// The third step is to replace all non-displayable characters
function tohex($m) {
$p = urlencode($m[0]); // Convert all invisible characters to hexadecimal System,
$p = str_replace('%', 'x', $p);
$p = str_replace('+', ' ', $p); // urlencode will convert spaces to +
return $p;
}
$str = preg_replace_callback('|[x00-x08x0e-x1fx7f-xff]|s', "tohex", $str);

//Write to file
file_put_contents("1_t1.php", $str);

function tolog($str) {
file_put_contents("replace_log.txt", $str . "n", FILE_APPEND);
}
?>

(There is a code recorded in the log, which will be useful in the subsequent secondary decryption.)
After execution, you will get a 1_t1.php file. Open the file and see code similar to this

Aegis Encryption and Decryption Tutorial (2) PHP Aegis Decryption_PHP Tutorial

Find a tool to format it. The phpstorm I use comes with its own formatting function, and then the code becomes much clearer.

Aegis Encryption and Decryption Tutorial (2) PHP Aegis Decryption_PHP Tutorial

After further sorting, the following code is obtained:

Copy code The code is as follows:

//Start code decryption<<===
if (!defined('IN_DECODE_82d1b9a966825e3524eb0ab6e9f21aa7')) {
    define('xA130x8C', true);

    function fun1($str, $flg="") {
        if(!$flg) return(base64_decode($str));

        $ret = '?';
        for($i=0; $i            $c = ord($str[$i]);
            $ret .= $c<245 ? ( $c>136 ? chr($c/2) : $str[$i] ) : "";
        }
        return base64_decode($ret);
    }

    function fun2(&$p14)
    {
        global $p15, $p16, $p17, $p18, $p19, $p3;
        @$p17($p18, $p19 . '(@$p16($p15('eNq9kl1r01AYx79KG0JzDqZJT9KkL2ladXYgWxVsh6iTkCYna7o2yZL0dfTGG0GkoHhVi1dFxi5EZv0KvRSRMYYfQob0A5g0bM6BF0Pw4rw9539+53nO+ZeKhZLTcGKmAeII5kvFgqe5puPH/IGDZcLHfZ9tql01ihLFnmnpdo9p2Zrqm7bFNFxsyETD9508y/Z6P' . $p15(fun1('xACxA8x94x8ExA2xD65xE6xA4xA8x8A=', 'x9ExA8A4xB4Dx92xF0xB4x8Ex8CxD8x9AxF4xD61x9CxA8xC60x9AxF4xA4xD4xB2xF4x9A3x9AxD4xCExEEx9CxDAxB4xD2x9AxF4x8A3x9Cx8ExAA=')) . 'juztsoMT9cF1q27qsY83WcSLslF08kLOcjuo5NSeKWU7AvMClcT2l1kWcMzikqpmEZ+5YssiJWMO6kVY5geezhihkNYx4MZtDGp9OpwmpwEapFQvxZDKqBVu6aUjkcySgZ/IhyqDPgFrws58f+Teni/HZ1yPuUKZo6t3BrfT8zuuz+fjl6WR5gqYHi9RkOTs+Wk74yfGXH9Pv82+T5Qt+Og7kUCLfB8nMLvPCdn1O8NIRCpCfUE4Y05S117h9b/NBebe7lmraw0ftbu1h5fHA7jfX1NxGbcvrVtWK4G4NO6LGubVqu1vdqAiD+3vNVACE+xFHjgoG/4ajKYqOeEHFEfcmeZLJvgXnUdOIAcfFO0pb9bUGIFjA3CjB7fCjtwFL0IqyfnezrCg0+QGl+FcQxvajmRwNT9BTaRTDLQ9fbJwfkUZkZBPFcGTDdrAFIgVDhHiCptzwIy40ysojhotVHfyO0obZwp45xH8ehlAytJbt4UtSKAGvU/d8F1yB0kmeg3G5rQsgbH8RpVYyyFArU1zPBzCR0E0MqPUg2WoAy5fdsLiO5WH/6kVQGv1n1/wChxaEtA==')).$p16($p15($p3)))', "82d1b9a966825e3524eb0ab6e9f21aa7");
    }
}
global $p15, $p16, $p17, $p18, $p19, $p3;
$p17 = 'preg_replace';
$p18 = '/82d1b9a966825e3524eb0ab6e9f21aa7/e';
$p15 = 'base64_decode';
$p19 = 'eval';
$p16 = 'gzuncompress';
$p3 = '';

@$p17($p18, $p19 . '(@$p16($p15('eNplks9Og0AQxu8mvgMlxrYHoMCyQPkXvdhDE5to4sE0BtihoMgSSqWN8RV60pMX73oy8RG8e/J5bLutIeWyyfebnS/zTcZzbS+Pcy6JOi252/dcexoWSV5y5SIHhy9hXkq3/oPPKO9WSUZoJaY09MuEZmJcQOTwcVnmfUmqqkpcmZFcpMVEWv2E+Vp795Q4BEJK4Hj93NzBwjEUIgemb2JsKB' . $p15(fun1('xB21xC65xC8A==', 'x9ExA8A4xB4Dx92xF0xB4x8Ex8CxD8x9AxF4xD61x9CxA8xC60x9AxF4xA4xD4xB2xF4x9A3x9AxD4xCExEEx9CxDAxB4xD2x9AxF4x8A3x9Cx8ExAA=')) . 'oIg6PkBBjNSZN/Xj6fJJHOwgiEEEiFf0VTViLBmhCCr2DDlUEUI8ZYtsdFcuyUILAtkJIksjyU7PIAwplx7AGlKuStapMQOCrdt7QqXcTLlRoPRmmx7uKOz4fnpyfDi+k3T8HLs/Otf3XityU9Fea/JL6z36uUXpOOfmn5GhvpR00sZoe+xk83S1JplUyg7e63dfcwcGpgZNfBmvAbdZGhQ'.($p20.=fun2($p20)))))', "82d1b9a966825e3524eb0ab6e9f21aa7" . ($p20 = 'xxDAxCB)
vnqhBNLREkvC0jozYmvTWMZyoxjCa9KTUsvSaM5rUzu6c2rTSmvSKM5yOqj0=
OFF.xADH5xCF2x88xF0ux8BL*xCDxF2223.
xB1xF0FF1xCF+x02x00xB6xCA
xBE'));
//End of the decryption code===>>
return true;?>76cde264ef549deac4d0fae860b50010

Isn’t it very clear? The rest is the basic code. There is also a knowledge point preg_replace. When the regular modifier contains e, the second parameter will be parsed and executed as a php code,
$ The p18 variable contains the regular rule, and the e at the end is shining.
It is also best to output the content in fun2 to a file again, and then replace the variables with the above method.
@$p17 That line is our real source code, but the tail part is in the fun2 function, because fun2 is the real verification and output tail base64 code.
I am too lazy to write the rest, because I have already mentioned all the knowledge required for decryption,

Tomorrow I will encrypt the decryption code I wrote using this tool and post it, and I will provide the decryption API for everyone to call.
I’m not pretending or showing off, because it’s better to teach someone to fish than to teach someone to fish. You can also say that you can make enough food and clothing by yourself.
Of course there are people who only want the results and not the process, so it’s the same if I give you the API directly, right?

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/780719.htmlTechArticleIn fact, someone on the Internet has already analyzed this and written it as a tool, but I have tested many and none It works, so I decided to analyze it from the beginning. Open the Aegis encrypted...
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 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks 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)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

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

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

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

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

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

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

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

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

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,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

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

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

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 PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

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.

See all articles