Communitygithub.com

building-c2-redirector-infrastructure

Build dumb-pipe and traffic-filtering C2 redirectors with nginx (proxy_pass) and Apache (mod_rewrite), deriving filter rules from a Malleable C2 profile, layering Let's Encrypt TLS, and applying OPSEC controls for resilient, low-attribution red-team infrastructure.

building-c2-redirector-infrastructure란 무엇인가요?

이 스킬은 레드팀 C2 인프라에서 중요 구성 요소인 리다이렉터(중계 서버)를 구축하는 방법을 다룹니다. 리다이렉터는 실제 팀 서버를 숨기고, 악성코드 임플란트 트래픽을 필터링하여 블루팀 분석자나 스캐너를 유인용 사이트로 우회시킵니다. 이 스킬은 socat/iptables를 이용한 단순 포트 전달(Dumb Pipe) 방식과, nginx `proxy_pass` 및 Apache `mod_rewrite`를 이용한 지능형 필터링 리다이렉터를 모두 다루며, Cobalt Strike의 Malleable C2 프로필에서 직접 필터 규칙을 추출하는 방법(cs2modrewrite 도구 사용)을 포함합니다. 또한 Let's Encrypt로 TLS를 종료하고, 헤더 검증, 지리적 필터링, 도메인 카테고리화, CDN/도메인 프론팅과 같은 OPSEC 제어를 적용하여 탐지 및 차단에 강한 인프라를 구축합니다. 이 기술은 MITRE ATT&CK T1090.002(외부 프록시)에 매핑되며, 모든 활동은 승인된 레드팀 또는 방어 연구 범위 내에서만 수행해야 합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/building-c2-redirector-infrastructure

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

C2 리다이렉터 인프라 구축

승인된 용도로만 사용: 이 스킬은 승인된 레드팀 활동, 적군 모의 훈련, 방어 연구만을 위한 것입니다. 명령 및 제어(C2) 인프라는 이중 용도로 사용될 수 있습니다. 리다이렉터를 배포하여 명시적으로 테스트 권한이 없는 시스템의 악성코드를 제어하는 것은 불법입니다. 서명된 규칙 문서( Rules of Engagement)에 명시된 합의된 범위 내에서만 운영하고, 활동 종료 시 인프라를 폐기하십시오.

개요

C2 리다이렉터는 피해자 임플란트와 실제 팀 서버 사이에 위치하는 중계 호스트입니다. 비콘(Beacon)은 리다이렉터의 공용 도메인/IP에 연결됩니다. 리다이렉터는 각 요청을 검사하여 합법적인 C2 트래픽만 숨겨진 팀 서버로 프록시하고, 나머지(스캐너, 블루팀 분석자, 샌드박스)는 모두 무해한 유인(decoy) 사이트로 우회시킵니다. 이는 팀 서버를 탐지, 차단, 귀속(attribution)으로부터 보호하며, 운영자는 백엔드를 재구축하지 않고 공용 엣지를 교체할 수 있습니다. 이 기술은 MITRE ATT&CK T1090.002(프록시: 외부 프록시) 에 매핑됩니다. 즉, 공격자는 C2를 중간 노드를 통해 라우팅하여 실제 기원을 숨깁니다.

리다이렉터는 두 가지 유형이 있습니다. 덤 파이프(Dumb Pipe) (socat, iptables NAT)는 포트를 맹목적으로 전달하여 분리를 제공하지만 필터링은 하지 않습니다. 스마트/필터링 리다이렉터 (nginx proxy_pass, Apache mod_rewrite with [P], 또는 RedWarden과 같은 전용 도구)는 HTTP 요청을 분석하고 임플란트의 Malleable C2 프로필(올바른 URI, User-Agent, 헤더)과 일치하는 트래픽만 전달하며, 나머지는 302 응답으로 실제 웹사이트로 리디렉션합니다. 필터링 로직은 C2 프레임워크의 트래픽 프로필에서 직접 파생되므로, 두 가지가 동기화되어 있어야 합니다. cs2modrewrite와 같은 도구는 Cobalt Strike Malleable C2 프로필에서 Apache/nginx 규칙을 자동으로 생성합니다.

이 스킬은 nginx와 Apache를 사용한 덤 파이프 및 필터링 리다이렉터 구축, Malleable 프로필에서 필터 규칙 도출, Let's Encrypt를 이용한 TLS 계층 추가, 그리고 탄력적이고 낮은 귀속도의 인프라를 위한 OPSEC 제어(카테고리화된 도메인, 도메인 프론팅/CDN 프론팅, 헤더 검증, 지역/UA 필터링) 적용을 다룹니다.

사용 시기

  • 블루팀 조사 및 도메인 차단 요청을 견뎌야 하는 레드팀 C2를 구축할 때
  • 활동 중 인터넷에 노출된 호스트로부터 숨겨진 팀 서버를 분리할 때
  • 프로필과 일치하는 요청만 백엔드에 도달하도록 임플란트 트래픽을 필터링하고 스캐너를 우회시킬 때
  • HTTP(S) 리스너에 TLS 종료, 도메인 카테고리화, CDN/도메인 프론팅을 추가할 때
  • 방어자가 외부 프록시 C2(T1090.002)가 어떻게 구축되는지 이해하여 탐지할 수 있도록 교육할 때

전제 조건

  • 하나 이상의 일회용 클라우드 VPS 인스턴스(리다이렉터 엣지)와 별도의 방화벽으로 보호된 팀 서버 호스트
  • DNS를 제어할 수 있는 등록된 도메인(가급적 노후화되고 카테고리화된 도메인)
  • 리다이렉터 호스트의 루트 권한. 웹 서버 및 TLS 도구 설치:
    # Debian/Ubuntu 리다이렉터
    sudo apt update
    sudo apt install -y nginx apache2 socat certbot python3-certbot-nginx git
    # mod_rewrite 리다이렉터 사용 시 Apache 프록시 모듈 활성화
    sudo a2enmod rewrite proxy proxy_http ssl headers
    
  • URI, User-Agent, 헤더를 정의하는 C2 프레임워크의 Malleable C2 프로필 (Cobalt Strike .profile, Sliver/Havoc HTTP 프로필)
  • Cobalt Strike 프로필에서 규칙을 자동 생성하는 cs2modrewrite:
    git clone https://github.com/threatexpress/cs2modrewrite
    
  • 팀 서버의 방화벽을 설정하여 C2 포트에 대해 리다이렉터 소스 IP만 허용

목표

  • 빠른 포트 분리를 위한 덤 파이프 리다이렉터(socat/iptables) 배포
  • Malleable 프로필에 키가 지정된 필터링 nginx 리버스 프록시 리다이렉터 배포
  • [P] 프록시 및 302 유인 폴백이 포함된 Apache mod_rewrite 리다이렉터 배포
  • cs2modrewrite로 Cobalt Strike 프로필에서 리다이렉터 규칙 자동 생성
  • Let's Encrypt로 TLS 종료 및 공용 엣지 강화
  • OPSEC 적용: 헤더/UA 검증, 지역 필터링, 유인 우회, 인프라 교체

MITRE ATT&CK 매핑

기술 ID공식 명칭관련성
T1090.002프록시: 외부 프록시리다이렉터는 C2를 프록시하여 팀 서버를 숨기는 외부 중개자 역할
T1090.004프록시: 도메인 프론팅CDN 프론팅은 비콘 트래픽을 신뢰할 수 있는 평판 좋은 도메인을 통해 라우팅
T1071.001애플리케이션 계층 프로토콜: 웹 프로토콜C2는 Malleable 프로필에 의해 형성된 HTTP/HTTPS를 통해 터널링됨
T1573.002암호화된 채널: 비대칭 암호화리다이렉터에서의 TLS 종료는 비콘 채널을 암호화
T1583.006인프라 획득: 웹 서비스탄력적인 C2를 위해 일회용 VPS/CDN 엣지 획득

작업 흐름

1. 팀 서버 격리 및 방화벽 설정

팀 서버를 사설 호스트에 배치합니다. C2 포트를 리다이렉터 IP로만 제한합니다.

# 팀 서버에서: 오직 리다이렉터(203.0.113.10)만 443/tcp에 접근 가능
sudo ufw default deny incoming
sudo ufw allow from 203.0.113.10 to any port 443 proto tcp
sudo ufw allow OpenSSH
sudo ufw enable

2. 덤 파이프 리다이렉터 (socat / iptables)

필터링 없이 빠른 분리를 위해 C2 포트를 팀 서버로 전달합니다.

# socat 포그라운드 전달: 443 -> 팀 서버
socat TCP4-LISTEN:443,fork,reuseaddr TCP4:10.0.0.2:443

# 또는 iptables DNAT (영구적)
sysctl -w net.ipv4.ip_forward=1
iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination 10.0.0.2:443
iptables -t nat -A POSTROUTING -p tcp -d 10.0.0.2 --dport 443 -j MASQUERADE

3. 필터링 nginx 리버스 프록시 리다이렉터

Malleable 프로필과 일치하는 URI의 요청만 프록시하고, 나머지는 302로 유인 사이트로 보냅니다. location 정규식과 User-Agent를 프로필의 값으로 바꾸십시오.

# /etc/nginx/sites-available/redirector.conf
server {
    listen 443 ssl;
    server_name cdn.example.com;

    ssl_certificate     /etc/letsencrypt/live/cdn.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/cdn.example.com/privkey.pem;

    # 프로필과 일치하는 C2 URI만 숨겨진 팀 서버로 프록시
    location ~ ^/(api/v2/jobs|cm/[a-z0-9]+|push) {
        # 임플란트의 정확한 User-Agent 요구
        if ($http_user_agent != "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36") {
            return 302 https://www.legitimate-decoy.com/;
        }
        proxy_pass https://10.0.0.2;
        proxy_ssl_verify off;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
    }

    # 나머지 모든 요청 -> 무해한 유인 사이트
    location / {
        return 302 https://www.legitimate-decoy.com/;
    }
}
sudo ln -s /etc/nginx/sites-available/redirector.conf /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

4. Apache mod_rewrite 리다이렉터

Apache의 [P] 플래그는 일치하는 요청을 팀 서버로 프록시하고, 일치하지 않는 요청은 302 리디렉션합니다. 이것이 cs2modrewrite가 생성하는 형식입니다.

# /etc/apache2/sites-available/redirector.conf  (<VirtualHost *:443> 내부)
RewriteEngine On
SSLProxyEngine On
# 임플란트 User-Agent 요구
RewriteCond %{HTTP_USER_AGENT} "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" [NC]
# Malleable 프로필의 유효한 C2 URI(GET/POST/stager) 일치
RewriteCond %{REQUEST_URI} ^/(api/v2/jobs|cm/[a-z0-9]+|push)/?$
# URI를 유지하며 숨겨진 팀 서버로 프록시
RewriteRule ^.*$ https://10.0.0.2%{REQUEST_URI} [P,L]
# 나머지 -> 유인 사이트
RewriteRule ^.*$ https://www.legitimate-decoy.com/ [R=302,L]
sudo a2ensite redirector && sudo apache2ctl configtest && sudo systemctl reload apache2

5. Malleable 프로필에서 규칙 생성

cs2modrewrite를 사용하여 Cobalt Strike 프로필에서 직접 Apache 또는 nginx 규칙을 빌드하여 필터가 비콘 트래픽과 정확히 일치하도록 합니다.

cd cs2modrewrite
# Apache mod_rewrite 규칙
python3 cs2modrewrite.py -i havex.profile -c https://10.0.0.2 \
  -r https://www.legitimate-decoy.com -o /etc/apache2/redirect.rules
# nginx 설정
python3 cs2nginx.py -i havex.profile -c https://10.0.0.2 \
  -r https://www.legitimate-decoy.com -H cdn.example.com > /etc/nginx/sites-available/c2.conf

6. Let's Encrypt로 TLS 종료

유효한 인증서를 발급하여 비콘 HTTPS가 TLS 경고를 발생시키지 않고 엣지가 합법적으로 보이도록 합니다.

sudo certbot --nginx -d cdn.example.com --agree-tos -m [email protected] --redirect
# 자동 갱신 확인
sudo certbot renew --dry-run

7. OPSEC 제어 적용

블루팀 분석에 대한 방어 계층을 적용합니다: 헤더 검증, 대상 국가로 지리적 차단(Geofencing), 샌드박스 우회, 엣지 교체. 지원되는 경우 CDN/도메인 프론팅(T1090.004)을 고려하십시오.

# 예시: ipset/GeoIP로 방화벽에서 비대상 지역 차단,
# 프로필에서 사용자 정의 인증 헤더 요구, 정기적으로 리다이렉터 도메인/IP 교체.
# 리다이렉터가 일치하는 트래픽만 전달하는지 확인:
curl -k https://cdn.example.com/                       # expect 302 to decoy
curl -k -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \
  https://cdn.example.com/api/v2/jobs                  # expect proxied response

도구 및 리소스

도구목적출처
nginx필터링 리버스 프록시 리다이렉터https://nginx.org/
Apache mod_rewrite[P] 프록시 + 302 유인 리다이렉터https://httpd.apache.org/docs/current/mod/mod_rewrite.html
cs2modrewriteCS 프로필에서 Apache/nginx 규칙 생성https://github.com/threatexpress/cs2modrewrite
RedWardenMalleable 인식 필터링 C2 리버스 프록시https://github.com/mgeeky/RedWarden
redi자동화된 nginx + Let's Encrypt CS 리다이렉터https://github.com/taherio/redi
socat덤 파이프 TCP 전달자http://www.dest-unreach.org/socat/
Let's Encrypt / certbot무료 TLS 인증서https://certbot.eff.org/
ired.team레드팀 인프라 참고 자료https://www.ired.team/offensive-security/red-team-infrastructure

검증 기준

  • 팀 서버 방화벽이 C2 포트에서 리다이렉터 소스 IP만 허용하도록 설정됨
  • 리다이렉터 배포됨 (덤 파이프 및/또는 필터링 리버스 프록시)
  • 실제 Malleable C2 프로필(URI + User-Agent + 헤더)에서 필터 규칙 도출됨
  • 일치하지 않는 요청은 무해한 유인 사이트로 302를 반환함 (curl로 확인)
  • 일치하는 비콘 요청은 숨겨진 팀 서버로 프록시됨 (curl로 확인)
  • 유효한 TLS 인증서 발급 및 자동 갱신 확인됨
  • OPSEC 제어 적용됨 (UA/헤더 검증, 지리적 차단, 유인 우회)
  • 도메인 카테고리화 / CDN 프론팅이 해당되는 경우 고려됨
  • 인프라 교체 및 폐기 계획 문서화됨
  • 모든 활동은 승인된 활동 범위 내로 제한됨

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

관련 스킬