BellaCiao Technical Analysis
Comprehensive technical analysis of both BellaCiao variants, covering command-and-control protocols, persistence mechanisms, operational security, and defensive strategies.Executive Summary
BellaCiao is a sophisticated multi-variant backdoor malware developed by CharmingKitten (IRGC-IO Department 40) for persistent access to compromised Microsoft Exchange and IIS web servers. The malware demonstrates advanced operational security, flexible deployment options, and robust C2 mechanisms.First Seen
2022Deployed against Middle East targets
Confirmed Victims
50+Turkey, UAE, Saudi Arabia, Kuwait, Iran
Attribution Confidence
HighSource code, infrastructure, personnel
Variant Comparison Matrix
| Characteristic | Variant 1 (C#) | Variant 2 (PowerShell) |
|---|---|---|
| Language | C# (.NET Framework 4.0) | PowerShell 5.1+ |
| File Type | Compiled executable (PE32) | Script (.ps1) |
| Installation | Windows Service | Script execution |
| Persistence | Service auto-start | Scheduled task / Registry |
| C2 Protocol | DNS beaconing | SSH reverse tunnel |
| C2 Interval | 24 hours | Persistent connection |
| Webshell Type | ASP.NET (.aspx) | PowerShell HTTP server |
| Deployment Path | IIS wwwroot, Exchange OWA | Localhost only |
| File Operations | Upload, download, execute | Upload, download, execute, browse |
| Stealth | Service masquerading | Legitimate PowerShell |
| OPSEC | Good (DNS tunneling) | Moderate (SSH on 443) |
| Modularity | Low (monolithic) | High (separate components) |
| Detection Difficulty | Medium | Medium-High |
Command and Control Analysis
Variant 1: DNS-Based C2
Protocol Overview
Variant 1 implements a sophisticated DNS-based command and control protocol:Command Encoding Scheme
IP Address Structure:212: Use predefined filename- Other: Use random generated filename
175: Path type 1 (IIS wwwroot / Exchange themes resources)176: Path type 2 (IIS wwwroot2 / Exchange themes)177: Path type 3 (Exchange OWA auth current)
168: Exchange Server target- Other: IIS target
58: Deploy webshell59: Remove all webshells
Example Commands
- Deploy Exchange Webshell
- Deploy IIS Webshell
- Remove All Webshells
DNS Response:
212.175.168.58Decoded Action:212: Use predefined name (owafont.aspx)175: Use path 1 (themes resources)168: Exchange Server58: Deploy webshell
C2 Resilience
Domain Failover:- Bypasses many firewall rules (DNS typically allowed)
- Low network footprint (single query every 24 hours)
- Difficult to detect without DNS logging
- No direct connection to C2 server
- Natural traffic pattern (applications query DNS regularly)
Variant 2: SSH Reverse Tunnel
Tunnel Architecture
Tunnel Configuration
Plink Command:| Parameter | Value | Purpose | OPSEC Impact |
|---|---|---|---|
echo Y | Auto-accept | Bypass host key warning | Enables unattended operation |
| Target | twittsupport.com | C2 domain | Uses legitimate-looking domain |
-P 443 | SSH port 443 | Port selection | Mimics HTTPS traffic |
-C | Compression | Enable SSH compression | Reduces bandwidth, harder to analyze |
-R | Reverse tunnel | Forward C2:9090 to victim:49450 | No inbound firewall rules needed |
-l Israel | Username | SSH authentication | Hardcoded credential |
-pw Israel@123! | Password | SSH authentication | Weak password, reused across ops |
| Binary path | Java Update Services.exe | Plink masquerading | Appears as Java updater |
Operator Access Flow
Establish tunnel from victim
Victim system initiates outbound SSH connection to C2 server on port 443
C2 server opens local port
C2 server opens listening port 9090 on localhost (only accessible to C2 system)
Operator connects to localhost
Operator on C2 server browses to
http://localhost:9090 in web browserPersistence Mechanisms
Variant 1: Windows Service
Installation:- Survives reboots
- Runs as SYSTEM
- Appears legitimate (Microsoft in name)
- Standard Windows management (sc.exe)
Variant 2: Multiple Options
Scheduled Task Persistence
Registry Run Key
WMI Event Subscription
Webshell Analysis
Variant 1 Webshells
The webshells dropped by Variant 1 are base64-encoded ASP.NET pages. The malware stores them as:- File upload/download
- Command execution via
cmd.exeorpowershell.exe - Directory browsing
- Process listing and termination
- Registry access
Variant 2 Webserver
Variant 2 implements a full PowerShell HTTP server with extensive capabilities:Web Interface Routes
| Route | Method | Function | Risk Level |
|---|---|---|---|
/ | GET | Command execution form | Critical |
/script | POST | Upload and execute PS1 scripts | Critical |
/upload | POST | Upload arbitrary files | High |
/download | GET/POST | Download files from system | High |
/log | GET | View webserver access logs | Medium |
/time | GET | Get system time | Low |
/starttime | GET | View webserver start time | Low |
/beep | GET | System beep (presence check) | Low |
/exit or /quit | GET | Stop webserver | Medium |
/* (any path) | GET | Browse filesystem, download files | High |
Command Execution Interface
The root path (/) provides a web-based PowerShell prompt:
HTML Interface:
Operational Security Analysis
OPSEC Strengths
Variant 1 OPSEC Strengths
Variant 1 OPSEC Strengths
- DNS Tunneling
- Blends with normal DNS traffic
- Low frequency (24-hour beacon interval)
- Minimal network footprint
- Legitimate Paths
- Targets system directories (wwwroot, Exchange)
- Files named to appear legitimate (aspnet, owafont, themes)
- Service Masquerading
- Service name mimics Microsoft naming convention
- Runs as LocalSystem (expected for system services)
- Command Encoding
- IP addresses appear as normal DNS responses
- No obvious command structure in network traffic
- Minimal Artifacts
- Single service binary
- No registry keys beyond service installation
- Webshells only created on demand
Variant 2 OPSEC Strengths
Variant 2 OPSEC Strengths
- Reverse Tunnel
- No inbound connections required
- Bypasses inbound firewall rules
- Operator connects through tunnel
- Port 443 Mimicry
- SSH on port 443 appears as HTTPS
- Blends with legitimate encrypted web traffic
- Localhost Binding
- Webserver only accessible via tunnel
- No direct network exposure
- Appears as internal application
- PowerShell Native
- No compiled binaries to analyze
- Uses built-in Windows functionality
- Harder to signature-match
- Legitimate Tool Abuse
- Plink is a legitimate SSH client
- PowerShell is a built-in Windows tool
- Both have valid administrative uses
OPSEC Weaknesses
Variant 1 OPSEC Weaknesses
Variant 1 OPSEC Weaknesses
- Fixed Domain Pattern
- DNS queries always to
*.eposta.maill-support.comor*.eposta.mailupdate.info - Easy to block once identified
- DNS queries always to
- Predictable Subdomain Format
- Pattern:
[A-Z]{2}[a-z]{3}EXH - “EXH” marker makes detection easier
- Pattern:
- Hardcoded Strings
- Domain names in binary
- File paths in binary
- Service name predictable
- Base64 in Memory
- Webshell payload stored as base64 string
- Memory scanning can detect
- 24-Hour Timer
- Predictable beacon interval
- Can correlate with DNS logs
Variant 2 OPSEC Weaknesses
Variant 2 OPSEC Weaknesses
- Hardcoded SSH Credentials
- Username:
Israel - Password:
Israel@123! - Same credentials used across all deployments
- Username:
- SSH Protocol Detection
- Despite port 443, SSH protocol identifiable by DPI
- SSL/TLS inspection can detect SSH tunneling
- Hardcoded C2 Domains
twittsupport.comandmsn-center.uk- Easy to block once identified
- Plink Renamed but Detectable
- File renamed but PE structure unchanged
- Can be identified by hash or PE headers
- PowerShell Script Block Logging
- If enabled, captures full script execution
- Webserver source code logged
- Localhost Port 49450
- Fixed port number
- Easy to monitor for HTTP listener
Credential Reuse Issues
This allows defenders to:- Search SSH logs for username “Israel”
- Identify compromised systems with authentication attempts
- Track CharmingKitten infrastructure by SSH login patterns
- Correlate attacks across different targets
Attack Pattern Analysis
Typical Kill Chain
Initial Access
ProxyShell Exploitation (CVE-2024-1709)
- Target: Microsoft Exchange Server
- Method: ProxyShell vulnerability chain
- Result: Remote code execution as SYSTEM
Persistence - Phase 1
BellaCiao Variant 1 Deployment
- Deploy as Windows Service
- Establish DNS beaconing
- Drop initial webshell to Exchange OWA path
Persistence - Phase 2
BellaCiao Variant 2 Deployment
- Deploy PowerShell script
- Establish SSH reverse tunnel
- Start local webserver for operator access
Discovery
Network and System Reconnaissance
- Domain enumeration:
net user /domain,nltest - Network scanning:
nmap, internal IP ranges - Credential dumping: SAM/SYSTEM registry hives
Lateral Movement
Spread to Additional Systems
- Use harvested credentials
- Deploy webshells to other servers
- Establish persistence on key systems
Real-World Attack: Turkish Foreign Ministry
Timeline:Indicators of Compromise (IoCs)
File System IoCs
Network IoCs
Registry IoCs
Process IoCs
Detection and Hunting
Hunting Queries
- Splunk
- Microsoft Sentinel (KQL)
- PowerShell
YARA Rules
Defensive Recommendations
Prevention
Patch Management
Patch Management
- ProxyShell vulnerabilities: CVE-2021-34473, CVE-2021-34523, CVE-2021-31207
- Related CVEs: CVE-2024-1709 (observed in attack reports)
- Update Microsoft Exchange to latest security patches
- Implement virtual patching if immediate patching not possible
Network Segmentation
Network Segmentation
- Isolate Exchange servers from general network
- Restrict outbound connections from Exchange to only required destinations
- Block SSH outbound except from authorized jump hosts
- Implement DNS filtering to block known malicious domains
Application Whitelisting
Application Whitelisting
- Implement AppLocker or Windows Defender Application Control (WDAC)
- Block unsigned or untrusted binaries
- Restrict PowerShell execution to signed scripts only
- Block plink.exe and other SSH clients on Exchange servers
PowerShell Hardening
PowerShell Hardening
- Enable PowerShell Constrained Language Mode on servers
- Implement Just Enough Administration (JEA)
- Configure PowerShell Script Block Logging
- Configure PowerShell Module Logging
- Configure PowerShell Transcription
- Restrict
Invoke-Expressionusage
Detection
Enable comprehensive logging
- Windows Security Event Logging (4688, 4689 with command line)
- PowerShell logging (4104 script block logging)
- DNS query logging
- IIS/Exchange request logging
- Service installation logging (7045)
Deploy detection rules
- Sigma rules for BellaCiao IoCs
- YARA rules for file scanning
- Network IDS rules for DNS patterns and SSH tunnels
- EDR behavioral detections
Monitor for specific indicators
- DNS queries to
*.eposta.maill-support.comor*.eposta.mailupdate.info - Service installations with “Microsoft” in name from non-Microsoft paths
- SSH connections outbound to port 443
- PowerShell
HttpListenerinstantiation - Localhost HTTP servers on unusual ports
- ASPX files in Exchange OWA authentication paths
Response
If BellaCiao infection is confirmed:Contain the infection
- Isolate affected system from network
- Block C2 domains at firewall and DNS
- Disable affected services
- Kill malicious processes
Preserve evidence
- Take memory dump
- Export relevant logs
- Image disk for forensic analysis
- Document all actions taken
Eradicate malware
- Stop and delete malicious services
- Remove persistence mechanisms
- Delete webshells and malware files
- Check for additional persistence
Recover and harden
- Reset all potentially compromised credentials
- Rebuild system if complete eradication uncertain
- Apply security patches
- Implement additional hardening measures
Attribution and Context
CharmingKitten (also known as APT35, Phosphorus, NewsBeef, Newscaster) is an Iranian threat actor group operating under the Islamic Revolutionary Guard Corps Intelligence Organization (IRGC-IO). Department 40 operates under the Counterintelligence Division (Unit 1500) of IRGC-IO. Leadership: Abbas Rahrovi (National ID: 4270844116) See:Additional Resources
Variant 1 Analysis
Deep dive into C# webshell dropper
Variant 2 Analysis
PowerShell reverse proxy analysis
Infrastructure
C2 infrastructure and credentials
Episode 3
Source code release episode