NullSec BeaconHunt

February 27, 2026 ยท View on GitHub

C2 Beacon Detector

A command and control beacon detection tool written in Elixir, demonstrating functional programming and pattern matching for network traffic analysis.

Elixir Security Version License

๐ŸŽฏ Overview

NullSec BeaconHunt analyzes network connections to identify command and control (C2) beacon patterns. It detects regular communication intervals, DNS tunneling, and covert channels with confidence scoring.

โœจ Features

  • Beacon Pattern Detection - Identify regular callback intervals
  • Jitter Analysis - Measure timing variations
  • DNS Tunneling - Detect DNS-based C2
  • Protocol Classification - HTTP, HTTPS, DNS, ICMP
  • Confidence Scoring - Probabilistic detection
  • MITRE ATT&CK - Technique mapping

๐Ÿ” Detection Capabilities

Beacon TypeProtocolMITREDescription
HTTP BeaconTCP/80T1071.001Web-based C2
HTTPS BeaconTCP/443T1071.001Encrypted web C2
DNS BeaconUDP/53T1071.004DNS tunneling
ICMP BeaconICMPT1095Ping-based covert channel
CustomVariousT1095Non-standard protocols

๐Ÿ“ฆ Installation

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

# Run with Elixir
elixir beaconhunt.exs

# Or compile with Mix
mix escript.build
./beaconhunt

๐Ÿš€ Usage

# Analyze PCAP file
elixir beaconhunt.exs capture.pcap

# Live capture
elixir beaconhunt.exs -i eth0

# Set confidence threshold
elixir beaconhunt.exs -t 0.7 traffic.pcap

# JSON output
elixir beaconhunt.exs -j capture.pcap

# Run demo
elixir beaconhunt.exs

๐Ÿ’ป Example Output

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘             NullSec BeaconHunt - C2 Beacon Detector              โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

[Demo Mode]

Analyzing sample network connections...

  [CRITICAL] BEACON_HTTPS_001
    Destination: 185.220.101.1
    Type:        https
    Connections: 16
    Avg Interval: 60.0s
    Jitter:      0.0s
    Confidence:  90.0%
    MITRE:       T1071.001
    Description: Possible C2 beacon detected to 185.220.101.1

  [HIGH] BEACON_DNS_001
    Destination: 23.129.64.100
    Type:        dns
    Connections: 21
    Avg Interval: 30.0s
    Jitter:      0.0s
    Confidence:  80.0%
    MITRE:       T1071.004
    Description: Possible C2 beacon detected to 23.129.64.100

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

  Summary:
    Connections Analyzed: 42
    Beacons Detected:     2
    Critical/High: 2

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   Connection Parser                          โ”‚
โ”‚              PCAP | Live Capture | Zeek Logs                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚
                           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Group by Destination IP                         โ”‚
โ”‚            Enum.group_by(& &1.dst_ip)                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚
                           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚               Interval Analysis                              โ”‚
โ”‚    calculate_intervals | calculate_jitter | confidence      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚
                           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 Alert Generation                             โ”‚
โ”‚    BeaconPattern โ†’ Alert with severity and MITRE            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ’œ Elixir Features Demonstrated

  • Pattern Matching - Function head matching for different cases
  • Pipe Operator - |> for data transformation chains
  • Comprehensions - for expressions for list generation
  • Structs - %Connection{}, %BeaconPattern{}, %Alert{}
  • Modules - Namespaced with defmodule
  • Guards - when length(timestamps) < 2
  • Enum Functions - group_by, map, filter, sort_by
  • Anonymous Functions - & &1.dst_ip capture syntax

๐Ÿ”ง Data Structures

defmodule BeaconPattern do
  defstruct [
    :dst_ip,
    :intervals,
    :avg_interval,
    :jitter,
    :connection_count,
    :bytes_pattern,
    :beacon_type,
    :confidence
  ]
end

defmodule Alert do
  defstruct [
    :severity,
    :beacon_pattern,
    :rule_name,
    :description,
    :mitre,
    :iocs
  ]
end

๐Ÿ“Š Confidence Scoring

FactorWeightCondition
Regular Intervals+30%>3 intervals, jitter < 5s
Many Connections+20%>10 connections
Known Malicious IP+40%In threat intel list
Low Relative Jitter+20%jitter/avg < 10%

๐Ÿ›ก๏ธ Security Use Cases

  • Threat Hunting - Proactively search for C2
  • Incident Response - Identify active beacons
  • Network Forensics - Analyze historical traffic
  • SOC Operations - Real-time beacon detection
  • Malware Analysis - Understand C2 behavior

This tool is intended for:

  • โœ… Authorized network monitoring
  • โœ… Security operations
  • โœ… Incident response
  • โœ… Research and education

Only analyze network traffic you're authorized to inspect.

๐Ÿ“„ License

MIT License - See LICENSE file for details.

๐Ÿท๏ธ Version History

  • v1.0.0 - Initial release with beacon detection and jitter analysis

Part of the NullSec Security Toolkit