[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 08-21-2007, 01:28 PM   #1 (permalink)
NamePros Regular
 
John84's Avatar
 
Join Date: Apr 2006
Posts: 267
4.50 NP$ (Donate)

John84 is an unknown quantity at this point


Hacker Help

Not sure if this is the correct place to post this. Or even if this is allowed to be posted. If not, please delete this thread.

I found this upload script that is exactly what I was looking for. However, I found that it keeps getting hacked shortly after I put it up. Can someone please tell me what makes this script so easily hacked? Where are the security holes and how can it be fixed? Would a mandatory login function help? I know there are plenty other scripts out there but I really like this one.


Upload Script
John84 is offline  
Old 08-21-2007, 01:46 PM   #2 (permalink)
Traveller
 
-NC-'s Avatar
 
Join Date: Mar 2007
Location: Yet another city
Posts: 1,392
614.57 NP$ (Donate)

-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of-NC- has much to be proud of

Animal Cruelty Animal Rescue Ethan Allen Fund Protect Our Planet
looks to me like you are allowing upload of .php files.

you should probably restrict upload of all executable files e.g. .php,.asp
i'm not familiar with this particular script, but they usually have a config file which sets file extensions to block.

edit:
having looked at this script, it appears to have no built in way to restrict the file types. ideally for security, i would recommend the script is modified to:

- upload files to a directory out of the webroot
- download files via a php file which pushes the file to the user's browser (no direct access to the file)
- block any file extensions you specify

None of these things are particularly complicated, maybe the script creator would do them if asked nicely?

Last edited by -NC-; 08-21-2007 at 02:12 PM.
-NC- is offline  
Old 08-21-2007, 02:15 PM   #3 (permalink)
cef
NamePros Regular
 
Join Date: May 2004
Location: NYC
Posts: 236
76.50 NP$ (Donate)

cef is a jewel in the roughcef is a jewel in the roughcef is a jewel in the rough

Animal Rescue
In addition to checking the extension as -NC- says, I also run the uploaded files through the "file" command, which takes further steps to verify the file type beyond merely looking at the extension:

file -b <filename>

This prints out something like "PHP script text" for a php script, even if it has an image extension (like .gif or .jpg). For a gif image, the command might print out something like "GIF image data, version 89a, 10 x 81", regardless of the file extension.
cef is offline  
Old 08-21-2007, 03:10 PM   #4 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
Quote:
Originally Posted by cef
In addition to checking the extension as -NC- says, I also run the uploaded files through the "file" command, which takes further steps to verify the file type beyond merely looking at the extension:

file -b <filename>

This prints out something like "PHP script text" for a php script, even if it has an image extension (like .gif or .jpg). For a gif image, the command might print out something like "GIF image data, version 89a, 10 x 81", regardless of the file extension.
Doesn't *always* work, I was able to fool it.

But yes, it'd be a good idea to have the script restrict file types/extensions.
__________________
Eric is offline  
Old 08-21-2007, 03:13 PM   #5 (permalink)
cef
NamePros Regular
 
Join Date: May 2004
Location: NYC
Posts: 236
76.50 NP$ (Donate)

cef is a jewel in the roughcef is a jewel in the roughcef is a jewel in the rough

Animal Rescue
True, and you can put a payload in gif file headers as well. But the combination of extension + type check is effective 99% of the time.

And as mentioned, it's only part of a complete solution.
cef is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 04:18 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85