<?php
function hex2ip($hex){
$rip = long2ip( hexdec( $hex));
$temp = explode(".",$rip);
$ip = $temp[3]. ".". $temp[2] . ".". $temp[1]. ".". $temp[0];
return $ip;
}
$farr = file("/proc/net/tcp");
foreach($farr as $f ) {
$a = preg_split('/[\s,:]+/',$f, -1, PREG_SPLIT_NO_EMPTY);
//var_dump($a);
//echo $a[5]."\n";
if( $a[3] == "00000000" && $a[4] == "0000" ){
//echo $a[1].":".$a[2]."-->".$a[3].":".$a[4]."\n";
$port[] = $a[2];
}
if( !in_array($a[2], $port) && $a[5] == "01") {
echo hex2ip($a[1]),":", hexdec($a[2]) ." -->". hex2ip( $a[3]) .":". hexdec( $a[4])."\n";
}
}
?>
function hex2ip($hex){
$rip = long2ip( hexdec( $hex));
$temp = explode(".",$rip);
$ip = $temp[3]. ".". $temp[2] . ".". $temp[1]. ".". $temp[0];
return $ip;
}
$farr = file("/proc/net/tcp");
foreach($farr as $f ) {
$a = preg_split('/[\s,:]+/',$f, -1, PREG_SPLIT_NO_EMPTY);
//var_dump($a);
//echo $a[5]."\n";
if( $a[3] == "00000000" && $a[4] == "0000" ){
//echo $a[1].":".$a[2]."-->".$a[3].":".$a[4]."\n";
$port[] = $a[2];
}
if( !in_array($a[2], $port) && $a[5] == "01") {
echo hex2ip($a[1]),":", hexdec($a[2]) ." -->". hex2ip( $a[3]) .":". hexdec( $a[4])."\n";
}
}
?>