public class HashPatternDetector extends Object implements Serializable
| Constructor and Description |
|---|
HashPatternDetector(RouterContext context) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
analyzeAndPredict(Hash hash,
RouterContext context)
Analyze a router hash and apply predictive ban if pattern matches known attack signatures.
|
boolean |
detectCrossPrefixPatterns(List<String> hashes)
Check for cross-prefix sequential patterns (e.g., 0xAA01FF -> 0xAA0200).
|
boolean |
detectSequentialPatterns(List<String> hashes)
Detect sequential patterns by analyzing gaps between sorted hashes.
|
void |
disablePredictiveBanning()
Disable predictive banning manually or after recovery period.
|
String |
getHashPrefix(Hash hash)
Public method to get the hex prefix of a hash.
|
long |
getRemainingRecoveryTime()
Get remaining recovery time in milliseconds.
|
Set<String> |
getSuspiciousPrefixes()
Get suspicious prefixes that are part of a sequential pattern.
|
boolean |
hasScriptedPattern(List<String> hashes)
Quick check for scripted patterns - returns true if any pattern detected.
|
boolean |
hasSequentialPattern()
Check if recorded prefixes show sequential/counter patterns indicating algorithmic generation.
|
boolean |
isPredictiveBanningActive()
Check if predictive banning is currently active and within recovery period.
|
void |
recordBan(Hash hash,
String reason)
Record a ban for pattern analysis.
|
void |
scanNetDBForPatterns()
Scan netDB for routers matching suspicious patterns and auto-ban them.
|
void |
startScanner()
Initialize the NetDB scanner with configured frequency.
|
void |
stopScanner()
Stop the NetDB scanner.
|
public HashPatternDetector(RouterContext context)
public boolean analyzeAndPredict(Hash hash, RouterContext context)
hash - Router hash to analyzecontext - Context for banlist operationspublic boolean detectCrossPrefixPatterns(List<String> hashes)
hashes - List of router hashes to analyzepublic boolean detectSequentialPatterns(List<String> hashes)
hashes - List of router hashes to analyzepublic void disablePredictiveBanning()
public String getHashPrefix(Hash hash)
public long getRemainingRecoveryTime()
public Set<String> getSuspiciousPrefixes()
public boolean hasScriptedPattern(List<String> hashes)
hashes - List of router hashes to checkpublic boolean hasSequentialPattern()
public boolean isPredictiveBanningActive()
public void recordBan(Hash hash, String reason)
hash - Banned router hashreason - Ban reasonpublic void scanNetDBForPatterns()
public void startScanner()
public void stopScanner()