Ignore:
Timestamp:
Aug 8, 2008, 4:37:54 PM (16 years ago)
Author:
waue
Message:

SnortBase?.java -> tuning some field
SnortParser?.java -> debug and fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sample/hadoop-0.16/test.java

    r46 r47  
    282282  }
    283283
     284  void selRegular(String str) {
     285    Pattern patten_line1, patten_line2;
     286    Matcher matcher;
     287    String logData = new String();
     288
     289    patten_line1 = Pattern
     290        .compile("^\\[Classification: ([^\\]]*)\\] \\[Priority: ([1-9]*)\\].*$");
     291    patten_line2 = Pattern.compile("^\\[Priority: ([1-9]*)\\].*$");
     292    matcher = patten_line1.matcher(str);
     293
     294    if (matcher.matches()) {
     295      int number = matcher.groupCount();
     296      String[] data = new String[number];
     297      for (int j = 0; j < number; j++) {
     298        data[j] = matcher.group(j + 1);
     299        logData += (data[j] + ";");
     300      }
     301    } else {
     302      matcher = patten_line2.matcher(str);
     303      if (matcher.matches()) {
     304        logData = "Port Scan;" + matcher.group(1) + ";";
     305      } else {
     306        logData = ";;";
     307      }
     308    }
     309
     310    System.out.println(logData);
     311    System.out.println("end");
     312
     313  }
     314  void splitExc(){
     315    String arr = "140.110.1.1:255";
     316    int n = arr.indexOf(":");
     317    if (n == -1) {
     318      System.out.println("ip :" + arr);
     319    } else {
     320      System.out.println("ok");
     321      String[] vec = arr.split(":");
     322      System.out.println("ip :" + vec[0]);
     323      System.out.println("port :" + vec[1]);
     324    }
     325  }
     326  void callByRefFun(int a,int b){
     327    b = a;
     328  }
     329  void callByRef(){
     330    test t = new test();
     331    this.na =5;
     332    int b = 10;
     333    t.callByRefFun(b, this.na);
     334    System.out.println(this.na);
     335  }
     336
    284337  public static void main(String[] args) throws Exception {
    285338
     
    305358    // 測試取得現在時間
    306359    // t.getNowTime();
    307     t.setTime();
     360    // t.setTime();
     361    // 測試 選擇性正規表示法
     362    // t.selRegular(String str);
     363    // 測試 split()的例外處理
     364    // t.splitExc();
     365    t.callByRef();
     366   
     367    // if(vec[1] != null){
     368    // System.out.print(" \nport:" + vec[1] );
     369    // }
    308370  }
    309371
Note: See TracChangeset for help on using the changeset viewer.