Current location: Hot Scripts Forums » Programming Languages » PHP » Blocking unless the server wants it

Blocking unless the server wants it

Reply
  #1 (permalink)  
Old 06-25-09, 12:38 PM
smithygotlost smithygotlost is offline
Coding Addict
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 345
Thanks: 7
Thanked 0 Times in 0 Posts
Blocking unless the server wants it

Heya guys

is there anyways atall to block access to things like mysql access unless its from my server ip ? as we had problem with someone getting out database connect and including it in their own site to insert raw data... just need to find someway of stopping things being inserted that arnt ment to be, any hints tips or advice will be greatfully appreciated

Thanks
MIke
__________________
Make People Friendly Say " Thanks "
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-25-09, 12:48 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 7,535
Thanks: 5
Thanked 17 Times in 16 Posts
Usually remote access can be disabled, (and is disabled by default). You might not be able to change that yourself, though. In that case I'd have a word with your hosting provider.

And aren't you using a username/password?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-25-09, 12:51 PM
smithygotlost smithygotlost is offline
Coding Addict
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 345
Thanks: 7
Thanked 0 Times in 0 Posts
well what we got is php pages that include a file called, includes.php inside this it then includes the database connect file, now someone made a page else where on their server and included ourdomain.com/includes/database.php as an example this allowed them to fill our database with anything they wanted

how can i stop this ?
__________________
Make People Friendly Say " Thanks "
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 06-25-09, 01:03 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 7,535
Thanks: 5
Thanked 17 Times in 16 Posts
That's technically impossible.

PHP is being parsed on your server, and there's no way for any user/server to get variable names, let alone values. Unless you tell PHP to output something, they'll just get a blank page.

The only thing that I can think of, is that you're using PHP's short open tags (<?), and the server doesn't have these enabled. So when you include the page in another page on your server, it'll parse the content as expected, but when you call the page remotely, you'll just get the source code.

Suggestion: Use .htaccess to block remote access to the includes folder:
Code:
Deny from all
... save this as ".htaccess" in your includes folder.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 06-25-09, 01:56 PM
smithygotlost smithygotlost is offline
Coding Addict
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 345
Thanks: 7
Thanked 0 Times in 0 Posts
excellent star as always nico

now whats the best way to stop sql injects ??

ive tried things like

Code:
$profile_text = preg_replace('/\'\'/', '\'', $profile_text);
if ($_POST["text"] != ""){
	$new_profile_text = mysql_real_escape_string($_POST["text"]);
ect what else can i use ??

Thanks
Mike
__________________
Make People Friendly Say " Thanks "
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 06-25-09, 02:07 PM
=OTS=G-Man =OTS=G-Man is offline
Newbie Coder
 
Join Date: Jun 2009
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by smithygotlost View Post
excellent star as always nico

now whats the best way to stop sql injects ??

ive tried things like

Code:
$profile_text = preg_replace('/\'\'/', '\'', $profile_text);
if ($_POST["text"] != ""){
	$new_profile_text = mysql_real_escape_string($_POST["text"]);
ect what else can i use ??

Thanks
Mike
That should be good enough, but depending on what your escaping, you can just limit the characters allowed, for example, for the username on my site, i only allows [a-zA-Z0-9] so that stopped any possible use of special chars in the username field
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 06-25-09, 02:39 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 2,832
Thanks: 13
Thanked 10 Times in 9 Posts
Quote:
Originally Posted by =OTS=G-Man View Post
That should be good enough
Trust me, that's nowhere near good enough. Check out the code in this post, it'll do a reasonable job of blocking most exploits:

http://www.programmingtalk.com/showthread.php?t=50793
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data (scroll down)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


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

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
LogicWeb .:. $69 Dedicated Server Specials + Free *DOUBLE* Bundled Upgrades LogicWeb General Advertisements 0 04-16-09 05:34 PM
Status2k PRICE ON HOLD - Server Statistics and Monitoring Script! status2k General Advertisements 0 01-14-09 09:19 AM
[SOLVED] 500 Internal Server Error - Please help Dawn Perl 15 07-08-08 12:08 PM
Free web site, control panel, and dedicated IP with game server purchase for only $25 twastudios General Advertisements 3 10-20-05 07:13 AM
FREE Team Speak server w/ every purchase of a Call of Duty Server twastudios General Advertisements 0 10-31-03 02:14 AM


All times are GMT -5. The time now is 08:08 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.