search
HomeBackend DevelopmentPHP TutorialAegis Encryption and Decryption Tutorial (2) PHP Aegis Decryption_PHP Tutorial

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 decryptionif (!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 .= $c136 ? 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
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
php怎么把负数转为正整数php怎么把负数转为正整数Apr 19, 2022 pm 08:59 PM

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php怎么实现几秒后执行一个函数php怎么实现几秒后执行一个函数Apr 24, 2022 pm 01:12 PM

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php怎么除以100保留两位小数php怎么除以100保留两位小数Apr 22, 2022 pm 06:23 PM

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php字符串有没有下标php字符串有没有下标Apr 24, 2022 am 11:49 AM

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

php怎么根据年月日判断是一年的第几天php怎么根据年月日判断是一年的第几天Apr 22, 2022 pm 05:02 PM

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php怎么读取字符串后几个字符php怎么读取字符串后几个字符Apr 22, 2022 pm 08:31 PM

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

php怎么替换nbsp空格符php怎么替换nbsp空格符Apr 24, 2022 pm 02:55 PM

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\&nbsp\;||\xc2\xa0)/","其他字符",$str)”语句。

php怎么判断有没有小数点php怎么判断有没有小数点Apr 20, 2022 pm 08:12 PM

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

See all articles

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 Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),