Latest / CyberCode Academy / Course 5 - Full Mobile Hacking | Episode 4: Comprehensive Android Debugging and Control: ADB, SCRCPY, and Security Manipulation
Transcript
- 0:00Speaker 1: If you've ever used an Android phone, well, you know
- 0:02Speaker 1: the interface, right, the apps, the settings, it's all pretty smooth.
- 0:05Speaker 2: Yeah, it's designed that way. But think of it like
- 0:08Speaker 2: a really nicely wrapped gift box. Okay, inside that box,
- 0:12Speaker 2: it's actually a full blown, powerful Linux machine.
- 0:15Speaker 1: Right. Most people just see the wrapping paper the user
- 0:17Speaker 1: interface exactly.
- 0:18Speaker 2: But there's a way to get inside. To bypass that
- 0:21Speaker 2: graphical stuff entirely.
- 0:22Speaker 1: You need a key, and that key, I'm guessing, is
- 0:25Speaker 1: what we're diving into today.
- 0:26Speaker 2: Precisely. It's the Android debug Bridge. Add it's this command
- 0:31Speaker 2: line tool that just fundamentally changes how you interact with
- 0:35Speaker 2: an Android device.
- 0:36Speaker 1: So it stops treating it like just a phone.
- 0:38Speaker 2: Yeah exactly, it treats it more like the programmable Linux server. Yeah.
- 0:43Speaker 2: It really is deep down essential stuff if you're into programming, debugging,
- 0:47Speaker 2: or you know, just really want to master your device.
- 0:49Speaker 1: So today we're going to take a deep dive into
- 0:52Speaker 1: how ADB actually works. We want to understand its architecture.
- 0:56Speaker 1: It's power, right.
- 0:57Speaker 2: The mission here is to see how we can turn
- 0:59Speaker 2: a sim computer terminal into well a remote control for
- 1:03Speaker 2: any Android environment.
- 1:05Speaker 1: And we're going to cap it off with a pretty
- 1:07Speaker 1: serious example, right, like manipulating core system settings.
- 1:10Speaker 2: Yeah, we'll walk through how you could potentially bypass a
- 1:13Speaker 2: screenlock just using commands.
- 1:15Speaker 1: Wow. Okay, but first things first, what is ADB like? Technically?
- 1:21Speaker 1: You said, it's not just one thing.
- 1:22Speaker 2: That's right. It's more like a system three parts working together.
- 1:25Speaker 2: You've got the client.
- 1:26Speaker 1: That's the command line on my computer.
- 1:28Speaker 2: Yep. Then there's the damon, which is a little background
- 1:31Speaker 2: process running on the Android device itself, always listening.
- 1:34Speaker 1: Okay, client demon. What's the third piece.
- 1:37Speaker 2: The server that also runs on your host computer, your
- 1:40Speaker 2: main machine.
- 1:41Speaker 1: Uh huh.
- 1:41Speaker 2: It's kind of like the traffic controller.
- 1:43Speaker 1: Ah. So if I have, say a phone and an
- 1:45Speaker 1: emulator running exactly.
- 1:47Speaker 2: The server, make sure your command from the client gets
- 1:49Speaker 2: to the right demon on the correct device. It handles
- 1:53Speaker 2: all that communication. Got it?
- 1:54Speaker 1: Client, server, Demon, a whole system.
- 1:57Speaker 2: It's a neat setup. But before we start growing powerful
- 2:00Speaker 2: commands around, we really need a safe place to play, right.
- 2:04Speaker 1: You don't want to mess up your actual phone. So
- 2:06Speaker 1: virtualization absolutely a sandbox. Tools like Android Studio that you
- 2:11Speaker 1: create an AVD and Android virtual device so I can
- 2:14Speaker 1: pretend I have what a pixel three XL.
- 2:17Speaker 2: Yeah, or whatever. Pick the hardware. Pick the Android version,
- 2:20Speaker 2: say Android ten API twenty nine, boot it.
- 2:23Speaker 1: Up, and now I have an isolated environment. Mistakes are
- 2:26Speaker 1: okay here exactly.
- 2:27Speaker 2: So once that sandbox is running, the very first thing
- 2:30Speaker 2: is just checking the connection. Is the bridge even there?
- 2:32Speaker 1: How do we do that?
- 2:33Speaker 2: ADB devices? Just type that in your terminal should I
- 2:36Speaker 2: see if it's working? Your computer will list the connected device.
- 2:39Speaker 2: It might show up as something like emulator five five
- 2:42Speaker 2: five four.
- 2:42Speaker 1: Okay, so that confirms the client, server and demon are
- 2:45Speaker 1: all talking.
- 2:46Speaker 2: Yep, the bridge is up. Now for the really cool
- 2:49Speaker 2: part crossing that bridge. This is the ADB shell command
- 2:53Speaker 2: you mentioned.
- 2:54Speaker 1: That's one ADB shell. When you run that, you kind
- 2:56Speaker 1: of teleport. You stop talking to the device and start
- 2:59Speaker 1: talking as the device exactly. You're dropped right into its
- 3:02Speaker 1: underlying Linux operating system. The command prompt changes.
- 3:07Speaker 2: But I'm not all powerful just yet, am I?
- 3:09Speaker 1: No? Not?
- 3:09Speaker 2: Initially, when you first land in the shell, you're logged
- 3:12Speaker 2: in as the shell user. You can look around run
- 3:15Speaker 2: basic commands, but you can't change anything critical. You're restricted.
- 3:18Speaker 1: Okay, So how do we get the real power the
- 3:20Speaker 1: keys to the kingdom?
- 3:22Speaker 2: That requires escalating your privileges. You need to run. The
- 3:25Speaker 2: SU command stands for.
- 3:27Speaker 3: Super user ah, the classic Linux root access.
- 3:30Speaker 2: Precisely you run. If you the system might prompt the
- 3:34Speaker 2: virtual device for permission, and if.
- 3:36Speaker 1: Successful, I go from being shell to root.
- 3:39Speaker 2: Bingo, and root means total unrestricted control, file, system, settings, services, everything.
- 3:45Speaker 1: That's a huge step. I see why you emphasize the
- 3:47Speaker 1: virtual device first.
- 3:49Speaker 2: Absolutely paramount doing is on a real device while you're
- 3:52Speaker 2: operating without a safety net. Root access is serious power.
- 3:55Speaker 1: Okay, so let's use that power you mentioned by passing
- 3:58Speaker 1: a screen lock. Let's say I set up virtual device
- 4:00Speaker 1: with a PI like twelve thirty four and then whoops,
- 4:03Speaker 1: forgot it.
- 4:04Speaker 2: It's a perfect scenario to show what roude can do. Yeah,
- 4:07Speaker 2: so you're already in the shell and you've run SU
- 4:09Speaker 2: successfully your route.
- 4:10Speaker 1: Right, where do we go? Now? We need to navigate
- 4:13Speaker 1: to where Android keeps its core settings. So first command
- 4:16Speaker 1: dot CD data, change directory into data. Okay. Then inside
- 4:21Speaker 1: data there's another important directory, dot cd system. So we're
- 4:24Speaker 1: in data system. What's in here? This is like the
- 4:27Speaker 1: system's private storage for critical configurations, security stuff, user settings,
- 4:32Speaker 1: and the file we care about is right here lock settings,
- 4:35Speaker 1: dot dB DOTKEDB.
- 4:39Speaker 2: That sounds like a database file.
- 4:40Speaker 1: It is. Specifically, it's a Squilight database, not a plain
- 4:43Speaker 1: text file. You can just addit.
- 4:45Speaker 2: So we need a special tool to talk to it.
- 4:46Speaker 1: Yep. Android usually has the quite three command line tool
- 4:49Speaker 1: built in. So we run sklight threelock settings dot.
- 4:52Speaker 2: dB and that opens the database like connecting to a
- 4:54Speaker 2: database server.
- 4:55Speaker 1: Pretty much. Yeah, you get a new prompt, the Squilight prompt.
- 4:58Speaker 1: Now we can run SQL queries directly against this setting's database.
- 5:01Speaker 2: SQL like select statements and update statements exactly.
- 5:04Speaker 1: The same principles. We don't need to guess the twelve
- 5:07Speaker 1: thirty four PI and we just need to tell the
- 5:08Speaker 1: database that the lock screen isn't actually enabled anymore.
- 5:12Speaker 2: How do we find the right setting in the database. First,
- 5:15Speaker 2: let's see the tables. You can type dot tables. It'll
- 5:18Speaker 2: likely show one main table, probably called lock settings.
- 5:20Speaker 1: Okay, lock settings. And how do we see what's inside?
- 5:23Speaker 2: Select from lock settings. That'll dump all the key value
- 5:26Speaker 2: pairs stored in there. You'll see names like lockscreen disabled
- 5:29Speaker 2: and lockscreen password type.
- 5:30Speaker 1: Ah okay, so we need to change those values exactly.
- 5:33Speaker 2: Two main things we need to do. First, find the
- 5:36Speaker 2: setting named lock screen disabled and set its value to one.
- 5:39Speaker 2: One usually means true in these contexts.
- 5:42Speaker 1: So and sql up date command for that row. Got it.
- 5:46Speaker 1: What's the second thing we.
- 5:47Speaker 2: Need to tell the system it doesn't have a password
- 5:48Speaker 2: type anymore, so we find the road name lock screen
- 5:51Speaker 2: password type and set its value to zero.
- 5:53Speaker 1: Zeroing it out makes sense anything else.
- 5:55Speaker 2: There's often an alternate setting too, like lock screen password
- 5:58Speaker 2: type bilternate, which is probably zero out as well, just
- 6:00Speaker 2: to be safe, same command, different names that value to
- 6:03Speaker 2: zero one. Okay, so three up day commands disabled to
- 6:07Speaker 2: the lock value one, remove password type value zero, alternate
- 6:12Speaker 2: password at value zero. That's the core logic. Once you
- 6:14Speaker 2: run those uk DAID statements, you exit squeal eight maybe
- 6:17Speaker 2: type dot quit. Then you exit the main shell.
- 6:20Speaker 1: To and the device still looks locked at this point.
- 6:23Speaker 2: Yeah, the changes are in the database, but the running
- 6:25Speaker 2: system hasn't re read them yet. So we boot. That's
- 6:27Speaker 2: the moment of truth. Restart the virtual device, and.
- 6:29Speaker 3: When it boots back up, no more lock screen.
- 6:33Speaker 2: If you go straight to the home screen or whatever
- 6:34Speaker 2: was underneath.
- 6:35Speaker 1: Wow, and if I checked the settings app.
- 6:37Speaker 2: It you'd show the screen lock as none. You've effectively
- 6:41Speaker 2: told the system from the inside to forget the lock
- 6:44Speaker 2: ever existed.
- 6:45Speaker 1: That's incredibly powerful and a bit scary.
- 6:49Speaker 2: It really highlights why root access and ADB are so
- 6:52Speaker 2: critical for say, forensic analysis or deep system repair, but
- 6:57Speaker 2: also why they need to be handled carefully.
- 6:59Speaker 1: Definitely. But ADB isn't just for these like super deep packs, right,
- 7:04Speaker 1: it's useful for every day development too. Oh.
- 7:06Speaker 2: Absolutely, constantly looking down at a tiny device screen while
- 7:08Speaker 2: you're coding and debugging as well. Inefficient.
- 7:12Speaker 1: Yeah, my neck hurts just thinking about it.
- 7:14Speaker 2: Right. This is where other tools that use ADB come
- 7:16Speaker 2: in handy, like one called scrcpy.
- 7:19Speaker 1: Scrcpy screen copy, Yeah, screen copy scrcpy.
- 7:23Speaker 2: It's this amazing little executable. You run it while EB
- 7:27Speaker 2: is connected, and what does it do. It mirrors your
- 7:29Speaker 2: Android screen onto your computer desktop, Windows, Mac, Linux, doesn't
- 7:34Speaker 2: matter and it's fast, really low latency.
- 7:37Speaker 1: So I see my phone screen in a window on
- 7:39Speaker 1: my computer.
- 7:40Speaker 2: Yeap, and you can control it using your computer's mouse
- 7:42Speaker 2: and keyboard, click buttons, type text, open apps, change settings
- 7:46Speaker 2: all visually from your desktop.
- 7:48Speaker 1: Okay, that sounds incredibly useful for development and testing.
- 7:51Speaker 2: It's a game changer. Well, what makes it even better?
- 7:53Speaker 2: Is you don't need the USB cable plugged in all
- 7:55Speaker 2: the time.
- 7:56Speaker 1: Well, you can do ADB stuff wirelessly, you sure can.
- 8:00Speaker 2: You can switch ADB from using USB to using TCPIP
- 8:03Speaker 2: your Wi Fi network.
- 8:04Speaker 1: How does that work? Do I need the IP address? Yeah?
- 8:07Speaker 2: First, while the USB cable is still plugged in, you
- 8:09Speaker 2: need to know your device's Wi Fi IP address, you know,
- 8:12Speaker 2: like one ninety two point one sixty eight point one
- 8:14Speaker 2: point five or whatever.
- 8:15Speaker 1: Okay, find the IP address in the Wi Fi settings.
- 8:17Speaker 1: Then what Then? You run a command ADB TCP IP
- 8:21Speaker 1: followed by a port number you want to use. Let's
- 8:23Speaker 1: just pick nine nine nine nine. So ADB TCCP nine
- 8:27Speaker 1: nine nine nine, ADB TCP IP nine nine h nine.
- 8:31Speaker 1: What does that command do?
- 8:32Speaker 2: It tells the ADB damon on the Android device to
- 8:35Speaker 2: stop listening over USB and start listening for connections over
- 8:38Speaker 2: the network on port nine nine nine nine.
- 8:40Speaker 1: Ah. Okay, so the device is now waiting for a
- 8:42Speaker 1: network connection exactly.
- 8:44Speaker 2: Now you can unplug the USB cable freedom.
- 8:47Speaker 1: Okay, cable's out. How does my computer connect? Now?
- 8:49Speaker 2: Add connect followed by the IP address and the port
- 8:51Speaker 2: number we chose. So ADB connect one nine two point
- 8:53Speaker 2: one sixty eight point one point five point nine nine
- 8:56Speaker 2: nine nine. If everything's on the same network, it should
- 8:58Speaker 2: say connected. Now you have a full eighty B connection wirelessly.
- 9:01Speaker 1: So adbshall works, ADB Devices shows it connected.
- 9:04Speaker 2: Over IP YEP and even better at crcpy works too.
- 9:07Speaker 2: You can run scrcpy and it'll mirror and control the
- 9:09Speaker 2: device over Wi Fi.
- 9:11Speaker 1: That's fantastic, full remote control, visual mirroring, no wires. That
- 9:15Speaker 1: really transforms how you can interact with the device completely.
- 9:19Speaker 2: It makes testing and debugging so much more fluid.
- 9:21Speaker 1: Okay, so we've covered connection, root, access, security, manipulation, even
- 9:25Speaker 1: wireless control with screen mirroring. But you mentioned ADB shell
- 9:29Speaker 1: has more tools inside it.
- 9:31Speaker 2: Oh yeah, getting into the shell is just the start.
- 9:34Speaker 2: Once you're in, especially as root, you have access to
- 9:37Speaker 2: some really powerful built in utilities for managing the system
- 9:41Speaker 2: at a deep level.
- 9:42Speaker 1: Like what kind of tools are we talking about?
- 9:44Speaker 2: Well, one of the most important for developers is the
- 9:46Speaker 2: package manager. You access it with ADB Shell PM PM.
- 9:50Speaker 1: For Package Manager. What does that let you do?
- 9:52Speaker 2: Think of it like the device's master inventory list. You
- 9:56Speaker 2: can use PM commands to list every single application pack
- 10:00Speaker 2: installed on the device.
- 10:01Speaker 1: Okay, useful for seeing what's there.
- 10:03Speaker 2: But also more. You can list all the hardware and
- 10:05Speaker 2: software features the device reports having, like does it have
- 10:07Speaker 2: a fingerprint scanner? Does it support camera dot flash? Can
- 10:11Speaker 2: it handle screen rotation?
- 10:12Speaker 1: Ah? So you can programmatically check device capabilities exactly.
- 10:16Speaker 2: You can even check for available system libraries like keystore
- 10:19Speaker 2: for security stuff crucial for planning app development.
- 10:22Speaker 1: Makes sense? What else is in that toolbox?
- 10:24Speaker 2: Another big one is the Activity Manager ADB shell.
- 10:28Speaker 1: AmAm Activity Manager. If PM is the inventory, what's am?
- 10:32Speaker 2: AM is more like the operational control center. It deals
- 10:37Speaker 2: with what applications and processes are doing right now. It's
- 10:41Speaker 2: vital for diagnostics and performance tuning.
- 10:43Speaker 1: So if an app is acting weird or the phone
- 10:45Speaker 1: is slow.
- 10:46Speaker 2: AMS where you'd look. You can use it to monitor
- 10:48Speaker 2: running activities, see how much memory things are using. There's
- 10:51Speaker 2: even a command like dump heap to get detailed memory
- 10:55Speaker 2: info for a specific process.
- 10:56Speaker 1: Wow. Okay, that sounds like serious debugging power.
- 10:59Speaker 2: It is. You could even use AM to force stop
- 11:02Speaker 2: misbehaving apps or manually start specific services, which is great
- 11:05Speaker 2: for isolating problems during testing.
- 11:07Speaker 1: Okay, PM for inventory, AM for live operations any others.
- 11:11Speaker 2: There's also the Device Policy Manager ADB shell DPM. This
- 11:15Speaker 2: one's less common for individual users, more for like enterprise environments.
- 11:19Speaker 1: Like companies managing fleets of phones exactly.
- 11:22Speaker 2: DPM lets you set up device owners, apply security policies,
- 11:25Speaker 2: configure devices remotely in bulk, powerful but more specialized.
- 11:29Speaker 1: Got it? So these tools work together, right pm?
- 11:32Speaker 2: Am, Yeah, and the integrate seamlessly with basic shell commands
- 11:36Speaker 2: and ADB itself. We'll give you a quick practical example.
- 11:39Speaker 2: So you see a visual bug on the screen.
- 11:41Speaker 1: Okay, you can use a shell command ADB shell screencap
- 11:44Speaker 1: sdcardbugimit dot PNG. That screencap takes the screenshot yep, and.
- 11:48Speaker 2: Saves it directly onto the device's internal storage, in this
- 11:52Speaker 2: case the sd card directory as bug image dot png.
- 11:55Speaker 1: Okay, screenshot, take it on the device. Now I need
- 11:57Speaker 1: it on my computer. Easy, No need to leave your terminal.
- 12:01Speaker 1: Just run ADB pull sdcard big image dot PNG. ADB
- 12:06Speaker 1: polls the file from the device instantly.
- 12:08Speaker 2: ADB handles the transfer and that bug image dot p
- 12:11Speaker 2: and file appears right there in the current directory on
- 12:13Speaker 2: your computer.
- 12:13Speaker 1: Two commands, and I have a screenshot from the device
- 12:15Speaker 1: sitting on my desktop. That's efficient.
- 12:18Speaker 2: That's the whole point. It's about efficient programmatic control over
- 12:20Speaker 2: every aspect of the device. We started seeing ADB as
- 12:24Speaker 2: just a connector yeah.
- 12:25Speaker 1: Just ADB devices, right, but we quickly.
- 12:28Speaker 2: Saw it opens the door to filesystem navigation, root access,
- 12:32Speaker 2: direct database manipulation for security settings.
- 12:34Speaker 1: Then seamless wireless control and screen mirroring with SCRCPY.
- 12:39Speaker 2: And finally these deep diagnostic tools like PM and AM
- 12:42Speaker 2: inside the shell itself, it really covers the whole stack.
- 12:46Speaker 1: So mastering ADB isn't just about learning a few commands,
- 12:48Speaker 1: It's about understanding how to really control the Android operating
- 12:52Speaker 1: system underneath the surface exactly.
- 12:54Speaker 2: It shifts you from just being a user of the
- 12:57Speaker 2: technology to someone who can actually manage and manipulated add
- 13:00Speaker 2: its core, which brings us to a final thought for
- 13:03Speaker 2: you the listener. Imagine this scenario. You've got remote wireless
- 13:07Speaker 2: ADB access to a device starting really slowly, maybe sluggish,
- 13:10Speaker 2: and you suspect some background app is acting up, maybe
- 13:13Speaker 2: leaking memory. Okay, classic performance problem.
- 13:16Speaker 1: You need to diagnose this using only ADYB tools. Which
- 13:20Speaker 1: of those manager utilities we talked about, PM the Inventory
- 13:22Speaker 1: manager or AM the Activity manager, will you focus on first.
- 13:25Speaker 3: Good question inventory or live operations and thinking about that
- 13:30Speaker 3: specific tool, what kind of command within that manager might
- 13:33Speaker 3: give you the clues you need.
- 13:35Speaker 1: What information are you actually looking for to find that
- 13:37Speaker 1: misbehaving process.
- 13:39Speaker 2: Think about whether you need a list of what's installed
- 13:42Speaker 2: or data about what's actively running and consuming resources. Figuring
- 13:46Speaker 2: that out is really key to using these tools effectively.
- 13:49Speaker 1: Definitely something to chew on. It shows how powerful this
- 13:52Speaker 1: knowledge can be.