未加星标

Hacking Wordpress 4.7.0-1

字体大小 | |
[开发(php) 所属分类 开发(php) | 发布者 店小二04 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

The guys from sucuri have recently published a blog post with details of a WordPress vulnerability which allows an unauthenticated attacker to easily edit any blog post of their liking by abusing a bug in the WordPress REST API. I am not going to write about the details of the vulnerability because that has been discussed in the original blog post as mentioned. Instead, I will show you how to easily exploit this issue by using our Rest tool.

Let's setup a quick test environment for this exercise. We will use docker compose in order to quickly spin it up. Create a docker-compose.yml file with the following contents:

version: '2' services: wordpress: image: wordpress:4.7.0 ports: - 8080:80 environment: WORDPRESS_DB_PASSWORD: example entrypoint: - /bin/sh - -c - (sleep 5; echo "define('WP_AUTO_UPDATE_CORE', false);" >> /var/www/html/wp-config.php) & docker-entrypoint.sh apache2-foreground mysql: image: mariadb environment: MYSQL_ROOT_PASSWORD: example

This is pretty standard. The only thing that sort of stands out is that instead of running the default Dockerfile ENTRYPOINT we use our own which injects the wp-config.php file with a constant to prevent WordPress from auto-updating itself mid-testing. The exploit will not work in 4.7.2 so we need this to get the environment in the right state.

Once you are happy with everything just run the following command to bootstrap the database and WordPress.

$ docker-compose up --force-recreate; docker-compose down -v

Before we move on you will also have to configure WordPress with some credentials. Visit the application url which is most likely available on localhost:8080 or in case you are using Mac OS X it will be $(docker-machine ip):8080 . Go through the setup process. If you want you can even create a couple of blog posts. There is a default blog post with id of 1 which we will override with the following exploit.


Hacking Wordpress 4.7.0-1

The exploit is relatively straightforward but I will take you step by step how to set it up on Rest . First, let's open Rest and setup some variables which we will use to control the base URL and the number of the blog post we want to change. This is done like this.


Hacking Wordpress 4.7.0-1

Now we need to configure the URL. According to the exploit details we need to encode the post id in the URL. In fact, this step is not necessery and we can supply an arbitrary value but I am going to do it anyway to show how powerful the variable substituation feature really is. Notice how we use both variables to build dynamically the URL.


Hacking Wordpress 4.7.0-1

The next step is to actually override the post id using the trick which actually bypasses the authorisation controls in the WordPress REST API. We need to define a query parameter which takes the post id and pads it with the value abc .


Hacking Wordpress 4.7.0-1

The next step is to build the payload. We need to change the method from GET to POST and setup the content type of the request to JSON. This is straightforward as shown in the screenshot bellow.


Hacking Wordpress 4.7.0-1

We are almost there. The last step is to build the actual JSON payload. Switch to the Body tab and select the text/plain body type. We need to create a simple JSON payload that should look like this:

{ "content": "The content that you want to appear instead of the original post." }

This is enough for the test but we will make it slightly more interesting by building the payload dynamically which will allow us greater control over the exploitation process in case we change our mind and we want to do something more advance. Let's setup another variable which we will call post_content, which will hold the new content.


Hacking Wordpress 4.7.0-1

Now let's build everything dynamically inside the body. We will use the JSON encoding gadget to make it perfect.


Hacking Wordpress 4.7.0-1

Notice how cool this setup is! The exploit is ready so let's test it.


Hacking Wordpress 4.7.0-1

Mission accomplished. Because our setup is fully dynamic we now have full flexibility to do whatever we want without the need to worry how the final request is generated. Remember - everything is dynamic. So let's now properly deface the blog by making a nice ASCII art defacement page and upload it.


Hacking Wordpress 4.7.0-1

And the final result looks like this.


Hacking Wordpress 4.7.0-1

There you go! In this post we managed to own WordPress 4.7.0 and 4.7.1 with a single request and a fully customisable payload - all of this without touching any broken python, perl or ruby scripts and running with the full backing and network capabilities of Google Chrome and Mozilla Firefox. This is exactly how I like my hacks to be.

Follow us on twitter for more ASCII madness.

本文开发(php)相关术语:php代码审计工具 php开发工程师 移动开发者大会 移动互联网开发 web开发工程师 软件开发流程 软件开发工程师

主题: RESTWordDockerSQLChromeAUTUTAURYFirefox
分页:12
转载请注明
本文标题:Hacking Wordpress 4.7.0-1
本站链接:http://www.codesec.net/view/533555.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 开发(php) | 评论(0) | 阅读(27)