3 /**************************************************************************
4 ** (c) Copyright 2003, Andromeda Technology & Automation
5 ** This is free software; you can redistribute it and/or modify it under the
6 ** terms of the GNU General Public License, see the file COPYING.
7 ***************************************************************************
8 ** MODULE INFORMATION *
9 ***********************
10 ** FILE NAME : abuse.php
11 ** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
12 ** VERSION NUMBER : $Revision: 1.1 $
14 ** DESCRIPTION : Abuse list page
19 ***************************************************************************
20 ** ADMINISTRATIVE INFORMATION *
21 ********************************
22 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
23 ** CREATION DATE : Apr 13, 2004
24 ** LAST UPDATE : Apr 13, 2004
26 **************************************************************************/
28 /*****************************
30 Revision 1.1 2005-06-04 07:24:38 arjen
33 ******************************/
35 // RCSID = "$Id: abuse.php,v 1.1 2005-06-04 07:24:38 arjen Exp $";
37 ini_set('include_path', '.:./classes:../phpclasses');
39 require_once('page.class.php');
42 class abuse_list extends page
47 if (!empty($_GET['oid']))
49 $res = pg_exec($this->database, "SELECT objectname FROM object
50 WHERE objectid=CAST('" . $_GET['oid']."' AS BIGINT)");
51 $obj = pg_fetch_object($res, 0);
52 echo "<h1>Abuse List for " . $obj->objectname . "</h1><hr>";
54 if (!empty($_POST['ACTION']) && ($_POST['ACTION'] == 'Abuse'))
57 $Source_IP = $_POST['source'];
58 echo "Reporting " . $_POST['ACTION'] . " for " . $_POST['source'] . "<br>\n";
59 $res = pg_exec($this->database, "SELECT * FROM object_abuse
60 WHERE objectid='". $_GET['oid'] ."' AND source='$Source_IP'");
61 if (pg_numrows($res) == 0)
63 echo "$Source_IP is new.<br>";
64 pg_exec($this->database, "INSERT INTO object_abuse VALUES ('" . $_GET['oid'] .
65 "', '$Source_IP', '$abuse_points')");
69 $abuse = pg_fetch_object($res, 0);
70 $abuse_points += $abuse->nr_abuses;
71 echo $Source_IP . " will get " . $abuse_points . " abuse points.<br>";
72 echo "Status was " . $abuse->status . "<br>";
73 pg_exec($this->database, "UPDATE object_abuse SET nr_abuses='$abuse_points'" .
74 " WHERE objectid='" . $_GET['oid'] . "' AND source='$Source_IP'");
76 if ($abuse_points >= 6)
78 echo "<h2 class='error'>Block IP adrress $Source_IP on the firewall.</h2>";
79 pg_exec($this->database, "UPDATE object_abuse SET status='dropped'" .
80 " WHERE objectid='" . $_GET['oid'] . "' AND source='$Source_IP'");
83 //select rawdata from log where logid in (select logid from log_abuse where source='');
86 else if (!empty($_POST['ACTION']) && $_POST['ACTION'] == 'Investigate')
88 // Present a list of abuse addresses in one subnet
90 $Subnet = $_POST['subnet'];
91 $res = pg_exec($this->database, "SELECT * FROM object_abuse
92 WHERE objectid='". $_GET['oid'] ."' AND source << '$Subnet'");
94 echo pg_numrows($res) . " records found.<br>";
97 echo "<tr><th>IP address</th><th>Abuses</th><th>Status</th></tr>\n";
99 for ($ip = 0; $ip < pg_numrows($res); $ip++)
101 $abuse = pg_fetch_object($res, $ip);
105 echo $abuse->nr_abuses;
113 else if (!empty($_POST['ACTION']) && $_POST['ACTION'] == 'Block')
115 // Block an entire subnet and remove the addresses from the list
117 $Subnet = $_POST['subnet'];
118 pg_exec($this->database, "DELETE FROM object_abuse WHERE objectid = '" . $_GET['oid']
119 . "' AND source << '$Subnet'");
121 pg_exec($this->database, "INSERT INTO object_abuse VALUES ('" . $_GET['oid'] .
122 "', '$Subnet', '$abuse_points', 'dropped')");
125 echo "<form method='post'>";
126 echo "Report <input type='submit' name='ACTION' value='Abuse'>";
127 echo " for IP address <input type='text' name='source'>";
130 echo "<form method='post'>";
131 echo "<input type='submit' name='ACTION' value='Investigate'>";
132 echo " or <input type='submit' name='ACTION' value='Block'>";
133 echo " this subnet: <input type='text' name='subnet'>";
136 $res = pg_exec($this->database, "SELECT * FROM object_abuse
137 WHERE objectid='". $_GET['oid'] ."' ORDER BY source");
139 echo pg_numrows($res) . " records found.<br>";
142 echo "<tr><th>IP address</th><th>Abuses</th><th>Status</th></tr>\n";
144 for ($ip = 0; $ip < pg_numrows($res); $ip++)
146 $abuse = pg_fetch_object($res, $ip);
150 echo $abuse->nr_abuses;
160 $page = new abuse_list("Gnucomo Abuse List");