The Art of Mac Malware, Volume 2: Detecting Malicious Software - podcast episode cover

The Art of Mac Malware, Volume 2: Detecting Malicious Software

May 30, 202517 min
--:--
--:--
Download Metacast podcast app
Listen to this episode in Metacast mobile app
Don't just listen to podcasts. Learn from them with transcripts, summaries, and chapters for every episode. Skim, search, and bookmark insights. Learn more

Episode description

A technical guide focused on programmatic Mac malware detection. The content covers examining various data sources like process information, network activity, and persistence mechanisms to identify malicious behavior. It explains how to parse executable files, validate code signing, and monitor system events using native macOS frameworks and APIs, including the NetworkExtension and Endpoint Security frameworks. The sources discuss case studies of real-world malware and tools like KnockKnock and BlockBlock as practical examples of detection methods.

You can listen and download our episodes for free on more than 10 different platforms:
https://linktr.ee/cyber_security_summary

Get the Book now from Amazon:
https://www.amazon.com/Art-Mac-Malware-Detecting-Malicious/dp/1718503784?&linkCode=ll1&tag=cvthunderx-20&linkId=2bda107e6375bc0ac86fa4610caa342c&language=en_US&ref_=as_li_ss_tl



Discover our free courses in tech and cybersecurity, Start learning today:
https://linktr.ee/cybercode_academy

Transcript

Speaker 1

Welcome to the deep Dive. Today, we're plunging into a stack of sources focused on a genuinely fascinating and critical topic, how security tools can programmatically detect mego s malware.

Speaker 2

That's right, you've shared excerpts from the Art of Mac Malware, which really gets deep into the technical underpinnings. You know how security software spots malicious activity IMAX, often at a very low level.

Speaker 1

Think of this as your shortcut. Really, our mission is to pull out the most important insights from these pages. We want to help you understand what makes Mac malware tick and critically, how tools can find it, even the nie stuff.

Speaker 2

Exactly getting to the core knowledge without you having to weighe through every line of code yourself.

Speaker 1

It's about moving beyond just like lists of known threats.

Speaker 2

Right, understanding the fundamental mechanics of detection.

Speaker 1

Okay, let's unpack this. So the first big challenge you hit, maybe the most fundamental one, is the flaw and traditional signature based detection.

Speaker 2

Absolutely scanning for known malicious bites as it's efficient, sure for malware you've already seen.

Speaker 1

But the drawback is huge massive.

Speaker 2

It completely fails against anything new, unique, or even just slightly tweaked.

Speaker 1

And you see this play out perfectly with that fruitfly example from the material. Oh yeah, this thing spied on people for what over a decade, completely undetected.

Speaker 2

Just because no signature existed for it. Yet it was actively using mics and webcams, which.

Speaker 1

Is an incredibly observable behavior, right, even if the code bytes were unknown.

Speaker 2

Exactly behavior.

Speaker 1

So the core idea here, the real shift is understanding that all malware doesn't matter how new or stealthy it is, it has to interact with the system somehow.

Speaker 2

It has to leave a trace. These interactions generate events.

Speaker 1

Things like spawning processes, accessing files.

Speaker 2

Connecting to networks.

Speaker 1

Yeah, all observable, and these behaviors they often reflect the malware's goals right directly.

Speaker 2

Adwaar messes with your browser, a back door opens, a listening port. Anything wanting persistence must modify this system.

Speaker 1

Somehow, writing files, changing settings.

Speaker 2

Precisely, and programmatically detecting those behaviors. That's where the real power in modern detection lies.

Speaker 1

So if behavior is the key, then a logical starting point is looking at what's running right now on the system.

Speaker 2

Makes sense. Most Mac malware tends to run as a standalone.

Speaker 1

Process, So analyzing the info, the metadata about these processes is a great first step, definitely. One simple technique highlighted is just looking for hidden files or directories in the process's path.

Speaker 2

You know, the leading dot trick. Malware loves hiding things that way. What legitimate apps almost never benign system stuff user apps, They just don't hide their main executable path like that. So finding a process running from a dot path, that's a really strong heuristic, a good early flag.

Speaker 1

You can also pull out the run time arguments, like what command line options were used when it launched.

Speaker 2

And these can screen what a process is up to. The calendar two ad example is just perfect right, looked legit, but but when it launched its hidden cryptomnor xmr stack. The arguments literally mentioned monarow and a mining pool address. Hard to miss.

Speaker 1

Yeah, not exactly subtle.

Speaker 2

Even just having unusually long or complex arguments for a simple looking app can be suspicious in itself.

Speaker 1

Okay, what about process hierarchies. The parent child relationship.

Speaker 2

Also crucial helps you trace the chain of execution. How did this thing actually start?

Speaker 1

Because sometimes the malware gets launched by something else.

Speaker 2

Exactly and the source points out some simple ways to get the parent process ID. They often just point back to launched, the main system launcher, which isn't that helpful.

Speaker 1

Sometimes ah okay, But using the.

Speaker 2

More specific Application Services APIs things like get process for PD with process serial numbers. That gives you the true user level of parent.

Speaker 1

So you'd see finder or the dock launching calculator for instance, precisely or spotlight.

Speaker 2

You get the real origin, which is vital context.

Speaker 1

You mentioned launched. Can you get infodirectly from it too? Oh?

Speaker 2

Yeah. Launch keeps a ton of details about running processes. You can programmatically query it and parse out key value pairs looking for suspicious settings or properties.

Speaker 1

And another technique mentioned is programmatically running command line tools like automating what an analyst might do manually.

Speaker 2

Exactly, using something like the NS task API m code, n S task.

Speaker 1

That's Apple's way to run external commands, right.

Speaker 2

So you can automate running say vmap to see what libraries a process is loaded into memory, or LSOLF to list its open files and network connections.

Speaker 1

We saw that trojanized I term example earlier. Vmap could spot that weird library.

Speaker 2

Load absolutely, or LSoft could show you unexpected network sockets opened by a process, very powerful for dynamic analysis.

Speaker 1

The source also mentions getting file descriptors using proppit info.

Speaker 2

Yes, file descriptors are how processes handle files, network sockets pipes. By filtering for the network types like afinet for IPv four or a finet six for IV six.

Speaker 1

You can find open network connections.

Speaker 2

And extract the local and remote IP addresses. The ports basically map out as network activity.

Speaker 1

And you can even figure out the architecture Intel, Apple, Silicon.

Speaker 2

Yeah, programmatically check if it's native or running translated under Rosetta. All this process info builds a really rich picture.

Speaker 1

Okay, so that's looking at live processes. What about analyzing the actual files the executables before they run static analysis? Right?

Speaker 2

Static analysis is inspecting the bleed print the binary file itself without running it. It's different from dynamic analysis where you watch it run.

Speaker 1

And this static look can reveal a lot.

Speaker 2

Definitely. You can see its direct dependencies, the shared libraries it links against, so you.

Speaker 1

Know what system capabilities it intends to use.

Speaker 2

Exactly that trojanized I term against. Statically parsing it show that suspicious link to lib crypto using a relative path inside the app bundle not typical.

Speaker 1

You can also pull out symbols like function names YEP.

Speaker 2

The names of functions and APIs inside the binarya that it calls. These can really give away its purpose.

Speaker 1

So if you see function names related to network sockets or key logging, big.

Speaker 2

Red flag using a tool like MM on malware like DAZZLESFI can show you functions clearly related to its malicious activities. You can even do programmatic introspection to explore properties within the code.

Speaker 1

Static analysis can also spot packers right mm hmm malware trying to hide its code.

Speaker 2

It can sometimes packers leave obvious clues like section names. The IP store malware had that up xdeast section pretty clear giveaway it was packed with UPX.

Speaker 1

But I guess malware authors could just rename that section.

Speaker 2

Oh absolutely, custom packers modified ones, they won't have those obvious names. Name based detection.

Speaker 1

Is brittle, So how else do you detect packing?

Speaker 2

Entropy? Calculation is a good alternative. Packed code is usually compressed.

Speaker 1

Or encrypted, which makes it look more random.

Speaker 2

Exactly, it increases the randomness the entropy. You can measure this programmatically, and if a binaries code section has anomalously high entropy compared to typical piled code, it's a strong sign it might be packed.

Speaker 1

Okay, shifting gear slightly. Code signing, how does that fit in?

Speaker 2

Code signing is absolutely vital on macOS. It helps security tools reduce false positives. If something is properly signed by a trusted developer.

Speaker 1

You're less likely to flag it just because it does something slightly unusual.

Speaker 2

Right, and it confirms the software hasn't been tampered with since it was signed. Apple System's pretty.

Speaker 1

Robust here, but malware authors try to get around it using maybe fake certificates or stolen ones.

Speaker 2

They do ad hoc signing, fraudule inserts, yeah, stolen developer IDs, Yeah, we see it all. But here's a really interesting point from the source. Okay, malware is rarely notorized. Notorization is that extra step where developers submit their app to Apple before distributing it.

Speaker 1

Apple scans it for malware.

Speaker 2

The scan it, so if an app is notorized, it's past that check it's highly likely to be benign. Malware authors generally can't or won't go through that notorization process, so lack.

Speaker 1

Of notorization isn't proof of malice, but having notorization is a strong sign of legitimacy, a.

Speaker 2

Very strong signal yes. And you can check all this programmatically using Apple's built in security frameworks, the secypis so your tool.

Speaker 1

Can automatically check is it signed, is the cert valid? Is it revoked?

Speaker 2

Is it notarized exactly? You can automate what the code design command line tool does detect if something like evil Quest is unsigned or if Creative Update certificate was revoked.

Speaker 1

And you can specifically check if it's signed by Apple itself.

Speaker 2

Yeah, using the anchor Apple requirement string crucial for verifying that core system components haven't been tampered with or replaced.

Speaker 1

All right, So beyond analyzing the code or the process, malware needs to stick around.

Speaker 2

Persistence the fundamental goal for most threats, yeah, surviving a reboot, and to do that it has to modify the system in some detectable way.

Speaker 1

These modifications leave footprints, like.

Speaker 2

What common mechanisms are launch agents and launched demons. These use configuration files plists in specific system folders like.

Speaker 1

That dazzles by example, pretending to be software update exactly.

Speaker 2

Others include browser extensions injecting dynamic libraries dlibs, into legitimate processes adding log in items.

Speaker 1

The source goes into detail on the background Task Management subsystem BTM. That's Apple's internal thing.

Speaker 2

Yeah, it manages certain types of persistent items storing info in a database file. You can dump it manually with cephal tool dumptium, but programmatically.

Speaker 1

You can get fancier right.

Speaker 2

Security tools can actually load the BTM damon's code dynamically, open access its internal functions, read and de serialize that database file directly, and enumerate all the registered items. Find that ones.

Speaker 1

Getting details like the path, the developer.

Speaker 2

Id tmid how it runs. Yeah, and the.

Speaker 1

Knock knock tool is mentioned as doing this comprehensively.

Speaker 2

Knock Knock is a great example. It uses various plugins, checks, BTM, browser extensions, dillib hijacks, log in items, a whole lot more to try and find everything set to run automatically, and.

Speaker 1

It shows you the critical details for each item path, hash's signature status.

Speaker 2

Virus total results. The plist file involves signing status. If flagg windtail is a malicious login item, show dazzle spy as unsigned. Really useful for an analyst or a tool?

Speaker 1

What about bypassing these checks malware tries that too, right, always a.

Speaker 2

Cat and mouse game. One simple bypass mentioned is just running cell tool reset BTM.

Speaker 1

Wipes the BTM database, clean clears.

Speaker 2

The database, stops alerts until the next reboot. But you can detect that specific behavior using Apple's Endpoint Security framework. You monitor for process executions at seven TPU dexic and if you see seven to fel tool running with the reset BTM argument, you can block it. You can deny the execution right there, prevent the bypass clever.

Speaker 1

What about the other bypass sending a stop signal?

Speaker 2

Sending sig stop to the BTM agent process itself just pauses it stops it from reporting.

Speaker 1

And endpoint security can catch that too.

Speaker 2

Yep. Endpoint security has events related to signal delivery. You can monitor for signals targeting critical security processes like the BTM agent and block them.

Speaker 1

So snapshots are good, persistence checks are good, but you really need continuous real time monitoring.

Speaker 2

Absolutely essential to catch things as they happen.

Speaker 1

One source for this is the system log.

Speaker 2

Huge amount of data in the unified log. Now there aren't public APIs for efficiently streaming it in real time, but reverse engineering the log stream command reveals private APIs you could use programmatically okay, and crucially you can apply filters predicates to only get the log messages you care.

Speaker 1

About, like only messages about webcam access.

Speaker 2

It's exactly filter for the core media IO subsystem. Maybe specific strings like cmio extension property device control PID which indicates hardware access, then pull out the process ID, path, et cetera from the log message. Oversight uses this method.

Speaker 1

Network monitoring too, continuously using the network extension framework.

Speaker 2

Right. Network extension is key for host based monitoring because it tells you which process is making the connection. Using APIs like endstat manager Create, you get callbacks with network statistics and connection info.

Speaker 1

But the source really emphasizes DNS monitoring as being particularly effective.

Speaker 2

It is highly effective and efficient. Why because almost any malware calling home to a command and control server needs to.

Speaker 1

Look up the server's domain name first.

Speaker 2

Right, So monitoring DNS requests and responses instantly flags any new process trying to use the network and reveals where it's trying to connect, often to suspicious domains like.

Speaker 1

The iweb updater example, begonning to iweb services cloud dot com.

Speaker 2

Just seeing a request for that known bad domain is a strong indicator, or the three CX.

Speaker 1

Attack that was huge customers notice traffic to MS storage boxes dot com.

Speaker 2

And comparing that domain registered via name cheap with weird whis to the legit THREECX dot cloud domain. That unusual network behavior was the critical.

Speaker 1

First clue and the DNS monitor tool implents.

Speaker 2

This YEP uses network extension to watch DNS traffic cash it potentially block suspicious requests. Need special entitlements, of course, since it's system wide monitoring.

Speaker 1

Okay, you've mentioned it a few times now endpoint security, this seems like a really core piece.

Speaker 2

It's the modern low level framework from Apple for building security tools. It lets you monitor and critically control system.

Speaker 1

Events, stress starts, file access, network events.

Speaker 2

All sorts of things. It requires specific entitlements from Apple on Apple Dot Developer, Dot, Endpoint, dash Security, dot Client, and needs proper packaging even for background tools.

Speaker 1

The slogger tool is mentioned for exploring the events.

Speaker 2

Super useful. Let's you see what's available. It seven type pin notive xx for process execution, notify, create or unlink for file events.

Speaker 1

Lots more, and you mentioned the key difference notify versus OFUTH.

Speaker 2

Events critical distinction notify events notify tell you after something happened, useful for logging ofth events. AUX, however, intercept the action before it happens.

Speaker 1

Giving the security tool a chance to say.

Speaker 2

Yes or no exactly. Your tool receives the authorization request and can respond with EASE RESULTALLO or ESOS results then a real preventative power.

Speaker 1

And the event data is rich process path, arguments.

Speaker 2

Path RGS, essexacarg CPU type, imaging, apotype, full code signing details, id T, id C to hash.

Speaker 1

And on newer mac os you get parent and responsible process info. Two audit tokens.

Speaker 2

Yeah. Audit tokens bundle up the security context, helping you accurately track process lineage right within the event data.

Speaker 1

Hugely valuable, and you can mute noisy events.

Speaker 2

You don't need right control the fire hose. Yeah, but the authodents are where you block things.

Speaker 1

Like we discussed blocking a settle tool reset BTM or SIG stop signals to the BTM agent.

Speaker 2

Using EZEPOPEXAC or the appropriate signal off event.

Speaker 1

You could also protect specific files or folders like my documents.

Speaker 2

Definitely monitor a seven timee puth opin it's fifthempeth in the link for files and sensitive locations if the process trying to access or delete them isn't trusted.

Speaker 1

Deny it stop malware like Windtail from grabbing or deleting your stuff.

Speaker 2

Percisely.

Speaker 1

Block block is the tool example here using endpoint security for real time persistence detection.

Speaker 2

Yes, block block uses endpoint security and some file monitoring specifically to catch persistence attempts in real time. It alerts the user immediately and lets them block the action. Uses a privileged demon for monitoring and a user agent for the UI.

Speaker 1

So it really sounds like you need to put all these techniques together. It's not just one magic bullet.

Speaker 2

Not at all. That's the key takeaway. Sophisticated detection is layered. A tool might spot suspicious network traffic first.

Speaker 1

From the DNS or a network monitor right then.

Speaker 2

It pivots, checks the process, arguments the code signing, looks for persistence attempts. Maybe it does a quick static scan of the binary. It combines the evidence.

Speaker 1

The Dazzle spy case fits that persistence caught by file monitoring. Maybe endpoint security is notified create for the betlist and.

Speaker 2

It's network C and C access caught by network or DNS monitoring looking for that hard coded IP and three CX.

Speaker 1

The initial flag was that we your DNS look up via network monitor.

Speaker 2

Exactly Yeah, mcstorage boxes dot Com. That anomalous behavior was the trigger later data exfiltration to another domain as MSA dot Wiki would also be caught by the same network monitor.

Speaker 1

So wrapping this up, what's the big picture here? From this deep dive, I think it's clear.

Speaker 2

That detecting modern Mac malware isn't just about keeping lists of known bad files anymore. It's part of it, but not the whole game.

Speaker 1

It's really about observing and analyzing the behaviors. What are processes and files actually doing on the system exactly?

Speaker 2

Looking for those footprints malware has to leave how it persists, how it talks on the network, how it uses system resources.

Speaker 1

And understanding how security tools can tap into macOS itself. Using things like endpoint security logging network extensions to watch for these behaviors programmatically, it.

Speaker 2

Gives you much deeper, more resilient security insight. It shows that even clever threats often leave tracks if you know where and how to look.

Speaker 1

So even sophisticated stuff isn't invisible.

Speaker 2

Often not no, which leads to maybe final thoughts that you on Okay, if detection is increasingly focused on behavior, on spotting things that look unusual or interact with the system in sensitive ways, does that mean legitimate, non malicious software that just happens to be poorly written or maybe does something unconventional could end up getting flagged by these same tools. Where does legitimate but weird behavior end and potentially unwanted behavior begin.

Transcript source: Provided by creator in RSS feed: download file
For the best experience, listen in Metacast app for iOS or Android