OSSIM源码之Event.inc

<?php

require_once ("ossim_db.inc");

class Event {

var $id;
    var $timestamp;
    var $sensor;
    var $interface;
    var $type;
    var $plugin_id;
    var $plugin_sid;
    var $protocol;
    var $src_ip;
    var $dst_ip;
    var $src_port;
    var $dst_port;
    var $condition;
    var $value;
    var $time_interval;
    var $absolute;
    var $priority;
    var $reliability;
    var $asset_src;
    var $asset_dst;
    var $risk_c;
    var $risk_a;
    var $asset_src;
    var $asset_dst;
    var $snort_sid;
    var $snort_cid;
    var $alarm;
   
    function Event ($id, $timestamp, $sensor, $interface, $type,
                    $plugin_id, $plugin_sid, $protocol, $src_ip, $dst_ip,
                    $src_port, $dst_port, $condition, $value, $time_interval,
                    $absolute, $priority, $reliability, $risk_c, $risk_a,
                    $asset_src, $asset_dst, $snort_sid, $snort_cid, $alarm)
    {
        $this->id           = $id;
        $this->timestamp    = $timestamp;
        $this->sensor       = $sensor;
        $this->interface    = $interface;
        $this->type         = $type;
        $this->plugin_id    = $plugin_id;
        $this->plugin_sid   = $plugin_sid;
        $this->protocol     = $protocol;
        $this->src_ip       = $src_ip;
        $this->dst_ip       = $dst_ip;
        $this->src_port     = $src_port;
        $this->dst_port     = $dst_port;
        $this->condition    = $condition;
        $this->value        = $value;
        $this->time_interval = $time_interval;
        $this->absolute     = $absolute;
        $this->priority     = $priority;
        $this->reliability  = $reliability;
        $this->risk_c       = $risk_c;
        $this->risk_a       = $risk_a;
        $this->asset_src    = $asset_src;
        $this->asset_dst    = $asset_dst;
        $this->snort_sid    = $snort_sid;
        $this->snort_cid    = $snort_cid;
        $this->alarm        = $alarm;
    }

function get_id()               { return $this->id;             }
    function get_timestamp()        { return $this->timestamp;      }
    function get_sensor()           { return $this->sensor;         }
    function get_interface()        { return $this->interface;      }
    function get_type()             { return $this->type;           }
    function get_plugin_id()        { return $this->plugin_id;      }
    function get_plugin_sid()       { return $this->plugin_sid;     }
    function get_protocol()         { return $this->protocol;       }
    function get_src_ip()           { return $this->src_ip;         }
    function get_dst_ip()           { return $this->dst_ip;         }
    function get_src_port()         { return $this->src_port;       }
    function get_dst_port()         { return $this->dst_port;       }
    function get_condition()        { return $this->condition;      }
    function get_value()            { return $this->value;          }
    function get_time_interval()    { return $this->time_interval;  }
    function get_absolute()         { return $this->absolute;       }
    function get_priority()         { return $this->priority;       }
    function get_reliability()      { return $this->reliability;    }
    function get_risk_c()           { return $this->risk_c;         }
    function get_risk_a()           { return $this->risk_a;         }
    function get_asset_src()        { return $this->asset_src;      }
    function get_asset_dst()        { return $this->asset_dst;      }
    function get_snort_sid()        { return $this->snort_sid;      }
    function get_snort_cid()        { return $this->snort_cid;      }
    function alarm()                { return $this->alarm;          }
   
    function get_count($conn, $where = "")
    {
        $query = OssimQuery("SELECT count(*) FROM event $where");
        if (!$rs = &$conn->Execute($query)) {
            print $conn->ErrorMsg();
        } else {
            return $rs->fields["count(*)"];
        }
    }

function get_list($conn, $args = "", $inf = 0, $sup = 25)
    {
        $i = 0;
   
        $query = OssimQuery("SELECT *, inet_ntoa(src_ip), inet_ntoa(dst_ip)
            FROM event $args");
        if (!$rs = &$conn->Execute($query)) {
            print $conn->ErrorMsg();
        } else {
            $list = array();
            while (!$rs->EOF) {
                if (($i++ >= $inf) && ($inf++ <= $sup)) {
                        $list[] = new Event (  $rs->fields["id"],
                                           $rs->fields["timestamp"],
                                           $rs->fields["sensor"],
                                           $rs->fields["interface"],
                                           $rs->fields["type"],
                                           $rs->fields["plugin_id"],
                                           $rs->fields["plugin_sid"],
                                           $rs->fields["protocol"],
                                           $rs->fields["inet_ntoa(src_ip)"],
                                           $rs->fields["inet_ntoa(dst_ip)"],
                                           $rs->fields["src_port"],
                                           $rs->fields["dst_port"],
                                           $rs->fields["condition"],
                                           $rs->fields["value"],
                                           $rs->fields["time_interval"],
                                           $rs->fields["absolute"],
                                           $rs->fields["priority"],
                                           $rs->fields["reliability"],
                                           $rs->fields["risk_c"],
                                           $rs->fields["risk_a"],
                                           $rs->fields["asset_src"],
                                           $rs->fields["asset_dst"],
                                           $rs->fields["snort_sid"],
                                           $rs->fields["snort_cid"],
                                           $rs->fields["alarm"]);
                } elseif ($inf > $sup) {
                    break;
                }
                $rs->MoveNext();
            }
        }
        return $list;
    }

function delete($conn, $id)
    {
        if (!strcmp($id, "all")) {
            $sql = "DELETE FROM event";
            $params = array();
        } else {
            $sql = "DELETE FROM event WHERE id = ?";
            $params = array($id);
        }
        if ($conn->Execute($sql, $params) === false) {
            print ‘error deleting: ‘.$conn->ErrorMsg().‘<BR>‘;
        }
    }

}

?>

时间: 2024-10-10 10:27:21

OSSIM源码之Event.inc的相关文章

Zepto源码分析-event模块

源码注释 // Zepto.js // (c) 2010-2015 Thomas Fuchs // Zepto.js may be freely distributed under the MIT license. ;(function($){ var _zid = 1, undefined, slice = Array.prototype.slice, isFunction = $.isFunction, isString = function(obj){ return typeof obj

有关OSSIM源码

有关OSSIM源码 在OSSIM系统中绝大部分源码都能查到,但有些Python脚本进行了加密,例如/usr/share/alienvault/ossim-agent/./usr/share/ossim-framework/ossimframework/./usr/share/alienvault/alienvault-forward/对于这几个目录下的加密脚本,若读者需要可以到我博客(http://chenguang.blog.51cto.com )查询.目前Alievanult网站上发布的OS

libevent源码分析-event

event结构 event相关接口 Libevent对event的管理 event结构 event是Reactor模式中的最重要的组件.它包含了了一个句柄fd,并设置监听这个句柄上的哪些事件(读/写等),设置了对应的函数指针,在事件到来时,回调函数指针来处理事件. 先看一下event的结构.它位于include/event2/event_struct.h中 struct event { TAILQ_ENTRY(event) ev_active_next; TAILQ_ENTRY(event) e

Libevent源码分析—event, event_base

event和event_base是libevent的两个核心结构体,分别是反应堆模式中的Event和Reactor.源码分别位于event.h和event-internal.h中 1.event: struct event { TAILQ_ENTRY (event) ev_next; //I/O事件 TAILQ_ENTRY (event) ev_active_next; //所有激活事件的链表 TAILQ_ENTRY (event) ev_signal_next; //Signal事件 //定时

jQuery源码分析--Event模块(2)

接下来就是触发事件了.事件触发后的处理函数的分发主要靠两个函数,一个jQuery.event.dispatch,一个是jQuery.event.handlers.这个dispatch会调用handlers,而handlers会返回一个数组,这个数组是符合本次事件条件的所有处理函数对象.dispatch只管执行.那这个handlers是如何运作的呢.绑定在一个元素上面的非代理事件是肯定要被触发的,所以会全数被返回.主要是代理事件的筛选,jQuery会从触发了事件(target所指的元素)的元素一级

nginx源码分析——event模块

源码:nginx 1.12.0 一.简介 nginx是一款非常受欢迎的软件,具备高性能.模块化可定制的良好特性.之前写了一篇nginx的http模块分析的文章,主要对http处理模块进行了分析讲解,同时也涉及了nginx模块化的内容.至于nginx高性能的原因,希望能够在在这篇文章中就自己对于这方面的理解给大家分享一下. nginx的event处理模型包含两个方面:高效的IO处理函数,事件的异步处理(可选的线程池). 二.IO复用函数 nginx中包含epoll.poll.select.devp

jQuery源码分析--event事件绑定(上)

上文提到,jquery的事件绑定有bind(),delegate()和one()以及live()方式.我用的jQuery2.1.3版本,live()已经被废弃了. bind(),delegate()和one()的内部源码. //7491行 bind: function( types, data, fn ) { return this.on( types, null, data, fn ); }, //7498行 delegate: function( selector, types, data,

Libevent源码分析-event处理流程

event处理流程 Libevent处理时间的大概流程为 1.设置event_base(即初始化Reactor) 2.设置event事件(初始化event) 3.将event和event_base关联(将event注册到event_base) 4.进入循环,等待事件 5.事件发生,处理事件. 用UML序列图可以表示为: #include <iostream> #include <sys/time.h> #include <event.h> struct event ev

backbone-1.3.3源码解析-----------Event

第一次写,写的不对的请指正 backbone.js中的Event实现了自定义事件.自定义事件就是一个对象的键值对,key为事件名,value为一个function数组.在backbone这个对象中有一个内置的对象_events保存着所有的事件 所有Events的方法都是通过eventsApi调用的. eventsApi = function(iteratee, events, name, callback, opts){...} 分别传入offApi,onceMap,triggerApi作为ev