diff -u ./c_struct.py /home/alegen/repos/nmap/luis/ipv6tests/c_struct.py --- ./c_struct.py 2015-02-25 16:41:30.948037425 +0100 +++ /home/alegen/repos/nmap/luis/ipv6tests/c_struct.py 2015-03-23 17:13:34.653833466 +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 /home/alegen/repos/nmap/luis/ipv6tests: gen_model.sh Common subdirectories: ./liblinear-1.8 and /home/alegen/repos/nmap/luis/ipv6tests/liblinear-1.8 Only in /home/alegen/repos/nmap/luis/ipv6tests: nmap.model diff -u ./nmap.set /home/alegen/repos/nmap/luis/ipv6tests/nmap.set --- ./nmap.set 2015-02-25 16:41:30.692037425 +0100 +++ /home/alegen/repos/nmap/luis/ipv6tests/nmap.set 2015-03-23 17:13:34.793833470 +0100 @@ -40,6 +40,7 @@ $IPV6 * [ PLEN TC + HLIM ] TCP_ISR diff -u ./parse.py /home/alegen/repos/nmap/luis/ipv6tests/parse.py --- ./parse.py 2015-02-25 16:41:30.720037425 +0100 +++ /home/alegen/repos/nmap/luis/ipv6tests/parse.py 2015-03-23 17:13:34.825833470 +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": Common subdirectories: ./results and /home/alegen/repos/nmap/luis/ipv6tests/results Only in .: .svn diff -u ./vectorize.py /home/alegen/repos/nmap/luis/ipv6tests/vectorize.py --- ./vectorize.py 2015-02-25 16:41:30.696037425 +0100 +++ /home/alegen/repos/nmap/luis/ipv6tests/vectorize.py 2015-03-23 17:20:58.965844282 +0100 @@ -78,7 +78,6 @@ return None return packet.getlayer(TCP) - def vectorize_plen(ip, rs): if ip is None: return UNKNOWN @@ -89,6 +88,33 @@ return UNKNOWN return ip.tc +def vectorize_hlim(ip, rs): + def guess(h, er_lim): + if 32 - er_lim <= h and h <= 32: + return 32 + elif 64 - er_lim <= h and h <= 64: + return 64 + elif 128 - er_lim <= h and h <= 128: + return 128 + elif 255 - er_lim <= h and h <= 255: + return 255 + return UNKNOWN + + if ip is None: + return UNKNOWN + hlim = ip.hlim + # check for the DS value in the fingerprint SCAN line + if 'DS' in rs.scan_line: + DS = rs.scan_line['DS']; # distance value + DC = rs.scan_line['DC']; # distance calculation method + if (DC == 'T' or # count from traceroute hops + DC == 'I'): # count from ICMP response to U1 probe + hlim += DS - 1 + hlim = guess(hlim, 5) + else: + hlim = guess(hlim, 20) + return hlim + def vectorize_tcp_window(ip, rs): tcp = find_tcp(ip) if tcp is None: @@ -201,6 +227,7 @@ INDIVIDUAL_TESTS = { "PLEN": vectorize_plen, "TC": vectorize_tc, + "HLIM": vectorize_hlim, "TCP_WINDOW": vectorize_tcp_window, "TCP_URGP": vectorize_tcp_urgp, "TCP_FLAG_F": make_vectorize_tcp_flag(1 << 0),