#include "debug.h"
#include "plugbase.h"
#include "parser.h"
#include "snort.h"
#include "scoreboard.h"
#include "server_stats.h"
#include "spp_flow.h"
#include "flowps.h"
#include "flowps_snort.h"
#include "packet_time.h"
#include "event_wrapper.h"
#include "generators.h"
#include "common_defs.h"
#include "util_str.h"
#include "util_net.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <ctype.h>
Go to the source code of this file.
Defines | |
#define | PSDEFAULT_SB_ROWS_ACTIVE 1000000 |
#define | PSDEFAULT_SB_MEMCAP_ACTIVE (ONE_MBYTE * 24) |
#define | PSDEFAULT_SB_ROWS_SCANNER (PSDEFAULT_SB_ROWS_ACTIVE/4) |
#define | PSDEFAULT_SB_MEMCAP_SCANNER (PSDEFAULT_SB_MEMCAP_ACTIVE/4) |
#define | PSDEFAULT_UT_ROWS 1000000 |
#define | PSDEFAULT_UT_MEMCAP (ONE_MBYTE * 24) |
#define | PSDEFAULT_SERVER_ROWS (1 << 16) |
#define | PSDEFAULT_SERVER_MEMCAP (ONE_MBYTE * 2) |
#define | PSDEFAULT_SERVER_LEARNING_TIME (ONE_HOUR * 8) |
#define | PSDEFAULT_SERVER_IGNORE_LIMIT 500 |
#define | PSDEFAULT_SERVER_SCANNER_LIMIT 500 |
#define | PSDEFAULT_BASE_SCORE 1 |
#define | PSDEFAULT_ALERT_ONCE 1 |
#define | PSDEFAULT_OUTPUT_MODE VARIABLEMSG |
#define | PSDEFAULT_TCP_PENALTIES 1 |
#define | PSTALKER_FIXED_SIZE 30 |
#define | PSTALKER_SLIDING_SIZE 30 |
#define | PSTALKER_SLIDING_SCORE 30 |
#define | PSTALKER_FIXED_SCORE 15 |
#define | PSTALKER_WINDOW_SCALE (0.5) |
#define | PSSCANNER_FIXED_SIZE 15 |
#define | PSSCANNER_SLIDING_SIZE 20 |
#define | PSSCANNER_SLIDING_SCORE 40 |
#define | PSSCANNER_FIXED_SCORE 15 |
#define | PSSCANNER_WINDOW_SCALE (0.5) |
#define | FLOWPSMAXPKTSIZE (IP_MAXPACKET - (IP_HEADER_LEN + ETHERNET_HEADER_LEN)) |
Functions | |
void | FlowPSRestart (int signal, void *data) |
void | FlowPSCleanExit (int signal, void *data) |
static void | FlowPSInit (u_char *args) |
static void | FlowPSParseArgs (PS_CONFIG *config, char *args) |
static int | flowps_generate_flow_event (SCORE_ENTRY *sep, FLOWPACKET *p, u_int32_t *address, FLOWPS_OUTPUT output_type, time_t cur) |
static int | flowps_init_pkt (void) |
static Packet * | flowps_mkpacket (SCORE_ENTRY *sep, FLOWPACKET *orig_packet, u_int32_t *address, time_t cur) |
void | FlowPSSetDefaults (PS_CONFIG *config) |
void | SetupFlowPS (void) |
static void | FlowPSOutputConfig (PS_TRACKER *trackerp) |
static void | FlowPSParseOption (PS_CONFIG *config, char *fname, int lineno, char *key, char *value) |
int | flowps_newflow_callback (FLOW_POSITION position, FLOW *flowp, int direction, time_t cur, FLOWPACKET *p) |
static int | score_entry_sprint (unsigned char *buf, int buflen, SCORE_ENTRY *sep, u_int32_t *address) |
Variables | |
static PS_TRACKER | s_tracker |
static int | s_debug = 0 |
static Packet * | s_pkt = NULL |
Definition in file flowps_snort.c.
|
Definition at line 74 of file flowps_snort.c. Referenced by flowps_mkpacket(). |
|
Definition at line 54 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 53 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 55 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 43 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 45 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 42 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 44 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 51 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 50 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 49 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 48 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 52 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
enable TCP penalities by default Definition at line 59 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 47 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 46 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
pt tally Definition at line 71 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 68 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
pt tally Definition at line 70 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
window frame Definition at line 69 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
multiplier for wsize Definition at line 72 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
pt tally Definition at line 65 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
Definition at line 62 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
pt tally Definition at line 64 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
window frame Definition at line 63 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
multiplier for wsize Definition at line 66 of file flowps_snort.c. Referenced by FlowPSSetDefaults(). |
|
|
Initialize the static packet used for the portscan flow plugin. This allocates 2 bytes over what it needs to so that the IP header will be 32bit aligned.
Definition at line 1041 of file flowps_snort.c. References _Packet::data, _Packet::eh, _EtherHdr::ether_dst, _EtherHdr::ether_src, _EtherHdr::ether_type, ETHERNET_HEADER_LEN, flow_fatalerror(), FLOW_SUCCESS, _IPHdr::ip_len, IP_MAXPACKET, _IPHdr::ip_proto, _IPHdr::ip_tos, _IPHdr::ip_ttl, _Packet::iph, memcpy, NULL, _Packet::pkt, _Packet::pkth, SET_IP_HLEN, and SET_IP_VER. Referenced by FlowPSInit(). |
|
Make a packet with the flowps data in it. This is used to generate a fake IP datagram to carry portscan data from snort so that it can be processed by custom utilities. SRC + DST mac addresses = "MACDAD" sip+dip == attacker ip proto 255 ttl = 0 chksum = 0
Definition at line 988 of file flowps_snort.c. References pcap_pkthdr::caplen, _Packet::data, _Packet::dsize, ETHERNET_HEADER_LEN, FLOWPSMAXPKTSIZE, GetIPv4DstIp(), _IPHdr::ip_dst, IP_HEADER_LEN, _IPHdr::ip_len, _IPHdr::ip_src, _Packet::iph, pcap_pkthdr::len, memcpy, NULL, _Packet::pkth, score_entry_sprint(), and pcap_pkthdr::ts. Referenced by flowps_generate_flow_event(). |
|
The callback for the flow-portscan module This function's purpose is to do about the same thing as a traditional snort preprocessor. The only difference is that this occurs only on a specific FLOW position. This individual callback position is only valid in the "NEW" flow position. The operations are pretty much the same as laid out by Chris Green, Marc Norton, Dan Roelker Basic code flow: 1) Get the score and flag type 2) return if the score is 0 3) Get the score entry node 4) Perform time window maintence
Definition at line 605 of file flowps_snort.c. References _PS_CONFIG::alert_once, _PS_TRACKER::config, _Packet::dp, _PS_SCORE_ENTRY::fixed_scanner, _PS_SCORE_ENTRY::fixed_talker, _PS_SCORE_ENTRY::flags, FLOW_NEW, FLOW_NOTFOUND, flow_printf(), FLOW_SUCCESS, flowkey_print(), flowps_add_entry(), flowps_enabled(), flowps_entry_print(), flowps_find_entry(), flowps_fixed_winadj(), flowps_generate_flow_event(), flowps_get_score(), flowps_is_ignored_ipv4(), flowps_score_entry(), flowps_set_last_address(), flowps_sliding_winadj(), GetTcpFlags(), inet_ntoax(), _FLOWKEY::init_address, _IPHdr::ip_dst, _IPHdr::ip_src, _Packet::iph, IsTcpPacket(), _FLOW::key, _PS_CONFIG::limit_scanner, _PS_CONFIG::limit_talker, mktcpflag_str(), NULL, _PS_CONFIG::output_mode, _PS_SCORE_ENTRY::position, _FLOWKEY::resp_address, s_debug, scoreboard_move(), _PS_SCORE_ENTRY::sliding_scanner, _PS_SCORE_ENTRY::sliding_talker, _Packet::sp, _PS_TRACKER::table_active, _PS_TRACKER::table_scanner, TRACKER_ACTIVE, and TRACKER_SCANNER. Referenced by flow_callbacks(). |
|
Definition at line 558 of file flowps_snort.c. References flowps_destroy(), flowps_stats(), NULL, pv, and _progvars::quiet_flag. Referenced by FlowPSInit(). |
|
Initialize the configuration of the flow preprocessor
Definition at line 222 of file flowps_snort.c. References AddFuncToCleanExitList(), AddFuncToRestartList(), file_line, file_name, flow_fatalerror(), FLOW_SUCCESS, flowps_init(), flowps_init_pkt(), FlowPSCleanExit(), FlowPSOutputConfig(), FlowPSParseArgs(), FlowPSRestart(), FlowPSSetDefaults(), NULL, _PS_CONFIG::sb_memcap_total, and SppFlowIsRunning(). Referenced by SetupFlowPS(). |
|
|
Parse out the snort.conf line output type - (variable alert string, custom file, pktkludge) watch-net - optional ignore-net - optional
Definition at line 490 of file flowps_snort.c. References file_line, file_name, flow_fatalerror(), FlowPSParseOption(), NULL, _PS_CONFIG::server_ignore_limit, _PS_CONFIG::server_scanner_limit, and _PS_CONFIG::server_watchnet_ipv4. Referenced by FlowPSInit(). |
|
Definition at line 270 of file flowps_snort.c. References _PS_CONFIG::alert_once, _PS_CONFIG::base_score, _PS_CONFIG::dst_ignore_ipv4, _PS_CONFIG::dumpall, file_line, file_name, _SCORE_THRESHOLD::fixed, _SCORE_THRESHOLD::fixed_size, flow_fatalerror(), flow_printf(), ip4_setparse(), ipset_new(), IPV4_FAMILY, _PS_CONFIG::limit_scanner, _PS_CONFIG::limit_talker, NULL, _PS_CONFIG::output_mode, PKTKLUDGE, s_debug, _PS_CONFIG::sb_memcap_scanner, _PS_CONFIG::sb_memcap_talker, _PS_CONFIG::sb_rows_scanner, _PS_CONFIG::sb_rows_talker, _PS_CONFIG::server_ignore_limit, _PS_CONFIG::server_learning_time, _PS_CONFIG::server_memcap, _PS_CONFIG::server_rows, _PS_CONFIG::server_scanner_limit, _PS_CONFIG::server_watchnet_ipv4, _SCORE_THRESHOLD::sliding, _SCORE_THRESHOLD::sliding_size, _PS_CONFIG::src_ignore_ipv4, strcasecmp, _PS_CONFIG::tcp_penalties, toggle_option(), _PS_CONFIG::ut_memcap, _PS_CONFIG::ut_rows, VARIABLEMSG, and _SCORE_THRESHOLD::window_scale. Referenced by FlowPSParseArgs(). |
|
Definition at line 553 of file flowps_snort.c. Referenced by FlowPSInit(). |
|
Definition at line 90 of file flowps_snort.c. References flowps_mkconfig(), flowps_mkthreshold(), _PS_CONFIG::limit_scanner, _PS_CONFIG::limit_talker, PSDEFAULT_ALERT_ONCE, PSDEFAULT_BASE_SCORE, PSDEFAULT_OUTPUT_MODE, PSDEFAULT_SB_MEMCAP_ACTIVE, PSDEFAULT_SB_MEMCAP_SCANNER, PSDEFAULT_SB_ROWS_ACTIVE, PSDEFAULT_SB_ROWS_SCANNER, PSDEFAULT_SERVER_IGNORE_LIMIT, PSDEFAULT_SERVER_LEARNING_TIME, PSDEFAULT_SERVER_MEMCAP, PSDEFAULT_SERVER_ROWS, PSDEFAULT_SERVER_SCANNER_LIMIT, PSDEFAULT_TCP_PENALTIES, PSDEFAULT_UT_MEMCAP, PSDEFAULT_UT_ROWS, PSSCANNER_FIXED_SCORE, PSSCANNER_FIXED_SIZE, PSSCANNER_SLIDING_SCORE, PSSCANNER_SLIDING_SIZE, PSSCANNER_WINDOW_SCALE, PSTALKER_FIXED_SCORE, PSTALKER_FIXED_SIZE, PSTALKER_SLIDING_SCORE, PSTALKER_SLIDING_SIZE, and PSTALKER_WINDOW_SCALE. Referenced by FlowPSInit(). |
|
Print the score entry to a buffer snprintf doesn't protect us any since we are calculating so much but it does make me be explicit on how much data I am putting in.
Definition at line 891 of file flowps_snort.c. References _CONN_ENTRY::cflags, _PS_SCORE_ENTRY::connections_seen, _PS_SCORE::ends, _PS_SCORE_ENTRY::event_id, _PS_SCORE_ENTRY::event_sec, _PS_SCORE_ENTRY::fixed_scanner, _PS_SCORE_ENTRY::fixed_talker, _PS_SCORE_ENTRY::flags, FLOWPS_HOSTS_SIZE, _CONN_ENTRY::ip, _PS_SCORE_ENTRY::last_hosts, _CONN_ENTRY::port, _CONN_ENTRY::protocol, _PS_SCORE::score, _PS_SCORE_ENTRY::sliding_scanner, _PS_SCORE_ENTRY::sliding_talker, snprintf, and _PS_SCORE::start. Referenced by flowps_mkpacket(). |
|
Definition at line 125 of file flowps_snort.c. References FlowPSInit(), and RegisterPreprocessor(). Referenced by SetupFlow(). |
|
Definition at line 77 of file flowps_snort.c. |
|
Definition at line 78 of file flowps_snort.c. |
|
Definition at line 76 of file flowps_snort.c. |