Class Level2Features
- java.lang.Object
-
- com.tonic.analysis.fingerprint.features.Level2Features
-
- All Implemented Interfaces:
FeatureVector
public class Level2Features extends Object implements FeatureVector
Detailed fingerprint features: opcode-category bigrams, CFG edge and terminator histograms, and dominance depth.
-
-
Constructor Summary
Constructors Constructor Description Level2Features(Map<String,Integer> opcodeNgrams, Map<String,Integer> cfgEdgeTypes, int dominanceDepth, Map<String,Integer> terminatorTypes, Map<String,Integer> instructionTypes)Creates a level-2 feature set, normalizing every histogram to per-mille proportions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]computeHash()Digests every extracted feature into a hash usable for equality and lookup.Map<String,Integer>getCfgEdgeTypeDistribution()intgetDominanceTreeDepth()Map<String,Integer>getInstructionTypeHistogram()static StringgetOpcodeCategory(int opcode)Maps an opcode onto a coarse category name such as const, load, math, or invoke.Map<String,Integer>getOpcodeNgramHistogram()Map<String,Integer>getTerminatorTypeHistogram()booleanisValid()doublesimilarity(Level2Features other)Scores similarity to another level-2 feature set from histogram overlaps and dominance-depth closeness.
-
-
-
Constructor Detail
-
Level2Features
public Level2Features(Map<String,Integer> opcodeNgrams, Map<String,Integer> cfgEdgeTypes, int dominanceDepth, Map<String,Integer> terminatorTypes, Map<String,Integer> instructionTypes)
Creates a level-2 feature set, normalizing every histogram to per-mille proportions.- Parameters:
opcodeNgrams- counts per opcode-category bigramcfgEdgeTypes- counts per CFG edge typedominanceDepth- the dominance tree depthterminatorTypes- counts per block-terminator typeinstructionTypes- counts per instruction category
-
-
Method Detail
-
getOpcodeCategory
public static String getOpcodeCategory(int opcode)
Maps an opcode onto a coarse category name such as const, load, math, or invoke.- Parameters:
opcode- the opcode to classify- Returns:
- the category name, "other" if unrecognized
-
computeHash
public byte[] computeHash()
Description copied from interface:FeatureVectorDigests every extracted feature into a hash usable for equality and lookup.- Specified by:
computeHashin interfaceFeatureVector- Returns:
- the digest bytes
-
isValid
public boolean isValid()
- Specified by:
isValidin interfaceFeatureVector- Returns:
- true if extraction produced features that can be matched against
-
similarity
public double similarity(Level2Features other)
Scores similarity to another level-2 feature set from histogram overlaps and dominance-depth closeness.- Parameters:
other- the feature set to compare against- Returns:
- a score in [0, 1], 0 if other is null
-
getOpcodeNgramHistogram
public Map<String,Integer> getOpcodeNgramHistogram()
- Returns:
- an unmodifiable view of the normalized opcode-category bigram histogram
-
getCfgEdgeTypeDistribution
public Map<String,Integer> getCfgEdgeTypeDistribution()
- Returns:
- an unmodifiable view of the normalized CFG edge-type distribution
-
getDominanceTreeDepth
public int getDominanceTreeDepth()
- Returns:
- the dominance tree depth
-
getTerminatorTypeHistogram
public Map<String,Integer> getTerminatorTypeHistogram()
- Returns:
- an unmodifiable view of the normalized terminator-type histogram
-
-