Advertisement
Guest User

Untitled

a guest
Aug 30th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. <?php
  2. static $query_xss_char;
  3. static $found_word_xss=0;
  4. static $found_char=0;
  5. static $found_word_sqli;
  6. function firewall_xss_alarm($sanitizeit)//This Function checks for Blacklisted words and logs
  7. //the ip if possible attack is found
  8. {
  9. $sanitizeit= strtolower($sanitizeit);
  10. $blacklist_word_xss= array("src","javascript","alert","onload","onmouseover","onerror","onmouseout","prompt");
  11. foreach ($blacklist_word_xss as $blacklist_word_temp)
  12. {
  13. if (strpos($sanitizeit,$blacklist_word_temp)!==FALSE)
  14. {
  15. $GLOBALS['found_word_xss']=1;
  16. }
  17. if ($GLOBALS['found_word_xss']===1)
  18. {
  19. $logs=fopen("logs.txt","a");
  20. fwrite($logs,"Attacker IP=".$_SERVER['REMOTE_ADDR'].":::Possible Attack String:".$sanitizeit."\n") or die("Cannot Write into file");
  21. break;
  22. }
  23. if ($GLOBALS['found_word_xss']===1)
  24. {
  25. $ip=fopen("ip.txt","a");
  26. fwrite($ip,$_SERVER['REMOTE_ADDR']."::");
  27. }
  28. }
  29. }
  30. function firewall_charcheck_xss($sanitizeit)//This Fuction checks the input for blacklisted characters and words
  31. //,replace it with space if any illegal character or word is found and returns sanitized string
  32. {
  33. $sanitizeit=strtolower($sanitizeit);
  34. $array1=str_split($sanitizeit);//Splitting String into an array
  35. $blacklist_char=array("<",">","%","#","=","'",'"',"/",";","",",","&","onload","onmouseover","onerror","onmouseout","src");//Characters to block
  36. $GLOBALS['query_xss_char'] = str_replace($blacklist_char," ",$sanitizeit);
  37. return $GLOBALS['query_xss_char'];
  38. }
  39. ////Illegal Character Checking Fucntion ENDS Here
  40. ////////////////////////////////////////////////////////////
  41. ///////////////////////////////////////////////////
  42. //Illegal words Checking Function STARTS here
  43. function firewall_wordcheck_sqli($input)//this function checks for different sql injection words and logs the ip
  44. //if such word is found
  45. {
  46. $input= strtoupper($input);
  47. $blacklist_word=array("UNION","SELECT","DATABASE()","CONCAT","GROUP_CONCAT");
  48. foreach ($blacklist_word as $blacklist_word_temp)
  49. {
  50. if (strpos($input,$blacklist_word_temp)!==FALSE)
  51. {
  52. $GLOBALS['found_word_sqli']=1;
  53. }
  54. if ($GLOBALS['found_word_sqli']===1)
  55. {
  56. $logs=fopen("logs.txt", "a");
  57. fwrite($logs,"Attacker Ip:".$_SERVER['REMOTE_ADDR'].":::") or die("Cannot Write into file");
  58. fwrite($logs,"Attack String:".$input."\n");
  59. break;
  60. }
  61. }
  62. }
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement