Image
 
linkedin_logo.png rss_logo.jpg
twitter_logo.png youtube_logo.jpg
Latest Additions
 
EH-Net Login
Welcome Guest.






Lost Password?
No account yet? Register
Who's Online
We have 61 guests online
 
Advertisement

You are here: Home arrow Ethical Hacking Discussions and Related Certificationsarrow Web Applicationsarrow PHP in GIF file.
EH-Net
May 25, 2013, 01:00:33 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Go back to The Ethical Hacker Network Online Magazine Home Page
 
   Home   Help Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: PHP in GIF file.  (Read 6021 times)
0 Members and 1 Guest are viewing this topic.
jonas
Newbie
*
Offline Offline

Posts: 46


View Profile
« on: July 25, 2011, 08:06:49 AM »

Hi again.  I'm trying out the exploit http://www.exploit-db.com/exploits/16181/.
I made a PHP payload in meterpreter (which works) and want to upload it to my wordpress site using the vuln described in exploit-db.

I edited the file header with the hex code provided in the exploit provided as so:


Then I'm using Webscarab to intercept the POST command and edit the content-type to "image/gif".  The file im uploading is ofcourse .php file.
The upload is somewhat successful as i don't get the usual error message telling me its the wrong filetype:



However, when checking my directory there are no files being uploaded.
Does anyone know the reason for this?  I don't think its the filesize as my payload (php) is 1.28K.  Did i miss someting?

Im thinking im missing some size definition of my picture maybe?
« Last Edit: July 25, 2011, 08:25:06 AM by jonas » Logged
j0rDy
Hero Member
*****
Offline Offline

Posts: 590


View Profile
« Reply #1 on: July 25, 2011, 11:44:54 AM »

whats the full name of the file that you try to upload? it may be possible the application does not accept .php files (even with modified content-type). try something like evil.php.gif or evil.php%00.gif...good luck!
Logged

ISC2 Associate, CEH, ECSA, OSCP, OSWP

earning my stripes appears to be a road i must travel alone...with a little help of EH.net
jonas
Newbie
*
Offline Offline

Posts: 46


View Profile
« Reply #2 on: July 25, 2011, 12:47:08 PM »

Hi again.

i just tested renaming the file to gif and it works.  So there is something wrong with my content type change i guess.
« Last Edit: July 25, 2011, 01:00:27 PM by jonas » Logged
hell_razor
Jr. Member
**
Offline Offline

Posts: 90


View Profile
« Reply #3 on: July 25, 2011, 12:58:22 PM »

Why not download a file that is already appropriate (read an avatar or whatnot) and open it in a hex editor and still the header portion?
Logged

A+, Network+, Server+, CISSP, GSEC, GCIH, GPEN, GCIA, GISP, GCFW
MaXe
Hero Member
*****
Offline Offline

Posts: 669


I've just upgraded myself to a cyborg muahahaa!!1


View Profile WWW
« Reply #4 on: July 25, 2011, 01:10:38 PM »

If all of the files you upload, are not stored on the webserver, then you need to make that directory writeable, and possibly also check who's the owner of that directory if you're on Linux. (It's quite important if you don't run Apache workers as root, which wouldn't be very smart to do hehe  Wink )

As the others said, to execute a GIF file as PHP, you would need to have one of the following conditions in order: (This is just a few examples, not a complete list.)
1) Be able to upload a file like image.gif.php (or for that sake image.php%00.gif)
2) Include the GIF file, in a PHP script which evaluates the code (often include() or require() is vulnerable.). In this case, the file extension can be image.gif without any extra .php or similar extensions after .gif
3) Force "php" on the target to execute your image.gif file as a php script. (Unlikely, because if you control "php" on the target, you probably got shell access already.)
Logged

I'm an InterN0T'er
jonas
Newbie
*
Offline Offline

Posts: 46


View Profile
« Reply #5 on: July 25, 2011, 01:46:23 PM »

1. I am allowed to upload .jpg/.gif etc to that folder as it is a profile picture plugin, and with regular pictures it works.  The files appear in the folder.
2. If i try upload anything else i get an error saying its the wrong format.
3. If i change the content header in the media stream upon upload (file extension is .PHP) it say that the picture was uploaded and awaiting for confirmation. Which probably means that it passed the "extension" check and all should be good. However, the file is not there.
4. I uploaded a jpg pic now, downloaded the processed picture and added my shell code to the end of it.  Using the content header i can upload it no problems.
Although it does not end up in the directory.

If you read the exploit description this upload method should work.  BUT i am doing somethig wrong ofcourse since its not working...

THANKS for all the input so far!
Logged
tturner
Sr. Member
****
Offline Offline

Posts: 432


View Profile WWW
« Reply #6 on: July 25, 2011, 02:21:32 PM »

Is there a reason you think the existing Wordpress install is a vulnerable version? That sploit is 5 months old and may have been patched...
Logged

Certifications:
CISSP, CISA, GPEN, GWAPT, GAWN, GCIA, GCIH, GSEC, OPSE, CSWAE, CSTP, VCP

WIP: OSWP, GSSP-JAVA, GXPN

Udacity on hold, again. I suck.

http://sentinel24.com/blog  @tonylturner http://bsidesorlando.org
MaXe
Hero Member
*****
Offline Offline

Posts: 669


I've just upgraded myself to a cyborg muahahaa!!1


View Profile WWW
« Reply #7 on: July 25, 2011, 03:45:06 PM »

As tturner was referring to below, have you installed the plugin / extension as well? ( http://wordpress.org/extend/plugins/user-photo/ ), and of course, the vulnerable version? I know it's a stupid question, but you won't be able to exploit a patched version. (Naturally, I just want to confirm.)

Is there a reason you think the existing Wordpress install is a vulnerable version? That sploit is 5 months old and may have been patched...


So, your exploit should work, if you run the right / same versions as the researcher did. Because the exploit is verified, so it's guaranteed to work, on vulnerable versions that is. So make sure you grab the vulnerable version in case you haven't, and retry everything in the proof of concept.

I don't have that much more comments, except that you should of course be doing this on your own server, so you can easily see what happens, but one thing you should be aware of, are errors ment to be in PoC's. I can't see any obvious ones in this, but potentially it could be there. (To prevent common abuse.)  Wink
Logged

I'm an InterN0T'er
jonas
Newbie
*
Offline Offline

Posts: 46


View Profile
« Reply #8 on: July 26, 2011, 04:54:44 AM »

I appreciate the level of confidence being shown in regards to my intellect! Cheesy
The screenshot posted is the plugin functionality, and im using the plugin version specified in the exploit tturner.  I can't see where i have specified using the newest plugin version, as this obviously would be patched.

I will be trying some more and update if i find a solution.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!
Page created in 0.087 seconds with 23 queries.
 
Exclusive Deal

sansfire13_245x90_cw90.jpg
SANSFIRE 2013
June 15 - 22

5% Off w/ Code: EHN_5

SANS Deals 4 EH-Netters
5% OFF Any SANS Course in Any Format!
Coupon Code: EHN_5 Including SANS Rocky Mountain 2013 & SANS Boston 2013
Polls
Compared to this year, 2013 will be:
 
Recent Forum Topics
EH-Net News Feeds
Latest Additions
 
         
Free Business and Tech Magazines and eBooks

© 2013 The Ethical Hacker Network
Joomla! is Free Software released under the GNU/GPL License.