Presenting ‘Nirorat’: Python-Based Trojan Avoids Detection Via Advanced Self-Modification
“A new type of Trojan has entered the game involving detection evading via advanced self-modification.”
The cybersecurity industry has been shaken by a recently discovered cyberthreat, a Python-based Remote Access Trojan (RAT) called nirorat.py. Since the malware’s primary design is based on dynamic evasion, experts caution that it is a step ahead in the arms race between hackers and defenders, making the majority of conventional, signature-based antivirus software useless.
With an SHA256 signature of 7173e20e7ec2l7f6a1591flfc9be6d0a4496d78615cc5ccdf7b9a3a37e3ecc3c, the RAT was uploaded to VirusTotal. Its remarkably low detection metrics at this time demonstrate its capacity for self-misrepresentation.
Its use of powerful polymorphic (multi-form) and self-modifying capabilities, which depend on the deft exploitation of Python’s own runtime features, characterizes this “high-risk threat.”
The Self-Adapting Engine: An Electronic Mask
Nirorats use a clever “self-modifying and packing mechanism” at the heart of their avoidance. This procedure is intended to neutralize static analysis by guaranteeing that the malware’s file signature is distinct each time it executes.
The RAT starts by retrieving its own source code while it is running using Python’s inspect module. Self_modifying_wrapper() is a function that handles its essential operations, like the main payload, as data.

After that, it uses XOR encoding and a procedure that uses the zlib and marshal modules to mimic a compression/decompression cycle. The exec() function is then used to run the original source in memory.
By simulating a genuine software packer, this dynamic transformation, which is tracked, guarantees that every run appears as a distinct binary.
Code Obfuscation in the Polymorphic Pipeline
In addition to altering its signature, Nirorat uses a forceful “Advanced Polymorphic Obfuscation Pipeline” to make automated and human analysis more difficult. The polymorph_code() function is used in this process, methodically destroying the structure and readability of the code.
It starts by randomly renaming every variable. After that, it inserts unnecessary, non-functional code, or “junk snippets,” including randomized time, empty list comprehensions, and methods that aren’t used. At random points, sleep() calls and empty try/except blocks are made.
Lastly, function definitions are extracted, shuffled, and re-merged. It is practically hard for a security analyst to follow the code’s original logic because of these structural changes, which obstruct static analysis.
A Wide-Ranging Attack Surface
When Nirorat is run, it becomes a fully functional remote access trojan that gives attackers a lot of options. The malware has a wide “attack surface” that includes data exfiltration, command-and-control capabilities, and network dissemination.
Its capabilities include
- Network Propagation: Socket_network_scan() and spread_to_network() are two functions that allow for lateral movement throughout the internal systems of a target.
- Intrusion: Attempts to use functions like test_default_credentials() to brute-force network devices.
- Surveillance: The capability to record_screen_webcam(), take a snapshot(), and record audio().
- Command & Control (C2): Features for collecting system information, uploading and downloading files, and running shell commands.
- Unique Feature: By integrating a Discord bot interface, the malware enables attackers to give commands. Notably, it contains the commands /xworm to drop a secondary payload from an external URL and /encrypt to encrypt files, indicating the possibility of ransomware in the future.
Changes in Defense and Mitigation
Security defenders must switch from file signatures to behavioral analysis to counter this dynamic threat. Indicators of Compromise (IoCs) highlight particular actions that are observable:
- Monitoring Python Processes: Defenders need to keep an eye on Python processes for unexpected use of marshal.loads() and dynamic calls to inspect. getsource().
- Behavioral Red Flags: Important indicators of compromise include random delays and frequent imports of the zlib module, which are symptoms of the unpacking and obfuscation pipeline.
- Recommended Action: To identify and stop this complex, multifaceted malware, experts advise doing thorough runtime behavioral analysis in sandboxed environments together with file integrity checks on Python scripts.
About The Author
Suraj Koli is a content specialist in technical writing about cybersecurity and & information security. He has written many amazing articles related to cybersecurity concepts, with the latest trends in cyber awareness and ethical hacking. Find out more about “Him.”
Read More:
QR Code Quishing Attack: Microsoft Users Targeted