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)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 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)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

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

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

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

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles