Only in nmap/luis/ipv6tests: common.pyc diff -u -x 'liblinear*' -x 'FPModel*' ipv6tests/c_struct.py nmap/luis/ipv6tests/c_struct.py --- ipv6tests/c_struct.py 2015-02-25 16:41:30.948037425 +0100 +++ nmap/luis/ipv6tests/c_struct.py 2015-02-25 16:32:38.866879730 +0100 @@ -48,7 +48,7 @@ return "{" + ", ".join(c_quote_or_null(x) for x in osclass) + "}" -def save_model_c_struct(f, model): +def save_model_c_struct_cc(f, model): """Write a liblinear model as a C struct.""" if model.model.bias >= 0: w_size = model.model.nr_feature + 1 @@ -167,6 +167,22 @@ f.write("\treturn matches;\n"); f.write("}\n"); +def save_model_c_struct_h(f, model): + if model.model.bias >= 0: + w_size = model.model.nr_feature + 1 + else: + w_size = model.model.nr_feature + f.write("#ifndef _FPMODEL_H_\n") + f.write("#define _FPMODEL_H_\n") + f.write("\n") + f.write("extern struct model FPModel;\n") + f.write("extern double FPscale[][2];\n") + f.write("extern double FPmean[][%d];\n" % w_size) + f.write("extern double FPvariance[][%d];\n" % w_size) + f.write("extern FingerMatch FPmatches[];\n") + f.write("\n") + f.write("#endif\n") + opts, args = getopt.gnu_getopt(sys.argv[1:], "hm:", ["help", "model="]) for o, a in opts: if o == "-h" or o == "--help": @@ -181,4 +197,11 @@ model = parse.parse_model_file(options.model_filename) -save_model_c_struct(sys.stdout, model) +cc_file = open('FPModel.cc', 'w') +h_file = open('FPModel.h', 'w') + +save_model_c_struct_cc(cc_file, model) +save_model_c_struct_h(h_file, model) + +cc_file.close() +h_file.close() Only in nmap/luis/ipv6tests: gen_model.sh Only in nmap/luis/ipv6tests: hlims Only in nmap/luis/ipv6tests: impute.pyc Only in ipv6tests: nmap.model diff -u -x 'liblinear*' -x 'FPModel*' ipv6tests/nmap.set nmap/luis/ipv6tests/nmap.set --- ipv6tests/nmap.set 2015-02-25 16:41:30.692037425 +0100 +++ nmap/luis/ipv6tests/nmap.set 2015-02-25 16:32:38.878879730 +0100 @@ -42,6 +42,8 @@ TC ] +IPV6_HLIM + TCP_ISR $TCP * [ diff -u -x 'liblinear*' -x 'FPModel*' ipv6tests/parse.py nmap/luis/ipv6tests/parse.py --- ipv6tests/parse.py 2015-02-25 16:41:30.720037425 +0100 +++ nmap/luis/ipv6tests/parse.py 2015-02-25 17:13:57.037522320 +0100 @@ -170,6 +170,7 @@ self.desc = OSDescription() self.flow_label = None + self.scan_line = {} self.responses = {} self.timed_responses = {} @@ -251,7 +252,13 @@ fp = parse_nmapfp_raw(s) for probe_name, tests in fp: if probe_name == "SCAN": - continue + for test_name, test_value in tests: + if test_value: # pythonic check for empty string + # convert integer values from strings to ints + # keep rest as strings + self.scan_line[test_name] = int(test_value) \ + if test_name in ['OT', 'CT', 'CU', 'DS'] \ + else test_value if probe_name == "EXTRA": for test_name, test_value in tests: if test_name == "FL": Only in nmap/luis/ipv6tests: parse.pyc Common subdirectories: ipv6tests/results and nmap/luis/ipv6tests/results Only in ipv6tests: .svn diff -u -x 'liblinear*' -x 'FPModel*' ipv6tests/vectorize.py nmap/luis/ipv6tests/vectorize.py --- ipv6tests/vectorize.py 2015-02-25 16:41:30.696037425 +0100 +++ nmap/luis/ipv6tests/vectorize.py 2015-02-25 17:15:18.285522248 +0100 @@ -3,6 +3,7 @@ import getopt import hashlib import struct +import collections import common import parse @@ -399,6 +400,28 @@ self.seq = seq self.t = t +def vectorize_hlim(rs): + # add all hop limit values from probe responses to the same array + hlims = [] + for probe_responses in rs.responses.values(): + for response in probe_responses: + if response.p is not None: + hlims.append(response.p.hlim) + # get the frequency of each hop limit value + c = collections.Counter(hlims) + # search for the value with highest frequency (e.g. in case of middlebox interference) + vhlim = 0 # vectorized value we will return + freq = -1 # variable for highest frequency encountered + for hlim, count in c.items(): + if freq < count: + vhlim = hlim + freq = count + # check for the DS value in the fingerprint SCAN line + if 'DS' in rs.scan_line and rs.scan_line['DS'] > 0: + # and obtain the original hop limit value + vhlim += rs.scan_line['DS'] - 1 + return vhlim + def vectorize_tcp_isr(rs): seqs = [] for probe_name in TCP_SEQ_PROBES: @@ -425,6 +448,7 @@ "FLOWLABEL_ALG_TCP_CLOSED": vectorize_flowlabel_alg_tcp_closed, "FLOWLABEL_VALUE_TCP_CLOSED": vectorize_flowlabel_value_tcp_closed, "FLOWLABEL_INCREMENT_TCP_CLOSED": vectorize_flowlabel_increment_tcp_closed, + "IPV6_HLIM": vectorize_hlim, "TCP_ISR": vectorize_tcp_isr, } Only in nmap/luis/ipv6tests: vectorize.pyc