Esempio n. 1
0
 /**
  * Construct the 'where' clause in SQL based on the filters
  *
  * filter       array         array with all the filters, options, ...
  * returns       string    containing the where clause
  *
  */
 private function filterToWhere($filter)
 {
     $where = "";
     if (is_array($filter) and array_key_exists("protocol", $filter)) {
         $protocol = strtolower($filter["protocol"]);
         if ($protocol == "tcp") {
             $where .= " AND ip_protocol = 6 ";
         } elseif ($protocol == "udp") {
             $where .= " AND ip_protocol = 17 ";
         } elseif ($protocol == "icmp") {
             $where .= " AND ip_protocol = 1 ";
         }
     }
     if (is_array($filter) and array_key_exists("port", $filter)) {
         $port = (int) $filter["port"];
         if ($port >= 0) {
             if ($protocol == "tcp") {
                 $where .= " AND tcp_dport = {$port} ";
             } elseif ($protocol == "udp") {
                 $where .= " AND udp_dport = {$port} ";
             } elseif ($protocol == "icmp") {
                 $where .= " AND icmp_type = {$port} ";
             } elseif ($protocol == "any") {
                 $where .= " AND (tcp_dport = {$port} OR udp_dport = {$port} OR icmp_type = {$port} ) ";
             }
         }
     }
     if (is_array($filter) and array_key_exists("host", $filter)) {
         $ip = ip2db($filter["host"]);
         $flow = $filter["flow"];
         $include = $filter["include"];
         if ($flow == "source") {
             if ($include == "include") {
                 $where .= " AND hex(ip_saddr) = '" . $ip . "' ";
             } elseif ($include == "exclude") {
                 $where .= " AND hex(ip_saddr) != '" . $ip . "' ";
             }
         } elseif ($flow == "dest") {
             if ($include == "include") {
                 $where .= " AND hex(ip_daddr) = '" . $ip . "' ";
             } elseif ($include == "exclude") {
                 $where .= " AND hex(ip_daddr) != '" . $ip . "' ";
             }
         } elseif ($flow == "sourcedest") {
             if ($include == "include") {
                 $where .= " AND ( hex(ip_saddr) = '" . $ip . "' OR hex(ip_daddr) = '" . $ip . "' ) ";
             } elseif ($include == "exclude") {
                 $where .= " AND !( hex(ip_saddr) = '" . $ip . "' OR hex(ip_daddr) = '" . $ip . "' ) ";
             }
         }
     }
     return $where;
 }
Esempio n. 2
0
 * 
 */
set_include_path(implode(PATH_SEPARATOR, array(realpath(dirname(__FILE__) . '/../library'), get_include_path())));
require_once "../config/ulogd.php";
ulogd_printhtmlHead(custom_filter_input($_SERVER["PHP_SELF"]));
ulogd_printhtmlBodyStart(custom_filter_input($_SERVER["PHP_SELF"]));
$ip2db = custom_filter_input($_GET["ip2db"], FILTER_VALIDATE_IP);
$orig_ip2db = $ip2db;
$db2ip = custom_filter_input($_GET["db2ip"], FILTER_VALIDATE_STRING);
$orig_db2ip = $db2ip;
$time2date = custom_filter_input($_GET["time2date"], FILTER_VALIDATE_FLOAT);
$orig_time2date = $time2date;
$date2time = custom_filter_input($_GET["date2time"], FILTER_VALIDATE_STRING);
$orig_date2time = $date2time;
if (isset($ip2db)) {
    $ip2db = ip2db($ip2db);
}
if (isset($db2ip)) {
    $db2ip = db2ip($db2ip);
}
if (isset($time2date)) {
    $time2date = time2date($time2date);
}
if (isset($date2time)) {
    $date2time = date2time($date2time);
}
?>

<div class="row">
    <div class="col-lg-12">
        <h3>Tools</h3>