📄 parameters.java
字号:
/*================= * Copyright (C) 2001 Todd Kaplan * * Lisys is a program that monitors TCP SYN packets to detect network * traffic anomalies. * * Licensed under the GNU General Public License (GPL), version 2 or * higher. Please see the COPYING and PATENT files included with the Lisys * distribution, which can be found at: * * http://www.cs.unm.edu/~judd/lisys/ * * Also, the current text of the GPL can be found at: * * http://www.gnu.org/copyleft/gpl.html * * Note that Lisys has NO WARRANTY! *=================*/package edu.unm.cs.lisys.detection;import edu.unm.cs.lisys.debug.*;import edu.unm.cs.lisys.detection.bip.*;import edu.unm.cs.lisys.detection.bif.*;import edu.unm.cs.lisys.detection.matchrule.*;import java.util.*;import java.io.*;import java.lang.reflect.*;/*========== * Parameters.java * * Here are the people who have worked on this code in the order they * have worked on it: * @author Todd Kaplan <kaplan@cs.unm.edu> * @author Hajime Inoue <hinoue@cs.unm.edu> * @author Justin Balthrop <judd@cs.unm.edu> *==========*/public class Parameters implements Serializable{ private String debugLevel = "standard"; private String host = ""; private int port = 9090; private String saveFile = ""; private int saveDelay = 10000; private String anomaliesLog = ""; private String bipType = "bip.TCPDump49BitBIP"; private String bifType = "bif.PurePermutationBIF"; private String matchRuleType = "matchrule.ContiguousMatchesMatchRule"; private int matchLength = 12; private int activationThreshold = 10; private double sensitivityIncrement = 1.5; private double sensitivityDecay = 0.1; private int maxMemoryDetectors = 0; private boolean useMemory = false; private int numberDetectors = 100; private int maxPossibleDetectors = 10000; private double deathProbability = 0.0; private int tolerizationPeriod = 50000; private long randomSeed = 10000; private int costimulationDelay = 25000; private boolean costimulationStatus = false; private Vector costimulationMailList = new Vector(); private int costimulationMailDelay = 200; private String costimulationServer = ""; private int costimulationServerPort = 0; private double matchDecay = 0; public Parameters(String propsFilename) { Properties props = new Properties(System.getProperties()); try { props.load(new BufferedInputStream(new FileInputStream(propsFilename))); System.setProperties(props); } catch (IOException ioe) { Debug.exception(this, ioe); } // set the global debug level debugLevel = getStringProperty(props, "debug.level", debugLevel); Debug.setLevel(debugLevel); host = getStringProperty(props, "detection.node.host", host); port = getIntProperty(props, "detection.node.port", port); saveFile = getStringProperty(props, "save.file", saveFile); anomaliesLog = getStringProperty(props, "anomalies.log.file", anomaliesLog); saveDelay = getIntProperty(props, "save.delay", saveDelay); bipType = getStringProperty(props, "bip.type", bipType); bifType = getStringProperty(props, "bif.type", bifType); matchRuleType = getStringProperty(props, "matchrule.type", matchRuleType); matchLength = getIntProperty(props, "matchrule.matchlength", matchLength); activationThreshold = getIntProperty (props, "activation.threshold", activationThreshold); sensitivityIncrement = getDoubleProperty (props, "sensitivity.increment", sensitivityIncrement); sensitivityDecay = getDoubleProperty (props, "sensitivity.decay", sensitivityDecay); maxMemoryDetectors = getIntProperty (props, "detectors.max.memory", maxMemoryDetectors); useMemory = getBooleanProperty(props, "memory.use", useMemory); numberDetectors = getIntProperty(props, "detectors.number", numberDetectors); maxPossibleDetectors = getIntProperty (props, "detectors.max.possible", maxPossibleDetectors); deathProbability = getDoubleProperty (props, "death.probability", deathProbability); tolerizationPeriod = getIntProperty (props, "tolerization.period", tolerizationPeriod); randomSeed = getLongProperty(props, "random.seed", randomSeed); costimulationDelay = getIntProperty (props, "costimulation.delay", costimulationDelay); costimulationStatus = getBooleanProperty (props, "costimulation.status", costimulationStatus); costimulationMailList = getStringVectorProperty (props, "costimulation.mail.list", costimulationMailList); costimulationMailDelay = getIntProperty (props, "costimulation.mail.delay", costimulationMailDelay); costimulationServer = getStringProperty (props, "costimulation.server", costimulationServer); costimulationServerPort = getIntProperty (props, "costimulation.server.port", costimulationServerPort); matchDecay = getDoubleProperty(props, "match.decay", matchDecay); } private String getStringProperty(Properties props, String key, String value) { String s = props.getProperty(key); if (s == null) return value; else return s; } private Vector getStringVectorProperty(Properties props, String key, Vector value) { Vector v = new Vector(); String s = props.getProperty(key); if (s == null) { return value; } else { StringTokenizer st = new StringTokenizer(s, ":"); while (st.hasMoreTokens()) v.addElement(st.nextToken()); } return v; } private boolean getBooleanProperty(Properties props, String key, boolean value) { String s = props.getProperty(key); if (s == null) return value; else return (Boolean.valueOf(s)).booleanValue(); } private long getLongProperty(Properties props, String key, long value) { String s = props.getProperty(key); long l; if (s == null) { return value; } else { try { l = Long.parseLong(s); } catch (NumberFormatException e) { Debug.exception(this, e); return value; } } return l; } private double getDoubleProperty(Properties props, String key, double value) { String s = props.getProperty(key); double d; if (s == null) { return value; } else { try { Double bigD = Double.valueOf(s); d = bigD.doubleValue(); } catch (NumberFormatException e) { Debug.exception(this, e); return value; } } return d; } private int getIntProperty(Properties props, String key, int value) { String s = props.getProperty(key); int i; if (s == null) { return value; } else { try { i = Integer.parseInt(s); } catch (NumberFormatException e) { Debug.exception(this, e); return value; } } return i; } public BinaryInputPattern getBIP() { try { BinaryInputPattern bip = (BinaryInputPattern) Class.forName(bipType).newInstance(); return bip; } catch (Exception e) { Debug.exception(this, e); } return null; } public String getBIPType() { return bipType; } public void setBIPType(String s) { bipType = s; } public int getBIPLength() { try { BinaryInputPattern bip = getBIP(); return bip.getLength(); } catch (Exception e) { Debug.exception(this, e); } return 0; } public BinaryInputFilter getBIF() { try { BinaryInputFilter bif = (BinaryInputFilter) Class.forName(bifType).newInstance(); return bif; } catch (Exception e) { Debug.exception(this, e); } return null; } public String getBIFType() { return bifType; } public void setBIFType(String s) { bifType = s; } public MatchRule getMatchRule() { try { MatchRule mr = (MatchRule) Class.forName(matchRuleType).newInstance(); return mr; } catch (Exception e) { Debug.exception(this, e); } return null; } public String getMatchRuleType() { return matchRuleType; } public void setMatchRuleType(String s) { matchRuleType = s; } public String getDetectionNodeHost() { return host; } public int getPort() { return port; } public String getSaveFile() { return saveFile; } public int getSaveDelay() { return saveDelay; } public String getAnomaliesLog() { return anomaliesLog; } public int getMatchLength() { return matchLength; } public void setMatchLength(int i) { matchLength = i; } public int getActivationThreshold() { return activationThreshold; } public void setActivationThreshold(int i) { activationThreshold = i; } public double getSensitivityIncrement() { return sensitivityIncrement; } public void setSensitivityIncrement(double d) { sensitivityIncrement = d; } public double getSensitivityDecay() { return sensitivityDecay; } public void setSensitivityDecay(double d) { sensitivityDecay = d; } public int getMaximumNumberOfMemoryDetectors() { return maxMemoryDetectors; } public void setMaximumNumberOfMemoryDetectors(int i) { maxMemoryDetectors = i; } public boolean useMemory() { return useMemory; } public int getNumberOfDetectors() { return numberDetectors; } public void setNumberOfDetectors(int i) { numberDetectors = i; } public int getMaximumPossibleDetectors() { return maxPossibleDetectors; } public void setMaximumPossibleDetectors(int i) { maxPossibleDetectors = i; } public double getDeathProbability() { return deathProbability; } public void setDeathProbability(double d) { deathProbability = d; } public int getTolerizationPeriod() { return tolerizationPeriod; } public void setTolerizationPeriod(int i) { tolerizationPeriod = i; } public long getRandomSeed() { return randomSeed; } public int getCostimulationDelay() { return costimulationDelay; } public boolean getCostimulationStatus() { return costimulationStatus; } public Vector getCostimulationMailList() { return costimulationMailList; } public int getCostimulationMailDelay() { return costimulationMailDelay; } public void setCostimulationDelay(int i) { costimulationDelay = i; } public String getCostimulationServer() { return costimulationServer; } public int getCostimulationServerPort() { return costimulationServerPort; } public double getMatchDecay() { return matchDecay; } public void setMatchDecay(double d) { matchDecay = d; } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("\n\n=== " + this.getClass().getName() + " values ===\n"); Field[] fields = this.getClass().getDeclaredFields(); for (int i = 0; i < fields.length; i++) { try { sb.append(fields[i].getName() + " [" + fields[i].getType() + "] = " + fields[i].get(this) + "\n"); String s = fields[i].getType().toString(); } catch (Exception e) { Debug.exception(this, e); } } sb.append("=== " + this.getClass().getName() + " values ===\n\n"); return sb.toString(); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -