From acac9de4f997f8f05866cd56aa231908bd3fefd7 Mon Sep 17 00:00:00 2001 From: arjen Date: Sat, 4 Jun 2005 07:24:38 +0000 Subject: [PATCH] New page: Abuse list --- src/web/abuse.php | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/web/objects.php | 20 +++++-- 2 files changed, 178 insertions(+), 6 deletions(-) create mode 100644 src/web/abuse.php diff --git a/src/web/abuse.php b/src/web/abuse.php new file mode 100644 index 0000000..2595e0b --- /dev/null +++ b/src/web/abuse.php @@ -0,0 +1,164 @@ +database, "SELECT objectname FROM object + WHERE objectid=CAST('" . $_GET['oid']."' AS BIGINT)"); + $obj = pg_fetch_object($res, 0); + echo "

Abuse List for " . $obj->objectname . "


"; + + if (!empty($_POST['ACTION']) && ($_POST['ACTION'] == 'Abuse')) + { + $abuse_points = 2; + $Source_IP = $_POST['source']; + echo "Reporting " . $_POST['ACTION'] . " for " . $_POST['source'] . "
\n"; + $res = pg_exec($this->database, "SELECT * FROM object_abuse + WHERE objectid='". $_GET['oid'] ."' AND source='$Source_IP'"); + if (pg_numrows($res) == 0) + { + echo "$Source_IP is new.
"; + pg_exec($this->database, "INSERT INTO object_abuse VALUES ('" . $_GET['oid'] . + "', '$Source_IP', '$abuse_points')"); + } + else + { + $abuse = pg_fetch_object($res, 0); + $abuse_points += $abuse->nr_abuses; + echo $Source_IP . " will get " . $abuse_points . " abuse points.
"; + echo "Status was " . $abuse->status . "
"; + pg_exec($this->database, "UPDATE object_abuse SET nr_abuses='$abuse_points'" . + " WHERE objectid='" . $_GET['oid'] . "' AND source='$Source_IP'"); + + if ($abuse_points >= 6) + { + echo "

Block IP adrress $Source_IP on the firewall.

"; + pg_exec($this->database, "UPDATE object_abuse SET status='dropped'" . + " WHERE objectid='" . $_GET['oid'] . "' AND source='$Source_IP'"); + } + } +//select rawdata from log where logid in (select logid from log_abuse where source=''); + + } + else if (!empty($_POST['ACTION']) && $_POST['ACTION'] == 'Investigate') + { + // Present a list of abuse addresses in one subnet + + $Subnet = $_POST['subnet']; + $res = pg_exec($this->database, "SELECT * FROM object_abuse + WHERE objectid='". $_GET['oid'] ."' AND source << '$Subnet'"); + + echo pg_numrows($res) . " records found.
"; + + echo ""; + echo "\n"; + + for ($ip = 0; $ip < pg_numrows($res); $ip++) + { + $abuse = pg_fetch_object($res, $ip); + echo ""; + } + echo "
IP addressAbusesStatus
"; + echo $abuse->source; + echo ""; + echo $abuse->nr_abuses; + echo ""; + echo $abuse->status; + echo "
"; + + } + else if (!empty($_POST['ACTION']) && $_POST['ACTION'] == 'Block') + { + // Block an entire subnet and remove the addresses from the list + + $Subnet = $_POST['subnet']; + pg_exec($this->database, "DELETE FROM object_abuse WHERE objectid = '" . $_GET['oid'] + . "' AND source << '$Subnet'"); + $abuse_points = 8; + pg_exec($this->database, "INSERT INTO object_abuse VALUES ('" . $_GET['oid'] . + "', '$Subnet', '$abuse_points', 'dropped')"); + } + + echo "
"; + echo "Report "; + echo " for IP address "; + echo "
"; + + echo "
"; + echo ""; + echo " or "; + echo " this subnet: "; + echo "
"; + + $res = pg_exec($this->database, "SELECT * FROM object_abuse + WHERE objectid='". $_GET['oid'] ."' ORDER BY source"); + + echo pg_numrows($res) . " records found.
"; + + echo ""; + echo "\n"; + + for ($ip = 0; $ip < pg_numrows($res); $ip++) + { + $abuse = pg_fetch_object($res, $ip); + echo ""; + } + echo "
IP addressAbusesStatus
"; + echo $abuse->source; + echo ""; + echo $abuse->nr_abuses; + echo ""; + echo $abuse->status; + echo "
"; + } + } +} + +$page = new abuse_list("Gnucomo Abuse List"); + +$page->Showpage(); + +?> diff --git a/src/web/objects.php b/src/web/objects.php index 536d910..6a9c434 100644 --- a/src/web/objects.php +++ b/src/web/objects.php @@ -9,7 +9,7 @@ *********************** ** FILE NAME : objects.php ** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring -** VERSION NUMBER : $Revision: 1.9 $ +** VERSION NUMBER : $Revision: 1.10 $ ** ** DESCRIPTION : Objects Administration page. ** Input parameters: action (POST) : empty, 'Create' @@ -29,7 +29,10 @@ /***************************** $Log: objects.php,v $ - Revision 1.9 2003-09-01 06:55:00 arjen + Revision 1.10 2005-06-04 07:24:38 arjen + New page: Abuse list + + Revision 1.9 2003/09/01 06:55:00 arjen Provides an interface to edit the list of services and users for an object. @@ -59,7 +62,7 @@ ******************************/ -// RCSID = "$Id: objects.php,v 1.9 2003-09-01 06:55:00 arjen Exp $"; +// RCSID = "$Id: objects.php,v 1.10 2005-06-04 07:24:38 arjen Exp $"; ini_set('include_path', '.:./classes:../phpclasses'); @@ -347,7 +350,7 @@ class object_page extends page - + "; echo ""; echo ""; - echo ""; - echo "
ObjectDescriptionLog entriesParametersNotifications
ParametersNotificationsAbuses
objectid'>" . $this->nr_notifications . " (" . $this->closed_notifications . " closed)" ?> + + objectid'>" . "Abuse list" + . " " ?>
@@ -399,8 +405,10 @@ class object_page extends page echo "
 $count_logs$count_parameters ($removed_parameters removed)$count_notifications ($closed_notifications closed)
"; + echo "$count_notifications ($closed_notifications closed)"; + echo " "; + echo "\n"; + echo "\n"; ?> -- 2.11.0