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.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
.htaccess rewrite for security
Old 02-22-2009, 04:29 PM .htaccess rewrite for security
MZA
Experienced Talker

Posts: 47
Trades: 0
I run a forum and am having trouble with shells being uploaded to the server (I'm on a shared server). My host is no help so I've been trying to come up with a solution on my own. I am trying to add conditions to my .htaccess file to redirect the URL whenever someone tries to access a shell on my server. Since the name of the php file changes just about every time, I can't figure out how to do it successfully.

I would like to redirect any URL containing the following:
".php?act=f&f=config.php&d=%2Fhome%2Fusername%2Fpu blic_html&"
to my site's home page, so they won't be able to get my DB info (I plan to add lines for more commands after I get this one working as well).

I am completely new to .htaccess and have read several guides on all different methods, but I have been unable to get any of them to work, does anyone have any suggestions?

Thanks
MZA is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-28-2009, 03:26 PM Re: .htaccess rewrite for security
MZA
Experienced Talker

Posts: 47
Trades: 0
Come on, somebody has to know how to do this...
MZA is offline
Reply With Quote
View Public Profile
 
Old 02-28-2009, 04:31 PM Re: .htaccess rewrite for security
Novice Talker

Posts: 12
Trades: 0
i'm not sure i understand -- you're saying people are illegally accessing your shell from outside?
jenniec is offline
Reply With Quote
View Public Profile Visit jenniec's homepage!
 
Old 03-01-2009, 01:30 AM Re: .htaccess rewrite for security
Average Talker

Posts: 29
Trades: 0
You could add the following to your .htaccess file in your document root.

# Set the default handler.
DirectoryIndex index.php
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Protect files from prying eyes.
<FilesMatch "(\.inc|\.sh|.*sql|config\.php)$">
Order allow,deny
</FilesMatch>

ErrorDocument 403 /index.php
ErrorDocument 404 /index.php


You could put a .htaccess file in the directory that contains config.php that says "deny all". Provided that it is not in your document root directory.

The above only works for http traffic and not shell access or ftp

If they are accessing from someplace else - shell access or ftp, the server is not secure and you might want to get another shared hosting company.

Last edited by noobster; 03-01-2009 at 01:35 AM..
noobster is offline
Reply With Quote
View Public Profile
 
Old 03-02-2009, 04:28 AM Re: .htaccess rewrite for security
MZA
Experienced Talker

Posts: 47
Trades: 0
Quote:
Originally Posted by noobster View Post
You could add the following to your .htaccess file in your document root.

# Set the default handler.
DirectoryIndex index.php
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Protect files from prying eyes.
<FilesMatch "(\.inc|\.sh|.*sql|config\.php)$">
Order allow,deny
</FilesMatch>

ErrorDocument 403 /index.php
ErrorDocument 404 /index.php


You could put a .htaccess file in the directory that contains config.php that says "deny all". Provided that it is not in your document root directory.

The above only works for http traffic and not shell access or ftp

If they are accessing from someplace else - shell access or ftp, the server is not secure and you might want to get another shared hosting company.
Thanks so much, I will test this out. And yes, they were accessing from http so this should do the job. And the config.php happens to be in the document root

EDIT: I added that and it's not working, I can still view my config file from the shell

Last edited by MZA; 03-02-2009 at 05:19 AM..
MZA is offline
Reply With Quote
View Public Profile
 
Old 03-03-2009, 12:46 AM Re: .htaccess rewrite for security
Average Talker

Posts: 29
Trades: 0
What shell are you using? Did you type in domain.com/config.php?
noobster is offline
Reply With Quote
View Public Profile
 
Old 03-10-2009, 05:33 PM Re: .htaccess rewrite for security
MZA
Experienced Talker

Posts: 47
Trades: 0
Quote:
Originally Posted by noobster View Post
What shell are you using? Did you type in domain.com/config.php?
I am testing with a C99 shell that I removed the last time they hacked us. And no, I didn't try accessing the file directly from my browser, as my forum software already prevents that and that's not what I'm worried about.

A little more clarification:
The person uploads a shell on my server without my permission (my host isn't much help in preventing this), lets say the filename is shell.php. Then they run the shell from their browser http://mysite.com/shell.php which gives them several options to modify and view things that they shouldn't be. My main concern is protecting my database, whose information is stored in my config file. When they view the config file from the shell, the URL is something like this: http://mysite.com/shell.php?mode=edit&file=config.php&.....

I want .htaccess look for that string "config.php" in all URLs and redirect any URLs containing that string to another page
MZA is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to .htaccess rewrite for security
 

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.26141 seconds with 12 queries