Skip to content

hypnguyen1209/offensive-claude / skills/malware-analysis

malware-analysis

Unverified

Use when reverse-engineering or detecting malware — static triage + capa/YARA-X, emulation/DBI/.NET unpacking, dynamic/fileless/Volatility 3 memory analysis, C2 config extraction (Cobalt Strike/CAPE), C2 traffic detection (JA4+, beaconing)

references/network-c2-detection.md

View on GitHub
# Network & C2 Traffic Detection

Goal: detect and characterize C2 traffic from PCAP/network telemetry without (or before) having the
sample — beaconing cadence, TLS/HTTP fingerprints, tunneled and DoH-hidden channels. Complements
config extraction: configs tell you *what to look for*; this cluster finds it on the wire and
fingerprints unknown infra.

## Theory / mechanism

- **Beaconing.** Implants poll C2 on a fixed `sleep` ± `jitter`. Even with jitter, inter-arrival
  times cluster tightly relative to human traffic — a **low coefficient of variation (CV = stdev/mean)**
  of deltas per flow is the core signal. Long-lived, low-volume, outbound-initiated flows to a single
  endpoint are the classic implant shape.
- **TLS/HTTP fingerprinting without decryption.** **JA4+** (FoxIO) is the modern successor to JA3, a
  suite covering multiple layers: **JA4** (TLS client hello), **JA4S** (server hello), **JA4H** (HTTP
  client), **JA4X** (X.509 certificate *generation*), **JA4SSH**, JA4T/JA4L. It is human+machine
  readable and stable, so detections are reliable and pivots survive IP rotation.
- **JA4X is the killer feature for randomized-cert C2.** Sliver dedicates 400+ lines to randomly
  generating TLS certs, so cert-hash pivoting is useless — but every Sliver cert is generated by the
  same code and shares one **JA4X**. **Havoc reuses Sliver's code** → same JA4X, distinguishable by
  Org-Name / Postal-Code length. JA4X also catches SoftEther, Tor, Metasploit, generic RAT C2.
  Caveat: certs are cleartext in TLS 1.2 but **encrypted in TLS 1.3**, so JA4X needs a proxy/NDR with
  inspection.
- **Evasion via trusted infra & tunneling.** 2025 actors increasingly route C2 through
  **TryCloudflare / cloudflared tunnels**, Dropbox, and SOCKS tunnelers (CHISEL, PYSOXY, REVSOCKS,
  RPIVOT), creating **outbound-only, HTTPS-wrapped** channels. DoH (DNS-over-HTTPS) hides DNS-based
  C2/DGA lookups inside HTTPS to a public resolver.

## Modern 2024-2026 variants (verified)

- **JA4+** adopted into **Zeek** (maintained package, logs alongside conn/ssl/http/ssh — Jan 2026),
  **TheHive/StrangeBee** analyzer against the public FoxIO DB (Oct 2025), Suricata/Wireshark.
  JA4 (TLS client) is BSD-licensed; JA4S/H/X/SSH under the FoxIO license (free for internal defense).
- **2025 ransomware C2 tradecraft** (LockBit 5.0 / Akira / Qilin / Black Basta affiliates): heavy use
  of **cloudflared** installed via `msiexec` for outbound-only C2 after exploiting an app (e.g.
  SharePoint RCE); broad tunneler adoption (CHISEL/PYSOXY/REVSOCKS + private LIONSHARE/VIPERTUNNEL).
  Cobalt Strike still prevalent; proactive infra-blocking (e.g. flagging a CS IP 76 days early) works.
- **AsyncRAT delivery** through TryCloudflare tunnels + malicious PyPI packages (Feb 2025 campaign).

## Complete working detection

### A. Beacon detection from PCAP / Zeek

```bash
# periodicity scoring per (src,dst,dport) flow; estimates sleep + jitter
python3 scripts/beacon_profiler.py capture.pcap --min-beacons 6 --score-threshold 0.6
python3 scripts/beacon_profiler.py --zeek conn.log
# output: flow, beacon_score (1.0=perfect cadence), interval~Ns, jitter~N%, beacons, avg_bytes
```

`scripts/beacon_profiler.py` clusters inter-arrival deltas, computes CV-based periodicity, estimates
sleep/jitter, and flags near-perfect cadence (scheduled-task or low-jitter implant). Works on pcap
(scapy) or Zeek `conn.log` (stdlib only).

### B. JA4+ fingerprinting

```bash
# Zeek with the FoxIO JA4 package -> ja4.log, ssl.log carries ja4/ja4s/ja4x
zeek -r capture.pcap LOCAL ja4
cat ja4.log | zeek-cut uid ja4 ja4s ja4x ja4h

# standalone FoxIO ja4 binary
ja4 capture.pcap --json | jq '.[] | {src:.src, ja4:.JA4, ja4x:.JA4X, ja4h:.JA4H}'

# pivot: Sliver/Havoc share a JA4X regardless of randomized cert values
# hunt internet scan data (Censys/Shodan/validin) for that JA4X to map actor infra
```

### C. Tunneled / DoH C2 surfacing

```bash
# cloudflared / TryCloudflare tunnels: long-lived TLS to *.cloudflareclient.com / argotunnel
zeek-cut id.orig_h id.resp_h server_name < ssl.log | grep -iE 'trycloudflare|cfargotunnel|argotunnel'
# DoH endpoints (DNS hidden in HTTPS) - flag non-browser hosts hitting public DoH resolvers
zeek-cut id.orig_h server_name < ssl.log | grep -iE 'dns.google|cloudflare-dns|doh\.|mozilla.cloudflare-dns'
# SOCKS tunnelers (chisel/revsocks) - websocket upgrade + steady bidirectional flow
grep -i 'upgrade: websocket' http.log
```

## Detection rules

- **Suricata — generic HTTPS beacon to tunnel infra** (tune to your baseline):

```
alert tls $HOME_NET any -> $EXTERNAL_NET 443 (msg:"Possible cloudflared tunnel C2";
  tls.sni; content:"trycloudflare.com"; nocase; flow:established,to_server;
  threshold: type both, track by_src, count 5, seconds 600; sid:9000001; rev:1;)
```

- **Sigma — Cobalt Strike default Malleable URIs / UA** (from extracted config or defaults):

```yaml
title: Cobalt Strike Default Beacon HTTP Pattern
logsource: { category: proxy }
detection:
  selection:
    cs-uri-stem|contains: ['/submit.php','/__utm.gif','/pixel','/activity']
    cs-user-agent|contains: 'MSIE'
  condition: selection
level: high
tags: [attack.command_and_control, attack.t1071.001]
```

- **JA4X watchlist:** maintain JA4X hashes for Sliver/Havoc/Metasploit/Tor and alert on any internal
  host whose outbound TLS server presents a matching JA4X.
- **IOCs:** beacon interval+jitter, JA4/JA4S/JA4X/JA4H tuples, C2 SNI/host, tunnel endpoints,
  WebSocket-upgrade SOCKS flows.

## OPSEC

- This is defensive/passive analysis of captured traffic — no target interaction.
- If actively fingerprinting suspected C2 infra (e.g. scanning to collect JA4S/JA4X), that scanning
  is attributable and may tip off the operator — scan from non-attributable infrastructure and prefer
  passive internet-scan datasets (Censys/Shodan/Validin) over live touches.
- JA4X requires TLS-1.3 cert visibility only at an inspecting proxy/NDR; don't assume edge sensors
  see it.

## References

- FoxIO — *JA4+ Network Fingerprinting* (suite overview, Sliver/Havoc JA4X): https://blog.foxio.io/ja4+-network-fingerprinting
- FoxIO-LLC/ja4 (reference implementations + license): https://github.com/FoxIO-LLC/ja4
- Zeek — *How to Use JA4 Network Fingerprints in Zeek* (Jan 2026): https://zeek.org/2026/01/how-to-use-ja4-network-fingerprints-in-zeek/
- Red Canary — *Ransomware Trends* / Threat Detection Report (2025 tunneler + early-stage C2 focus): https://redcanary.com/threat-detection-report/trends/ransomware/
- Google Cloud / Mandiant — *Ransomware TTPs in a Shifting Threat Landscape* (cloudflared, tunnelers): https://cloud.google.com/blog/topics/threat-intelligence/ransomware-ttps-shifting-threat-landscape
- Check Point — *Feb 2025 Malware Spotlight: AsyncRAT* (TryCloudflare + PyPI delivery): https://blog.checkpoint.com/security/february-2025s-malware-spotlight-asyncrat-emerges-targeting-trusted-platforms/
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall