readme.spade.usage

来自「入侵检测系统.linux下与MySql连用的例子」· USAGE 代码 · 共 306 行

USAGE
306
字号
Usage file for the Spade v092200.1----------------------------------Author: Jim Hoagland (hoagland@SiliconDefense.com)This file contains information about how to use and configure the StatisticalPacket Anomaly Detection Engine (Spade), spp_anomsensor.-= The main configuration line =-To enable spp_anomsensor, you must have a line of this form in your snortconfiguration file:    preprocessor spade: <anom-report-thresh> <state-file> <log-file> <prob-mode> <checkpoint-freq>For example:    preprocessor spade: 10.5 spade.rcv log.txt 3 50000The following subsections describe what these arguments mean and additionalavailable lines in the configuration do.  Note that on this line and all Spadeconfiguration lines that if you leave some of the arguments at the end, theywill assume their default value.-= Threshold =-<anom-report-thresh> is the (initial) threshold at which packets are reported. If a packet has an anomaly score at least as big as this threshold, it willbe sent as an alert.  If this is a negative number, Spade will start up withan with no reporting.  -1 is the default.-= Log file =-<log-file> is a the logging file for Spade.  This is regenerated on everySIGHUP, SIGQUIT, and SIGUSR1 and on Snort exit.  At a minimum, the number ofpackets accepted by Spade (not counting those that were not TCP SYNs or thatdid not meet the homenet requirements) and the number of alerts sent isreported here.  Some optional parts of Spade write to this log file as well.If this argument is '-', then standard output (stdout) is used.  '-' is thedefault.-= Checkpointing and recovery =-Since Spade maintains a history-based probability table, it is important tohave persistent storage for this table, especially since some sites restarttheir snort processes regularly.Towards this end, Spade has a checkpoint and recovery feature.  (At present,this just covers the probability tables.)  The state file is given by the<state-file> argument (default "spade.rcv").  If this file is present whenstarting up, the initial state of Spade is taken from this.  (Otherwise itstarts up with a clean slate.)  Periodically this state file is updated withthe current state.  This is done with a frequency of every <checkpoint-freq>accepted packets (default 50000), on SIGHUP, SIGQUIT, and SIGUSR1, and onSnort exit.To disable checkpointing and recovering (not generally recommended), give "0"as the <state-file> argument.Note that the size of the of file is roughly the size of Spade in memory. Also note that it may take a few seconds to checkpoint during which time snortwill not otherwise run.-= Probability mode =-There are four probability modes available in Spade.  These modes configurehow Spade determines the likelihood of a particular packet.  We do not knowwhich is best and it might be different depending on the characteristics ofyour network, so we allow you to decide.  You may just want to leave thedefault unless you wish to play with it.The probability mode is set by the <prob-mode> argument on the mainconfiguration line.  The possible values are:+ 0:  a Bayes network approximation of P(sip,sport,dip,dport)+ 1:  P(sip,sport,dip,dport)+ 2:  P(sip,dip,dport)+ 3:  P(dip,dport)The default is 3.Warning:  If you change probability modes, you will need to discard yourstate-file from checkpointing.  The wrong set of information has beenrecorded.  Not doing this will not cause a crash, the probabilities may justbe off.-= Home networks =-You can restrict Spade to considering packets destined to particular networksor hosts.  That is, packets for addresses outside those networks are ignoredby Spade.   The default is to consider all packets.  To enable this, add aline like this to your snort configuration file:    preprocessor spade-homenet: <network> <network> ...where <network> is either CIDR notation for a network (e.g., 123.123.128.0/17)or an IP address (e.g. 123.123.123.123).Note that this home network specification is independent of the -h option ofsnort and the HOMENET variable in the rules file.-= Finding a good threshold =-There are 4 facilities for helping you find and maintain an appropriatereporting threshold, so that you do not get flooded with alerts about normalpackets by having too low of a threshold and so that you do not miss packetsof interest by having too high a threshold.  One is threshold learning and theother three are different means of automatically adapting the threshold tomeet observed conditions.The premise for these is that you want to aim for a certain rate of alerts, arate just high enough to catch interesting events.  Each of these facilitiesobserves the network for a certain interval of time, keeping record of theanomaly scores for the packets observed.  Based on this, an "ideal" thresholdcan be derived that would have produced exactly the number of alerts wanted. At least, during that time interval.  We have observed that this is a prettynoisy process and this will vary from interval to interval.Note that regardless of the way your threshold is set, your rate of alertswill not be steady.  This is since the rate of anomalous events is not steady. For example, if someone runs a noisy Nmap on you, you will get more alertsthan normal (unless, of course, this is normal).  So, for whatever target rateyou aim for, consider that to be your target for most of the time intervals.You can either use one of the 4 facilities described in the next twosubsections or do it yourself by trying out different threshold values.-= Threshold learning =-To start up threshold learning mode when Snort starts up, provide a line ofthis form in the Snort configuration file:	preprocessor spade-threshlearn: <num-scores> <obs-time>	This mode is enabled for <obs-time> hours (default 24), after which it reportson the threshold that would have been needed to produce <num-scores> scores(default 200) during that time.  At the end of the time period, a report aboutthis is generated to the log file specified on the main sensor configurationline.  An intermediate report is produced on every SIGHUP, SIGQUIT, andSIGUSR1 and on Snort exit.-= Threshold adapting =-There are three modes of adapting.  None of these are on by default, but ifone were, then method #3 would be the default since we think it should workthe best.  Your network may disagree though :).Method #1 is the simplest approach.  It periodically takes a weighted averageof the current threshold and the recently observed ideal.  You activate thisby adding a line of this form to the Snort configuration file:    preprocessor spade-adapt: <target-count> <adapt-time> <new-weight> <interval-by-count>The target packet count is given by the <target-count> argument (default 20).The length of time during which that count is aimed for and the refresh ratefor the threshold is given by <adapt-time> (default 2).  <new-weight> is theweight given to the new component of the weighted average (default 0.5). Higher values (up to 1.0) give more weight to recent observations.An option with method #1 is to measure the adapt period by packet count ratherthan by time.  That is, the adapt time specification is converted into a countof packets, based on the current best estimate of a rate of packets.  Theadvantage here is that observed ideal values between periods is more likely tobe similar since about the same number of packets were considered for each, sothe transitions will be steadier.  This is on by default.  To disable, set the<interval-by-count> argument to 0 (rather than 1).Method #2 is more involved.  A new threshold is based the average of short,medium and long term components.  This is the line to add to the configurationfile:    preprocessor spade-adapt2: <target-spec> <obs-time> <NS> <NM> <NL><target-spec> is the specification of the number of alerts wanted.  If it is>= 1, it is an hourly alert rate.  If it is < 1, then it is a fraction ofconsidered packets to report, based on the best estimate of your packet rate. The later form of specification might be preferred if your network mightexperience a shift in packet rates.  The default is 0.01 (1%).<obs-time> is the number of minutes in an observation window (default 15). The is the frequency with which the reporting threshold is updated and isactually converted to a packet count.  <NS> times <obs-time> is how long theshort term is.  The default for <NS> is 4, so the combined default is 1 hour. <NM> is the number of short term periods in the medium term (default 24) and<NL> is the number of medium term periods in the long term (default 7).For a more complete description of how this mode works, see the comments inthe source code.Method #3 is fairly simple.  The reporting threshold is based on an average ofthe ideal threshold values from the last N observation periods.  (If therehaven't been N observation periods yet, it just takes the average of the onesseen so far).  This mode is invoked with a line of the form:    preprocessor spade-adapt3: <target-spec> <obs-time> <num-obs>    <target-spec> is the specification of the target alert rate and takes the sameform as that in method #2 (default 0.01).  <obs-time> is the number of minutesin a period of observation (default 60); this is converted to count ofpackets.  <num-obs> is the number of observations to average over (default168, which is the number of hours in a week).-= Survey mode =-Survey mode periodically reports information about the anomaly scores producedin the last time interval.  It is activated with the following line:    preprocessor spade-survey: <survey-file> <observation-period>where <survey-file> is the file to write the output to (default is standardoutput) and <observation-period> is the frequency of the observation period,in minutes (default 60).  This mode is active for as long as Snort is running.The file produced is in a table form suitable for importing into spreadsheetsand databases.  A line of column headers is on the first line and thefollowing are tab-separated on the following lines:+ interval #+ number of accepted packets in the interval+ median (50th percentile) anomaly score in the interval+ 90th percentile anomaly score+ 99th percentile anomaly scoreLinear interpolation is used for the percentile results if there is no exactscore in the indicated position.Note that at present a O(n*n) algorithm is used for storing the anomalyscores, so that when number of accepted packets in the interval becomes large,this mode runs slowly.  If this mode becomes used seriously, we should use anorder statistics tree or some other O(n*log(n)) algorithm.-= Statistics mode =-When the statistics mode is activated certain information about the networktraffic is reported.  This makes use of the already available probabilitiesfrom the calculation of the anomaly scores, which will depend on theprobability mode selected.  It is enabled with the following line in theconfiguration file:    preprocessor spade-stats: <stat-option> <stat-option> ...where <stat-option> is one of:+ "entropy" (to display the known entropies and conditional entropies)+ "uncondprob" (to display the known non-0 simple (joint) probabilities)+ "condprob" (to display the known non-0 conditional (joint) probabilities)These are written to the log file on SIGHUP, SIGQUIT, and SIGUSR1 and on Snortexit.  Be aware that it might take a while to write the "uncondprob" and"condprob" results as there is in general alot of those.The following results are available from probability mode 3:+ H(dip), H(dport|dip)+ P(dip=x), P(dip=x,dport=y)+ P(dport=x|dip=y)For finer grained control over what statistics are available, you will need tomodify the source code.  See the "parts" variable.  Warning:  this process isa bit ugly.-= Source code parameters =-There are a few tunable parameters that you will need to change some numbersin the source code in order to adjust.  Fortunately most people probably won'twant to change these anyway.A set of parameters in anomsensor_plug.h configure how the adjustment ofprobability is done to more strongly reflect recent network characteristics. SCALE_FREQ is the frequency (in seconds) with which this is updated (4 hoursis the distributed value).  Note that scaling is a fairly intensive operation.SCALE_FACTOR is the relative weight to give to traffic observed before anupdate as compared to the traffic after (0.96409 is the distributed value).  It is reasonable to adjust these without discarding the state file.  So, theprobabilities you had before the scale is only SCALE_FACTOR as important asthose in the later period.  4 hours and 0.96409 together imply a half life ofa little over 3 days.At some point, the occurrance of something a long time ago (relative to thenumber of times it occurred) makes little difference in the anomaly scoresproduces, so it might as well be discarded to save memory.  MIN_NODE_SIZE isthe size of an occurrance count at which the record of something has occurredis discarded (distributed value is 0.18).  The combination of these parametersas distributed means that a one-time occurrence is discarded after a littleover one week (and a double occurrance after two weeks, etc.).A different set of parameters are used to control how much memory can be usedin maintaining the probability state.  A description of exactly what these dorequires a discussion beyond the scope of this document.  For now, if you geta message of the form "exhausted all X blocks of Y <whatever>, try increasingthe corresponding DEFAULT_MAX_*_SIZE parameter in params.h.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?