note 111457 deleted from security.database.sql-injection by danbrown

From: Date: Mon, 04 Mar 2013 17:58:23 +0000
Subject: note 111457 deleted from security.database.sql-injection by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-193859@lists.php.net to get a copy of this message
Note Submitter: info at djdb dot be ---- code underconstruction let me now if there is an issue <?php /** * @author Lieven Roegiers * @copyright 2009 * @CMS autosite * opensource http://code.google.com/p/autosite/ * <script language='JavaScript' src='<?php print $autosite['javascript']?>form.val.js'></script> * <form onsubmit="return formCheck()" enctype="text/plain" method="GET"></form> */ class valid{ public function is_valid(&$GETorPOST){ if(is_array($GETorPOST)){ foreach($GETorPOST as $key->$value){ if($this->is_phpkeyinject($key)){ return false; } if( $this->is_phpinject($value)|| $this->is_sqlinject($value)|| $this->illegalcharconverter($value)){ return false; } } } return true; } /** * Prevention of * files.php?login_id=1234567890 OR 1=1 * De volgende SQL query wordt uitgevoerd: * SELECT * FROM files WHERE id = 1234567890 OR 1=1 * * * @param mixed $var * @return */ function is_sqlinject($var){//DROP TABLE return pos($var,"DROP TABLE")||pos($var,"DROP")||(pos($var," WHERE ") && pos($var," OR "))||pos($var,"SELECT * FROM"); } /** * @param mixed $var * @return */ function is_phpinject($var){ return pos($var,"print_r")||pos($var,"DROP"); } /** * prevention of * .php?a[]=asd&a[]=asdasd&b[]=$a * * @param mixed $var * @return */ function is_phpkeyinject($var){ return pos($var,"["); } /** * @param mixed $var * @return */ function is_spaminject($var){ return pos($var,"sex")||pos($var,"SEX"); } // %&#37 (&#40 )&#41 function illegalcharconverter($str){ $chars=array("&" ,"<" , ">" ,"!" ,'"' ,"," ,"$" ,"'" ,"*" ,"+" ); $ascii=array("&#38;","&lt;", "&gt;","&#33;","&#34;","&#44;","&#36;","&#39;","&#42;","&#43;"); return str_replace($chars,$ascii , $str); } } ?>

« previous php.notes (#193859) next »