Jump to content
MakeWebGames

A way to protect against sql injection


stryker

Recommended Posts

put this

 

$_POST['urpostinfo']=str_replace('\\\'',''', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('refresh','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('meta','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('redirect','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('html','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('query','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('UPDATE','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('SET','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('style','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('img','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('dynsrc','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('bg','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('background','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('.','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('title','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('embed','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('printf','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('xxs','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('script','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('javascript','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('body','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('onload','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('load','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('div','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('frame','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('FRAME SRC','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('md5','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('FRAMESET','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('db','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace('query','', $_POST['urpostinfo']);
$_POST['urpostinfo']=str_replace(array("<", ">", "\\\'"), array("<", ">", "'"), $_POST['urpostinfo']);
$post=str_replace(array("<",">","'"),array("<",">","''"),$_POST['urpostinfo']);

before your post statments and after your get statements, you only need this where there is an area to type into.

Link to comment
Share on other sites

Re: A way to protect against sql injection

not taking credit...just sharing. might be helpful to those whom have no clue, i sure as hell ain't sharing mine last thing i need is my sql injection preventer posted on every warez and security board online...

Link to comment
Share on other sites

Re: A way to protect against sql injection

Yup that has nothing to do with it...

BTW it would save you lots of time if you just did array();

or

$r="table name";

$_POST[$r]=str_replace(blahblah);

to save people time from editing.

Functions tend to save more time and easier to make more edits to.

But by the way...It's nothing to do with SQL Injections..

I don't see anything to do with DB there lol.

Link to comment
Share on other sites

Re: A way to protect against sql injection

actually if you would look close you would see that yes it is, it blocks ppl from using the text fields to enter whatever they want. thus exploiting the system, sql injection is not only done through the address bar.

Link to comment
Share on other sites

Re: A way to protect against sql injection

actually magic quotes should be off, it says is mccode that it needs to be on thats a bunch of bull.

here is what i use on my game

/*+++++++++++++++++++++++++++++++++++++*/
/*            Mod Start                */
/*Mod By Twysted of Dynamic-Designz.com*/
/*+++++++++++++++++++++++++++++++++++++*/
//check if incomingData is not empty and of the expected length
function checkIncomingData($idata, $minsize, $maxsize) 
{
if ( 
  strlen($idata)<$minsize
  or  
  strlen($idata)>$maxsize 
  ) 
{
return false;
}
  else
{
  return true;
  }
}
//make sure that nothing bad can be entered by the user (-->sql injection attack)
function cleanIncomingData($idata) 
{
$cleaned = trim($idata); 
$cleaned = mysql_real_escape_string($cleaned);
return $cleaned;
}
/*+++++++++++++++++++++++++++++++++++++*/
/*            Mod Ended                */
/*Mod By Twysted of Dynamic-Designz.com*/
/*+++++++++++++++++++++++++++++++++++++*/
Link to comment
Share on other sites

Re: A way to protect against sql injection

Can anyone explain what the difference is with / without magic quotes?

Also the function posted by stryker looks good, I use something similar except try to escape the quotes using addslashes() on the inputs.

Link to comment
Share on other sites

Re: A way to protect against sql injection

So can anyone post their Anti SQL code that they use, instead of just bragging about it. I have never even thought about it until recently my game began suffering from these types of attacks, and i cannot protect against it, as i cannot find a code that will prevent against it.

Link to comment
Share on other sites

Re: A way to protect against sql injection

 

So can anyone post their Anti SQL code that they use, instead of just bragging about it. I have never even thought about it until recently my game began suffering from these types of attacks, and i cannot protect against it, as i cannot find a code that will prevent against it.

Why don't you scroll up a bit in the topic and see that someone already posted a code example, also as mentioned you can simply use addslashes() when you get the inputs, just do something like

$inputWhateva = addslashes($_GET['fieldname']);
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...