攻防世界web2

题目

web2
解密

解题思路

打开题目,就是一段源码:


$miwen="a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws";

function encode($str){
    $_o=strrev($str);
    // echo $_o;
        
    for($_0=0;$_0<strlen($_o);$_0++){
       
        $_c=substr($_o,$_0,1);
        $__=ord($_c)+1;
        $_c=chr($__);
        $_=$_.$_c;   
    } 
    return str_rot13(strrev(base64_encode($_)));
}

highlight_file(__FILE__);

题目告诉我们解密$miwen之后就是flag,根据encode函数写出decode函数即可。


$miwen="a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws";

function decode($miwen) {
	$_ = base64_decode(strrev(str_rot13($miwen)));
	$idx = strlen($_) - 1;
	$_o = '';
	while ($idx >= 0) {
		$_c = $_[$idx];
		$__ = ord($_c);
		$_c = chr($__ - 1);
		$_o = $_o . $_c;
		$idx--;
	}
	return $_o;
}

echo decode($miwen);
// flag:{NSCTF_b73d5adfb819c64603d7237fa0d52977}

你可能感兴趣的:(CTF,CTF,加密)