亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? op_sguil.c

?? 知名的開源IDS的日志工具
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* $Id: op_sguil.c,v 1.5 2004/04/03 19:57:33 andrewbaker Exp $ *//*** Copyright (C) 2001-2002 Andrew R. Baker <andrewb@snort.org>**** This program is distributed under the terms of version 1.0 of the ** Q Public License.  See LICENSE.QPL for further details.**** This program is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.***//* op_sguil is a modified op_acid_db plugin configured to work with * sguil (Snort GUI for Lamerz). Sguil and ACIDs DB schemas differ. * Sguil combines the event and iphdr tables along with moving the * src and dst port columns into event. I've also added SguilSendEvent * which opens a network socket and sends RT events to sguild. * * Andrew, sorry about mangling your code but it works so well :) * * Bammkkkk*//*  I N C L U D E S  *****************************************************/#ifdef ENABLE_MYSQL /* Wrap the whole thing in an ENABLE_MYSQL block */#include <stdio.h>#include <string.h>#include <stdlib.h>#include <sys/types.h>#include <netinet/in.h>#include <time.h>#include <errno.h>#include <unistd.h>#include <ctype.h>#include "strlcpyu.h"#include "ConfigFile.h"#include "plugbase.h"#include "mstring.h"#include "sid.h"#include "classification.h"#include "util.h"#include "input-plugins/dp_log.h"#include "op_plugbase.h"#include "op_decode.h"#include "event.h"/* Needed for network socket */#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <netdb.h>#ifdef ENABLE_MYSQL#include <mysql.h>#include <errmsg.h>#endif /* ENABLE_MYSQL *//*  D A T A   S T R U C T U R E S  **************************************/typedef struct _OpSguil_Data {    u_int8_t flavor;  /* what flavor of db?  MySQL, postgres, ... */    u_int16_t unused;    char *server;    char *database;    char *user;    char *password;    int sensor_id;    int options;    char *sguild_host;    int sguild_sock;    int sguild_port;    int nospin;    u_int32_t event_id;    /* db handles go here */#ifdef ENABLE_MYSQL    MYSQL *mysql;#endif /* ENABLE_MYSQL */} OpSguil_Data;#define MAX_QUERY_SIZE 8192#define SYSLOG_BUF 1024/* database flavor defines */#define FLAVOR_MYSQL    1#define FLAVOR_POSTGRES 2static char *sgdb_flavours[] = {NULL, "mysql", "postgres"};/* Network socket defines */#define MAX_MSG_LEN 100/* Output plug-in API functions */static int OpSguil_Setup(OutputPlugin *, char *args);static int OpSguil_Exit(OutputPlugin *);static int OpSguil_Start(OutputPlugin *, void *);static int OpSguil_Stop(OutputPlugin *);static int OpSguil_Log(void *, void *);static int OpSguil_LogConfig(OutputPlugin *outputPlugin);/* Internal functions */int SguildConnect(OpSguil_Data *);int SguilSendEvent(OpSguil_Data *data, char *eventMsg);int read_line();OpSguil_Data *OpSguil_ParseArgs(char *);int sgDbClose(OpSguil_Data *data);int sgDbConnect(OpSguil_Data *data);u_int32_t SguilGetNextCid(OpSguil_Data *data);u_int32_t SguilGetSensorId(OpSguil_Data *data);int SguilCheckSchemaVersion(OpSguil_Data *data);int InsertIPData(OpSguil_Data *data, Packet *p);int sgInsertICMPData(OpSguil_Data *data, Packet *p);int sgInsertUDPData(OpSguil_Data *data, Packet *p);int sgInsertTCPData(OpSguil_Data *data, Packet *p);int sgInsertPayloadData(OpSguil_Data *data, Packet *p);int sgSelectAsUInt(OpSguil_Data *data, char *sql, unsigned int *result);int sgInsert(OpSguil_Data *data, char *sql, unsigned int *row_id);int sgBeginTransaction(OpSguil_Data *);int sgEndTransaction(OpSguil_Data *);int sgAbortTransaction(OpSguil_Data *);#ifdef ENABLE_MYSQLint sgMysqlConnect(OpSguil_Data *);int sgMysqlClose(MYSQL *mysql);int sgMysqlSelectAsUInt(MYSQL *mysql, char *sql, unsigned int *result);int sgMysqlInsert(MYSQL *mysql, char *sql, unsigned int *row_id);#endif/* Global variables */static char sql_buffer[MAX_QUERY_SIZE];/*  * Rather than using an incremental connection id (cid), this uses the * current time in milliseconds. BY is fast, but will we get dups in the * same millisecond? * Okay, lets wait on doing this.long GetMilliseconds() {    struct timeval  tv;    gettimeofday(&tv, NULL);    return (long)(tv.tv_sec * 1000 + tv.tv_usec / 1000);}*//* init routine makes this processor available for dataprocessor directives */void OpSguil_Init(){    OutputPlugin *outputPlugin;    outputPlugin = RegisterOutputPlugin("sguil", "log");    outputPlugin->setupFunc = OpSguil_Setup;    outputPlugin->exitFunc = OpSguil_Exit;    outputPlugin->startFunc = OpSguil_Start;    outputPlugin->stopFunc = OpSguil_Stop;    outputPlugin->outputFunc = OpSguil_Log;    outputPlugin->logConfigFunc = OpSguil_LogConfig;    }int OpSguil_LogConfig(OutputPlugin *outputPlugin){    OpSguil_Data *data = NULL;    if(!outputPlugin || !outputPlugin->data)        return -1;    data = (OpSguil_Data *)outputPlugin->data;        LogMessage("OpSguil configured\n");    /* XXX We need to print the configuration details here */    return 0;}    /* Setup the output plugin, process any arguments, link the functions to * the output functional node */int OpSguil_Setup(OutputPlugin *outputPlugin, char *args){    /* setup the run time context for this output plugin */    outputPlugin->data = OpSguil_ParseArgs(args);    return 0;}/* Inverse of the setup function, free memory allocated in Setup  * can't free the outputPlugin since it is also the list node itself */int OpSguil_Exit(OutputPlugin *outputPlugin){    return 0;}/*  * this function gets called at start time, you should open any output files * or establish DB connections, etc, here */int OpSguil_Start(OutputPlugin *outputPlugin, void *spool_header){    char tmpMsg [256];    OpSguil_Data *data = (OpSguil_Data *)outputPlugin->data;    LogMessage("OpSguil_Start\n");    if(data == NULL)        FatalError("ERROR: Unable to find context for Sguil startup!\n");    /* Connect to sguild */    if(SguildConnect(data))      FatalError("OpSguil_: Failed to connect to sguild: %s:%i\n",        data->sguild_host, data->sguild_port);    /* Write a system-info message*/    sprintf(tmpMsg, "RTEvent |||system-info|%s||Barnyard started.||||||||\n", pv.hostname);    SguilSendEvent(data, tmpMsg);        /* Connect to the database */    if(sgDbConnect(data))        FatalError("OpSguil_: Failed to connect to database: %s:%s@%s/%s\n",                data->user, data->password, data->server, data->database);    /* check the db schema */    /*if(SguilCheckSchemaVersion(data))        FatalError("OpSguil_: database schema mismatch\n");*/     /* if sensor id == 0, then we attempt attempt to determine it dynamically */    if(data->sensor_id == 0)    {        data->sensor_id = SguilGetSensorId(data);        /* XXX: Error checking */    }    /* Get the next cid from the database */    data->event_id = SguilGetNextCid(data);    if(pv.verbose)    {        LogMessage("OpAcidDB configuration details\n");        LogMessage("Database Flavour: %s\n", sgdb_flavours[data->flavor]);        LogMessage("Database Server: %s\n", data->server);        LogMessage("Database User: %s\n", data->user);        LogMessage("SensorID: %i\n", data->sensor_id);        LogMessage("Sguild Host: %s\n", data->sguild_host);        LogMessage("Sguild Port: %i\n", data->sguild_port);    }    if((data->nospin) == NULL)    {        if(pv.verbose)        {            LogMessage("Barnyard will sleep(15) if unable to connect to sguild.\n");        }        data->nospin = 0;    }    else    {        if(pv.verbose)        {            LogMessage("Spinning disabled.\n");        }    }    sprintf(tmpMsg, "RTEvent |||system-info|%s||Database Server: %s.||||||||\n",		   pv.hostname, data->server);    SguilSendEvent(data, tmpMsg);    sprintf(tmpMsg, "RTEvent |||system-info|%s||Database Next CID: %i.||||||||\n",		    pv.hostname, data->event_id);    SguilSendEvent(data, tmpMsg);    return 0;}int OpSguil_Stop(OutputPlugin *outputPlugin){    OpSguil_Data *data = (OpSguil_Data *)outputPlugin->data;    if(data == NULL)        FatalError("ERROR: Unable to find context for Sguil startup!\n");    /* close database connection */    sgDbClose(data);        return 0;}/* sguil only uses log */int OpSguil_Log(void *context, void *data){    char timestamp[TIMEBUF_SIZE];    char syslogMessage[SYSLOG_BUF];    char eventInfo[SYSLOG_BUF];    //int MAX_INSERT_LEN = 1024;    char insertColumns[MAX_QUERY_SIZE];    char insertValues[MAX_QUERY_SIZE];    char valuesTemp[MAX_QUERY_SIZE];    char ipInfo[38];    char portInfo[16];    char *esc_message;    Sid *sid = NULL;    ClassType *class_type;    UnifiedLogRecord *record = (UnifiedLogRecord *)data;     OpSguil_Data *op_data = (OpSguil_Data *)context;    Packet p;    bzero(syslogMessage, SYSLOG_BUF);    bzero(insertColumns, MAX_QUERY_SIZE);    bzero(insertValues, MAX_QUERY_SIZE);#if 0 /* this is broken */    /* skip tagged packets, since the db does not have a mechanism to      * deal with them properly     */    if(record->log.event.event_reference)    {        LogMessage("Skipping tagged packet %i\n", record->log.event.event_reference);        return 0;    }#endif    RenderTimestamp(record->log.pkth.ts.tv_sec, timestamp, TIMEBUF_SIZE);    //fprintf(stdout, "Timestamp: %lu\n", GetMilliseconds());    //fflush(stdout);    sid = GetSid(record->log.event.sig_generator, record->log.event.sig_id);    if(sid == NULL)        sid = FakeSid(record->log.event.sig_generator, record->log.event.sig_id);    class_type = GetClassType(record->log.event.classification);    //sgBeginTransaction(op_data); /* XXX: Error checking */    /* Build the event insert. */    snprintf(insertColumns, MAX_QUERY_SIZE,            "INSERT INTO event (status, sid, cid, signature_id, signature_rev, signature, timestamp, priority, class");    esc_message = malloc(strlen(sid->msg)*2+1);    mysql_real_escape_string(op_data->mysql, esc_message, sid->msg, strlen(sid->msg));    if(class_type == NULL)    {        snprintf(valuesTemp, MAX_QUERY_SIZE,                "VALUES ('0', '%u', '%u', '%d', '%d', '%s', '%s', '%u', 'unknown'",                op_data->sensor_id, op_data->event_id, sid->sid, sid->rev, esc_message, timestamp,                 record->log.event.priority);        snprintf(eventInfo, SYSLOG_BUF, "RTEvent |0|%u|unknown|%s|%s|%u|%u|%s",                record->log.event.priority,                 pv.hostname, timestamp, op_data->sensor_id, op_data->event_id,                sid->msg);    }    else    {        snprintf(valuesTemp, MAX_QUERY_SIZE,                "VALUES ('0', '%u', '%u', '%d', '%d', '%s', '%s', '%u', '%s'",                op_data->sensor_id, op_data->event_id, sid->sid, sid->rev, esc_message, timestamp,                 record->log.event.priority, class_type->type);        snprintf(eventInfo, SYSLOG_BUF, "RTEvent |0|%u|%s|%s|%s|%u|%u|%s",                record->log.event.priority, class_type->type,                pv.hostname, timestamp, op_data->sensor_id, op_data->event_id,                sid->msg);    }    free(esc_message);    insertValues[0] = '\0';    strcat(insertValues, valuesTemp);    syslogMessage[0] = '\0';    strcat(syslogMessage, eventInfo);    /* decode the packet */    if(DecodePacket(&p, &record->log.pkth, record->pkt + 2) == 0)    {        if(p.iph)        {            /* Insert ip header information */            //InsertIPData(op_data, &p);            strcat(insertColumns,                    ",src_ip, dst_ip, ip_proto, ip_ver, ip_hlen, ip_tos, ip_len, ip_id, ip_flags, ip_off, ip_ttl, ip_csum");            snprintf(valuesTemp, MAX_QUERY_SIZE,                    ",'%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u'",

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
免播放器亚洲一区| 亚洲成人在线免费| 欧美色涩在线第一页| 久久电影网电视剧免费观看| 亚洲韩国精品一区| 中文字幕一区在线| 精品精品欲导航| 欧美日本在线看| 一本久久a久久免费精品不卡| 国产成人一区二区精品非洲| 麻豆精品视频在线观看免费| 亚洲电影一区二区三区| 中文字幕亚洲电影| 国产精品美女久久久久av爽李琼| 日韩精品中文字幕在线一区| www.激情成人| 9l国产精品久久久久麻豆| 国产一区91精品张津瑜| 国产在线播放一区| 久久精品99久久久| 视频一区视频二区中文字幕| 亚洲一区欧美一区| 亚洲大片一区二区三区| 亚洲图片自拍偷拍| 亚洲第一精品在线| 亚洲综合久久久久| 日韩中文字幕av电影| 丝袜美腿亚洲综合| 蜜臀久久99精品久久久画质超高清| 中文字幕在线观看不卡视频| 国产精品对白交换视频| 最新国产成人在线观看| 亚洲综合在线五月| 中文一区二区在线观看| 亚洲欧美色一区| 亚洲国产精品影院| 麻豆国产欧美一区二区三区| 老司机一区二区| 成人免费看的视频| 色婷婷av一区二区三区软件| 欧美日韩一级片在线观看| 欧美一区二区三区免费视频 | 日韩福利视频导航| 久久99国产精品免费| 国产乱色国产精品免费视频| 国产一区二区三区不卡在线观看 | 五月综合激情婷婷六月色窝| 日本在线不卡一区| 国产成人一区二区精品非洲| 激情综合网av| 欧美综合欧美视频| 久久免费看少妇高潮| 亚洲免费在线观看| 精品亚洲porn| 国产成人精品午夜视频免费| 91在线免费播放| 欧美一区日本一区韩国一区| 久久蜜桃一区二区| 樱桃视频在线观看一区| 久久精品国产亚洲5555| 色妹子一区二区| 精品美女一区二区| 亚洲国产成人精品视频| 国产一区91精品张津瑜| 欧美日本韩国一区二区三区视频| 日韩欧美国产一区二区三区 | thepron国产精品| 91精品国产91综合久久蜜臀| 中文字幕在线观看不卡| 久久99精品国产| 337p亚洲精品色噜噜| 亚洲欧洲另类国产综合| 久久99国产精品成人| 欧美综合亚洲图片综合区| 亚洲国产成人午夜在线一区| 狠狠网亚洲精品| 久久精品在线免费观看| 国产精品亚洲人在线观看| 久久久亚洲国产美女国产盗摄 | 久久99国产精品麻豆| 精品国产乱码久久久久久久久| 蜜桃久久精品一区二区| 日韩精品中文字幕一区| 精品一区二区三区香蕉蜜桃 | 3atv在线一区二区三区| 奇米影视7777精品一区二区| 欧美一区二区三区四区高清| 经典三级一区二区| 久久精品视频在线看| 99热在这里有精品免费| 悠悠色在线精品| 欧美成人vps| 福利一区二区在线| 亚洲精品国久久99热| 欧美日韩的一区二区| 久久99国产精品久久99| 自拍偷拍国产精品| 欧美精品粉嫩高潮一区二区| 韩国毛片一区二区三区| 中文字幕亚洲成人| 91精品国产综合久久精品| 国产成人综合在线| 亚洲高清免费观看| 久久夜色精品一区| 在线观看亚洲精品| 国产自产高清不卡| 一区二区三区精密机械公司| 欧美一区午夜视频在线观看| 成人精品一区二区三区四区| 亚洲国产成人porn| 久久久国际精品| 欧美日产在线观看| 成人手机在线视频| 美女网站在线免费欧美精品| ...av二区三区久久精品| 日韩午夜在线观看视频| 91一区一区三区| 韩国欧美国产1区| 婷婷综合久久一区二区三区| 日本一区二区电影| 精品免费国产二区三区 | 国产综合色精品一区二区三区| 亚洲精品自拍动漫在线| 欧美激情一区二区在线| 日韩一级精品视频在线观看| 色偷偷88欧美精品久久久| 国产精品自拍三区| 日本vs亚洲vs韩国一区三区二区| 亚洲色图都市小说| 久久精品在这里| www欧美成人18+| 日韩精品一区二| 欧美一级理论片| 777奇米成人网| 欧美丝袜自拍制服另类| 91国偷自产一区二区三区观看| 粉嫩av一区二区三区粉嫩| 国产在线乱码一区二区三区| 日产欧产美韩系列久久99| 午夜精品一区二区三区免费视频| 成人欧美一区二区三区小说 | 久久亚洲综合av| 日韩欧美一卡二卡| 91精品国产免费| 日韩视频一区二区在线观看| 777a∨成人精品桃花网| 欧美日韩中文另类| 在线观看日韩一区| 精品视频免费看| 欧美日韩午夜影院| 欧美精品第1页| 日韩欧美国产一二三区| 欧美一区二区精品在线| 欧美一区二区三区在线电影 | 成人欧美一区二区三区在线播放| 国产精品女人毛片| 17c精品麻豆一区二区免费| 亚洲欧洲精品一区二区三区不卡| 亚洲视频1区2区| 亚洲午夜精品网| 久久99精品久久久久婷婷| 国产高清久久久久| 91网站在线观看视频| 在线观看亚洲a| 91精品国产91久久综合桃花| 欧美tickling挠脚心丨vk| 久久久久久久久久久久久女国产乱 | 日韩欧美亚洲国产精品字幕久久久 | 天堂成人国产精品一区| 日韩精彩视频在线观看| 久久精品国产久精国产| 国产91精品精华液一区二区三区| 成人黄色777网| 欧美三级在线看| 日韩精品中文字幕一区二区三区| 国产欧美一区二区三区在线看蜜臀| 国产精品天干天干在观线| 亚洲精品乱码久久久久久| 日韩电影在线观看一区| 国产精品888| 欧美在线观看一区二区| 久久综合久久综合久久| 亚洲婷婷综合久久一本伊一区| 亚洲国产另类av| 国产91富婆露脸刺激对白| 欧美亚洲一区三区| 久久综合九色综合97婷婷女人| 欧美国产日韩亚洲一区| 亚洲午夜在线视频| 国产成人综合在线播放| 欧美日韩黄视频| 欧美国产日韩精品免费观看| 亚洲最大成人网4388xx| 丁香一区二区三区| 欧美群妇大交群的观看方式| 国产精品妹子av| 精品在线一区二区三区| 91福利区一区二区三区| 国产亚洲一区二区三区在线观看| 亚洲中国最大av网站|