Necro is a Python-based botnet, also known as Necromorph, N3Cr0m0rPh, and FreakOut, that targets Windows and Linux systems. First identified in 2015, it is associated with the Keksec threat group. Its principal activities include distributed denial-of-service attacks, cryptocurrency mining, malware deployment, and traffic interception. It is distinct from the Android Trojan dropper also called Necro.
Necro propagates through network scanning, SSH and Telnet weak-password attacks, exploitation of vulnerable internet-facing applications, and SMB-based propagation. Exploited products include TerraMaster TOS, Zend Framework, Laravel, Oracle WebLogic, Liferay Portal, and VMware vCenter Server. Some Windows variants incorporate EternalBlue and EternalRomance exploits, while others use credential-based remote service creation. Payloads are distributed as Python scripts with standalone interpreters or as PyInstaller-packaged Windows and Linux executables.
Operators control Necro through IRC-based command-and-control communications. Variants use Tor proxies, domain generation algorithms, encrypted communications, and polymorphic Python code to resist detection and infrastructure blocking. Necro supports reverse shells, file download and execution, configurable scanning, packet sniffing, ARP spoofing, and multiple DDoS methods, including UDP, SYN, HTTP, Slowloris, and amplification attacks. It establishes startup persistence on both supported operating systems. Windows variants inject the r77 user-mode rootkit into other processes to conceal malicious activity.
Necro deploys XMRig miners and can install additional botnet payloads such as Gafgyt_tor. On compromised Linux web servers, it modifies web files to inject malicious JavaScript into pages served to visitors. Associated browser payloads support cryptocurrency mining, keylogging, form-data collection, cookie and clipboard theft, arbitrary JavaScript execution, and browser-based DDoS attacks. Its traffic-sniffing functionality also forwards captured network data to attacker infrastructure.
9 CVEs Mallory has correlated with this family across public research and vendor advisories. Each card links to the full Mallory page for that vulnerability.
2 distinct threat actors Mallory has associated with this family across public reporting. Open in Mallory to see the full evidence chain and overlapping campaigns.
2021 – Spytech Necro is an updated version of Necro python malware with significant updates to the C2 protocol and additional exploits.
Further analysis revealed that the family is closely related to the Necro family we made public in January, and is behind the same group of people, the so-called keksec group.
49 distinct techniques documented for this family, organized by ATT&CK tactic.
We can see that Keksec launched scans and attacks on targets across the network almost non-stop. Our honeypots see new variants and exploits all the time, with the exception of some occasional breaks. When a new exploit is introduced, the scans increase significantly.
Once an IP address is generated, the bot will connect to a list of ports and attempt to spread either by using a hardcoded list of SSH credentials and issuing a remote command if a login attempt is successful.
Necro’s goal in infecting web files is to spread JS Bot (Cloud9). The bot is loaded when the user accesses an infected page through a browser.
Necro spreads by exploiting TerraMaster RCE (CVE-2020-35665), Zend RCE (CVE-2021-3007), Laravel RCE (CVE-2021-3129), and WebLogic RCE (CVE-2020-14882).
The case of CamScanner showed that an app’s legitimate behavior can be supplemented with malicious functions by updating its code for handling advertising.
python .benchmark.py||python2 .benchmark.py||python2.7 .benchmark.py||./.benchmark||./.benchmark.py &
The Windows exploit uses Powershell, which first downloads the packaged Python 2.7 executable (py.exe), then downloads and executes Necro (setup.py).
The Laravel exploit uses a reverse shell to first download a bash script. The WebLogic Linux exploit uses bash, which downloads and executes both Necro (setup.py) and the mining program.
Developed in Python to target dual systems: Necro
Necro traverses '*.js', '*.html', '*.htm', '*.php' files and inserts code that loads campaign.js from ublock-referer.dev.
the other one utilizes an 1-day vulnerability (CVE-2020-35665)... Version 2 ... include the Zend Framework (known as CVE-2021-3007).
Persistence is ensured by modifying the /etc/rc.local script to include commands to launch the bot when the system is booted.
Once an IP address is generated, the bot will connect to a list of ports and attempt to spread either by using a hardcoded list of SSH credentials and issuing a remote command if a login attempt is successful.
The exploitation function of this sample does not contain EternalBlue and EternalRomance but attempts to connect over SMB (port 445) and create a service remotely to download and run the main bot file.
Finally, Necro will register the bootstrap item to SOFTWARE\Microsoft\Windows\CurrentVersion\Run.
On Linux, the bot first changes the DNS resolver configuration to point to Cloudflare DNS servers, 1.0.0.1 and 1.1.1.1, potentially to avoid the detection of its activity in the local DNS server logs.
Persistence is ensured by modifying the /etc/rc.local script to include commands to launch the bot when the system is booted.
Necro will then load the rootkit using a piece of shellcode using process injection from another open source project, sRDI; the code calls OpenProcess, VirtualAllocEx, WriteProcessMemory, and CreateRemoteThread.
Once an IP address is generated, the bot will connect to a list of ports and attempt to spread either by using a hardcoded list of SSH credentials and issuing a remote command if a login attempt is successful.
The exploitation function of this sample does not contain EternalBlue and EternalRomance but attempts to connect over SMB (port 445) and create a service remotely to download and run the main bot file.
Finally, Necro will register the bootstrap item to SOFTWARE\Microsoft\Windows\CurrentVersion\Run.
Necro downloads x86.dll or x64.dll, corresponding to the open-source r77-rootkit project, which hides files, directories, processes, registry items, connections, and other entities.
Necro implemented a code morphing algorithm based on the abstract syntax tree (AST), achieving randomized object names and broader obfuscation; samples had a reported VT detection rate of 0.
最新的2个版本为了确保能在没有Python2的受害机器上执行,会同时分发使用PyInstaller打包过的Python程序。
A very traditional technique on Linux systems is to use random strings to override argv parameters and prctl(PR_SET_NAME,buf) to change the process name and start parameters in order to disguise the process.
Necro will then load the rootkit using a piece of shellcode using process injection from another open source project, sRDI; the code calls OpenProcess, VirtualAllocEx, WriteProcessMemory, and CreateRemoteThread.
Once an IP address is generated, the bot will connect to a list of ports and attempt to spread either by using a hardcoded list of SSH credentials and issuing a remote command if a login attempt is successful.
Necro calls SetFileAttributesW on USERPROFILE\$6829.exe with FILE_ATTRIBUTE_HIDDEN.
On Linux, the bot first changes the DNS resolver configuration to point to Cloudflare DNS servers, 1.0.0.1 and 1.1.1.1, potentially to avoid the detection of its activity in the local DNS server logs.
Packet sniffing is one of the more favoured features of Keksec, and the code can be seen in all three families. The basic function is to capture TCP traffic after filtering out some specified ports and IPs, and to send the remaining data to the C2.
Apart from installing miner code, the JavaScript-based bot contains additional functionality to accept commands from the C2 server and it may be used to steal data from the clipboard, by logging keystrokes and launching DoS attacks.
The malicious JavaScript monitors events and reports data through /l.php to upload keyboard records.
The scanners used by Keksec are mainly telnet and SSH weak password scan and exploit scan.
After receiving the scan command, the built-in weak password brute force starts... SSH weak passwords are constantly updated by version upgrades, and new weak passwords are added to replace some of the less effective ones.
The JavaScript command "cookie" sends back cookie data through /c.php.
On Linux, the bot first changes the DNS resolver configuration to point to Cloudflare DNS servers, 1.0.0.1 and 1.1.1.1, potentially to avoid the detection of its activity in the local DNS server logs.
比较有意思的Necro还支持ARP投毒和网络流量嗅探。ARP欺骗是为了把受害者机器伪装成网关
Necro also supports ARP spoofing and network traffic sniffing. ARP spoofing is designed to disguise the victim machine as a gateway
Packet sniffing is one of the more favoured features of Keksec, and the code can be seen in all three families. The basic function is to capture TCP traffic after filtering out some specified ports and IPs, and to send the remaining data to the C2.
Necro first tries to install the paramiko library on the device, and if it succeeds, it adds port 22 to the list of scanned ports... Necro added the SMB scan code in one of its versions to achieve the function of horizontal propagation in the intranet.
...brute-forcing passwords over SSH... the bot will try to use one of the built-in exploits or log in using a hardcoded list of SSH credentials.
Necro added the SMB scan code in one of its versions to achieve the function of horizontal propagation in the intranet.
Keksec not only enriches it functionality with a lot of references to third-party code, but also delivers the complete open-source project directly to the target device to complete the corresponding functionality.
Apart from installing miner code, the JavaScript-based bot contains additional functionality to accept commands from the C2 server and it may be used to steal data from the clipboard, by logging keystrokes and launching DoS attacks.
The malicious JavaScript monitors events and reports data through /l.php to upload keyboard records.
The JavaScript command "clipboard" sends back clipboard content through /cb.php.
比较有意思的Necro还支持ARP投毒和网络流量嗅探。ARP欺骗是为了把受害者机器伪装成网关
Necro also supports ARP spoofing and network traffic sniffing. ARP spoofing is designed to disguise the victim machine as a gateway
Keksec’s malware mainly uses Gafgyt and IRC protocols to send commands.
The IRC protocol is the most widely used protocol in Keksec, and is supported by the Tsunami, Necro and DarkIRC families.
We found Tor proxy being used to communicate with the C2 in both Gafgyt and Necro.
Necro supports Tor for C2; its code includes multiple Tor proxy IP addresses and an onion-service C2 address.
Downloaded bash scripts download and execute another script malware.sh, Gafgyt_tor, and a mining program; Windows PowerShell downloads py.exe and setup.py.
This threat demonstrates several techniques of the MITRE ATT&CK framework, most notably ... Remote Access Software - T1219.
In its historical versions Necro used DGA to evade C2 interception.
The new version of Necro updated the DGA mechanism, using DGA to generate subdomains, and then with dynamic domain names to generate the final C2 domain name.
This threat demonstrates several techniques of the MITRE ATT&CK framework, most notably ... Non-Standard Port - T1571.
On January 20, 2021, in the latest version 3 sample the authors made another change to the DGA algorithm, modifying the seeds from 3 to 4096, and also started using SSL to encrypt the communication data.
The malware's core functionality enables operators to... sniff and exfiltrate network traffic...
Necro tampers with web service pages to perform browser mining; the injected page loads a mining JavaScript script from cloud-miner.de.
Necro integrates a Tor proxy-based DDoS attack method, torflood; other JavaScript commands issue repeated POST requests, image loads, and iframe loads to DDoS targets.
从这些命令串可以看出Necro是一个用于DDoS攻击的botnet,C2协议基于IRC,支持的攻击方式既包括常见的udpflood、synflood、slowloris、httpflood这些,也包括在botnet中不常见的amp反射攻击。
We found that Necro can infect web files (.js, .html, .htm, .php) on the target device... After receiving the infection command, it inserts a JS code, hxxp[:]//ublock-referer.dev/campaign.js, into the file.
192 indicators attributed across vendor reports, sandbox runs, and researcher write-ups. Values are masked here and available in full in Mallory.
15 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.