From 285607f396797b09a0c0e00798a225aae1e08862 Mon Sep 17 00:00:00 2001 From: Stephan Kleber Date: Thu, 17 Jun 2021 01:59:26 +0200 Subject: [PATCH] Squashed commit of the following: clean up eval scripts add cluster size check fix of a number of typos fix dhcp.secs type. closes #28 fix segment match calculation for templates, closes #29 fix cluster labels with 0 values a bit of code cleanup some default imports for nemere package fix element length tests fix type hints and toTikz return make eps statistics part of plots fix distance plot labels small fixes fix groundtruth fix support for empty (None) labels in DistancesPlotter fix disproportional axes in distance plots use internal figure instance assert input parameters of plotManifoldDistances fall back to scapy on pcapy errror fix minor wlan parser inaccuracies consolidate labels for large topology plots fix DistanceCalculator cache file name fix nemetyl eval script multi-process add more wlan.mgt fields and workarounds for faulty dissectors of vendor extensions add print of pcap in process fix double protocol import in message parser and add workaround for faulty value representation (non-conformance to 2-byte-hex) match regexes of field nodes in the json which should be descended into redesign of ParsingConstants class hierarchy all known l2/le protos in eval scripts fix #7 append terminal log of netzob-fms prepare layer select in netzob-fms best similarity thresholds refactor class hierarchy of nemere.visualization.simplePrint.SegmentPrinter enumerate symbol names in symbolsFromSegments TypeIdentificationByAlignment in nemetyl main scripts encapsulate the whole NEMETYL process in TypeIdentificationByAlignment replace parameter comparator by specimens Introduce SegmentPrinter and clean up related code centrally provide analyzer conversion in MessageAnalyzer.convertAnalyzers different placement of text in empty ax consolidate labels in distance plot of tft and make plot of segment values optional introduce ComparingPrinter and AbstractDissectorMatcher report detail improvements libpcap fixes #15 fail gratiously if no spd-say is available improve clustered symbol CSV format message type discriminator search utils check plot toolbar before update reorganize input cleanup cluster report writing nemetyl main script: use CachedDistances, StartupFilecheck enhanced tikz output refactor cacheAndLoadDC to a class pin empty cache and reports folders fully integrated dynamic protocol importing introduce watchdog for Netzob message parsing comments on tshark timeout increase timeout to wait for tshark output + networkx in requirements pcapy linktype conversion bugfixes and features about dot11 import, eval script improvements, tshark 3 support fix length check and dummy segments add interactive switch evaluation script for netzob output measured in FMS test Netzob compatibility overlapping test independent of class Target layer selection parameters consolidated add check for non-negative lengths in segments ensure tuples. closes #14 started support for tshark version 3.x Integrate ScaPyCAPimporter into specimen loader --- .gitignore | 7 +- .idea/NEMESYS.iml | 11 - .idea/dictionaries/stephan.xml | 2 + .idea/nemesys.iml | 13 - .idea/workspace.xml | 570 ------- README.md | 1 + eval-nemetyl-messagetype.sh | 108 +- eval-netzob-fms.sh | 57 + eval-netzob-messagetype.sh | 57 +- input/Sources.md | 12 +- .../dhcp_SMIA2011101X_deduped-100.pcap | Bin .../dhcp_SMIA2011101X_deduped-1000.pcap | Bin .../dhcp_SMIA2011101X_deduped-10000.pcap | Bin .../dns_ictf2010-new-deduped-100.pcap | Bin .../dns_ictf2010-new-deduped-1000.pcap | Bin .../dns_ictf2010-new-deduped-10000.pcap | Bin .../dns_ictf2010_deduped-100.pcap | Bin .../dns_ictf2010_deduped-2.pcap | Bin .../dns_ictf2010_deduped-982-1000.pcap | Bin .../dns_ictf2010_deduped-9911-10000.pcap | Bin .../nbns_SMIA20111010-one_deduped-100.pcap | Bin .../nbns_SMIA20111010-one_deduped-1000.pcap | Bin .../nbns_SMIA20111010-one_deduped-10000.pcap | Bin .../ntp_SMIA-20111010_deduped-100.pcap | Bin .../ntp_SMIA-20111010_deduped-1000.pcap | Bin .../ntp_SMIA-20111010_deduped-9995-10000.pcap | Bin .../smb_SMIA20111010-one_deduped-100.pcap | Bin .../smb_SMIA20111010-one_deduped-1000.pcap | Bin .../smb_SMIA20111010-one_deduped-10000.pcap | Bin ...MIA2011101X_deduped-10000_maxdiff-100.pcap | Bin ...IA2011101X_deduped-10000_maxdiff-1000.pcap | Bin ...IA2011101X_deduped-10000_maxdiff-1100.pcap | Bin ...ctf2010-new-deduped-10000_maxdiff-100.pcap | Bin ...tf2010-new-deduped-10000_maxdiff-1000.pcap | Bin ...tf2010-new-deduped-10000_maxdiff-1100.pcap | Bin ...dns_ictf2010_deduped-9911_maxdiff-100.pcap | Bin ...ns_ictf2010_deduped-9911_maxdiff-1000.pcap | Bin ...ns_ictf2010_deduped-9911_maxdiff-1100.pcap | Bin ...0111010-one_deduped-10000_maxdiff-100.pcap | Bin ...111010-one_deduped-10000_maxdiff-1000.pcap | Bin ...111010-one_deduped-10000_maxdiff-1100.pcap | Bin ...MIA-20111010_deduped-9995_maxdiff-100.pcap | Bin ...IA-20111010_deduped-9995_maxdiff-1000.pcap | Bin ...IA-20111010_deduped-9995_maxdiff-1100.pcap | Bin ...0111010-one_deduped-10000_maxdiff-100.pcap | Bin ...111010-one_deduped-10000_maxdiff-1000.pcap | Bin ...111010-one_deduped-10000_maxdiff-1100.pcap | Bin ...IA2011101X_deduped-10000_mindiff-1100.pcap | Bin ...tf2010-new-deduped-10000_mindiff-1100.pcap | Bin ...f2010_deduped-9911-10000_mindiff-1100.pcap | Bin ...111010-one_deduped-10000_mindiff-1100.pcap | Bin ...11010_deduped-9995-10000_mindiff-1100.pcap | Bin ...111010-one_deduped-10000_mindiff-1100.pcap | Bin requirements.txt | 6 + src/Contents.md | 38 + src/check_parse-pcap.py | 1 + src/check_pcap-info.py | 14 +- src/nemere/__init__.py | 3 + src/nemere/alignment/alignMessages.py | 178 ++- src/nemere/alignment/clusterMerging.py | 69 +- src/nemere/alignment/clusterSplitting.py | 33 +- .../alignment/hirschbergAlignSegments.py | 21 +- src/nemere/inference/analyzers.py | 7 +- src/nemere/inference/formatRefinement.py | 66 +- src/nemere/inference/segmentHandler.py | 142 +- src/nemere/inference/segments.py | 69 +- src/nemere/inference/templates.py | 55 +- src/nemere/utils/baseAlgorithms.py | 14 +- src/nemere/utils/evaluationHelpers.py | 905 ++++++----- src/nemere/utils/loader.py | 135 +- src/nemere/utils/reportWriter.py | 662 ++++++++ src/nemere/validation/dissectorMatcher.py | 630 +++++--- src/nemere/validation/messageParser.py | 1397 +++++++++++------ .../validation/netzobFormatMatchScore.py | 27 +- src/nemere/validation/protocols/__init__.py | 0 src/nemere/validation/protocols/wlan.py | 339 ++++ src/nemere/validation/reportWriter.py | 138 -- src/nemere/validation/tsharkConnector.py | 18 +- src/nemere/visualization/distancesPlotter.py | 283 ++-- src/nemere/visualization/multiPlotter.py | 18 +- src/nemere/visualization/plotter.py | 18 +- src/nemere/visualization/simplePrint.py | 310 +++- src/nemere/visualization/singlePlotter.py | 1 + src/nemesys.py | 32 +- src/nemesys_field-deviation-plot.py | 2 +- src/nemesys_fms.py | 5 +- src/nemetyl.py | 195 +++ src/nemetyl_align-segments.py | 762 ++++----- src/netzob_fms.py | 46 +- src/netzob_messagetypes.py | 26 +- src/prep_deduplicate-trace.py | 35 +- tests/netzob-support.py | 121 ++ .../test_import_udp_courtesy2NetzobTeam.pcap | Bin 0 -> 105 bytes 93 files changed, 4906 insertions(+), 2753 deletions(-) delete mode 100644 .idea/NEMESYS.iml delete mode 100644 .idea/nemesys.iml delete mode 100644 .idea/workspace.xml create mode 100755 eval-netzob-fms.sh rename input/{ => deduped-orig}/dhcp_SMIA2011101X_deduped-100.pcap (100%) rename input/{ => deduped-orig}/dhcp_SMIA2011101X_deduped-1000.pcap (100%) rename input/{ => deduped-orig}/dhcp_SMIA2011101X_deduped-10000.pcap (100%) rename input/{ => deduped-orig}/dns_ictf2010-new-deduped-100.pcap (100%) rename input/{ => deduped-orig}/dns_ictf2010-new-deduped-1000.pcap (100%) rename input/{ => deduped-orig}/dns_ictf2010-new-deduped-10000.pcap (100%) rename input/{ => deduped-orig}/dns_ictf2010_deduped-100.pcap (100%) rename input/{ => deduped-orig}/dns_ictf2010_deduped-2.pcap (100%) rename input/{ => deduped-orig}/dns_ictf2010_deduped-982-1000.pcap (100%) rename input/{ => deduped-orig}/dns_ictf2010_deduped-9911-10000.pcap (100%) rename input/{ => deduped-orig}/nbns_SMIA20111010-one_deduped-100.pcap (100%) rename input/{ => deduped-orig}/nbns_SMIA20111010-one_deduped-1000.pcap (100%) rename input/{ => deduped-orig}/nbns_SMIA20111010-one_deduped-10000.pcap (100%) rename input/{ => deduped-orig}/ntp_SMIA-20111010_deduped-100.pcap (100%) rename input/{ => deduped-orig}/ntp_SMIA-20111010_deduped-1000.pcap (100%) rename input/{ => deduped-orig}/ntp_SMIA-20111010_deduped-9995-10000.pcap (100%) rename input/{ => deduped-orig}/smb_SMIA20111010-one_deduped-100.pcap (100%) rename input/{ => deduped-orig}/smb_SMIA20111010-one_deduped-1000.pcap (100%) rename input/{ => deduped-orig}/smb_SMIA20111010-one_deduped-10000.pcap (100%) rename input/{ => hide}/maxdiff-filtered/dhcp_SMIA2011101X_deduped-10000_maxdiff-100.pcap (100%) rename input/{ => hide}/maxdiff-filtered/dhcp_SMIA2011101X_deduped-10000_maxdiff-1000.pcap (100%) rename input/{ => hide}/maxdiff-filtered/dhcp_SMIA2011101X_deduped-10000_maxdiff-1100.pcap (100%) rename input/{ => hide}/maxdiff-filtered/dns_ictf2010-new-deduped-10000_maxdiff-100.pcap (100%) rename input/{ => hide}/maxdiff-filtered/dns_ictf2010-new-deduped-10000_maxdiff-1000.pcap (100%) rename input/{ => hide}/maxdiff-filtered/dns_ictf2010-new-deduped-10000_maxdiff-1100.pcap (100%) rename input/{ => hide}/maxdiff-filtered/dns_ictf2010_deduped-9911_maxdiff-100.pcap (100%) rename input/{ => hide}/maxdiff-filtered/dns_ictf2010_deduped-9911_maxdiff-1000.pcap (100%) rename input/{ => hide}/maxdiff-filtered/dns_ictf2010_deduped-9911_maxdiff-1100.pcap (100%) rename input/{ => hide}/maxdiff-filtered/nbns_SMIA20111010-one_deduped-10000_maxdiff-100.pcap (100%) rename input/{ => hide}/maxdiff-filtered/nbns_SMIA20111010-one_deduped-10000_maxdiff-1000.pcap (100%) rename input/{ => hide}/maxdiff-filtered/nbns_SMIA20111010-one_deduped-10000_maxdiff-1100.pcap (100%) rename input/{ => hide}/maxdiff-filtered/ntp_SMIA-20111010_deduped-9995_maxdiff-100.pcap (100%) rename input/{ => hide}/maxdiff-filtered/ntp_SMIA-20111010_deduped-9995_maxdiff-1000.pcap (100%) rename input/{ => hide}/maxdiff-filtered/ntp_SMIA-20111010_deduped-9995_maxdiff-1100.pcap (100%) rename input/{ => hide}/maxdiff-filtered/smb_SMIA20111010-one_deduped-10000_maxdiff-100.pcap (100%) rename input/{ => hide}/maxdiff-filtered/smb_SMIA20111010-one_deduped-10000_maxdiff-1000.pcap (100%) rename input/{ => hide}/maxdiff-filtered/smb_SMIA20111010-one_deduped-10000_maxdiff-1100.pcap (100%) rename input/{ => hide}/mindiff-filtered/dhcp_SMIA2011101X_deduped-10000_mindiff-1100.pcap (100%) rename input/{ => hide}/mindiff-filtered/dns_ictf2010-new-deduped-10000_mindiff-1100.pcap (100%) rename input/{ => hide}/mindiff-filtered/dns_ictf2010_deduped-9911-10000_mindiff-1100.pcap (100%) rename input/{ => hide}/mindiff-filtered/nbns_SMIA20111010-one_deduped-10000_mindiff-1100.pcap (100%) rename input/{ => hide}/mindiff-filtered/ntp_SMIA-20111010_deduped-9995-10000_mindiff-1100.pcap (100%) rename input/{ => hide}/mindiff-filtered/smb_SMIA20111010-one_deduped-10000_mindiff-1100.pcap (100%) create mode 100644 src/Contents.md create mode 100644 src/nemere/utils/reportWriter.py create mode 100644 src/nemere/validation/protocols/__init__.py create mode 100644 src/nemere/validation/protocols/wlan.py delete mode 100644 src/nemere/validation/reportWriter.py create mode 100644 src/nemetyl.py create mode 100644 tests/netzob-support.py create mode 100644 tests/resources/test_import_udp_courtesy2NetzobTeam.pcap diff --git a/.gitignore b/.gitignore index 78fb6457..b0e5b175 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ +__pycache__ /cache* reports/ -__pycache__/ +workspace.xml +usage.statistics.xml +shelf/ +*.iml +gradle.xml diff --git a/.idea/NEMESYS.iml b/.idea/NEMESYS.iml deleted file mode 100644 index fae31720..00000000 --- a/.idea/NEMESYS.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/dictionaries/stephan.xml b/.idea/dictionaries/stephan.xml index 860636e7..a7de52ac 100644 --- a/.idea/dictionaries/stephan.xml +++ b/.idea/dictionaries/stephan.xml @@ -1,6 +1,8 @@ + basesegments + nemere tshark diff --git a/.idea/nemesys.iml b/.idea/nemesys.iml deleted file mode 100644 index e5a46f24..00000000 --- a/.idea/nemesys.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 92bf591e..00000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,570 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -