Let me let you in on a secret. Back when I was in my early 'know-it-all' phase—you know, that period where you think you've seen it all—I accidentally executed a piece of malware I had downloaded for analysis inside a folder shared with my host machine. Watching my desktop icons start to change in seconds is a feeling I can only describe as ice-cold water pouring down your spine. That day, I didn't just lose some data; I left my 'I never make mistakes' ego in that folder too. That’s the reality of malware analysis: a single moment of carelessness turns you from the hunter into the hunted.
Today, here at the labs, coffee in hand, we’re going to talk about how we dive into those suspicious .exe or .js files, the lies they try to tell us, and how we expose the truth. If you're ready, spin up your Virtual Machine (VM), double-check that 'host-only' network setting, and let’s get into it.
Static Analysis: Don't Judge a Book by Its Cover
The first thing you do when you encounter malware is put a magnifying glass over it before you even think about touching it. We call this static analysis. We’re essentially examining its anatomy without actually letting it run.
First, we grab the file's hash (MD5, SHA256) and check platforms like VirusTotal to see if it’s been spotted before. But a word of caution: if you're running a highly sensitive operation or analyzing a targeted attack (APT), uploading the file there is like sending a DM to the attacker saying, 'Hey, we found your file and we're dissecting it right now!'
Next, we use the strings command to look for readable text inside the binary. IP addresses, domains, file paths, or error messages... sometimes attackers even leave a little 'Hello' for us there.
For example, imagine you catch something like this:
http://example.com/updates/payload.bin
C:\Windows\Temp\debug_log.txt
Set-MpPreference -DisableRealtimeMonitoring $true
See that? That’s a 'I'm totally innocent' file screaming 'I’m actually very dangerous.' Any script trying to disable Windows Defender is an immediate red flag.
Packers and Entropy
Sometimes you look at a file and see... nothing. Just a jumble of meaningless characters. This is where 'Packers' come in. The file might be compressed with tools like UPX or encrypted using custom methods. When we measure the 'entropy' of a file, and the value is above 7.0, you can bet that file is hiding something. To find the order within the chaos, you have to peel that shell off first (unpacking).
Dynamic Analysis: Releasing the Mouse in the Maze
This is where the real fun begins. We run the file in an isolated environment (like FlareVM or Remnux). But first, we have to set the stage. We set up a fake internet connection (FakeNet-NG) so the malware thinks it's talking to the outside world, but it’s actually falling into our loopback trap.
When malware runs, it usually follows these steps:
- Discovery: 'What machine am I on? Am I in a VM? Am I being watched?'
- Persistence: 'How do I make sure I keep running even if the computer restarts?'
- C2 Communication: Reaching out to the Command and Control server to say 'I'm in, what's next?'
