sql注入大总结【万字详解】
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Insert注入</title>
</head>
<body>
<?php
function getIP() {
if (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP');
}
elseif (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
}
elseif (getenv('HTTP_X_FORWARDED')) {
$ip = getenv('HTTP_X_FORWARDED');
}
elseif (getenv('HTTP_FORWARDED_FOR')) {
$ip = getenv('HTTP_FORWARDED_FOR');
}
elseif (getenv('HTTP_FORWARDED')) {
$ip = getenv('HTTP_FORWARDED');
}
else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
$count = 0;
$ip = explode(',', getIP())[0];
error_reporting(0);
$con = mysql_connect('127.0.0.1','root','') or die("Unable to connect to the MySQL!");
mysql_select_db('sql22',$con);
mysql_query("set names utf8");
mysql_query("INSERT into log(ip) values('".$ip."')") or die(mysql_error());
$res = mysql_query("SELECT count(1) FROM log") or die(mysql_error());
$count = mysql_fetch_array($res)[0];
mysql_close($con);
?>
今日浏览量:<?php echo $count ?> <br/>
当前访问者:<?php echo $ip ?>
</body>
</html>