题目链接-攻防世界-web2
知识考察:PHP代码审计、逆向加解密

解题思路

先搞清楚各个PHP函数的含义

<?php
$miwen="a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws";//密文

function encode($str){
    $_o=strrev($str);//strrev反转字符串
    // echo $_o;
        
    for($_0=0;$_0<strlen($_o);$_0++){
       
        $_c=substr($_o,$_0,1);
        $__=ord($_c)+1;//ord函数返回字符串中第一个字符的 ASCII 值
        $_c=chr($__);//chr函数从不同 ASCII 值返回字符:
        $_=$_.$_c;   
    } 
    return str_rot13(strrev(base64_encode($_)));//str_rot13函数编码解码字符串
}

highlight_file(__FILE__);
/*
   逆向加密算法,解密$miwen就是flag
*/
?>

逆向思维得出解码函数

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

echo decode($miwen);
highlight_file(__FILE__);
?> 

CTF-Web-NSCTF-解密WP

相关文章:

  • 2021-10-20
  • 2022-12-23
  • 2022-01-16
  • 2022-02-11
  • 2022-12-23
  • 2022-01-23
猜你喜欢
  • 2021-12-27
  • 2022-12-23
  • 2021-08-22
  • 2021-08-01
  • 2021-10-04
  • 2021-06-09
  • 2021-08-06
相关资源
相似解决方案