Latest / CyberCode Academy / Course 16 - Red Team Ethical Hacking Beginner Course | Episode 5: Windows Lateral Movement: Manual Execution via WMIC, Scheduled Tasks
Transcript
- 0:00Speaker 1: Welcome back to the deep dive. If you work in
- 0:03Speaker 1: cybersecurity or IT administration, you know the biggest risk isn't
- 0:08Speaker 1: always that initial break in, it's what happens right after.
- 0:12Speaker 2: That's so true. I mean, picture it an adversaries already in.
- 0:15Speaker 2: They've got a foothold on one machine, and this is
- 0:18Speaker 2: the critical part. They have the keys to the kingdom exactly.
- 0:22Speaker 1: They've compromised a domain administrator account and in the scenario
- 0:26Speaker 1: we're digging into today, that user is called Peter Pan.
- 0:31Speaker 2: Yep, Peter Pan. And once that happens, the game just
- 0:33Speaker 2: completely shifts. It's not about getting in anymore. It's about
- 0:37Speaker 2: moving around, and that's what we call lateral movement.
- 0:39Speaker 1: And that is the critical phase. They use those credentials,
- 0:42Speaker 1: Peter Pan's credentials to jump from that one machine deeper
- 0:45Speaker 1: into the network.
- 0:46Speaker 2: And what's really fascinating here is they're not always using
- 0:49Speaker 2: some brand new, fancy malware. They are weaponizing tools already
- 0:54Speaker 2: built right into Windows, tools that.
- 0:55Speaker 1: Are trusted, signed and used by IT teams every single day,
- 1:00Speaker 1: which of course makes detecting the malicious use a real nightmare.
- 1:03Speaker 2: It really does.
- 1:04Speaker 1: Okay, so let's unpack this we're looking at how once
- 1:07Speaker 1: you have that domain admin account, you can make a
- 1:10Speaker 1: remote machine. In our deep dive, it's at IP address
- 1:13Speaker 1: one nine to two point one sixty eight point one
- 1:15Speaker 1: two two point one, three to two run your code.
- 1:19Speaker 2: We're essentially looking at how normal system functions can be
- 1:22Speaker 2: turned against themselves. We're turning administrative efficiency into a huge
- 1:26Speaker 2: security challenge.
- 1:27Speaker 1: So let's start with maybe the most direct method WMIC.
- 1:31Speaker 2: Right Windows Management Instrumentation Command. If you've ever managed Windows systems,
- 1:35Speaker 2: you know this tool. It's it's the Swiss Army Knight.
- 1:39Speaker 1: It's incredibly powerful, it's versatile, and that makes it a
- 1:41Speaker 1: prime target for this kind of lateral movement.
- 1:44Speaker 2: And because it's a core management tool, it's often just
- 1:46Speaker 2: allowed through firewalls by default. It's trusted traffic.
- 1:49Speaker 1: So we have Peter Pan's credentials, we have our target.
- 1:52Speaker 1: The first step, logically, is always a bit of recon
- 1:55Speaker 1: right verification.
- 1:57Speaker 2: Absolutely, you have to confirm you could even talk to
- 1:59Speaker 2: the machine with those privilegious So you might do something
- 2:01Speaker 2: simple like a remote directory listing.
- 2:03Speaker 1: Just try to list the files on the seed drive
- 2:05Speaker 1: of the target exactly.
- 2:07Speaker 2: If you get that directory listing back, you know two things.
- 2:11Speaker 2: The connection works and your permissions are solid. You're ready
- 2:14Speaker 2: to go.
- 2:14Speaker 1: Okay, so confirmation is done. Step two is getting the
- 2:17Speaker 1: payload over there. We're talking about a file. Let's call
- 2:21Speaker 1: it test dot ex, right.
- 2:23Speaker 2: The attacker copies that file to the remote machine's seed drive.
- 2:26Speaker 2: Once it's there, it's time for the execution. And this
- 2:29Speaker 2: is where WMIC is just so fast.
- 2:32Speaker 1: The command is surprisingly simple, isn't it.
- 2:34Speaker 2: It's incredibly direct. You use d namic, you pointed at
- 2:37Speaker 2: the remote node, the target IP, and you just use
- 2:40Speaker 2: the process create function until it was file to run.
- 2:43Speaker 1: And because the command is coming from a trusted domain admin,
- 2:46Speaker 1: the remote system just does it.
- 2:47Speaker 2: It does it immediately. It'll even report back that the
- 2:50Speaker 2: process was created and give you the process ID, the
- 2:52Speaker 2: APD in this case PID twenty nine to eighty.
- 2:55Speaker 1: And for the attacker, that means a new session pops up,
- 2:58Speaker 1: running test dot ex on the target.
- 3:00Speaker 2: And crucially running with the privileges of the domain admin
- 3:03Speaker 2: user Peter Pan.
- 3:05Speaker 1: So that's it. Lateral movement done. It's fast, it's efficient,
- 3:08Speaker 1: all using trusted admin traffic. But it seems almost too easy.
- 3:13Speaker 1: What's the downside for the attacker?
- 3:15Speaker 2: Well, that ease is also its weakness. It's it could
- 3:18Speaker 2: be pretty noisy. That process, called creativent is something that
- 3:21Speaker 2: a lot of modern defensive tools are specifically looking for.
- 3:24Speaker 1: Ah, so it leaves a clearer trail right back to
- 3:27Speaker 1: the compromised Peter Pan account, a very clear trail.
- 3:30Speaker 2: It's quick, but it's definitely not the stealthiest option on
- 3:33Speaker 2: the table.
- 3:33Speaker 1: Okay, So if w MIC is the loud smash and grab,
- 3:37Speaker 1: what if the attacker wants something a little quieter or
- 3:40Speaker 1: maybe with even more authority.
- 3:41Speaker 2: Well, that brings us to our second method, using scheduled tasks.
- 3:45Speaker 2: With this task's utility.
- 3:47Speaker 1: This is a really clever pivot. Instead of just running
- 3:49Speaker 1: a process directly, you're using the system's own scheduling mechanism.
- 3:52Speaker 2: Exactly, and that gives you a couple of big advantages.
- 3:55Speaker 2: For one, it can be more subtle, and two you
- 3:58Speaker 2: can often get a higher privileged level out of it.
- 4:00Speaker 1: So, same as before, the payload urtest dot ex needs
- 4:04Speaker 1: to be on the target machine first, but the configuration
- 4:07Speaker 1: of the task is where the trick lies.
- 4:09Speaker 2: Right. We're not trying to run something next week. We
- 4:11Speaker 2: want it to run now, but only once.
- 4:14Speaker 1: And this is the part I find so interesting. The
- 4:17Speaker 1: attacker creates a new task, but they set the start
- 4:20Speaker 1: date and time to a point in the past.
- 4:22Speaker 2: HM. It's a fantastic way to exploit the system's logic.
- 4:26Speaker 2: The task scheduler sees this one time task that's already overdue, so.
- 4:31Speaker 1: It says, oh, I missed this, I better run it
- 4:32Speaker 1: right now.
- 4:33Speaker 2: Precisely, it runs it immediately, and because the schedule time
- 4:36Speaker 2: is passed, the task doesn't run again. It helps the cleanup.
- 4:39Speaker 1: But the real price here isn't just the timing. It's
- 4:41Speaker 1: the privileged level. With w MIIC, we were running as
- 4:45Speaker 1: the domain admin Peter Pan.
- 4:47Speaker 2: But with a scheduled task, you can configure it to
- 4:49Speaker 2: run as the highest privileged level on the machine itself.
- 4:53Speaker 2: You can tell it to run a system.
- 4:55Speaker 1: Let's pause on that. What does running as system or
- 4:57Speaker 1: NT authority system actually mean? Why is that better than
- 5:01Speaker 1: being a domain admin?
- 5:02Speaker 2: That's a great question. A domain admin owns the entire
- 5:05Speaker 2: network domain, which is hugely powerful. But the system account, well,
- 5:10Speaker 2: it is the local operating system. It has master control
- 5:13Speaker 2: over that one machine.
- 5:14Speaker 1: So it can do things even a domain admin might
- 5:17Speaker 1: be blocked from doing on that local box.
- 5:18Speaker 2: Absolutely. It can manipulate COROS functions bypass security controls aimed
- 5:23Speaker 2: at user accounts. It's the ultimate level of local control,
- 5:27Speaker 2: a massive privilege escalation.
- 5:29Speaker 1: So the command to trigger the task is run remotely
- 5:32Speaker 1: and the result is a new session, not as Peter Pan,
- 5:36Speaker 1: but as the OS itself.
- 5:38Speaker 2: That's the key distinction. A very powerful and very sneaky
- 5:41Speaker 2: way to move and escalate all in one go.
- 5:44Speaker 1: All right, So we have w MIIC for speed and
- 5:47Speaker 1: scheduled tasks for that privilege jump. What about our third method,
- 5:51Speaker 1: the Service Control Manager.
- 5:53Speaker 2: Ah, the SCM. Now, this is often the choice when
- 5:56Speaker 2: an attacker is thinking about long term presence stability.
- 6:00Speaker 1: This is the kind of technique we hear about in
- 6:02Speaker 1: the context of professional toolkits right command and control frameworks
- 6:06Speaker 1: or C.
- 6:06Speaker 2: Two's exactly. If you've ever heard of a tool called PSEZC,
- 6:10Speaker 2: it uses a very similar principle. It's all about creating, starting,
- 6:13Speaker 2: and then deleting a temporary service on the remote machine
- 6:15Speaker 2: to run your code.
- 6:16Speaker 1: It sounds a bit more involved than the other two methods.
- 6:19Speaker 2: It is it requires more setup. For one thing, you
- 6:23Speaker 2: can't just use a standard test dot Ex payload. Why
- 6:25Speaker 2: not stability a normal program isn't designed to run as
- 6:29Speaker 2: a Windows service. It doesn't know how to handle the
- 6:31Speaker 2: signals the SEM sends it. It would likely just crash.
- 6:34Speaker 1: So the attacker needs a special kind of payload.
- 6:37Speaker 2: Correct, they'd use a tool something like ms venom to
- 6:40Speaker 2: generate an executable that is specifically formatted as an XC service,
- 6:45Speaker 2: a payload built to behave like a proper service.
- 6:47Speaker 1: Okay, So they create this special file, maybe they call
- 6:49Speaker 1: it test service dot ex and they copy that to
- 6:53Speaker 1: the target seed drive.
- 6:54Speaker 2: Yep, And now we get to the core of the
- 6:55Speaker 2: attack creating the service remotely.
- 6:58Speaker 1: So there's a command to create create a brand new
- 7:00Speaker 1: service on the target.
- 7:02Speaker 2: Machine, right, and the most important part of that command
- 7:04Speaker 2: is setting the binpath. The binary path you tell the
- 7:07Speaker 2: new service the program you need to run is located
- 7:10Speaker 2: at ctestservice dot exe.
- 7:12Speaker 1: And once the service is created, you just run another
- 7:14Speaker 1: command to start it.
- 7:15Speaker 2: You start the service and just like the scheduled task,
- 7:18Speaker 2: a new session appears, and.
- 7:19Speaker 1: Let me guess, the user is system again.
- 7:22Speaker 2: It's system again. And the reason is fundamental to how
- 7:26Speaker 2: Windows works. Services need deep privileged access to the operating
- 7:31Speaker 2: system to do their jobs. They run in the background
- 7:34Speaker 2: interacting with the kernel.
- 7:35Speaker 1: So system is their natural state of being.
- 7:38Speaker 2: It is, and that's what makes this method so robust.
- 7:40Speaker 2: It's powerful, and it's designed for stability and persistence.
- 7:43Speaker 1: Okay, so let's put this all together for everyone listening.
- 7:46Speaker 1: We've got three different ways to move laterally using tools
- 7:49Speaker 1: that are already on every Windows network.
- 7:51Speaker 2: Right, w MIC, schedule tasks, and the Service Control Manager.
- 7:55Speaker 1: The common thread. The absolute requirement for all of them
- 7:59Speaker 1: was having those domain admin credentials to begin with. Our
- 8:03Speaker 1: Peter Pan account was the key that unlocked the.
- 8:05Speaker 2: Door without a doubt. But once that key is in hand,
- 8:08Speaker 2: these native tools can do all the heavy lifting. They
- 8:11Speaker 2: copy the payload and get you code execution on the
- 8:13Speaker 2: remote machine.
- 8:14Speaker 1: And two out of three of those methods, shasks and
- 8:17Speaker 1: SCM also gave us that crucial privilege escalation up to system.
- 8:22Speaker 2: Which is often the ultimate goal and post exploitation.
- 8:25Speaker 1: So this brings us to the really big question, the
- 8:27Speaker 1: final provocative thought. These tools WMIC, shasks, SCM, they're essential
- 8:34Speaker 1: for IT administration. You can't just turn them off.
- 8:36Speaker 2: You definitely can't. Your entire operation would probably grind to
- 8:40Speaker 2: a halt.
- 8:40Speaker 1: Hey, if you can't block the tools. How can an
- 8:43Speaker 1: organization possibly defend against this?
- 8:45Speaker 2: And that is the absolute heart of the challenge for defenders.
- 8:48Speaker 2: It's not about blocking the tool, it's about monitoring the behavior.
- 8:52Speaker 1: What does that look like in practice, Well.
- 8:55Speaker 2: You start looking for anomalies. Is a domain admin account
- 8:58Speaker 2: suddenly using w MIE to create a process and a
- 9:01Speaker 2: temp folder that's weird? Are you seeing new scheduled tasks
- 9:05Speaker 2: being created with dates in the past, or a.
- 9:07Speaker 1: New randomly named service that's created, started, and then deleted
- 9:11Speaker 1: just minutes later.
- 9:12Speaker 2: Exactly. You're hunting for the malicious use of a legitimate tool,
- 9:16Speaker 2: and understanding the technical details like the ones we've discussed
- 9:19Speaker 2: is the very first step to knowing what to look for.
- 9:21Speaker 1: So here's something for you to think about in your
- 9:23Speaker 1: own environment. Are you watching for that pivot? Can you
- 9:26Speaker 1: tell the difference between an admin using w MIC for
- 9:30Speaker 1: a valid reason and an attacker using it to execute payload?
- 9:33Speaker 1: That's where the real defense begins.