Latest / CyberCode Academy / Course 42 - Mobile Malware Analysis Fundamentals | Episode 11: Dynamic Analysis for iOS and Android
Transcript
- 0:00Speaker 1: I want you to just imagine for a second that
- 0:02Speaker 1: you're holding your smartphone right now in your hand. Okay, like,
- 0:05Speaker 1: really look at it. It presents itself as this impenetrable fortress. Well. Absolutely,
- 0:10Speaker 1: it's closed off, it's polished. It's this mysterious, sleek, little
- 0:14Speaker 1: black box that you trust with literally everything, your bank accounts,
- 0:18Speaker 1: private conversations, your location.
- 0:21Speaker 2: Yeah, your whole life basically, right.
- 0:23Speaker 1: But the illusion of that black box completely shatters when
- 0:28Speaker 1: you understand how to crack it wide open while an
- 0:30Speaker 1: application is actively running exactly. I mean, we are talking
- 0:33Speaker 1: about changing the text on the screen on the fly,
- 0:36Speaker 1: or intercepting hidden network traffic, or even dissecting a really
- 0:41Speaker 1: sophisticated piece of malicious software that is just desperately trying
- 0:45Speaker 1: to hide inside his memory.
- 0:46Speaker 2: Yeah, because the interface we interact with every single day,
- 0:48Speaker 2: it's just a well, it's a very convincing facade. We
- 0:52Speaker 2: tend to think of downloaded applications as these rigid, unchangeable artifacts,
- 0:57Speaker 2: But to a malware analyst, an app is a living,
- 1:01Speaker 2: breathing environment that have a pulse. It has a pulse,
- 1:04Speaker 2: and if you have the right access, that environment can
- 1:07Speaker 2: be paused. It can be manipulated and interrogated in real time.
- 1:11Speaker 2: You're essentially taking off the blindfold and seeing the actual
- 1:14Speaker 2: matrix of the operating system.
- 1:16Speaker 1: And that transition from looking at static code to manipulating
- 1:20Speaker 1: a living process is exactly what we are dissecting today.
- 1:24Speaker 1: Welcome to our deep dive into the fascinating world of
- 1:27Speaker 1: mobile dynamic analysis, covering both iOS and Android.
- 1:31Speaker 2: It's going to be a fun one, it really is.
- 1:33Speaker 1: Our mission today is to take these advanced cybersecurity techniques
- 1:37Speaker 1: and just walk you through them step by step. So
- 1:39Speaker 1: whether you're an aspiring malware analyst, a cybersecurity student, or
- 1:42Speaker 1: just an insanely curious tech enthusiast, this deep dive will
- 1:46Speaker 1: reveal exactly how professionals manipulate running applications to uncover threats.
- 1:50Speaker 2: Yeah, it's it's like magic once you see how it works.
- 1:53Speaker 1: Totally. Okay, let's unpack this. I think we should start
- 1:55Speaker 1: with iOS, which presents a pretty unique challenge, right because
- 1:59Speaker 1: Apple's ECO system is famously designed to keep you completely
- 2:02Speaker 1: out of the underlying system files.
- 2:04Speaker 2: Oh yeah, walled garden exactly.
- 2:06Speaker 1: So to even begin, an analyst has to force their
- 2:10Speaker 1: way in and literally inject themselves into a running application.
- 2:14Speaker 1: How does that even work?
- 2:16Speaker 2: Well, it requires some clever engineering to bypass those walls,
- 2:19Speaker 2: that's for sure. Let's look at a classic script injection technique. Okay,
- 2:22Speaker 2: and we'll use a harmless target for this, like just
- 2:25Speaker 2: the standard iOS Weather app makes sense. The prerequisite here
- 2:29Speaker 2: is establishing a secure shell connection ashishing into a jailbroken iPhone.
- 2:35Speaker 1: As root read access.
- 2:37Speaker 2: Right, you have to operate with absolute top level privileges.
- 2:41Speaker 2: Otherwise the operating system will simply deny your request to
- 2:44Speaker 2: touch another app's memory. So once you have that rootshell open,
- 2:47Speaker 2: you just launch the weather app normally. So it's running
- 2:50Speaker 2: in the background.
- 2:50Speaker 1: But I mean the operating system doesn't call it the
- 2:52Speaker 1: weather app behind the scenes, right, It uses a number exactly.
- 2:56Speaker 2: Every single process gets a unique process ID or PID.
- 3:00Speaker 2: So from the command line we run a process status
- 3:03Speaker 2: check the lex command and filter the output with GREB
- 3:06Speaker 2: to find our specific target. So let's assume the system
- 3:10Speaker 2: assigns the Weather app the process idea of I don't know,
- 3:12Speaker 2: seven seven sixty.
- 3:13Speaker 1: Four, Okay, seven seven sixty four.
- 3:15Speaker 2: That number is our target. We take a scripting framework.
- 3:18Speaker 2: Syecript is a really heavily relied upon tool for this,
- 3:21Speaker 2: and we point it directly at PID seven seven sixty four.
- 3:24Speaker 1: Wow.
- 3:25Speaker 2: Yeah, We command the framework to attach itself to that
- 3:27Speaker 2: specific process, and in just a fraction of a second,
- 3:31Speaker 2: our script framework is injected into the live running memory
- 3:34Speaker 2: of the weather application.
- 3:35Speaker 1: Okay, wait, let's unpack the mechanics of that injection. When
- 3:38Speaker 1: you say we're injected, what access does that actually grant
- 3:41Speaker 1: us within the architecture of the app.
- 3:43Speaker 2: So the script hooks into the UI application object. Right
- 3:48Speaker 2: in iOS development, UI application is basically the core, the
- 3:51Speaker 2: central nervous system of the app itself. By hooking into
- 3:54Speaker 2: that specific object, we gain the ability to iterate through
- 3:57Speaker 2: everything else running inside that class.
- 3:59Speaker 1: Oh wow wow, Yeah.
- 4:00Speaker 2: We can scour the entire memory region for specific elements
- 4:04Speaker 2: using a memory inspection command known as choose.
- 4:06Speaker 1: The choose command right.
- 4:07Speaker 2: We are essentially asking the live memory to report back
- 4:09Speaker 2: on every single object it is currently holding.
- 4:12Speaker 1: So if we want to manipulate the user interface, we
- 4:15Speaker 1: would use that inspection command to look for the view
- 4:19Speaker 1: controllers exactly.
- 4:20Speaker 2: We ask the memory to choose all instances of uiview
- 4:24Speaker 2: controller and the system will instantly report back with a
- 4:27Speaker 2: handful of views currently loaded in memory. We can navigate
- 4:31Speaker 2: into those views and examine their properties, but to actually
- 4:34Speaker 2: change what the user sees, we drill down further and
- 4:37Speaker 2: search for UI label ah the text YEP, which returns
- 4:41Speaker 2: the underlying memory addresses for all the different text elements
- 4:44Speaker 2: currently rendered on the screen.
- 4:45Speaker 1: Okay, let's trace this out practically. So the weather app
- 4:48Speaker 1: is displaying a list of cities, right, Madrid, Barcelona, West Haven.
- 4:52Speaker 2: Right.
- 4:53Speaker 1: The analyst hunts through the dump labels until they isolate
- 4:56Speaker 1: the exact memory address for the UI label holding the
- 4:59Speaker 1: string Barcelona.
- 5:00Speaker 2: Uh huh.
- 5:02Speaker 1: And once we hold that memory address, we basically controlled
- 5:04Speaker 1: that piece of reality on the screen.
- 5:06Speaker 2: Yeah, it's exactly like that. We map a new variable
- 5:10Speaker 2: in our script to that specific memory address. Because we're
- 5:13Speaker 2: operating from inside the app's own process, we just write
- 5:16Speaker 2: a tiny bit of JavaScript to assign a new string
- 5:19Speaker 2: of text to that variable, like what Well, we change
- 5:22Speaker 2: the text property to let's say Brian's house, and instantly,
- 5:27Speaker 2: without the app crashing or reloading, the city name on
- 5:30Speaker 2: the physical iPhone screen shifts from Barcelona to Brian's house.
- 5:34Speaker 1: That is wild. It's literally like being a ghost in
- 5:37Speaker 1: the machine, you know, rearranging the furniture in a house
- 5:40Speaker 1: while the homeowner is just sitting on the couch entirely oblivious.
- 5:44Speaker 2: It really is. And you can push this way beyond
- 5:46Speaker 2: just modifying existing assets, you can spawn completely new elements.
- 5:50Speaker 1: Wait, really, like from scratch?
- 5:52Speaker 2: Oh yeah, if an analyst wanted to create a rogue
- 5:54Speaker 2: pop up message on the home screen the iOS springboard,
- 5:57Speaker 2: they would just drop the connection to the weather app
- 5:59Speaker 2: and at the springboards process ID instead.
- 6:02Speaker 1: So you just goes directly into the home screens process exactly.
- 6:05Speaker 2: From there, you allocate a completely new message using the
- 6:09Speaker 2: native UI alert few class. It requires standard objective C syntax.
- 6:14Speaker 1: Okay, so you code the alert right.
- 6:16Speaker 2: You initialize the alert, set a custom title like let's
- 6:19Speaker 2: make it hextates degrees, and then you inject a message
- 6:23Speaker 2: body saying something like learning with cyber will change your life.
- 6:27Speaker 1: Love that.
- 6:27Speaker 2: And then you set the delegate parameters to nil since
- 6:30Speaker 2: we aren't handling any complex callbacks, and attach a single
- 6:33Speaker 2: button reading yes, change my life.
- 6:36Speaker 1: And you've constructed this entire native UI element purely through
- 6:40Speaker 1: the terminal just sitting in the memory matrix. Yep.
- 6:42Speaker 2: To execute it, you just call the dot show method
- 6:45Speaker 2: on that object and a native looking alert box forces
- 6:48Speaker 2: its way onto the screen.
- 6:49Speaker 1: I mean, it is a brilliant demonstration of memory manipulation,
- 6:53Speaker 1: but I do have to push back here for a second.
- 6:55Speaker 2: Go for it.
- 6:56Speaker 1: This is great for pranking a weather app, you know,
- 6:59Speaker 1: modifying UI eye labels and throwing pop up boxes. It's
- 7:01Speaker 1: a great parlor trick. But it is entirely surface level.
- 7:06Speaker 2: That's true.
- 7:06Speaker 1: If our goal is to tear apart a sophisticated piece
- 7:09Speaker 1: of spyware or malware, don't we need to see the
- 7:11Speaker 1: actual code. Changing a text label doesn't actually help us
- 7:15Speaker 1: see what data the malware is exfltrating.
- 7:17Speaker 2: Right, You're absolutely right. Surface manipulation only proves we have
- 7:21Speaker 2: the keys to the building right To map out the
- 7:23Speaker 2: actual threat, to inspect the malicious logic as it executes
- 7:26Speaker 2: under the hood, we have to move much deeper into
- 7:29Speaker 2: the memory matrix using a debugger.
- 7:31Speaker 1: Okay, how do we do that?
- 7:33Speaker 2: For Apple environments? That means utilizing LLDB, which provides advanced
- 7:37Speaker 2: low level code instruction. But the immediate hurdle is that
- 7:41Speaker 2: Apple's native development environment xcode is strictly designed to debug
- 7:45Speaker 2: applications that you possess the original source.
- 7:48Speaker 1: Code for Oh so it fights you.
- 7:50Speaker 2: Oh, it actively fights your attempts to attach a debugger
- 7:53Speaker 2: to hostile third party code.
- 7:55Speaker 1: So we have to force the environment to accept foreign code.
- 7:59Speaker 2: Exactly.
- 7:59Speaker 1: If you are analyzing this on a standard, non jail
- 8:02Speaker 1: broken device, you basically have to repackage the malware. You
- 8:06Speaker 1: take open source tools like IPA, patch, rename the target application,
- 8:10Speaker 1: manipulate the build settings, and essentially trick x code into
- 8:13Speaker 1: deploying and debugging the malware as if you wrote it.
- 8:16Speaker 2: Yourself, right, which completely bypasses the need for paying for
- 8:20Speaker 2: an enterprise developer license.
- 8:22Speaker 1: Right. But what if we are using a jail broken device.
- 8:25Speaker 2: If you're utilizing a jailbroken test device, the workflow shifts
- 8:29Speaker 2: to network routing. You deploy a tool called i proxy,
- 8:33Speaker 2: which creates a tunnel between your analysis machine and the
- 8:35Speaker 2: debugging server running on the physical phone.
- 8:37Speaker 1: Okay, tunneling.
- 8:38Speaker 2: Yeah, You establish one proxy for your secure shell connection
- 8:42Speaker 2: and a secondary proxy exclusively for the debugging traffic. Then
- 8:46Speaker 2: you just launch LLEDB locally, configure it for remote iOS debugging,
- 8:50Speaker 2: and attach it to the process.
- 8:52Speaker 1: So now we are tapped directly into the malware's brain.
- 8:54Speaker 1: We are, But this is where we hit one of
- 8:56Speaker 1: the most frustrating security mechanisms in modern computing right ASLR.
- 9:03Speaker 2: YEP address basic layout randomization.
- 9:05Speaker 1: Because the debugger is basically useless if it doesn't know
- 9:07Speaker 1: where to look exactly.
- 9:08Speaker 2: ASLR is a fundamental defense mechanism built into iOS and
- 9:11Speaker 2: virtually all modern operating systems. Its entire purpose is to
- 9:15Speaker 2: prevent attackers or in our case, analysts, from reliably predicting
- 9:20Speaker 2: where specific functions live in memory.
- 9:22Speaker 1: Wait, so ASLR is basically like someone completely rearranging the
- 9:26Speaker 1: layout of the city streets every single time you boot
- 9:29Speaker 1: up the phone, so your old map is completely useless.
- 9:32Speaker 2: That is a perfect analogy. The physical buildings are the same,
- 9:35Speaker 2: but their GPS coordinates are scrambled every time the app launches.
- 9:39Speaker 1: So if I mapped out a malicious encryption function yesterday
- 9:42Speaker 1: at like memory address twelve three four, today, that same
- 9:45Speaker 1: function might be relocated to address nine to eight seven six.
- 9:49Speaker 2: Exactly, your old map is completely useless. But what's fascinating
- 9:53Speaker 2: here is how we actually beat ASLR.
- 9:55Speaker 1: Okay, how because that sounds impossible.
- 9:58Speaker 2: Well, the layout of the city, the relative distance between
- 10:00Speaker 2: the bank and the post office that remains static. The
- 10:03Speaker 2: operating system just moves the entire city to a new
- 10:06Speaker 2: starting coordinate. Our job is to calculate that new starting coordinate,
- 10:10Speaker 2: a metric we call the ASLR shift.
- 10:12Speaker 1: Okay, so walk through the math of translating that randomized coordinate.
- 10:16Speaker 1: How do we find that shift?
- 10:17Speaker 2: So inside the debugger we run the command image dump sections,
- 10:21Speaker 2: which prints out the current randomized memory map of the application.
- 10:25Speaker 2: And we are hunting for two specific architectural addresses, the
- 10:30Speaker 2: location of the text container and the location of the
- 10:33Speaker 2: page zero container.
- 10:34Speaker 1: Let's clarify what those actually represent in the architecture for
- 10:37Speaker 1: a second. The tech container isn't just text, right, It
- 10:40Speaker 1: is the segment of memory where the actual executable machine
- 10:43Speaker 1: code of the app lives correct, and page zero is
- 10:47Speaker 1: this protected, unreadable segment of memory placed at the very
- 10:51Speaker 1: beginning of the application space, specifically designed to catch null
- 10:55Speaker 1: pointer errors.
- 10:56Speaker 2: Spot on. So you isolate the physical memory address where
- 10:59Speaker 2: the text can t was randomly placed today, and you
- 11:02Speaker 2: subtract the baseline address of the page zero container text
- 11:06Speaker 2: minus page zero exactly. That calculation yields the ASLR shift.
- 11:11Speaker 2: It tells you exactly how far the operating system displaced
- 11:14Speaker 2: the application from its theoretical starting point.
- 11:17Speaker 1: Wow, so we have our master.
- 11:18Speaker 2: Key we do. We store that resulting shift value in
- 11:22Speaker 2: our debugger as a variable. Let's just call it delta.
- 11:24Speaker 1: Okay, delta.
- 11:25Speaker 2: Now we can bring in our static analysis map. We
- 11:28Speaker 2: look at a disassembler like Hopper, which analyzes the dead
- 11:32Speaker 2: non running code and maps out the relative distances. Hopper
- 11:36Speaker 2: tells us, hey, the main entry point for this malware
- 11:39Speaker 2: is located at this specific offset.
- 11:41Speaker 1: But Hopper's offset is technically incorrect because it doesn't account
- 11:44Speaker 1: for today's ASLR scramble.
- 11:46Speaker 2: Right, But because we calculated delta, we take the static
- 11:50Speaker 2: offset from Hopper, add our delta variable to it, and boom,
- 11:53Speaker 2: we suddenly possess the exact real time memory address of
- 11:57Speaker 2: that malicious function on the live device.
- 11:59Speaker 1: That is so yeah.
- 12:01Speaker 2: We execute the disassemble command on that newly calculated address,
- 12:04Speaker 2: and the debugger reveals the actual running machine code.
- 12:07Speaker 1: Which means we can finally set our traps. We instruct
- 12:10Speaker 1: the debugger to set a brake point at that exact address,
- 12:13Speaker 1: basically telling it to execute the program normally but freeze
- 12:15Speaker 1: the entire operating system the absolute millisecond the app tries.
- 12:19Speaker 2: To run that function precisely. We monitor the memory for
- 12:22Speaker 2: specific implementation methods. In iOS, seeing objecmsg send is a
- 12:28Speaker 2: massive indicator that a method is firing. The moment the
- 12:30Speaker 2: malware triggers it, we freeze the app and pull apart
- 12:33Speaker 2: the registers to see exactly what data it is trying
- 12:36Speaker 2: to process.
- 12:36Speaker 1: But you know, malware isn't just a static piece of code.
- 12:39Speaker 1: Memory analysis gives you the internal logic. Sure, but it
- 12:43Speaker 1: usually tries to phone home to a commanding control server.
- 12:46Speaker 1: It needs to exfiltrate the data it stole or get
- 12:49Speaker 1: new instructions.
- 12:50Speaker 2: Very true.
- 12:51Speaker 1: So if we have the app frozen under a debugger
- 12:53Speaker 1: and memory, how do we catch it whispering to the internet.
- 12:56Speaker 1: We have to shift from inspecting memory to sniffing the network.
- 12:59Speaker 2: In our yeah, we utilize a packet analyzer, typically tcpdump,
- 13:04Speaker 2: running directly on the jail broken device. We target the
- 13:08Speaker 2: iPhone's primary networking adapter, which is usually designated as N zero.
- 13:13Speaker 2: But standard network adapters are designed to be efficient. They
- 13:16Speaker 2: ignore background traffic that isn't specifically requested by the active foreground.
- 13:20Speaker 1: Process right to say, battery and processing.
- 13:23Speaker 2: Power exactly, So we have to override that behavior by
- 13:26Speaker 2: forcing the hardware interface into promiscuous mode.
- 13:29Speaker 1: Promiscuous mode stripped away all those hardware filters. It forces
- 13:33Speaker 1: the network card to blindly capture absolutely every packet moving
- 13:36Speaker 1: across the interface, regardless of its destination.
- 13:39Speaker 2: Yes, the command is tcpdump AI N zero in zero
- 13:43Speaker 2: TNPML dot p CAP. We piped that raw data stream
- 13:47Speaker 2: into a temporary capture file a PCA.
- 13:49Speaker 1: Well. Wait, the phone is constantly talking to Apple servers,
- 13:52Speaker 1: fetching background updates, pulling for emails. It's a massive haystack
- 13:56Speaker 1: of noise.
- 13:56Speaker 2: It is, which is why you filter the noise at
- 13:58Speaker 2: the command line using gp IF. Our earlier static analysis
- 14:01Speaker 2: revealed the malware contains a suspicious URL string. Like hexscapes,
- 14:07Speaker 2: you pipe the TCP dump output through a search filter
- 14:10Speaker 2: so it only writes packets containing that specific domain to
- 14:13Speaker 2: your file. O nice, you trigger the malware, it attempts
- 14:15Speaker 2: its cal out, and the packet analyzer quietly records the
- 14:18Speaker 2: entire conversation into the pcipp file, and then.
- 14:21Speaker 1: We take that resulting PCCAP file off the iPhone entirely right,
- 14:25Speaker 1: because reading raw hexadecimal network packets and a command line
- 14:28Speaker 1: terminal on a tiny screen is an exercise in mission, We.
- 14:31Speaker 2: Oh, absolute misery.
- 14:32Speaker 1: Don't do that, So we move the file over to
- 14:35Speaker 1: a dedicated analysis machine like a Kali Linux workstation and
- 14:39Speaker 1: open it in a visual tool like wire shark.
- 14:41Speaker 2: Exactly. Wire shark rebuilds the fragmented packets into a coherent conversation.
- 14:46Speaker 2: You can visually track the HTTP get requests, see the
- 14:50Speaker 2: exact payload the malware attempted to transmit, and analyze the
- 14:54Speaker 2: command server's response.
- 14:56Speaker 1: It completes the picture. You have the memory logic from
- 14:58Speaker 1: the debugger and the external communication from the packet capture.
- 15:01Speaker 1: So what does this all mean? Look at the sheer
- 15:03Speaker 1: amount of friction required to get those answers on iOS.
- 15:07Speaker 1: We're sessation into jailbroken devices, calculating memory offsets to beat
- 15:12Speaker 1: ASLR tunnel, and debug traffic through proxies. It is a
- 15:16Speaker 1: walled garden that we constantly have to scale.
- 15:18Speaker 2: It's exhausting sometimes.
- 15:19Speaker 1: Right. What happens when we analyze malware on a platform
- 15:22Speaker 1: that is notoriously open, making it a massive target for hackers.
- 15:26Speaker 1: Let's pivot to Android.
- 15:27Speaker 2: Let's do it.
- 15:28Speaker 1: Android is fundamentally built on a Linux kernel. It is
- 15:30Speaker 1: intrinsically open. If you have the right privileges, which completely
- 15:33Speaker 1: alters how we approach dynamic analysis.
- 15:35Speaker 2: Oh, it's night and day. The open architecture of Android
- 15:38Speaker 2: provides a massive ecosystem of specialized analysis tools. Because the
- 15:43Speaker 2: environment isn't actively fighting your attempts to inspect it, the
- 15:47Speaker 2: initial approach actually relies heavily on automation.
- 15:50Speaker 1: So the first instinct is to take the malicious Android
- 15:53Speaker 1: application package, the APK, and submit it to an online
- 15:57Speaker 1: malware sandbox, right like hybrid analysis exactly.
- 16:02Speaker 2: These cloud based sandboxes are incredibly robust. They spin up
- 16:06Speaker 2: the application inside their own instrumented virtual environments, interact with it,
- 16:10Speaker 2: and generate highly detailed reports of its behavior.
- 16:13Speaker 1: Because Android's architecture is so thoroughly documented, a single automated
- 16:17Speaker 1: run often highlights all the malicious activities.
- 16:20Speaker 2: Often, yeah, that alone accomplishes a lot of your analysis goals.
- 16:23Speaker 1: But hold on. Let's say you're an incident responder for
- 16:26Speaker 1: a Fortune five hundred company and you extract a highly targeted,
- 16:29Speaker 1: bespoke piece of espionage malware from an executive's device. If
- 16:34Speaker 1: I upload that highly sensitive corporate ABK to a public
- 16:37Speaker 1: website like Hybrid analysis, didn't I just expose my company's
- 16:40Speaker 1: breach to the entire Internet. The attackers immediately know I
- 16:44Speaker 1: found their tool.
- 16:45Speaker 2: This raises an important question and the answer is yes.
- 16:48Speaker 2: Public sandboxes are a catastrophic breach of operational security for
- 16:52Speaker 2: sensitive analysis. Everything you upload is generally available for public
- 16:56Speaker 2: consumption or shared with threat intelligence.
- 16:59Speaker 1: Platforms, so we can't use them for sensitive stuff.
- 17:01Speaker 2: No, the solution is migrating that automated sandbox locally.
- 17:06Speaker 1: Okay, Hell, we.
- 17:07Speaker 2: Use something like the Mobile Security Framework or MOBSEF. It
- 17:11Speaker 2: runs locally on your host hardware. It takes maybe ten
- 17:14Speaker 2: minutes to set up, runs on Windows, Mac or Linux,
- 17:18Speaker 2: and keeps the malware entirely contained within your own perimeter. Now,
- 17:22Speaker 2: to utilize the virtual dynamic features, MOBSEF needs direct access
- 17:26Speaker 2: to the host hardware virtualization. It struggles to emulate an
- 17:30Speaker 2: Android environment if you nest it inside another virtual machine.
- 17:33Speaker 1: Oh, that makes sense.
- 17:34Speaker 2: But once deployed, you upload the APTA to your local
- 17:36Speaker 2: dashboard and it performs an exhaustive extraction immediately. It maps
- 17:41Speaker 2: out every activity The app can trigger flags risky permissions
- 17:44Speaker 2: like a simple calculator requesting full Internet access and extracts
- 17:47Speaker 2: embedded URLs, emails and hidden text strings.
- 17:51Speaker 1: So mob ASF provides a brilliant automated blueprint, but it
- 17:54Speaker 1: is still a static report. In a way to truly
- 17:58Speaker 1: watch the malware squirm to see how how it reacts
- 18:00Speaker 1: to input or how it attempts to evade detection in
- 18:03Speaker 1: real time, we had to put it in a glass
- 18:05Speaker 1: box and poke it ourselves. We need an emulator.
- 18:08Speaker 2: We do. We build an Android Virtual Device and AVD
- 18:12Speaker 2: and the most effective way to construct it is by
- 18:14Speaker 2: leveraging Google's official developer environment androids studio. You get granular
- 18:18Speaker 2: command line control over the hardware and software configuration of
- 18:22Speaker 2: the virtual phone.
- 18:23Speaker 1: And the configuration is critical because we aren't building a
- 18:26Speaker 1: phone for daily use. We are building a trap. Right,
- 18:29Speaker 1: So on setting up the emulator, we walk through Android
- 18:32Speaker 1: Studios AVD Manager, and the absolute goal and rule here
- 18:36Speaker 1: is avoiding any system image that includes the Google Play APIs. Right,
- 18:40Speaker 1: we have to pick the standard open source Android project images.
- 18:43Speaker 2: Yes, this is crucial. System images bundled with Google Play
- 18:47Speaker 2: APIs and for strict production level security policies, they lock
- 18:51Speaker 2: down the environment completely, preventing you from gaining root access.
- 18:54Speaker 1: And without root you're just a standard.
- 18:55Speaker 2: User exactly, and you cannot inspect the underlying system processes.
- 19:00Speaker 2: You must maintain absolute administrative control root access over the
- 19:04Speaker 2: emulator to analyze the malware effectively.
- 19:06Speaker 1: You also configure the glass box with an older version
- 19:08Speaker 1: of the Android operating system, don't you, Yes, because if
- 19:11Speaker 1: you deploy complex malware onto the newest, most heavily patched
- 19:15Speaker 1: version of Android, the exploit might simply fail. The malware
- 19:19Speaker 1: crashes and you learn absolutely nothing about its attack chain.
- 19:23Speaker 2: Right, So we pick an older OS version and a
- 19:26Speaker 2: basic device like a pixel three within a by eighty
- 19:28Speaker 2: six image. By deploying it on an older, vulnerable architecture,
- 19:33Speaker 2: you allow the malware to succeed in its exploitation, giving
- 19:36Speaker 2: you a front row seat to observe its entire payload delivery.
- 19:39Speaker 1: And obviously, you isolate this vulnerable virtual device on a
- 19:42Speaker 1: host only network, routing all of its traffic through analysis
- 19:46Speaker 1: tools like IETSIM or remnuts, ensuring the malware cannot bridge
- 19:50Speaker 1: the connection and infect your actual lab environment naturally.
- 19:53Speaker 2: Oh and pro tip, if rendering the virtual screen is
- 19:56Speaker 2: consuming too much processing power, you execute the emulator in
- 19:59Speaker 2: headless mode. It runs purely in the background to maximize
- 20:02Speaker 2: hardware efficiency.
- 20:03Speaker 1: Love that Okay? So with the virtual device booted and
- 20:07Speaker 1: root access secured, we interface with it using the command
- 20:10Speaker 1: line via the Android debug Bridge or ADB.
- 20:13Speaker 2: YEP, ADB is your best friend here.
- 20:15Speaker 1: Now, if we are trying to do this on a
- 20:16Speaker 1: physical Android phone, we'd have to navigate through the UI,
- 20:19Speaker 1: go to settings, tap the build number like a crazy
- 20:22Speaker 1: person four three two one to become a developer, and
- 20:26Speaker 1: manually authorize USB debugging. The emulator bypasses all of that friction.
- 20:32Speaker 2: It does. ADB provides a direct privileged pipeline to the device.
- 20:36Speaker 2: You type ad devices to verify the connection, and then
- 20:39Speaker 2: command ab root to restart as route, ensuring every subsequent
- 20:42Speaker 2: command executes with top level system authority.
- 20:45Speaker 1: Here's where it gets really interesting. Instead of typing out
- 20:48Speaker 1: complex installation parameters, we use the debug bridge to seamlessly
- 20:52Speaker 1: sideload our analysis tools like the droser agent, directly onto
- 20:55Speaker 1: the device using ad install. Then we instruct ADB to
- 20:58Speaker 1: drop us into the system shell with ad cabshell, and
- 21:01Speaker 1: the command prompt shifts to a pound sign. We are
- 21:04Speaker 1: no longer interacting with Android. We are standing directly in
- 21:07Speaker 1: the underlying Linux operating system. We have god mode over
- 21:10Speaker 1: the device, allowing us to manually pull apart the Android
- 21:14Speaker 1: malware just as deeply as we did with the iOS
- 21:17Speaker 1: memory offsets earlier.
- 21:19Speaker 2: It highlights the fundamental difference between the two platforms perfectly.
- 21:22Speaker 2: iOS forces you to calculate offsets, inject scripts, and essentially
- 21:27Speaker 2: pick the lock just to sneak a look inside. Android
- 21:30Speaker 2: hands you the architectural blueprints and the tools to build
- 21:33Speaker 2: a custom interrogation environment, provided you understand the underlying Linux foundation.
- 21:37Speaker 1: Both platforms, though, require a pretty deep understanding of how
- 21:40Speaker 1: the operating system handles memory and processes. Absolutely, it's a
- 21:44Speaker 1: profound shift in perspective. We started this deep dive by
- 21:47Speaker 1: injecting JavaScript into a live iOS weather app to overwrite
- 21:51Speaker 1: its user interface on the.
- 21:52Speaker 2: Fly Brian's house right.
- 21:55Speaker 1: Then we explored the architecture of address space layout randomization,
- 21:59Speaker 1: calculating the exact asl R shift between the physical executable
- 22:03Speaker 1: code and its base padding so our debugger could locate
- 22:06Speaker 1: functions hidden in scrambled memory. We forced network hardware into
- 22:10Speaker 1: promiscuous mode to capture raw exfiltration attempts well on a
- 22:13Speaker 1: groundcovered and finally we explored why analyzing Android requires abandoning
- 22:18Speaker 1: public cloud tools to build localized root level virtual emulators
- 22:23Speaker 1: that allow malware to execute its full attack chain under observation.
- 22:26Speaker 2: These aren't just technical procedures, you know. They are the
- 22:29Speaker 2: foundational methodologies for forcing malicious code to reveal its true
- 22:33Speaker 2: nature when it believes it's operating in the shadows.
- 22:36Speaker 1: It really all comes back to how you build that
- 22:38Speaker 1: environment before we go test yourself. If you're setting up
- 22:42Speaker 1: an Android virtual device for malware analysis, why must you
- 22:45Speaker 1: specifically avoid using images with Google Play APIs to ensure.
- 22:49Speaker 2: You maintain root access. If you prioritize the convenience of
- 22:52Speaker 2: a production ready environment, you sacrifice the administrative root access
- 22:56Speaker 2: required to actually see what the malur is doing.
- 22:58Speaker 1: You have to intentionally build a vulnerable open system to
- 23:03Speaker 1: understand the threat.
- 23:04Speaker 2: But, and this is a big butt, the threat landscape
- 23:07Speaker 2: is evolving rapidly. Malware authors are acutely aware of these
- 23:11Speaker 2: dynamic analysis techniques. Modern payloads are increasingly equipped with environmental
- 23:16Speaker 2: awareness right They check CPU temperatures, screen resolutions, and specific
- 23:21Speaker 2: memory registers to detect if they are running inside a
- 23:24Speaker 2: virtual device or if a debugger is attached. If they
- 23:27Speaker 2: sense the glass box we built today, they simply refuse
- 23:30Speaker 2: to execute. They played dead.
- 23:32Speaker 1: Wow, which means the interrogation room we built today might
- 23:35Speaker 1: not work tomorrow. Nope. As malware becomes fully aware of
- 23:38Speaker 1: the operating system that lives in, security researchers will have
- 23:41Speaker 1: to move even deeper. We may have to stop relying
- 23:44Speaker 1: on software level debuggers and start building analysis capabilities directly
- 23:48Speaker 1: into the physical silicon of the processors themselves. How will
- 23:51Speaker 1: the next generation of mobile operating systems have to evolve
- 23:54Speaker 1: to stay one step ahead of code we can't even see.
- 23:57Speaker 1: It makes you look at that Slenk black box in
- 23:59Speaker 1: your handle differently, doesn't it?
- 24:01Speaker 2: It really does. It isn't just a phone, It's an active,
- 24:04Speaker 2: evolving battlefield.
- 24:06Speaker 1: Well said. Thank you so much for joining us on
- 24:08Speaker 1: this deep dive. Keep asking questions, keep dismantling the technology
- 24:12Speaker 1: around you, and we will catch you next time.