Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Extensions executing code when they shouldn't
Old 05-25-2008, 05:23 PM Extensions executing code when they shouldn't
Skilled Talker

Posts: 99
Trades: 0
I only allow certain extensions for my upload script (rar, zip, exe, dll, ini). But... someone decided to upload something called "blah.php.ini", and promptly owned my entire website.

If I only allow rar, zip, and exe, will that solve my problem? Why is it executing code even though the ini extension is on the end? Is there anything I can do with htaccess?
Arez20469 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-25-2008, 06:14 PM Re: Extensions executing code when they shouldn't
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
Only allowing certain file names may not always fix the problem (But is a good start), take a look at php.net's manual on this ( http://uk.php.net/manual/en/features.file-upload.php ).

Here are a few tips:
Make sure you confirm it is what they say (Can be done using $_FILES['userfile']['type']).

Encode the file (base64 will do) and store it somewhere where it cannot be accessed via http (I know about these types of scripts, it's a lot harder for them to work if you hide the file/make it useless).

If something does go wrong code wise (say a file was uploaded but is not there), note the IP and block it temporally, and alert a server guy.

It's most likely they done a using that blah.php.ini file, but there was an executor file also. For example say I uploaded a nasty file, then had another file run it.

Hope this helps (Sorry if it's a bit confusing, my English is currently not too good)
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 05-25-2008, 08:38 PM Re: Extensions executing code when they shouldn't
Skilled Talker

Posts: 99
Trades: 0
Yeah, guess I'll have to do more research.
Arez20469 is offline
Reply With Quote
View Public Profile
 
Old 05-26-2008, 09:49 AM Re: Extensions executing code when they shouldn't
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
A good technique is to allow only certain users to upload, like only let users who have earned it to use it.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 05-26-2008, 10:16 PM Re: Extensions executing code when they shouldn't
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Also you can prevent uploaded files from being accessed by uploading from the domain root before the public html root
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Extensions executing code when they shouldn't
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14742 seconds with 12 queries