script monitors your site for dangerous SQL injection and RFI vulnerabilities

Started on the old forum in February 2010 · view the original in the archive · old links redirect here

5 replies · 1,005 views · started 16 years ago · 1 min read

5 participants
12345xmen Developer · 239 posts #1

this php script help u to protect ur site for dangerous SQL injection and RFI vulnerabilities :

Installation

  1. make "logs " dir

  2. chmod the directory 'logs' to 777

  3. Add the following line to the .htaccess file in root folder to monitor the requests.

php_value auto_append_file /home/username/public_html/requestlogger.php

replace /home/username/public_html/ with your root path.

php script here :

<? // Security module by 12345 xmen
	// Please do not change anything in this file
log_requests();

function log_requests(){

$aurl=urldecode($_SERVER['REQUEST_URI']);

	if($GLOBALS['logged']!=1){

		$GLOBALS['logged']=1;

if(!(
strstr($aurl,'\'') ||
strstr($aurl,'"')
)
)return;

		$filename = $_SERVER['DOCUMENT_ROOT'].'/crappylog/crap-'.date("d-M-y", time()).'.txt';
		$somecontent = date("D d M y-H:i:s", time());

		$somecontent .= "|| TIME: ".$timespent;
		$somecontent .= "|| URI: ";
		$somecontent.=$_SERVER['REQUEST_URI'];
		$somecontent .= "|| URIU: ";
		//$somecontent.=$aurl;
		
/*
		$somecontent .= "|| BROWSER: ";
		$somecontent.=$_SERVER['HTTP_USER_AGENT'];

		
		$somecontent .= "|| IP: ";
		$somecontent.=$_SERVER['REMOTE_ADDR'];
		
		$somecontent .= "|| FORWARDED: ";
		$somecontent.=$_SERVER['HTTP_X_FORWARDED_FOR'];		

		$somecontent .= "|| POST: ";
		foreach($_POST as $k=>$v){
			$k=preg_replace("/[\s]/", " ", $k);
			$v=preg_replace("/[\s]/", " ", $v);
			$somecontent.="$k==$v::";
		}
*/

		touch($filename);

		if (is_writable($filename)) {
			$handle = fopen($filename, 'a');
			flock($handle, LOCK_EX);
		    if (!$handle) {
		         echo "Cannot open";
		    }
		    if (fwrite($handle, $somecontent."\n") === FALSE) {
		        echo "Cannot write";
		    }
			flock($handle, LOCK_UN);
		    fclose($handle);

		}
		else {
		    echo "logger not writable";
		}
	}
}
	
?>

i hope its hlp you if u like say thanks !

opera Newbie · 2 posts #4

Gr8

echo good job;

thanx

opera Newbie · 2 posts #5

wapmetal wrote: you can monitor but you cant prevent hacking LOL

btw theres also codes here posted by subzero

sanitize all inputs from user

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close