Skip to content

Commit

Permalink
Merge branch 'python-package' into awdl
Browse files Browse the repository at this point in the history
* python-package:
  fix little endian labels
  libpcap fixes #15
  • Loading branch information
skleber committed Oct 22, 2020
2 parents f3122c8 + aa97d7d commit b18cc6e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Have a look into `nemesys.py` resp. `nemesys_fms.py` to get an impression of the

## Requirements
* Python 3
* libpcap for pcapy: `apt-get install libpcap-dev libpq-dev`
* Install packages listed in requirements.txt: `pip install -r requirements.txt`
* Manual install of Netzob from the ["fix-layer-build" branch]([email protected]:skleber/netzob.git)
-- ~~currently NOT the official~~ [~~"next" branch~~](https://github.com/netzob/netzob/tree/next/netzob)! --
Expand Down
11 changes: 0 additions & 11 deletions eval-nemeftr-clustering.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,6 @@ report=reports/${prefix}-${cftnpad}-clustering-${currcomm}
mkdir ${report}


#for fn in ${input} ; do
#for sig in ${sigmas} ; do
##python src/nemeftr_cluster-segments.py -s ${sig} -r PCAmoco ${fn}
#python src/nemeftr_cluster-segments.py -s ${sig} -r PCA ${fn}
##python src/nemeftr_cluster-segments.py -s ${sig} -r base ${fn}
##python src/nemeftr_cluster-segments.py -s ${sig} -r original ${fn}
#
##python src/nemeftr_cluster-segments.py -p -s ${sig} -r PCAmoco ${fn}
#done
#done

for seg in ${segmenters} ; do
for ref in ${refines} ; do
if [[ ${seg} == "zeros" ]] && [[ ! ${ref} =~ ^(none|PCA1)$ ]] ; then
Expand Down
16 changes: 10 additions & 6 deletions src/nemeftr_cluster-segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def inferredFEs4segment(segment: MessageSegment) -> List[int]:
analysisArgs = None
analysisTitle = analysis_method
tokenizer = args.tokenizer
if tokenizer == "nemesys" and args.littleendian:
if tokenizer == "nemesys" and littleendian:
tokenizer = "nemesysle"

# # # # # # # # # # # # # # # # # # # # # # # #
Expand All @@ -158,13 +158,16 @@ def inferredFEs4segment(segment: MessageSegment) -> List[int]:
fromCache.configureRefinement(nemetylRefinements)
elif args.refinement == "PCA1":
fromCache.configureRefinement(pcaRefinements, littleEndian=littleendian)
refinement = args.refinement + "le"
if littleendian:
refinement = args.refinement + "le"
elif args.refinement == "PCAmoco":
fromCache.configureRefinement(pcaMocoRefinements, littleEndian=littleendian)
refinement = args.refinement + "le"
if littleendian:
refinement = args.refinement + "le"
elif args.refinement == "zerocharPCAmocoSF":
fromCache.configureRefinement(zerocharPCAmocoSFrefinements, littleEndian=littleendian)
refinement = args.refinement + "le"
if littleendian:
refinement = args.refinement + "le"
elif args.refinement is None or args.refinement == "none":
print("No refinement selected. Performing raw segmentation.")
else:
Expand All @@ -173,7 +176,8 @@ def inferredFEs4segment(segment: MessageSegment) -> List[int]:
elif tokenizer == "zeros":
if args.refinement == "PCA1":
fromCache.configureRefinement(pcaRefinements, littleEndian=littleendian)
refinement = args.refinement + "le"
if littleendian:
refinement = args.refinement + "le"
elif args.refinement is None or args.refinement == "none":
print("No refinement selected. Performing zeros segmentation with CropChars.")
else:
Expand Down Expand Up @@ -428,7 +432,7 @@ def inferredFEs4segment(segment: MessageSegment) -> List[int]:
clusterStats = report.precisionRecallList

# # # # # # # # # # # # # # # # # # # # # # # #
with open(join(reportFolder, "segmentclusters-" + filechecker.pcapstrippedname + ".csv"), "a") as segfile:
with open(join(filechecker.reportFullPath, "segmentclusters-" + filechecker.pcapstrippedname + ".csv"), "a") as segfile:
segcsv = csv.writer(segfile)
for cLabel, segments in ftclusters.items():
segcsv.writerows([
Expand Down

0 comments on commit b18cc6e

Please sign in to comment.