whitebearcode / typecho-bearsimple

一款简洁大方的Typecho主题

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[建议]拒绝输出部分header头部信息

Sualiu opened this issue · comments

commented

我注意到主题的header头部信息是直接使用的<?php $this->header(); ?>,这是不安全的,因为这会输出许多敏感信息。例如:Typecho版本、Temaple等敏感信息。这对于爬虫来说是很好的餐前甜点。

Typecho的header头部信息方法存放于 /var/Widget/Archive.php

 public function header($rule = NULL)
    {
        $rules = array();
        $allows = array(
            'description'   =>  htmlspecialchars($this->_description),
            'keywords'      =>  htmlspecialchars($this->_keywords),
            'generator'     =>  $this->options->generator,
            'template'      =>  $this->options->theme,
            'pingback'      =>  $this->options->xmlRpcUrl,
            'xmlrpc'        =>  $this->options->xmlRpcUrl . '?rsd',
            'wlw'           =>  $this->options->xmlRpcUrl . '?wlw',
            'rss2'          =>  $this->_feedUrl,
            'rss1'          =>  $this->_feedRssUrl,
            'commentReply'  =>  1,
            'antiSpam'      =>  1,
            'atom'          =>  $this->_feedAtomUrl
        );

官方推荐的更改header信息的方法:https://docs.typecho.org/themes/custom-header-output

也就是将<?php $this->header(); ?>改为<?php $this->header('generator=&template=&pingback=&xmlrpc=&wlw=&atom='); ?>以隐藏这些信息。

该项已在近期要推送的2.2.4版本中进行了优化处理:)