Protecting 777 chmodded folders

All about creating websites!
Post Reply
User avatar
DarkMindZ
On the way to fame!
On the way to fame!
Posts: 28
Joined: 21 Dec 2007, 17:00
16

Protecting 777 chmodded folders

Post by DarkMindZ »

As most of you already know, chmod 777 would give writing / executing rights for everyone `on *nix servers`, it is mostly used in upload scripts / galleries / logs..

Well, you can protect that folder, from being used as a lab for Mr Hacker..

Simple way of doing it is, using a .htaccess, and turning the PHP engine off on that folder and disallowing html / pl / php files.. here is how:

Create a new file, called .htaccess, in it:


php_flag engine off
<Files ~ "\.(php*|s?p?html|cgi|pl)$">
deny from all
</Files>





that's it, now the `hacker` cannot use this folder as a place for PHP shells / scripts or backdooring tools `mostly are perl scripts`...

User avatar
n3rd
Staff Member
Staff Member
Posts: 1474
Joined: 15 Nov 2005, 17:00
18
Location: my own perfect world in ma head :)
Contact:

Post by n3rd »

U might want to add your own IP incase you are using a CMS. otherwise no 1 can write in em.
[img]http://img580.imageshack.us/img580/8009/userbar2k.png[/img]

User avatar
Big-E
Administrator
Administrator
Posts: 1332
Joined: 16 May 2007, 16:00
16
Location: IN UR ____ , ____ING UR _____ .
Contact:

Post by Big-E »

Good informational post and if I have not done so thus far, welcome to the boards!

rhysh
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 767
Joined: 15 Nov 2006, 17:00
17
Contact:

Post by rhysh »

yes but wat will you add to allow files like index.php

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Post by bad_brain »

good one...additionally setting the sticky bit for the directory permissions would also be good, the sticky bit allows only the owner of the files in the directory (or the root user) to rename/delete them.

http://en.wikipedia.org/wiki/Sticky_bit

:wink:

rhysh
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 767
Joined: 15 Nov 2006, 17:00
17
Contact:

Post by rhysh »

but what canyou put in an .htaccess to make it so only files like
index.php and lol.php and a.html etc can be viewed

User avatar
n3rd
Staff Member
Staff Member
Posts: 1474
Joined: 15 Nov 2005, 17:00
18
Location: my own perfect world in ma head :)
Contact:

Post by n3rd »

ht access is only to deny modification to those pages from a remote location.
it can still be viewed.

taken from wikipedia:

.htaccess files are often used to specify the security restrictions for the particular directory,
Last edited by n3rd on 04 Jan 2008, 09:13, edited 1 time in total.
[img]http://img580.imageshack.us/img580/8009/userbar2k.png[/img]

User avatar
DarkMindZ
On the way to fame!
On the way to fame!
Posts: 28
Joined: 21 Dec 2007, 17:00
16

Post by DarkMindZ »

this htaccess

stops PHP in that dir, means the attacker cant use it as his shell-lab.

and it stops access from remote to html, perl,. and php files

what do you need more? ;s

rhysh
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 767
Joined: 15 Nov 2006, 17:00
17
Contact:

Post by rhysh »

wats say i want it in /http_docs/
that would be my main dir
but i have
index.php
and a shell is placed there called c99.php .pl .jav
i only want index.php to execute not c99.php or c99.pl etc
well?

User avatar
DarkMindZ
On the way to fame!
On the way to fame!
Posts: 28
Joined: 21 Dec 2007, 17:00
16

Post by DarkMindZ »

well then you wil need to mod that for your needs.

this is made to fully protect the dir and all the contents.

so lookup some .htaccess usage.

Post Reply