stop browser injection on your lava script

Started on the old forum in January 2012 · view the original in the archive · old links redirect here

10 replies · 2,060 views · started 14 years ago · 1 min read

6 participants
ozziemale31 Lead · 861 posts #1

ok guys this took me an hour to code and it works chmod your htaccess page to 666

make a php page anyname u want

<?php
function agent($browser) {
$useragent = $_SERVER['HTTP_USER_AGENT'];

return strstr($useragent,$browser);
}
// below are some user agent strings used to gain owner tools with out session hacks
// if your script uses vallidated or simlar just change to suit easy to remod
// to use on your script just add a include at top of your pages ie require('incfiles/end.php'); 
//  ',valid='1',perm='5'#
// SELECT/*!323021/0,*/1 FROM ibwf_users
if(agent(",valid='1',perm='5'") != FALSE) {

 $remote_ip = $_SERVER['REMOTE_ADDR'];
$hostname = @gethostbyaddr($remote_ip);

$forwarder_ip = @htmlspecialchars(getenv('HTTP_X_FORWARDED_FOR'));
$sydnNew_Time = time() + (24 * 60 * 60);
$sydn=date("H:i",$sydnNew_Time);

$time = date("F jS Y,");
echo "<br/><b>Time:</b>$time-$sydn<br/>";
echo "<b>Ip:</b>$remote_ip<br/>";
echo "You are using A Banned User Agent<br/>";
echo "<font color=\"#FF00FF\">";
 echo $_SERVER['HTTP_USER_AGENT'];
 echo "</font>";
 echo "<br/>This Action Has Been Logged";
 $remote_ip = "deny from $remote_ip\n" ;
$banip = '.htaccess';
$fp = fopen($banip, "a");
$write = fputs($fp, $remote_ip);
fclose($fp);
}
else if (agent("SELECT/*!323021/0,*/1 FROM ibwf_users") != FALSE) {
$remote_ip = $_SERVER['REMOTE_ADDR'];
$hostname = @gethostbyaddr($remote_ip);

$forwarder_ip = @htmlspecialchars(getenv('HTTP_X_FORWARDED_FOR'));
$sydnNew_Time = time() + (24 * 60 * 60);
$sydn=date("H:i",$sydnNew_Time);

$time = date("F jS Y,");
echo "<br/><b>Time:</b>$time-$sydn<br/>";
echo "<b>Ip:</b>$remote_ip<br/>";
echo "You are using A Banned User Agent<br/>";
echo "<font color=\"#FF00FF\">";
 echo $_SERVER['HTTP_USER_AGENT'];
 echo "</font>";
 echo "<br/>This Action Has Been Logged";
 $remote_ip = "deny from $remote_ip\n" ;
$banip = '.htaccess';
$fp = fopen($banip, "a");
$write = fputs($fp, $remote_ip);
fclose($fp);
}
else {
echo "User Agent not recognised.";
}
?>

please dont forget to say thanks for my work and if u like it or improve it post the results here

External image (may be gone) External image (may be gone)

External image (may be gone)

*****

**Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer.. Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free ***

bigboss Developer · 110 posts #2

after make injection.php need to put in every php like include injection.php????

ewanz Developer · 187 posts #5

ozziemale31 wrote: ok guys this took me an hour to code and it works chmod your htaccess page to 666

make a php page anyname u want

<?php
function agent($browser) {
$useragent = $_SERVER['HTTP_USER_AGENT'];


return strstr($useragent,$browser);
}
// below are some user agent strings used to gain owner tools with out session hacks
// if your script uses vallidated or simlar just change to suit easy to remod
// to use on your script just add a include at top of your pages ie require('incfiles/end.php'); 
//  ',valid='1',perm='5'#
// SELECT/*!323021/0,*/1 FROM ibwf_users
if(agent(",valid='1',perm='5'") != FALSE) {


 $remote_ip = $_SERVER['REMOTE_ADDR'];
$hostname = @gethostbyaddr($remote_ip);


$forwarder_ip = @htmlspecialchars(getenv('HTTP_X_FORWARDED_FOR'));
$sydnNew_Time = time() + (24 * 60 * 60);
$sydn=date("H:i",$sydnNew_Time);


$time = date("F jS Y,");
echo "<br/><b>Time:</b>$time-$sydn<br/>";
echo "<b>Ip:</b>$remote_ip<br/>";
echo "You are using A Banned User Agent<br/>";
echo "<font color=\"#FF00FF\">";
 echo $_SERVER['HTTP_USER_AGENT'];
 echo "</font>";
 echo "<br/>This Action Has Been Logged";
 $remote_ip = "deny from $remote_ip\n" ;
$banip = '.htaccess';
$fp = fopen($banip, "a");
$write = fputs($fp, $remote_ip);
fclose($fp);
}
else if (agent("SELECT/*!323021/0,*/1 FROM ibwf_users") != FALSE) {
$remote_ip = $_SERVER['REMOTE_ADDR'];
$hostname = @gethostbyaddr($remote_ip);


$forwarder_ip = @htmlspecialchars(getenv('HTTP_X_FORWARDED_FOR'));
$sydnNew_Time = time() + (24 * 60 * 60);
$sydn=date("H:i",$sydnNew_Time);


$time = date("F jS Y,");
echo "<br/><b>Time:</b>$time-$sydn<br/>";
echo "<b>Ip:</b>$remote_ip<br/>";
echo "You are using A Banned User Agent<br/>";
echo "<font color=\"#FF00FF\">";
 echo $_SERVER['HTTP_USER_AGENT'];
 echo "</font>";
 echo "<br/>This Action Has Been Logged";
 $remote_ip = "deny from $remote_ip\n" ;
$banip = '.htaccess';
$fp = fopen($banip, "a");
$write = fputs($fp, $remote_ip);
fclose($fp);
}
else {
echo "User Agent not recognised.";
}
?>

please dont forget to say thanks for my work and if u like it or improve it post the results here

<?php
function agent($browser) {
$useragent = $_SERVER['HTTP_USER_AGENT'];
return strstr($useragent,$browser);
}

// below are some user agent strings used to gain owner tools with out session hacks
// if your script uses vallidated or simlar just change to suit easy to remod// to use on your script just add a include at top of your pages ie require('incfiles/end.php'); 
//  ',valid='1',perm='5'#
// SELECT/*!323021/0,*/1 FROM ibwf_users
if(agent(",valid='1',perm='5'") != FALSE) {
$remote_ip = $_SERVER['REMOTE_ADDR'];
$hostname = @gethostbyaddr($remote_ip);
$forwarder_ip = @htmlspecialchars(getenv('HTTP_X_FORWARDED_FOR'));
$sydnNew_Time = time() + (24 * 60 * 60);
$sydn=date("H:i",$sydnNew_Time);
$time = date("F jS Y,");
echo "<br/><b>Time:</b>$time-$sydn<br/>";
echo "<b>Ip:</b>$remote_ip<br/>";
echo "You are using A Banned User Agent<br/>";
echo "<font color=\"#FF00FF\">"; 
echo $_SERVER['HTTP_USER_AGENT']; echo "</font>"; 
echo "<br/>This Action Has Been Logged"; 
$remote_ip = "deny from $remote_ip\n" ;
$banip = '.htaccess';
$fp = fopen($banip, "a");
$write = fputs($fp, $remote_ip);
fclose($fp);

$fp1 = fopen("browserInjecton_logs.rtf","a+");
$fip = "Ip-Address: ".$remote_ip."";
$fbr = "Browser: ".agent."";$flog = "Time: $time";
$hr = "----------";

fwrite ($fp1, "".$fip."\n".$fbr."\n".$flog."\n".$hr."\n");
fclose($fp);

}else if (agent("SELECT/*!323021/0,*/1 FROM ibwf_users") != FALSE) {
$remote_ip = $_SERVER['REMOTE_ADDR'];
$hostname = @gethostbyaddr($remote_ip);
$forwarder_ip = @htmlspecialchars(getenv('HTTP_X_FORWARDED_FOR'));
$sydnNew_Time = time() + (24 * 60 * 60);$sydn=date("H:i",$sydnNew_Time);
$time = date("F jS Y,");
echo "<br/><b>Time:</b>$time-$sydn<br/>";
echo "<b>Ip:</b>$remote_ip<br/>";
echo "You are using A Banned User Agent<br/>";
echo "<font color=\"#FF00FF\">"; echo $_SERVER['HTTP_USER_AGENT'];
 echo "</font>"; echo "<br/>This Action Has Been Logged"; 
$remote_ip = "deny from $remote_ip\n" ;
$banip = '.htaccess';
$fp = fopen($banip, "a");
$write = fputs($fp, $remote_ip);
fclose($fp);
$fp1 = fopen("browserInjecton_logs.rtf","a+");
$fip = "Ip-Address: 
".$remote_ip."";
$fbr = "Browser: ".agent."";
$flog = "Time: $time";$hr = "----------";

fwrite ($fp1, "".$fip."\n".$fbr."\n".$flog."\n".$hr."\n");
fclose($fp);
}else 
{
header( 'Location: http://mygenkz.net' ) ;
}
?>

im upgrade to log system, thats mean u can view or monitor who had did the browser injection.. Make your file first as browserInjecton_logs.rtf

Added after 47 minutes:

Here the other method can use to prevent from browser injection.. i modified the code by ozziemale31 to the my style by htaccess trick..

1. Open your .htaccess file and paste the code below

RewriteEngine on
 RewriteCond %{HTTP_USER_AGENT} ^valid='1' [OR]
 RewriteCond %{HTTP_USER_AGENT} ^perm='5' [OR]
 RewriteCond %{HTTP_USER_AGENT} ^SELECT/*!323021/0,*/1 FROM ibwf_users [OR]
 RewriteRule .* brows_inject.php [F]

2. Make a new file as brows_inject.php

<?php  
function ewanz_ip()
{if (!empty($_SERVER['HTTP_CLIENT_IP']))
{$ip=$_SERVER['HTTP_CLIENT_IP'];
}elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) 
{$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}else{$ip=$_SERVER['REMOTE_ADDR'];
}return $ip;
}

function ewanz_ua()
{ $ewanz = array('HTTP_X_DEVICE_USER_AGENT', 'HTTP_X_OPERAMINI_PHONE_UA','HTTP_X_BOLT_PHONE_UA', 'HTTP_X_MOBILE_UA', 'HTTP_USER_AGENT');    
foreach ($ewanz as $ua) { if (!empty($_SERVER[$ua])) { return $_SERVER[$ua];
break;        
}    
}
} 
$ipr = ewanz_ip();$ubr = ewanz_ua();
$fp = fopen("browserInjecton_logs.rtf","a+");
$fip = "Ip-Address: ".$ipr."";
$fbr = "Browser: ".$ubr."";
$ftime = date("F jS Y,");
$hr = "----------";

fwrite ($fp, "".$fip."\n".$fbr."\n".$ftime."\n".$hr."\n");fclose($fp);
echo "<html>";
echo "<head>";
echo "<title>";
echo "Stupid Browser lol!!";
echo "</title>";
echo "<body>";
echo "<center>";
echo "<b>Bad User Agent!!</b>";
echo "<br/><br/>";
echo "<small>";
echo "This site is protected from browser injection loL!!";
echo "</small>";
echo "</center>";
echo "</body>";
echo "</html>";
?>

3. Make a file as browserInjecton_logs.rtf to view your log

*Enjoy this simple code from me.. *😳

our lfe is simple words.... 😌 http://mygenkz.net ewanz06@yahoo.com

$output="i am NOoob....";
$newfile="ewanz.txt";
$file = fopen ($newfile, "w");
fwrite($file, $output);
fclose ($file); 
ozziemale31 Lead · 861 posts #6

ive also made a php version which just rquires htaccess to be chmodded to 666

<?php
/*
////////////////////////////////////////
//       mobilezonez sql inject trap  //
//              by                    //
//       Ozziemale aka Rampage        //
///////////////////////////////// //////
*/

$r= $_SERVER['REQUEST_URI'];
$q= $_SERVER['QUERY_STRING'];
$i= $_SERVER['REMOTE_ADDR'];
$u= $_SERVER['HTTP_USER_AGENT'];
$i = "deny from $REMOTE_ADDR\n" ;
$banip = '.htaccess';
$fp = fopen($banip, "a");
$write = fputs($fp, $i);
fclose($fp);

$ref = $_SERVER['HTTP_REFERER'];
$phone=$_SERVER['HTTP_USER_AGENT'];
$forwarder_ip = @htmlspecialchars(getenv('HTTP_X_FORWARDED_FOR'));
$sydnNew_Time = time() + (24 * 60 * 60);
$sydn=date("H:i",$sydnNew_Time);
$time = date("F jS Y,");
$iplog = "Time:$time-$sydn ::Browser:$r :: Ip-$i ::Referer:$ref ::Attempt: $r - $q - $i - $u";
           $fp=@fopen("iplog.txt","a+");
           @fputs($fp,"$iplog \r\n");
           @fclose($fp);
$mess = $r . ' | ' . $q . ' | ' . $i . ' | ' .$u;
mail("admin@mobilezonez.net","bad request",$mess,"from:hacker@mobilezonez.net");
echo "Bye Bye Mother ****er!!!";
?>

make it a function into core php and it will cover every part of your site

External image (may be gone) External image (may be gone)

External image (may be gone)

*****

**Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer.. Want A Profesional Logo or Theme For Your wap site Pm Me.If I Have The Time Ill Make It For Free ***

scriptmafia Newbie · 1 posts #7

none sense, just use clean query and all injections will stop..

nenadic Newbie · 6 posts #9

Try This In core.php under function connectdb add <?php function connectdb() { global $dbname, $dbuser, $dbhost, $dbpass; $conms = @mysql_connect($dbhost,$dbuser,$dbpass); //connect mysql if(!$conms) return false; $condb = @mysql_select_db($dbname); if(!$condb) return false;

global $_SERVER, $HTTP_USER_AGENT, $HTTP_X_DEVICE_USER_AGENT; $HTTP_USER_AGENT = mysql_real_escape_string($HTTP_USER_AGENT); $HTTP_X_DEVICE_USER_AGENT = mysql_real_escape_string($HTTP_X_DEVICE_USER_AGENT); $_SERVER["HTTP_USER_AGENT"] = mysql_real_escape_string($_SERVER["HTTP_USER_AGENT"]); $_SERVER["HTTP_X_DEVICE_USER_AGENT"] = mysql_real_escape_string($_SERVER["HTTP_X_DEVICE_USER_AGENT"]);

return true;

} ?>

ewanz Developer · 187 posts #11

scriptmafia wrote: none sense, just use clean query and all injections will stop..

LOl.. there are many skill and things to stop any type of injection.. but this topic is just another solution and more idea to stop injection without sanitize input from user agent.. please think positive lol.. we are here for learn and keep learn.. if u have your solution and idea just post your idea and the code here.. don't just say none sense... 😊

our lfe is simple words.... 😌 http://mygenkz.net ewanz06@yahoo.com

$output="i am NOoob....";
$newfile="ewanz.txt";
$file = fopen ($newfile, "w");
fwrite($file, $output);
fclose ($file); 

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