Software supply chain security firm Phylum has identified a malicious attack targeting Python Package Index (PyPI) users with the PoweRAT backdoor and information stealer.
The campaign was first detected on December 22, 2022, when a malicious package named PyroLogin was identified as Python malware designed to fetch code from a remote server and execute it silently.
Between December 28 and 31, Phylum’s security researchers observed five additional packages containing code similar to PyroLogin being published to PyPI: EasyTimeStamp, Discorder, Discord-dev, Style.py, and PythonStyles.
The infection chain, which involves the execution of various scripts and the abuse of legitimate operating system functions, begins with a setup.py file, meaning that the malware is automatically deployed if the malicious packages are installed using Pip.
Phylum’s analysis of the execution process revealed the use of obfuscation and attempts to prevent static analysis. To prevent raising victims’ suspicion, a message claiming ‘dependencies’ are being installed is displayed, while the malicious code is executed in the background.
The infection chain also includes the installation of multiple potentially invasive packages, including libraries that allow the attackers to control and monitor mouse and keyboard input and capture the screen, and dropping malicious code into the Windows startup folder, for persistence.
Once up and running on the victim’s machine, the malware allows the attackers to steal sensitive information such as browser cookies and passwords, crypto wallets, Discord tokens, and Telegram data. The harvested information is exfiltrated in a ZIP archive.
The malware also attempts to download and install on the victim’s computer Cloudflared, a Cloudflare command-line tunnel client that allows the attackers to access a Flask app on the victim’s system without modifying the firewall.
Acting as a command-and-control (C&C) client, the Flask app allows the attackers to extract information such as username, IPs, and machine details, run shell commands, download and execute remote files, and even run arbitrary Python code.
The malware, which functions as an information stealer combined with a remote access trojan (RAT), also contains a function that sends to the attackers a constant stream of images of the victim’s screen and allows them to trigger mouse click and button presses.
The malware is named Xrat, but Phylum decided to call it PoweRAT “because of its early reliance on PowerShell in the attack chain”.
“This thing is like a RAT on steroids. It has all the basic RAT capabilities built into a nice web GUI with a rudimentary remote desktop capability and a stealer to boot! Even if the attacker fails to establish persistence or fails to get the remote desktop utility working, the stealer portion will still ship off whatever it found,” Phylum concludes.
Related: Malicious PyPI Module Poses as SentinelOne SDK
Related: Malware Delivered to PyTorch Users in Supply Chain Attack