|
因为要参加CTF比赛, 遇到AAEncode 加密和解密的题目,目前来说有三种解决方法。
直接通过在线解密,网站很多,百度即可,但是比赛要求离线,这个基本废了。
通过浏览器开发者工具将加密代码进行解密,可以,但是只能解密不能加密。
自己搭建Apache + PHP + ZendEngel 然后写PHP脚本来实现,我这里就是这种方法。
首先 AAEnDeCode.php 主要进行解密加密算法.
- <?php
- $b = [
- "(c^_^o)",
- "(゚Θ゚)",
- "((o^_^o) - (゚Θ゚))",
- "(o^_^o)",
- "(゚ー゚)",
- "((゚ー゚) + (゚Θ゚))",
- "((o^_^o) +(o^_^o))",
- "((゚ー゚) + (o^_^o))",
- "((゚ー゚) + (゚ー゚))",
- "((゚ー゚) + (゚ー゚) + (゚Θ゚))",
- "(゚Д゚) .゚ω゚ノ",
- "(゚Д゚) .゚Θ゚ノ",
- "(゚Д゚) ['c']",
- "(゚Д゚) .゚ー゚ノ",
- "(゚Д゚) .゚Д゚ノ",
- "(゚Д゚) [゚Θ゚]"
- ];
- function charCodeAt($str, $index)
- {
- $char = mb_substr($str, $index, 1, 'UTF-8');
- if (mb_check_encoding($char, 'UTF-8'))
- {
- $ret = mb_convert_encoding($char, 'UTF-32BE', 'UTF-8');
- return hexdec(bin2hex($ret));
- }
- else
- {
- return null;
- }
- }
-
- function uchr ($codes) {
- if (is_scalar($codes)) $codes= func_get_args();
- $str= '';
- foreach ($codes as $code){
- $buf = html_entity_decode('&#'.$code.';',ENT_NOQUOTES,'UTF-8');
- $buf == '&#'.$code.';' && ($buf = mb_convert_encoding('&#' . intval($code) . ';', 'UTF-8', 'HTML-ENTITIES'));
- $str.= $buf;
- }
- return $str;
- }
-
-
- function aaencode($text)
- {
- global $b;
-
- $r = "゚ω゚ノ= /`m´)ノ ~┻━┻ //*´∇`*/ ['_']; o=(゚ー゚) =_=3; c=(゚Θ゚) =(゚ー゚)-(゚ー゚); ";
- if(preg_match('/ひだまりスケッチ×(365|356)\s*来週も見てくださいね[!!]/', $text)){
- $r .= "X=_=3; ";
- $r .= "\r\n\r\n X / _ / X < "来週も見てくださいね!";\r\n\r\n";
- }
-
- $r .= "(゚Д゚) =(゚Θ゚)= (o^_^o)/ (o^_^o);".
- "(゚Д゚)={゚Θ゚: '_' ,゚ω゚ノ : ((゚ω゚ノ==3) +'_') [゚Θ゚] ".
- ",゚ー゚ノ :(゚ω゚ノ+ '_')[o^_^o -(゚Θ゚)] ".
- ",゚Д゚ノ:((゚ー゚==3) +'_')[゚ー゚] }; (゚Д゚) [゚Θ゚] =((゚ω゚ノ==3) +'_') [c^_^o];".
- "(゚Д゚) ['c'] = ((゚Д゚)+'_') [ (゚ー゚)+(゚ー゚)-(゚Θ゚) ];".
- "(゚Д゚) ['o'] = ((゚Д゚)+'_') [゚Θ゚];".
- "(゚o゚)=(゚Д゚) ['c']+(゚Д゚) ['o']+(゚ω゚ノ +'_')[゚Θ゚]+ ((゚ω゚ノ==3) +'_') [゚ー゚] + ".
- "((゚Д゚) +'_') [(゚ー゚)+(゚ー゚)]+ ((゚ー゚==3) +'_') [゚Θ゚]+".
- "((゚ー゚==3) +'_') [(゚ー゚) - (゚Θ゚)]+(゚Д゚) ['c']+".
- "((゚Д゚)+'_') [(゚ー゚)+(゚ー゚)]+ (゚Д゚) ['o']+".
- "((゚ー゚==3) +'_') [゚Θ゚];(゚Д゚) ['_'] =(o^_^o) [゚o゚] [゚o゚];".
- "(゚ε゚)=((゚ー゚==3) +'_') [゚Θ゚]+ (゚Д゚) .゚Д゚ノ+".
- "((゚Д゚)+'_') [(゚ー゚) + (゚ー゚)]+((゚ー゚==3) +'_') [o^_^o -゚Θ゚]+".
- "((゚ー゚==3) +'_') [゚Θ゚]+ (゚ω゚ノ +'_') [゚Θ゚]; ".
- "(゚ー゚)+=(゚Θ゚); (゚Д゚)[゚ε゚]='\\\\'; ".
- "(゚Д゚).゚Θ゚ノ=(゚Д゚+ ゚ー゚)[o^_^o -(゚Θ゚)];".
- "(o゚ー゚o)=(゚ω゚ノ +'_')[c^_^o];".
- "(゚Д゚) [゚o゚]='\\"';".
- "(゚Д゚) ['_'] ( (゚Д゚) ['_'] (゚ε゚+";
- $r .= "(゚Д゚)[゚o゚]+ ";
-
- for( $i = 0; $i < mb_strlen($text); $i++ ){
- $n = charCodeAt($text,$i);
- $t = "(゚Д゚)[゚ε゚]+";
- if( $n <= 127 ){
- $t .= preg_replace_callback('/[0-7]/', function($c)use ($b){
- return $b[$c[0]]."+ ";
- }, ((string)decoct($n)));
- }else{
- if(preg_match('/[0-9a-f]{4}$/', '000'.((string)dechex($n)),$result)){
- $m = $result[0];
- }else{
- $m = '';
- }
- $t .= "(o゚ー゚o)+ " . preg_replace_callback('/[0-9a-f]/i',function($c)use ($b){
- return $b[ hexdec($c[0]) ] . "+ ";
- },$m);
- }
- $r .= $t;
- }
- $r .= "(゚Д゚)[゚o゚]) (゚Θ゚)) ('_');";
- return $r;
- }
-
-
- function aadecode($text){
- global $b;
- $text = strtr($text, ["(゚Д゚)[゚o゚]) (゚Θ゚)) ('_');" => '']);
-
- for($i=0;$i<count($b);$i++){
- $buf = $b[$i];
-
- if($i <=7){
- //8进制逆向
- $str = (($i));
- $text = strtr($text, [$buf."+ "=>$str]);
- }else{
- //16进制逆向
- $text = strtr($text, [$buf."+ " => dechex($i)]);
- }
-
- }
-
- $text = preg_replace_callback('/\(゚Д゚\)\[゚ε゚\]\+(\d+)/', function($c){
- return uchr(octdec($c[1]));
- }, $text);
- $text = preg_replace_callback('/\(゚Д゚\)\[゚ε゚\]\+\(o゚ー゚o\)\+\s+([0-9a-f]{4})/', function($c){
- return uchr(hexdec($c[1]));
- }, $text);
-
- $pre = [
- "゚ω゚ノ= /`m´)ノ ~┻━┻ //*´∇`*/ ['_']; o=(゚ー゚) =_=3; c=(゚Θ゚) =(゚ー゚)-(゚ー゚); ",
- "X=_=3; ",
- "\r\n\r\n X / _ / X < "来週も見てくださいね!";\r\n\r\n",
- "(゚Д゚) =(゚Θ゚)= (o^_^o)/ (o^_^o);",
- "(゚Д゚)={゚Θ゚: '_' ,゚ω゚ノ : ((゚ω゚ノ==3) +'_') [゚Θ゚] ",
- ",゚ー゚ノ :(゚ω゚ノ+ '_')[o^_^o -(゚Θ゚)] ",
- ",゚Д゚ノ:((゚ー゚==3) +'_')[゚ー゚] }; (゚Д゚) [゚Θ゚] =((゚ω゚ノ==3) +'_') [c^_^o];",
- "(゚Д゚) ['c'] = ((゚Д゚)+'_') [ (゚ー゚)+(゚ー゚)-(゚Θ゚) ];",
- "(゚Д゚) ['o'] = ((゚Д゚)+'_') [゚Θ゚];",
- "(゚o゚)=(゚Д゚) ['c']+(゚Д゚) ['o']+(゚ω゚ノ +'_')[゚Θ゚]+ ((゚ω゚ノ==3) +'_') [゚ー゚] + ",
- "((゚Д゚) +'_') [(゚ー゚)+(゚ー゚)]+ ((゚ー゚==3) +'_') [゚Θ゚]+",
- "((゚ー゚==3) +'_') [(゚ー゚) - (゚Θ゚)]+(゚Д゚) ['c']+",
- "((゚Д゚)+'_') [(゚ー゚)+(゚ー゚)]+ (゚Д゚) ['o']+",
- "((゚ー゚==3) +'_') [゚Θ゚];(゚Д゚) ['_'] =(o^_^o) [゚o゚] [゚o゚];",
- "(゚ε゚)=((゚ー゚==3) +'_') [゚Θ゚]+ (゚Д゚) .゚Д゚ノ+",
- "((゚Д゚)+'_') [(゚ー゚) + (゚ー゚)]+((゚ー゚==3) +'_') [o^_^o -゚Θ゚]+",
- "((゚ー゚==3) +'_') [゚Θ゚]+ (゚ω゚ノ +'_') [゚Θ゚]; ",
- "(゚ー゚)+=(゚Θ゚); (゚Д゚)[゚ε゚]='\\\\'; ",
- "(゚Д゚).゚Θ゚ノ=(゚Д゚+ ゚ー゚)[o^_^o -(゚Θ゚)];",
- "(o゚ー゚o)=(゚ω゚ノ +'_')[c^_^o];",
- "(゚Д゚) [゚o゚]='\\"';",
- "(゚Д゚) ['_'] ( (゚Д゚) ['_'] (゚ε゚+",
- "(゚Д゚)[゚o゚]+ ",
- ];
- $rA = [];
- foreach($pre as $val){
- $rA[$val] = '';
- }
- $text = strtr($text,$rA);
- return $text;
- }
- ?>
复制代码 然后调用方法:
- include_once 'AAEnDeCode.php';
-
- if($_POST['type']=="Encode")
- {
- echo aaencode($_POST['inputstr']);
- }
- if($_POST['type']=='Decode')
- {
- echo aadecode($_POST['inputstr']);
- }
复制代码
前台通过一个 标签,通过ajax 提交
- function SubmitForm(type)
- {
- $.ajax({
- type: "POST",
- url: "Submit.php",
- data: {type:type, inputstr:$("#Source").val()},
- dataType: "text",
- success: function(data)
- {
- $("#Source").val(data);
- }
- });
- }
复制代码 html 代码: 注意引入 [color=rgb(78, 161, 219) !important]jquery-1.8.0.min.js 库
- <form id="EncodeForm" >
- <div style="margin:0;">
- <h3>AAEncode加密解密 离线使用-支持中文汉字</h3>
- <textarea id="Source" style="width:100%;height:550px"></textarea>
- <div class="buttondiv">
- <input type="button" value="加密" onclick='SubmitForm("Encode")' /><input type="button" value="解密" onclick='SubmitForm("Decode")' />
- </div>
- </div>
- </form>
复制代码 实现:本地环境 http://localhost
点击加密:
然后点击解密,恢复明文:
O 了 , 然后就可以 http://localhost 跑脚本了。不怕没有网络。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|