Latest / CyberCode Academy / Course 42 - Mobile Malware Analysis Fundamentals | Episode 12: Dynamic Analysis Tools, Techniques, and Assessment
Transcript
- 0:00Speaker 1: So imagine just for a second that you have this
- 0:03Speaker 1: highly suspect application sitting right there on your device.
- 0:06Speaker 2: Oh that's never a good feeling.
- 0:08Speaker 1: Right, And you've already put in the grueling hours. You
- 0:11Speaker 1: pulled apart its code, extracted the APK, you know, sifted
- 0:15Speaker 1: through all those hard coded strings.
- 0:17Speaker 2: Yeah, you mapped out the whole static architecture exactly.
- 0:20Speaker 1: But here is the inherent limitation of static analysis, right.
- 0:24Speaker 1: Reading the code only really tells you what that application
- 0:29Speaker 1: has the potential to do.
- 0:31Speaker 2: It's basically just a theoretical threat model at that point.
- 0:34Speaker 1: Yeah, exactly, the code is just sitting there dormant. What
- 0:37Speaker 1: you really need is to see what that code actually
- 0:39Speaker 1: executes when it wakes up, allocates memory, and well comes
- 0:43Speaker 1: alive in a real environment.
- 0:45Speaker 2: Because a static binary is basically, I mean, it's just
- 0:47Speaker 2: a dormant blueprint until the operating system actually breathes life
- 0:51Speaker 2: into it.
- 0:51Speaker 1: Right.
- 0:52Speaker 2: You can study a recipe all day long, but you
- 0:54Speaker 2: don't really know how the ingredients will interact, or you know,
- 0:58Speaker 2: if the baker secretly swapped sugar for salt until you
- 1:00Speaker 2: actually bake the cake.
- 1:02Speaker 1: That's a great way to put it.
- 1:03Speaker 2: Yeah, when an app runs it interacts with the system state,
- 1:06Speaker 2: it pulls down dynamic configurations from remote servers, and it
- 1:10Speaker 2: might even decrypt hidden payloads in memory that were just
- 1:13Speaker 2: completely invisible during your static review.
- 1:16Speaker 1: Which brings us to the mission for today. Welcome to
- 1:18Speaker 1: this deep dive into dynamic analysis for mobile security. Today,
- 1:23Speaker 1: we want to give you a front row seat to
- 1:24Speaker 1: the live execution of an app.
- 1:26Speaker 2: Specifically, we're going deep into the Android ecosystem today.
- 1:29Speaker 1: They are We're going to map out exactly how to
- 1:31Speaker 1: systematically poke, prod, manipulate, and monitor a running application as
- 1:38Speaker 1: if you're sitting right there inside the os with it.
- 1:40Speaker 2: It is honestly a non negotiable skill for modern security research.
- 1:44Speaker 2: I mean static and dynamic analysis. They're really just two
- 1:47Speaker 2: sides of the same analytical coin. Yeah, your static analysis
- 1:50Speaker 2: forms your initial hypothesis. Right. You read the code and
- 1:53Speaker 2: you think, hmm, I suspect this function leaks user data,
- 1:57Speaker 2: and then you run the app dynamically to actually prove it.
- 2:00Speaker 1: The workflow could flip entirely.
- 2:02Speaker 2: Oh absolutely, You run the app, you observe this like
- 2:05Speaker 2: suspicious network beacon reaching out to a command server, and
- 2:09Speaker 2: then you pivot back to your static tools to hunt
- 2:11Speaker 2: down the exact cryptographic function that generated it.
- 2:14Speaker 1: I always conceptualize static analysis as you know, sitting at
- 2:18Speaker 1: a desk methodically reading a car's engineering schematic, like you
- 2:23Speaker 1: know where the engine block is, you see how the
- 2:25Speaker 1: fuel lines are routed. But dynamic analysis that is jumping
- 2:30Speaker 1: into the driver's seat, flooring the gas pedal and basically
- 2:34Speaker 1: seeing if the wheels actually stay on the chassis.
- 2:36Speaker 2: That captures the exact mindset perfectly. You're stress testing the environment.
- 2:40Speaker 2: You want to force the app down execution paths It
- 2:43Speaker 2: maybe wasn't intended to go down or paths.
- 2:46Speaker 1: The malware author really hoped you wouldn't find right.
- 2:49Speaker 2: But to achieve that level of manipulation on Android, you
- 2:52Speaker 2: can't just tap the screen with your finger. You need
- 2:54Speaker 2: a dedicated framework that hooks directly into the operating system's
- 2:58Speaker 2: internal communication channels.
- 3:00Speaker 1: Which introduces the corner zone of our toolkit today, which
- 3:02Speaker 1: is droser.
- 3:03Speaker 2: Yeah Drozer developed by MWR Labs. It is arguably the
- 3:07Speaker 2: premiere framework for Android dynamic security testing.
- 3:10Speaker 1: And why is it so ubiquitous.
- 3:13Speaker 2: The reason researchers rely on it so heavily is because
- 3:16Speaker 2: it operates as an interactive bridge. It doesn't just passively
- 3:19Speaker 2: monitor stuff. It allows you to actively forge and inject
- 3:23Speaker 2: Android interprocess communication messages or IPCs on the fly.
- 3:28Speaker 1: Oh wow, Yeah, so.
- 3:29Speaker 2: You can directly command and applications internal components to execute,
- 3:33Speaker 2: just completely bypassing the normal user interface.
- 3:36Speaker 1: Okay, let me stop you right there though, and kind
- 3:38Speaker 1: of challenge that concept because if we think about Android's
- 3:42Speaker 1: core security model, it is entirely built around this concept
- 3:45Speaker 1: of application sandboxing. Right now, absolutely every app gets its
- 3:49Speaker 1: own unique user ID, runs in its own virtual machine,
- 3:52Speaker 1: and it's explicitly forbidden from touching the memory of another app.
- 3:55Speaker 2: That's the design.
- 3:56Speaker 1: So if Android is locking everything down by default, how
- 3:59Speaker 1: does this rozer legally reach across that sandbox boundary to
- 4:03Speaker 1: manipulate our target app?
- 4:05Speaker 3: Like?
- 4:05Speaker 1: Are we essentially exploiting a vulnerability in our own embulator
- 4:08Speaker 1: just to get a foothold.
- 4:10Speaker 2: That is a phenomenal question, and it really gets to
- 4:13Speaker 2: the heart of how Android actually functions under the hood. Okay, no,
- 4:16Speaker 2: we aren't burning a zero day exploit to break the sandbox.
- 4:20Speaker 2: We're actually turning Android's own architectural design against itself.
- 4:24Speaker 1: Wait, really, how well?
- 4:25Speaker 2: Android applications aren't monolithic blocks of code. They are highly
- 4:29Speaker 2: fragmented collections of loosely coupled component.
- 4:32Speaker 1: Right activity services all that exactly.
- 4:35Speaker 2: And to make these components talk to each other, Android
- 4:38Speaker 2: uses a message passing system called Binder. Drozer just operates
- 4:42Speaker 2: on a client server architecture to exploit this exact system.
- 4:46Speaker 1: Okay, so break that client server architecture down for us.
- 4:49Speaker 1: What actually sits where in this setup?
- 4:51Speaker 2: So you have a server component running on your specialized
- 4:54Speaker 2: analysis machine. A common setup is running a Santoku Linux
- 4:59Speaker 2: virtual machine.
- 5:00Speaker 1: Which comes preloaded with all those mobile forensics tools exactly.
- 5:03Speaker 2: That's your command center. Then you deploy the Drozer agent,
- 5:06Speaker 2: which is really just a standard Android APK, directly onto
- 5:09Speaker 2: your target emulator or your physical test phone.
- 5:12Speaker 1: Ah. So the Drozer agent installs itself just like any
- 5:15Speaker 1: normal app, so it gets its own sandbox precisely.
- 5:19Speaker 2: It plays by the rules. But once the Droser agent
- 5:21Speaker 2: is inside the system, it acts as a translation layer. Okay,
- 5:25Speaker 2: when you type a command on your santokre VM, it
- 5:28Speaker 2: sends that command over the network to the Drozer agent
- 5:31Speaker 2: on the phone. The agent then crafts a perfectly formatted,
- 5:34Speaker 2: legitimate Android IPC message and basically hands it to the
- 5:39Speaker 2: OS asking it to deliver it to the target app.
- 5:42Speaker 1: That's incredibly clever. We're literally just using the built in
- 5:45Speaker 1: development and debugging pathways it Android inherently provides. Exactly So,
- 5:49Speaker 1: since we know the suspect app is sitting there hiding
- 5:51Speaker 1: its true behavior, we need this framework to force it
- 5:54Speaker 1: to react. Let's walk through the actual mechanics of wiring
- 5:58Speaker 1: this connection up for you listening at home. Yeah, let's
- 6:00Speaker 1: visualize that you're sitting at your terminal, you have your
- 6:02Speaker 1: son TOOKUVM spun up, and your Android emulator is running.
- 6:05Speaker 1: What's step one?
- 6:07Speaker 2: The very first step is to wake up that listening
- 6:09Speaker 2: post on the device. So you open the droser agent
- 6:12Speaker 2: app on your emulator and just toggle the embedded server
- 6:15Speaker 2: to on.
- 6:15Speaker 1: Simple enough.
- 6:16Speaker 2: Yeah, And when you do that, the agent opens a
- 6:19Speaker 2: very specific network port to listen for incoming demands from
- 6:23Speaker 2: your computer. That port is three one four one five.
- 6:26Speaker 1: Three one four one five, so the first five digits
- 6:29Speaker 1: of pie. Yeah, nice little easter egg from the developers.
- 6:31Speaker 2: There it is. But here's the networking hurdle you run
- 6:34Speaker 2: into Your host computers operating system cannot natively route traffic
- 6:39Speaker 2: directly into the isolated virtual network stack of the Android emulator.
- 6:43Speaker 1: Because it's walled off.
- 6:44Speaker 2: Right, the emulator is essentially running behind its own internal
- 6:47Speaker 2: GNAT router. So if you just try to send a
- 6:49Speaker 2: packet to port three one four four five on your
- 6:52Speaker 2: local machine, it'll just drop.
- 6:53Speaker 1: We need to build a tunnel, exactly.
- 6:55Speaker 2: We need a tunnel through that virtual router.
- 6:57Speaker 1: And this is where the Android debug Bridge or ADB
- 7:00Speaker 1: steps in. ADB is essentially the wormhole between your host
- 7:04Speaker 1: machine and the emulator's isolated environment.
- 7:07Speaker 2: That's exactly what it is. You drop into your host
- 7:09Speaker 2: terminal and you execute the command add forward at three
- 7:13Speaker 2: one four one five TCP tot three one four one five.
- 7:16Speaker 1: Let's dissect the syntax of that command for absolute clarity.
- 7:19Speaker 2: Sure, So, the adpay forward directive tells the ADB demon
- 7:22Speaker 2: to create a socket connection by specifying TCP point three
- 7:26Speaker 2: one four one five as the first argument. You're opening
- 7:30Speaker 2: port three one four one five on your local computer's
- 7:32Speaker 2: loop back interface at it. Then the second TCP point
- 7:36Speaker 2: three one four one five tells ADB to take any
- 7:38Speaker 2: traffic it receives on that local port, shove it through
- 7:41Speaker 2: the USB or virtual connection, and spit it out on
- 7:43Speaker 2: port three, one, four, one five inside the emulator's network stack.
- 7:47Speaker 1: Now, technically, depending on your shell environment, I know you
- 7:50Speaker 1: can sometimes omit the TCP protocol declaration.
- 7:52Speaker 2: You can't, Yeah, but explicitly stating it is an industry
- 7:56Speaker 2: best practice. It just prevents weird protocol mismatch errors down
- 7:59Speaker 2: the lad.
- 8:00Speaker 1: Okay, so the wormhole is established, our host machine and
- 8:03Speaker 1: the Drozer agent are now successfully shaking hands. What's next
- 8:07Speaker 1: from there?
- 8:07Speaker 2: The final step is incredibly simple. In your terminal, you
- 8:10Speaker 2: just type Drozer console connect.
- 8:12Speaker 1: That's it.
- 8:13Speaker 2: That's it. The framework leverages the ADB tunnel we just built.
- 8:16Speaker 2: The moment you hit enter, your terminal prompt will actually
- 8:19Speaker 2: change to DZ. That visual queue indicates your secure communications
- 8:23Speaker 2: channel is locked in. You're now interactively driving the Android
- 8:27Speaker 2: OS from your command line.
- 8:28Speaker 1: We are officially in the system, but I mean, an
- 8:31Speaker 1: empty emulator isn't giving up any secrets. We need to
- 8:34Speaker 1: put our suspect application onto the chopping block, right.
- 8:37Speaker 2: And the standard deployment method is using ADB again. Okay,
- 8:41Speaker 2: you use the command ab install, followed by the filepaths
- 8:45Speaker 2: to your application package. So for example, my app dot
- 8:48Speaker 2: app k ADB pushes the binary across the tunnel and
- 8:52Speaker 2: basically instructs the Android package manager to install it.
- 8:55Speaker 1: Now. Once the app is installed, we run into this
- 8:58Speaker 1: classic Android quirk that constantly trips up analysts transitioning from
- 9:02Speaker 1: desktop environment.
- 9:03Speaker 2: Even the naming thing.
- 9:04Speaker 1: Yes, the name you see on the emulator's home screen,
- 9:07Speaker 1: like the user friendly display name say Flashlight pro or whatever,
- 9:11Speaker 1: is entirely irrelevant to the operating system.
- 9:13Speaker 2: Yeah, the display name is purely cosmetic. The Android system
- 9:16Speaker 2: relies exclusively on the application's package name, which is structurally
- 9:19Speaker 2: formatted like a reverse domain.
- 9:21Speaker 1: Name, right like calmdot malicious dot flashlight exactly.
- 9:24Speaker 2: And you cannot guess this internal system name based on
- 9:27Speaker 2: the shiny icon on the screen.
- 9:29Speaker 1: So if the display name is just a facade, how
- 9:31Speaker 1: do we systematically hunt down the exact package name of
- 9:34Speaker 1: the target we just installed.
- 9:36Speaker 2: Well, Droser handles this beautifully at your DZ prompt. You
- 9:39Speaker 2: just execute run app dot package dot list.
- 9:43Speaker 1: Okay.
- 9:43Speaker 2: This command queries the Android package manager and dumps a
- 9:46Speaker 2: comprehensive list of every single package currently installed and recognized
- 9:51Speaker 2: by the system. You just parse that output until you
- 9:54Speaker 2: identify the reverse domain name that correlates to your target.
- 9:57Speaker 1: APK All right, so we have successful identified our target package.
- 10:01Speaker 1: The cross hairs are locked. What is our first real
- 10:04Speaker 1: intelligence gathering move here?
- 10:05Speaker 2: We want to pull down the application's entire profile. As
- 10:08Speaker 2: the system understands, it makes sense, so you use the
- 10:10Speaker 2: command run app not package dot info A, followed by
- 10:14Speaker 2: your targets package name. A switch is critical here. It
- 10:17Speaker 2: stands for all and what did that give us? It
- 10:20Speaker 2: forces droser to return a massive verbose dump of data.
- 10:24Speaker 2: It includes the app's active permissions, it's assigned Linux user ID, data,
- 10:29Speaker 2: directory paths, and most importantly, the contents of its Android manifest.
- 10:34Speaker 1: Okay, I'm going to push back on this step for
- 10:35Speaker 1: a moment because if we're following a standard security methodology,
- 10:39Speaker 1: we've already performed static analysis, right, sure, So that means
- 10:42Speaker 1: we've already run tools, unpacked the binary and read the
- 10:45Speaker 1: android manifest dot xml file. Yeah, why are we burning
- 10:49Speaker 1: time pulling the manifest again while the app is live
- 10:52Speaker 1: in memory? Isn't that redundant?
- 10:54Speaker 2: It definitely feels redundant until you understand how the runtime
- 10:58Speaker 2: environments actually process that file.
- 11:00Speaker 1: Okay, walk me through that.
- 11:01Speaker 2: During static analysis, the manifest you extract is a compiled,
- 11:04Speaker 2: compressed binary XML file. You have to rely on third
- 11:08Speaker 2: party reverse engineering tools to decompile and reconstruct.
- 11:11Speaker 1: It, and those aren't perfect exactly.
- 11:14Speaker 2: Sometimes those tools fail, or the malware author intentionally corrupts
- 11:17Speaker 2: the binary XML headers specifically to break your decompilers.
- 11:21Speaker 1: Ah, I see where this is going. The operating system
- 11:25Speaker 1: have to know how to read it to execute the app,
- 11:28Speaker 1: regardless of what tricks the author played.
- 11:30Speaker 2: That is the crucial AHA moment right there. When you
- 11:32Speaker 2: query the package info live through drozer, you're bypassing the
- 11:36Speaker 2: entire decompilation struggle. Wow, You're asking the Android OS to
- 11:41Speaker 2: hand you the fully instantiated, decoded manifest directly from memory.
- 11:46Speaker 2: It's the absolute ground truth of what the application is
- 11:49Speaker 2: actively claiming at run time.
- 11:51Speaker 1: So you see the exact permissions it currently.
- 11:53Speaker 2: Holds YEP, the specific shared libraries it has loaded into memory,
- 11:56Speaker 2: the network rules it's enforcing. You are analyzing the apps reality,
- 12:00Speaker 2: not just its static blueprint.
- 12:02Speaker 1: That distinction between the static blueprint and the runtime reality
- 12:05Speaker 1: is massive. It means we have successfully mapped the perimeter
- 12:09Speaker 1: with verified intel. Yes, we know exactly where the app
- 12:11Speaker 1: lives and what privileges it holds. So now it's time
- 12:14Speaker 1: to map out the attack surface.
- 12:16Speaker 2: Right, and to make this incredibly concrete for everyone listening,
- 12:19Speaker 2: let's pivot to a real world, highly complex target like
- 12:23Speaker 2: Google Chrome.
- 12:24Speaker 1: Okay, its system package name is Colm dot Android dot Chrome.
- 12:28Speaker 2: Correct. Our objective is to identify every single exposed entry
- 12:31Speaker 2: point where an external entity like our droser console or
- 12:35Speaker 2: maybe a piece of malware residing on the same device,
- 12:38Speaker 2: can force Chrome to interact.
- 12:40Speaker 1: To use a physical analogy, we aren't just looking at
- 12:42Speaker 1: the front door of a secure building. We're walking the
- 12:45Speaker 1: entire perimeter, you know, cataloging every loading dock, every side window,
- 12:50Speaker 1: and every air vent that connects the inside of that
- 12:53Speaker 1: building to the outside world exactly.
- 12:55Speaker 2: And Drozer provides the exact command to automate that perimeter walk.
- 12:59Speaker 2: It's run app dot package dot attack surfacecom dot Android
- 13:03Speaker 2: dot Chrome.
- 13:04Speaker 1: Nice and intuitive.
- 13:05Speaker 3: Yeah.
- 13:06Speaker 2: When you fire that command, Drozer interrogates the Android operating
- 13:09Speaker 2: systems routing tables and returns this highly structured breakdown for
- 13:13Speaker 2: a complex app like Chrome. The output will tell you
- 13:15Speaker 2: it's identified say nine activities, eleven broadcast receivers, three content providers,
- 13:20Speaker 2: and five services that are currently exported and listening.
- 13:23Speaker 1: Now, if you're listening to this deep dive, you likely
- 13:24Speaker 1: already understand what those core components are natively, but let's
- 13:28Speaker 1: recontextualize them specifically through the lens of security and attack surfaces.
- 13:32Speaker 2: Yeah, we aren't looking at these as developer features anymore.
- 13:35Speaker 2: We're looking at them as potential vulnerabilities. Right, Let's focus
- 13:40Speaker 2: on the activities, which are typically the components that drive
- 13:43Speaker 2: a user interface screen. In Android, you don't generally launch
- 13:47Speaker 2: an activity by calling a function directly.
- 13:50Speaker 1: You use the message passing system.
- 13:52Speaker 2: Yes, you create an object called an intent, and you
- 13:55Speaker 2: hand it to the operating system.
- 13:57Speaker 1: You know, I always explain intents like a restaurant ticketing system.
- 14:01Speaker 2: Oh I like that.
- 14:02Speaker 1: Yeah, The customer, which is one app, doesn't walk into
- 14:05Speaker 1: the kitchen and start cooking. The customer writes their order
- 14:08Speaker 1: on a ticket, which is the intent. They hand that
- 14:11Speaker 1: ticket to the waiter, which is the Android OS. The
- 14:14Speaker 1: waiter reads the ticket, figures out which chef can cook
- 14:17Speaker 1: the meal, and hands the ticket to that specific chef,
- 14:20Speaker 1: which would be the target activity.
- 14:22Speaker 2: That is a brilliant way to conceptualize Android's intent routing mechanism.
- 14:26Speaker 2: And here is where the attack surface comes into play.
- 14:29Speaker 2: If a developer sets an activities exported flag to true
- 14:33Speaker 2: in the manifest, they're essentially telling the waiter, I will
- 14:36Speaker 2: accept a cooking ticket from literally anyone who walks into
- 14:39Speaker 2: the restaurant. Wow, that activity becomes a completely public API endpoint.
- 14:45Speaker 2: Any malicious app on the phone can generate an intent
- 14:49Speaker 2: and force that activity to execute without any user interaction
- 14:52Speaker 2: or permission.
- 14:53Speaker 1: That is a massive security implication. Yeah, so we've identified
- 14:57Speaker 1: that Chrome has what nine of these open doors. Let's
- 15:00Speaker 1: start tuning the doorknobs all right.
- 15:01Speaker 2: To see the specific labels of those nine activities, we
- 15:04Speaker 2: use the command run app dot activity dot info. It
- 15:07Speaker 2: lists them all out. You'll almost always find an activity
- 15:10Speaker 2: labeled main.
- 15:11Speaker 1: That's the primary launch intent right the screen. You see
- 15:13Speaker 1: when you physically tap the chroll.
- 15:15Speaker 2: Micon the absolute front door the front door, and we
- 15:18Speaker 2: can forcefully kick that door open from our terminal using
- 15:21Speaker 2: run app dot activity dot start, followed by the main
- 15:24Speaker 2: activities fully qualified component name.
- 15:27Speaker 1: And this is where dynamic analysis really feels like a
- 15:29Speaker 1: magic trick.
- 15:30Speaker 2: It really does.
- 15:31Speaker 1: You're sitting at your host laptop, you execute that start command,
- 15:34Speaker 1: and instantly on the emulator running on a different screen,
- 15:38Speaker 1: the Chrome application just springs to life. You bypass the
- 15:41Speaker 1: launcher completely and command the OS to spin up that process.
- 15:45Speaker 2: It demonstrates absolute control over the execution flow. But you know,
- 15:49Speaker 2: launching the main activity is usually safe, right.
- 15:51Speaker 1: They expect people to use the front door exactly.
- 15:53Speaker 2: We want to test the side windows. Let's say in
- 15:56Speaker 2: our list of nine activities, we spot a deeply nested,
- 15:59Speaker 2: really specific component, maybe something named bookmark activity.
- 16:05Speaker 1: Okay, so we generate a custom intent using drozer and
- 16:09Speaker 1: fire the run app dot activity dot stirt command aimed
- 16:12Speaker 1: specifically at that bookmark activity. What's the expected outcome?
- 16:15Speaker 2: Well, this is where dynamic analysis totally diverges from predictable
- 16:19Speaker 2: static theory. You fire the command and you might watch
- 16:22Speaker 2: the emulator screen do absolutely nothing, okay, or the application
- 16:25Speaker 2: might immediately trigger a fatal exception and just crash right
- 16:28Speaker 2: back to the home screen.
- 16:29Speaker 1: But why the silent failure, Like if the door is
- 16:32Speaker 1: unlocked and exported, why did it crash when we walk
- 16:34Speaker 1: through it?
- 16:35Speaker 2: Because of application state tendency, The developer likely assumed that
- 16:39Speaker 2: the only way a user could ever reach that bookmark
- 16:42Speaker 2: ad screen was by first loading a web page, parsing
- 16:47Speaker 2: its metadata, and then clicking a button.
- 16:49Speaker 1: Which would pass all that necessary context into.
- 16:51Speaker 2: Memory exactly, but by using Drozer to force fully jumpstart
- 16:55Speaker 2: that specific activity out of thin air, the activity wakes up,
- 16:59Speaker 2: looks the web page metadata in memory, finds a null
- 17:02Speaker 2: pointer instead, and violently crashes, which.
- 17:04Speaker 1: Proves exactly why dynamic analysis is inherently an exercise and
- 17:08Speaker 1: trial error and forced mutation. Yeah, we're deliberately prodding the
- 17:13Speaker 1: application in unnatural, out of sequence ways to expose unhandled
- 17:18Speaker 1: exceptions and logical flaws. Absolutely, but this raises a fundamental
- 17:21Speaker 1: problem regarding visibility. If we trigger an activity and Drozer
- 17:25Speaker 1: in the app crashes, or worse, if it silently modifies
- 17:28Speaker 1: a system file, how do we actually capture the mechanics
- 17:31Speaker 1: of what just happened? Like staring at the emulator screen
- 17:34Speaker 1: isn't enough.
- 17:35Speaker 2: No, the screen is just the presentation layer. The real
- 17:37Speaker 2: action is happening deep inside the kernel and the file
- 17:40Speaker 2: system running the app is only i'd say twenty percent
- 17:43Speaker 2: of dynamic analysis. The other eighty percent is meticulously setting
- 17:47Speaker 2: your surveillance traps before you ever touch the application. You
- 17:51Speaker 2: need specialized telemetry tools running silently in the background.
- 17:54Speaker 1: Let's unpack that surveillance toolbox. If we're setting traps. What
- 17:58Speaker 1: are the primary domains we actually need to monitor?
- 18:01Speaker 2: There are three critical domains. The first is filesystem monitoring.
- 18:06Speaker 2: Applications are inherently noisy on the disc. They read configurations,
- 18:10Speaker 2: they write cash data, and critically, if they're malicious, they
- 18:14Speaker 2: drop secondary payloads or expltrate local databases.
- 18:17Speaker 1: Now, I know, Android studio has the device file explorer
- 18:20Speaker 1: and some real time monitoring capabilities built right in.
- 18:23Speaker 2: It does, and for standard app development, honestly it's sufficient.
- 18:26Speaker 2: But for deep programmatic security analysis, the Android's studio overhead
- 18:31Speaker 2: can be.
- 18:31Speaker 1: Really cumbersome to bulky. Yeah.
- 18:33Speaker 2: So for analysts who live in the command line, the
- 18:35Speaker 2: gold standard is a utility called f s MOND.
- 18:38Speaker 1: Fs MOND a dedicated filesystem monitor. Yeah.
- 18:41Speaker 2: It's lightweight, incredibly fast, and hooks directly into the kernels
- 18:45Speaker 2: in odify subsystem. You basically deploy fs MOND into the
- 18:49Speaker 2: emulator's data directory and you configure it to output its
- 18:53Speaker 2: telemetry as structured Jason data, just piping it to a
- 18:56Speaker 2: background file.
- 18:57Speaker 1: Oh that's smart.
- 18:57Speaker 2: Yeah. So while you're using drozer to rapidly trigger activities
- 19:01Speaker 2: and broadcast receivers, f SMD is quietly generating this machine
- 19:05Speaker 2: readable Jason log of every single read, write, and permission
- 19:11Speaker 2: change the application attempts on the disc.
- 19:13Speaker 1: I love that it outputs and chase on it means
- 19:15Speaker 1: you can ingest that log directly into a SUM or
- 19:18Speaker 1: write a quick Python script to parse out only this
- 19:21Speaker 1: suspicious file modification.
- 19:22Speaker 3: Exactly, all right, our filesystem trap is set. What is
- 19:25Speaker 3: the second domain network monitoring? This is the absolute lifeblood
- 19:29Speaker 3: of modern threat analysis. Whether it's a benign app updating
- 19:33Speaker 3: its UI or a malicious app phoning home to a
- 19:36Speaker 3: command and control server, the network traffic tells the true story.
- 19:39Speaker 1: Right.
- 19:39Speaker 2: You might be analyzing an app and looking for very
- 19:42Speaker 2: specific data exfiltration techniques because.
- 19:44Speaker 1: You know, maldare authors know we're watching the network, so
- 19:47Speaker 1: they rarely just send stolen data and plain text anymore.
- 19:50Speaker 2: Exactly. A super common evasion technique is encoding the stolen
- 19:54Speaker 2: data before transmission. Analysts often hunt for what are colloquially
- 19:59Speaker 2: termed hex scale data payloads that have been encoded into
- 20:02Speaker 2: hexadecimal escape sequences.
- 20:03Speaker 1: Right.
- 20:04Speaker 2: The malware does this to bypass simple string matching rules
- 20:07Speaker 2: on intrusion detection systems. If you're just looking for the
- 20:12Speaker 2: string password, you're going to completely miss it. If it's
- 20:15Speaker 2: sent as a hex encoded bite array.
- 20:17Speaker 1: So if the app is attempting to smuggle data out
- 20:19Speaker 1: via xcapes, we need a packet capture trap capable of
- 20:22Speaker 1: recording the raw byte streams at the interface level.
- 20:25Speaker 2: And for that we rely on the undisputed champion of
- 20:28Speaker 2: network analysis, tcp dump, the classic. It's pre compiled for
- 20:31Speaker 2: Android environments. You ssh and to the emulator. You bind
- 20:35Speaker 2: tcp dump to the will and zero interface, which simulates
- 20:38Speaker 2: the primary network adapter, and you just instruct it to
- 20:41Speaker 2: dump the raw packet capture into a standard dot pcap
- 20:44Speaker 2: file right there on the device.
- 20:45Speaker 1: So we've got a highly orchestrated environment running here. F
- 20:48Speaker 1: smon is actively tracking the file system writing a JSON log,
- 20:53Speaker 1: tcp dump is intercepting every network packet writing a PCCAP log.
- 20:57Speaker 1: We spend an hour using DROs to manipulate the attack surface.
- 21:02Speaker 1: Once the dust settles, how do we actually extract the
- 21:05Speaker 1: forensic evidence from the emulator.
- 21:07Speaker 2: We leverage our ADB wormhole again. Of course, you execute
- 21:10Speaker 2: the ad pole command to seamlessly drag those JSON and
- 21:14Speaker 2: pccap files off the Android devices storage and straight onto
- 21:17Speaker 2: your secure host machine. Okay, and from there you have
- 21:20Speaker 2: home field advantage. You can load the PCCAP into wire
- 21:23Speaker 2: Shark to reconstruct the network streams and hunt for those hexcapes,
- 21:27Speaker 2: and you can analyze the f s mont Jason in
- 21:29Speaker 2: your preferred text editor.
- 21:30Speaker 1: You're essentially sealing off the crime scene, collecting the security
- 21:33Speaker 1: camera footage, and bringing the tapes back to the lab
- 21:36Speaker 1: for frame by frame analysis.
- 21:37Speaker 2: Precisely. Now, there is a third surveillance domain, and this
- 21:40Speaker 2: is reserved for when you need granular instruction level of
- 21:43Speaker 2: visibility into the execution flow, and that's debugging.
- 21:46Speaker 1: Debugging. That's where we stop looking at the footprints the
- 21:49Speaker 1: app leaves behind and start looking at the actual neural
- 21:52Speaker 1: pathways of the code as it executes in real time.
- 21:55Speaker 2: Well said, And the debugging landscape on Android is bifurcated
- 21:59Speaker 2: to depending entirely on the architecture of the code you're targeting. Okay,
- 22:03Speaker 2: how so, if you're reverse engineering native code maining C
- 22:06Speaker 2: or C plus plus libraries that have been compiled directly
- 22:09Speaker 2: down to ARM machine instructions, you utilize GDB, the GNU
- 22:15Speaker 2: Project debugger, which is natively supported in Android environments.
- 22:19Speaker 1: And for you listeners who spend their days in the
- 22:21Speaker 1: iOS ecosystem. Using GDB on Android native libraries is the
- 22:26Speaker 1: exact conceptual equivalent of attaching LLEDB to an iOS binary.
- 22:30Speaker 2: It's identical in philosophy. You initialize a remote GDB server
- 22:34Speaker 2: on the Android device, use ADB to forward a specific
- 22:37Speaker 2: port and the industry standard default is usually port eighty
- 22:41Speaker 2: eight to eight, and then you can attach your local
- 22:43Speaker 2: GDB client.
- 22:44Speaker 1: And then you have full control.
- 22:45Speaker 2: Yeah, you can set memory breakpoints step through native assembly
- 22:48Speaker 2: instructions inspecs, CPU registers right as the code runs.
- 22:51Speaker 1: But the vast majority of standard Android applications aren't actually
- 22:54Speaker 1: compiled down to native machine code right. They're written in
- 22:57Speaker 1: Java or Cotlin, running inside the DELVIC or RT virtual machines.
- 23:03Speaker 1: GDB isn't really designed to debug manage Java by code correct.
- 23:07Speaker 2: If you're hunting bugs or analyzing logic in the managed
- 23:11Speaker 2: Java layer, your tool set has to shift. For a
- 23:14Speaker 2: robust graphical workflow, Attaching the Android Studio Java debugger via
- 23:18Speaker 2: the Java debug wire protocol is incredibly powerful.
- 23:21Speaker 1: But if you hate IDEs, right, if.
- 23:23Speaker 2: Your workflow is entirely CLI driven and you don't want
- 23:26Speaker 2: the immense overhead of an IDE, there are specialized command
- 23:29Speaker 2: line alternatives. Like anbug, which allow you to attach to
- 23:32Speaker 2: the dalvic run time and inspect Java objects directly from
- 23:35Speaker 2: your terminal.
- 23:36Speaker 1: Okay, we have covered a phenomenal amount of technical ground today.
- 23:39Speaker 1: We moved from the static theory of a dormant binary
- 23:42Speaker 1: to the dynamic reality of a live execution environment.
- 23:45Speaker 2: It's journey.
- 23:46Speaker 1: Yeah. We bridge the network gap using ADB, established command
- 23:49Speaker 1: and control with drozer, mapped out the intent attack surface,
- 23:52Speaker 1: and layered on this really comprehensive surveillance net of file
- 23:56Speaker 1: network and memory monitors.
- 23:57Speaker 2: It's a rigorous, deeply technical methodology, and what's really vital
- 24:02Speaker 2: to understand is that while the specific command line syntax
- 24:05Speaker 2: we discussed today is unique to Android, the underlying philosophy
- 24:08Speaker 2: of dynamic analysis is completely platform agnostic.
- 24:12Speaker 1: It applies everywhere exactly.
- 24:14Speaker 2: The tools adapt, but the mindset of isolating, manipulating, and
- 24:18Speaker 2: observing an application remains exactly the same, whether you're hunting
- 24:21Speaker 2: malware on Android or iOS.
- 24:23Speaker 1: Since you brought up cross platform methodologies, I actually want
- 24:26Speaker 1: to pivot and put you the listener to the test.
- 24:29Speaker 2: Oh a pop quiz.
- 24:30Speaker 1: Let's do a rapid fire knowledge check. I'm going to
- 24:33Speaker 1: ask a question synthesizing everything we just covered, and I'll
- 24:35Speaker 1: weave in a few iOS concepts to see how well
- 24:38Speaker 1: you can translate these security philosophies across operating systems. Ready,
- 24:42Speaker 1: I'll ask, give you a beat answer in your head,
- 24:44Speaker 1: and our expert will confirm.
- 24:46Speaker 2: Let's see how sharp they are.
- 24:47Speaker 1: Question one for you listening Sticking with our Android networking setup,
- 24:51Speaker 1: we just established that remote native debugging requires a tunnel.
- 24:55Speaker 1: What is the exact ADB command you would type to
- 24:57Speaker 1: forward your host traffic to the standard GDB debugging port.
- 25:01Speaker 2: If you visualize typing ab forward TCP do eight eight
- 25:05Speaker 2: eight eight TCP dot eight eight eight eight, you nailed
- 25:08Speaker 2: the networking concept perfectly.
- 25:09Speaker 1: Awesome. Question two, let's jump the fence to the Apple ecosystem.
- 25:14Speaker 1: When an iOS application is launched by the operating system,
- 25:16Speaker 1: what is the absolute first function that gets called to
- 25:19Speaker 1: initialize the apps life cycle?
- 25:21Speaker 2: The core entry point for every iOS application is UI
- 25:24Speaker 2: Application Main. That's where the entire execution thread begins.
- 25:27Speaker 1: Spot on question three. Staying deep in iOS architecture, we
- 25:30Speaker 1: talked about Android app states crashing when forcefully launched. How
- 25:34Speaker 1: many distinct execution states exist within an iOS applications life cycle?
- 25:38Speaker 2: The iOS architecture defines exactly five states not running, inactive, active, background,
- 25:43Speaker 2: and suspended. Understanding those states is critical for knowing when
- 25:46Speaker 2: your tools can actually.
- 25:47Speaker 1: Inject code exactly five states. And the final question for
- 25:51Speaker 1: you a bit of deep cut terminology trivia and Android.
- 25:53Speaker 1: We use Drozer to manipulate intents in iOS dynamic analysis.
- 25:57Speaker 1: What is the highly specific, slightly ridiculed industry term for
- 26:01Speaker 1: intercepting and replacing objective C methods at runtime? Is it boozing, lounging, weaseling.
- 26:06Speaker 2: It is certainly not weaseling. The definitive technique you rely
- 26:10Speaker 2: on in iOS is called swizzling method swizzling and then swizzling.
- 26:15Speaker 1: It is a foundational technique for iOS runtime manipulation. Acting
- 26:19Speaker 1: is the conceptual counterpart to how we leverage Drozer on Android, and.
- 26:23Speaker 2: Tying those cross platform concepts together leads to a crucial
- 26:27Speaker 2: final thought I want you to consider after this deep dive. Okay,
- 26:29Speaker 2: Throughout this discussion, we've demonstrated the absolute terrifying control that
- 26:34Speaker 2: frameworks like Drozer, ADB and GDB give you over an application.
- 26:38Speaker 2: You can force hidden screens to open, hijack network streams,
- 26:43Speaker 2: rewrite execution flaws, and memory.
- 26:45Speaker 1: You essentially have total dominion over the operating system.
- 26:48Speaker 2: We do because we're using these tools in a sterile
- 26:50Speaker 2: lab environment for security research, but consider the implications in
- 26:54Speaker 2: the wild. The Android architecture doesn't inherently distinguish between a
- 26:58Speaker 2: legitimate security researcher sending an intent via droser to test
- 27:02Speaker 2: an activity wow, and a sophisticated piece of malware exploiting
- 27:05Speaker 2: that exact same intent routing mechanism to silently harvest data
- 27:09Speaker 2: in the background. The pathways are identical.
- 27:11Speaker 1: That is a profoundly chilling realization. The exact structural mechanisms,
- 27:17Speaker 1: the IPC channels, the exported activities, the debugging protocols that
- 27:21Speaker 1: developers rely on to build and test the ecosystem are
- 27:24Speaker 1: the exact same mechanisms. Adversaries weaponized to dismantle it.
- 27:28Speaker 2: The architecture itself is dual use, and that reality is
- 27:31Speaker 2: precisely why mastering dynamic analysis is not optional. You cannot
- 27:35Speaker 2: defend a system you do not know how to manipulate,
- 27:38Speaker 2: which brings.
- 27:38Speaker 1: Us full circle to our starting premise. You can analyze
- 27:41Speaker 1: the static blueprint of an application all day long, you
- 27:44Speaker 1: can memorize every line of code, but until you jump
- 27:47Speaker 1: into the driver's seat, floor the gas pedal, and dynamically
- 27:50Speaker 1: force that code to execute in a live environment. You
- 27:53Speaker 1: have absolutely no idea what machine is truly capable of.
- 27:56Speaker 2: Never trust the static theory. Always force the application to
- 27:59Speaker 2: prove itself against the dynamic runtime reality.
- 28:02Speaker 1: Keep pulling apart the architecture, keep questioning the execution flow,
- 28:06Speaker 1: and keep diving deep