贡献个PHP小程序,统计内网使用P2P下载和视频的IP
<?// p2p traffic analysis
$p2p_down = array("Bittorrent", "eDonkey", "Poco", "迅雷",
"Gnutella", "Fasttrack", "DirectConnect",
"AppleJuice", "百度下吧", "百宝", "酷狗",
"Vagaa", "Ares", "Napster", "Mute",
"iMesh", "SoulSeek", "脱兔", "PPGou",
"天网Maze", "超级旋风", "酷我音乐盒", "BT扩展协议",
"搜娱",
);
$p2p_tv = array("PPStream", "PPLive", "沸点", "乐酷",
"QQ直播", "CCIPTV", "TVAnts", "TVKoo",
"PPMate", "MySee", "悠视TV", "SopCast",
"VJBase", "Jeboo", "风行", "迅雷看看",
"PPFilm",
);
$badguy = array();
$badip = array();
exec("/usr/panabit/bin/floweye flow list", $flowlist);
foreach ($flowlist as $line) {
// get the internal ip
if (preg_match("/192\.168\.(\d+)\.(\d+)/", $line, $out)) {
$proto = explode(" ", $line);
//echo $out." ".$proto."\n";exit;
if (in_array($proto, $p2p_down) || in_array($proto, $p2p_tv)) {
$badguy[ $proto ][ $out ] += 1;
if (!in_array($out, $badip)) {
array_push($badip, $out);
}
}
}
}
$down_rows = "";
foreach ($p2p_down as $p) {
if (array_key_exists($p, $badguy)) {
foreach ($badguy[$p] as $ip => $n) {
if ($ip == $_SERVER['REMOTE_ADDR']) {
$ip = "<font color='red'>".$ip."</font>";
}
$down_rows .= "<tr align='center'><td>$ip</td><td>$p</td><td>$n</td></tr>";
}
}
}
$tv_rows = "";
foreach ($p2p_tv as $p) {
if (array_key_exists($p, $badguy)) {
foreach ($badguy[$p] as $ip => $n) {
if ($ip == $_SERVER['REMOTE_ADDR']) {
$ip = "<font color='red'>".$ip."</font>";
}
$tv_rows .= "<tr align='center'><td>$ip</td><td>$p</td><td>$n</td></tr>";
}
}
}
?>
<div style="margin:auto; text-align:center; height:30px"><?if(in_array($_SERVER['REMOTE_ADDR'], $badip)){echo "[<font color='red'>{$_SERVER['REMOTE_ADDR']}</font>] 我们是害虫,我们是害虫,上班在用P2P!";}else{echo "[<font color='green'>{$_SERVER['REMOTE_ADDR']}</font>] 我们都是好孩子,上班不用P2P。";}?></div>
<table bordercolor="#000000" cellspacing="0" cellpadding="5" width="750" align="center" bgcolor="#ffffcc" border="1">
<tr bgcolor="#ffcc66" align="center">
<td width="40%">坏蛋IP</td>
<td width="30%">协议</td>
<td width="30%">会话数</td>
</tr>
<?
if ("" == $down_rows && "" == $tv_rows) {
echo "<tr bgcolor='#66ffff'><td colspan='3' align='center'>今天没人使用P2P :-)</td></tr>";
}
else {
if ("" != $down_rows) {
?>
<tr bgcolor='#66ffff'><td colspan='3' align='center'>P2P下载</td></tr>
<?
echo $down_rows;
}
if ("" != $tv_rows) {
?>
<tr bgcolor='#66ffff'><td colspan='3' align='center'>P2P视频</td></tr>
<?
echo $tv_rows;
}
}
?>
</table>
一般员工看到这个列表也就不好意思再使用P2P下载了,内网状况就能大为改善。
好东东,把源码放在哪里呢?如何去访问? 原帖由 faint 于 2008-4-8 14:10 发表 http://www.panabit.com/forum/images/common/back.gif
Very good! 原帖由 panabit 于 2008-4-8 14:45 发表 http://www.panabit.com/forum/images/common/back.gif
Very good!
还望版主加强panabit针对IP的流量统计功能,现在我还得用ntop去做统计。而且加载了panabit内核模块后无法sniff数据采集网卡,所以只能再加块网卡,交换机上也得另外再做一个镜像端口。 还是没有搞懂怎么使用,是否要freebsd安装appche才行? 肯定的否则无法运行php
页:
[1]