note 68879 added to function.preg-replace
| From: | Portugal at osu1 dot php dot net | Date: | Mon, 14 Aug 2006 18:46:51 +0000 |
| Subject: | note 68879 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115899@lists.php.net to get a copy of this message | ||
I'm doing a function/method to detect (My)SQL Injection Attacks and XSS and others, before they
reach the database or the site itself, not trying to fully avoid them without use general
techniques, but in a way that i can have a statistic page with attacks, and can ban the user that
tryed to attack my site.
the function is kind of:
--------------------------------
$tipo='SQL'
$variavel='String to check';
$fixed=$variavel;
for ($run=0;$run < count($this->mysql_pattern);$run++)
{
$fixed = preg_replace($this->mysql_pattern[$run], "", $fixed);
}
$sql_attack = strcmp($variavel,$fixed);
if ($sql_attack)
{
$this->registar_ataque($tipo,$ip);
die($tipo . ' ATAQUE');
}
--------------------------------
Perhaps you can tell me your opinion about it, or of ways of improve it. But what really brings me
here is:
I want to ask your opinion about the patterns that i'm using:
For XSS i'm using :
$xss_pattern= '@<script[^>]*?>.*?</script>@si'; // This one there was
posted here in php.net
For SQL I'm using: //Created by myself
mysql_pattern[0] = '/((OR)|(WHERE))\\s*.{1,3}\\s*=\\s*.{1,3}/';
mysql_pattern[1] = '/UNION((\\s*)|(\\s*ALL\\s*))SELECT/s';
mysql_pattern[2] = '/INSERT\\s*INTO/';
Thanks in advance
----
Server IP: 81.92.200.26
Probable Submitter: 193.136.33.132
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/68879
Del: integrated -- https://master.php.net/note/delete/68879/integrated
Del: useless -- https://master.php.net/note/delete/68879/useless
Del: bad code -- https://master.php.net/note/delete/68879/bad+code
Del: spam -- https://master.php.net/note/delete/68879/spam
Del: non-english -- https://master.php.net/note/delete/68879/non-english
Del: in docs -- https://master.php.net/note/delete/68879/in+docs
Del: other reasons-- https://master.php.net/note/delete/68879
Reject -- https://master.php.net/note/reject/68879
Search -- https://master.php.net/manage/user-notes.php