NullSec FlowTrace

February 27, 2026 Β· View on GitHub

Network Flow Analyzer

A pure functional network flow analysis tool written in Haskell, demonstrating algebraic data types and monadic composition for security-focused traffic inspection.

Haskell Security Version License

🎯 Overview

NullSec FlowTrace analyzes network flow data to detect suspicious patterns, malicious connections, and data exfiltration attempts using Haskell's powerful type system and pattern matching capabilities.

✨ Features

  • Flow Analysis - Deep inspection of NetFlow/IPFIX data
  • Malicious IP Detection - Known threat intelligence matching
  • Port Scanning Detection - Identify reconnaissance activity
  • Data Exfiltration Alerts - Large transfer detection
  • MITRE ATT&CK Mapping - Technique identification
  • Protocol Classification - Automatic protocol detection

πŸ” Detection Capabilities

CategoryDescriptionMITRE
Malicious IPKnown C2/botnet connectionsT1071
Suspicious PortBackdoor/RAT portsT1571
Data ExfiltrationLarge outbound transfersT1048
Port ScanningSYN scan detectionT1046
IRC C2IRC channel connectionsT1071.001

πŸ“¦ Installation

# Clone the repository
git clone https://github.com/bad-antics/nullsec-flowtrace
cd nullsec-flowtrace

# Compile with GHC
ghc -O2 FlowTrace.hs -o flowtrace

# Or run directly
runhaskell FlowTrace.hs

πŸš€ Usage

# Analyze flow data file
./flowtrace flows.nfcapd

# JSON output
./flowtrace -j flows.log

# Summary only
./flowtrace -s conn.log

# Run demo mode
./flowtrace

πŸ’» Example Output

╔══════════════════════════════════════════════════════════════════╗
β•‘            NullSec FlowTrace - Network Flow Analyzer             β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

[Demo Mode]

Analyzing sample network flows...

Processed 10 flows, found 8 alerts

  [Critical] Malicious IP
    Source: 192.168.1.100:45678
    Dest:   185.220.101.1:443
    Detail: Connection to known malicious IP: 185.220.101.1
    MITRE:  T1071

  [High] Suspicious Port
    Source: 10.0.0.50:12345
    Dest:   45.33.32.156:4444
    Detail: Connection to port 4444 (Metasploit default)
    MITRE:  T1571

  [High] Data Exfiltration
    Source: 192.168.100.5:50000
    Dest:   1.2.3.4:31337
    Detail: Large data transfer: 150000000 bytes
    MITRE:  T1048

═══════════════════════════════════════════

  Summary:
    Total Flows:   10
    Total Bytes:   152006564
    Total Packets: 58751
    Alerts:        8

  Top Protocols:
    β€’ TCP: 6 flows
    β€’ HTTPS: 2 flows
    β€’ DNS: 1 flow
    β€’ ICMP: 1 flow

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Flow Parser                          β”‚
β”‚  NetFlow v5/v9 | IPFIX | Zeek | Argus                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               Flow Data Structure                       β”‚
β”‚  Flow { srcIP, dstIP, srcPort, dstPort, protocol, ... }β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β–Ό               β–Ό               β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ IP Check β”‚   β”‚Port Checkβ”‚   β”‚ Volume   β”‚
    β”‚Malicious β”‚   β”‚Suspiciousβ”‚   β”‚ Check    β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚               β”‚               β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β–Ό
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚FlowAnalysis  β”‚
                  β”‚  Result List β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Ξ» Haskell Features Demonstrated

  • Algebraic Data Types - Flow, FlowAnalysis, Severity, Protocol
  • Pattern Matching - Exhaustive case analysis
  • List Comprehensions - Functional filtering and mapping
  • Higher-Order Functions - map, filter, sortBy, groupBy
  • Type Classes - Show, Eq, Ord instances
  • Maybe Monad - Optional MITRE mappings
  • Guards - Multi-way conditionals
  • Where Clauses - Local definitions

πŸ”§ Data Types

-- Flow record
data Flow = Flow
    { flowSrcIP    :: IPAddress
    , flowDstIP    :: IPAddress
    , flowSrcPort  :: Int
    , flowDstPort  :: Int
    , flowProtocol :: Protocol
    , flowBytes    :: Int
    , flowPackets  :: Int
    , flowDuration :: Float
    , flowFlags    :: [String]
    }

-- Analysis result
data FlowAnalysis = FlowAnalysis
    { analysisFlow     :: Flow
    , analysisSeverity :: Severity
    , analysisCategory :: String
    , analysisDetails  :: String
    , analysisMitre    :: Maybe String
    }

πŸ“Š Supported Formats

FormatExtensionSupport
NetFlow v5.nfcapdβœ…
NetFlow v9.nfcapdβœ…
IPFIX.ipfixβœ…
Zeek conn.log.logβœ…
Argus.argβœ…

πŸ›‘οΈ Security Use Cases

  • Threat Hunting - Identify C2 beacons in flow data
  • Incident Response - Trace lateral movement
  • Network Forensics - Reconstruct attack timelines
  • Compliance Monitoring - Detect policy violations
  • Anomaly Detection - Find unusual patterns

This tool is intended for:

  • βœ… Authorized network monitoring
  • βœ… Security operations centers
  • βœ… Incident response teams
  • βœ… Research and education

Only analyze network data you're authorized to inspect.

πŸ“„ License

MIT License - See LICENSE file for details.

🏷️ Version History

  • v1.0.0 - Initial release with flow analysis and threat detection

Part of the NullSec Security Toolkit