X-Git-Url: http://git.pjr.cc/?p=glcas.git;a=blobdiff_plain;f=bin%2Fscanhelper.php;fp=bin%2Fscanhelper.php;h=141c0ae38640a099b64190e3bf66f5e5270f3f2f;hp=0000000000000000000000000000000000000000;hb=e81521d3926c7dff1484e5c86a02dcfd8dc93b8e;hpb=e45207eb04184d0ee4c7f7b77bbe74b599c1a003 diff --git a/bin/scanhelper.php b/bin/scanhelper.php new file mode 100644 index 0000000..141c0ae --- /dev/null +++ b/bin/scanhelper.php @@ -0,0 +1,78 @@ +loadConfig($configpath); + + +$range = ""; +if(isset($argv[1])) { + $range = $argv[1]; +} + +if(isset($argv[2])) { + $hostgroup = $argv[2]; +} + + +if($range == "") { + echo "range makes no sense\n"; + exit(0); +} + + +$ips_v = explode(".", $range); + +$ips = $ips_v[0].".".$ips_v[1].".".$ips_v[2]; + +for($i = 1; $i < 255; $i++) { + $hostname = ""; + $ips_me = "$ips.$i"; + echo "Scanning $ips_me
"; + error_log("Scanning $ips_me
"); + flush(); + $hostname = gethostbyaddr($ips_me); + if($hostname != $ips_me) { + echo "Found host on $ips_me as $hostname
"; + error_log("Found host on $ips_me as $hostname"); + flush(); + $hosts = $glconfig->getData("hosts"); + $exists = false; + foreach($hosts as $key => $val) { + if($val["category"] == $hostname && $val["name"] == $ips_me) { + echo "Host in db already
"; + $exists = true; + flush(); + } + + } + if(!$exists) $glconfig->addData("hosts", "$hostname", "$ips_me", "$hostgroup"); + + + } +} +echo "Finished"; + +?> \ No newline at end of file