Investigating a Malicious .jar file
Hello guys, I’m back with another writeup. First of all, can you tell me why Ronaldo is out of the World cup? I could not sleep that day. Anyways.. that was just btw. Today’s lab was from LetsDefend. I realized its been a while I solved their labs hence checked out Samba spy and decided to make my writeup for it.
Relax and follow along. If by any chance you found this helpful, you can give this a clap and hit the follow button to get notified anytime I post a walkthrough or writeup. (I usually interchange those words lol)
Your organization has discovered an infection on one of its systems involving a malicious Java application. This malware performs environment checks to ensure it is not running inside a virtual machine and targets systems with specific configurations. Once the required conditions are met, it extracts files and executes malicious components that could compromise sensitive data or system integrity.
Uncover the the stealthy nature of the malware and its ability to evade detection which pose a serious threat, to secure the network and prevent further compromise.
I started by extracting the contents of the provided ZIP file, which returned a .jar file.
Press enter or click to view image in full size
Since the goal was to “uncover the stealthy nature of the malware,” decompiling the artifact was the logical first step. In the lab console, I selected Java Decompiler (JD) to open the .jar file. Once opened, the left panel displayed several classes. I expanded JavaApplication1.class to explore its methods and understand the malware’s logic.
Scrolling through the methods, I noticed one that stood out: isRunningInVM().
Answer: isRunningInVM
This method checks for virtualization indicators , allowing the malware to change its behavior if it detects a virtualized environment (essentially, it’s trying to fool the analyst).
Press enter or click to view image in full size
I performed a quick search for the keyword language within the decompiled code. I found that the malware checks if the system language is Italian before proceeding with execution. This is a geo-targeting technique likely to avoid detection in non-target regions.
Answer: Italian
Press enter or click to view image in full size
Searching for Prodotto.zip within the decompiled code, I found it referenced inside the extractLibs() method. This method handles the extraction of the malicious payload.
Answer: extractLibs
Press enter or click to view image in full size
Looking inside the extractLibs() method, the very first line specified a destinationPath:
destinationPath = "C:\\Users\\Public\\"So the malware drops its contents into a common public directory likely to avoid raising suspicion.
Join Medium for free to get updates from this writer.
Answer: C:\Users\Public
Press enter or click to view image in full size
Back in the main class, I traced the flow: after checking for virtualization and system language, the program looks for a file in the same extraction path (C:\Users\Public\). That file is declared as jarPath and is named Prodotto.png.
Yes, it’s a .png file masquerading as a JAR (classic trick to bypass file-type filters and user suspicion)
Answer: Prodotto.png
Press enter or click to view image in full size
From the previous question, we identified the path for the masqueraded jar file declared as jarPath. A few lines below the jarPath declaration, I found a process builder that clearly executes:
Answer:
java -jar C:\Users\Public\Prodotto.pngThis confirms that the malware uses Java to run the disguised .png as a JAR.
Press enter or click to view image in full size
Initially, I had identified that the isRunningInVM() method which firstly used the manufacture string for that check. You would realize there was Microsoft Corperation, among others.
This time, I need to find another method by which the malware checked for virtualization. A couple of lines below the manufacturer method was another method “wmic baseboard get manufacturer” as seen in the image below.
That command retrieves the motherboard manufacturer, which is another reliable indicator of virtualization.
Answer: wmic baseboard get manufacturer
Press enter or click to view image in full size
The program explicitly checks for four vendors:
These cover the most common virtualization platforms (VirtualBox, VMware, Xen, and Hyper-V)
Answer: 4
Completing the Samba Spy challenge on LetsDefend was more than just answering questions.. it was a a solid approach in understanding how a malicious Java application operates. The process walked me through the entire lifecycle of a Java-based threat, from initial decompilation to unpacking its evasion tactics and execution chain. When I first opened the .jar file in the Java Decompiler, I was struck by how clearly the code revealed its malicious intent which was almost like reading the attacker’s playbook . What made this challenge particularly valuable was the opportunity to map the malware’s behavior directly to the MITRE ATT&CK framework. Identifying specific techniques helps defenders understand what the malware is doing and, more importantly, why.
The malware employs several key techniques that correspond to specific MITRE ATT&CK tactics:
Viola! See you in my next post.
Press enter or click to view image in full size