Technical Analysis of the Backdoor and Attack Chain
A deep dive into the code structure reveals a highly calculated execution flow. The key to the backdoor is a hidden script named secret.py, placed within the helpers directory of the modified Pyrogram structure. The entry point of this backdoor is executed through one of two distinct triggering mechanisms, depending on the specific package variation installed:
Import-Time Trigger: In packages like vlifegram, the backdoor execution is triggered the moment the package is imported into any Python script. This is achieved by embedding an import statement for secret.py directly inside the helpers/__init__.py initialization file.
Startup-Time Trigger: In other variants, such as kelragram or pyrogram-navy, the backdoor is wired into the client startup lifecycle. It executes when the bot's start() routine is invoked, allowing the backdoor to piggyback on the legitimate client connection process.
The Gating Logic and Self-Exclusion Mechanisms
To ensure that the campaign remains stealthy and only targets high-value targets, the backdoor contains two critical gating conditions before executing its primary payloads:
First, it performs a contextual bot-exclusive check using the statement if self.me.is_bot. If the running instance is a standard user account (a userbot), the execution stops. This focuses the campaign strictly on production Telegram bots, which are typically hosted on cloud servers, virtual machines, or local enterprise databases, where access to secrets and production databases is common.
Second, the backdoor contains a self-exclusion guard that checks the bot's numeric account ID against a hardcoded array of integer IDs labeled OWNERS. If the bot's ID is found in this list, the execution immediately terminates. This ensures that when the attacker runs the backdoor code on their own testing environments, the payload does not trigger, preventing self-infection and reducing the risk of accidental exposure during development.
Command and Control (C2) and Remote Execution
Once the backdoor is successfully initialized, it registers stealthy event handlers that listen for specific messages from authorized accounts. These message handlers bypass the normal bot routing logic, listening silently for commands sent by accounts that match the hardcoded OWNERS list. The primary commands identified in the backdoor include:
Python Execution Command: Triggered via /asu or /wann, this command accepts a block of Python code as a string, compiles it, and executes it using the exec(compile()) statement. This provides the attacker with full control over the running Python process, allowing them to extract active environment variables, dump memory states, and hijack session data.
Host Shell Execution Command: Triggered via /asi or /wann2, this command executes arbitrary operating system commands by spawning a subprocess through /bin/bash -c. Because the command runs with the same privileges as the parent Python bot process, the attacker can traverse the file system, read sensitive system files like /etc/passwd, or download persistent binaries.
Native Data Exfiltration Channels
The backdoor relies entirely on Telegram's official MTProto API to communicate with the command and control nodes. This represents a classic "living off the API" technique, making network-level detection incredibly difficult. All commands and exfiltrated data are packaged inside standard, encrypted MTProto traffic, easily passing through corporate firewall systems and network security monitors. If the output of a shell command exceeds the maximum Telegram message limit of 4,096 bytes, the backdoor automatically saves the data into a temporary text file and uploads it to the attacker's channel using the native reply_document method.