Skip to content
Snippets Groups Projects
Select Git revision
  • 4cc0754f11b21c52c9924689487f36d756c59a52
  • master default protected
  • rednatco-v2
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • servers
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

symbol.ts

Blame
  • graph_TargetportActivity.php 1.65 KiB
    <?
    include("db.php");
    
    
    if(!isset($_GET['per'])){$_GET['per']="hour";}
    switch( $_GET['per']) {
            case "hour":
    		$agg = 1;
                    break;
            case "day":
    		$agg = 24;
                    break;
            case "month":
    		$agg = 24*30; // -30.5 ?
                     break;
    }
    
    #sqli todo
    #selector
    
    $query_cols = "target_port";
    if(IsSet($_GET['port']) && is_numeric($_GET['port'])){
    	$where = "target_port=".$_GET['port'];
    } else {
    	die("pars");
    }
    
    
    
    #seznam sloupcu ve vysledku, todo dyn, coz je ovsem seznam sledovanych velicin
    $cols=array();
    $i=0;
    $cols["events"]=$i++;
    $cols["uniqueSources"]=$i++;
    $cols["uniqueSensors"]=$i++;
    $cols["totalScale"]=$i++;
    $count_cols=count($cols);
    
    
    #select data
    $data=array();
    #casova posloupnost
    # premapuju podle staticky alokovanych sloupcu, posilam to rovnou do grafu
    $q = "
    SELECT 
    unix_timestamp(detected)-(unix_timestamp(detected)%(3600*$agg)) as t, 
    count(*) as events, 
    count(distinct source) as uniqueSources, 
    count(distinct concat_ws('-',hostname,service,type)) as uniqueSensors,
    sum(attack_scale) as totalScale 
    FROM events WHERE $where GROUP BY $query_cols, t;";
    
    #var_dump($q);
    $res = mysql_query($q, $db);
    while ($tmp = mysql_fetch_assoc($res)) { 
    	#var_dump($tmp);
            $d=array_fill(0, $count_cols, 0);
            $d[ $cols[ "events" ] ] = (int)$tmp["events"];
            $d[ $cols[ "uniqueSources" ] ] = (int)$tmp["uniqueSources"];
            $d[ $cols[ "uniqueSensors" ] ] = (int)$tmp["uniqueSensors"];
            $d[ $cols[ "totalScale" ] ] = (int)$tmp["totalScale"];
            array_unshift($d, (int)$tmp["t"]);
    	array_push($data, $d);
    }
    
    
    #print json_encode($d);
    print json_encode(array("cols"=>array_keys($cols), "data"=>$data));
    
    ?>