- Joined
- Jun 1, 2007
- Messages
- 96
- Reaction score
- 0
Hello everyone, I'm looking for a way to secure my site (MPOG) because
my site is hacked (LEVEL 99 ALL).
Your release stripped that and much more:
http://forum.ragezone.com/f245/my-way-of-protecting-from-sql-injections-570599/?#post4993113
Let's see - words such as "select" and "varchar" are automatically removed, without notifying anyone - as I mentioned, if my password were say, "select1", then my password would be "1" without the end user being notified.Code:function antisql($sql) { $sql = preg_replace(sql_regcase("(select|union|0x|cast|exec|varchar|insert into|delete from|update account|update login|update character|ugradeid|drop table|show tables)"),"",$sql); $sql = trim($sql); $sql = strip_tags($sql); $sql = addslashes($sql); return $sql; }
Rather than remove excess spaces and tags, it's easier to not permit those symbols.
Also, your add slashes will cause an annoyance if magic_quotes_gpc is on, as detailed inTo view the content, you need to sign in or register. (e.g.: \' would turn to \\\', inserting a backslash before the quote).
So no, that s most certainly not what you were doing.
function sqlesc($x) {
$x = stripslashes($x);
return "'".mysql_real_escape_string($x)."'";
}
if (!get_magic_quotes_gpc()) {
$sql = addslashes($sql);
}
That's not what I use either, it's what I released. What I used back then was for MySQL.:
PHP:function sqlesc($x) { $x = stripslashes($x); return "'".mysql_real_escape_string($x)."'"; }
function sqlesc ( $x ) {
return mysql_real_escape_string ( stripslashes ( $x ) ); // stripslashes() still isn't needed..
}
Also,
PHP:if (!get_magic_quotes_gpc()) { $sql = addslashes($sql); }
I don't see why anyone would put "select" as their password anywaysit would be rare if anyone did though.
Uhh..why are slashes being stripped? And, why wouldn't you just do:
PHP:function sqlesc ( $x ) { return mysql_real_escape_string ( stripslashes ( $x ) ); // stripslashes() still isn't needed.. }
That still doesn't represent the function you released, which you still claimed, "just felt safe".
Also, where's your MSSQL equivalent? Is your MSSQL equivalent the one you released?
It's all theoretical.
I've got lots of experience in MySQL injections, I'm looking into MSSQL ones ATM. Thought they were the same.
Take a look to this
To view the content, you need to sign in or register
Take a look to this
To view the content, you need to sign in or register
function antisql($sql)
{
$sql = htmlspecialchars($sql);
$sql = str_replace("'", '& #039;', $sql);
$sql = str_replace('"', '"e;', $sql);
return $sql;
}
I use this one.
~IcemanPHP:function antisql($sql) { $sql = htmlspecialchars($sql); $sql = str_replace("'", '& #039;', $sql); $sql = str_replace('"', '"e;', $sql); return $sql; }
That one clearly sucks. It blocks any slash, dot, comma, and so forth. Just clean ', " and \.