Latest / CyberCode Academy / Course 30 - Practical Malware Development - Beginner Level | Episode 1: C# Offensive Operations: Recon, Persistence, and File Acquisition
Transcript
- 0:00Speaker 1: Imagine for a second that you are a digital scout.
- 0:03Speaker 2: Okay, I'm with you.
- 0:04Speaker 1: You've just been entirely digitized, you know, parachuted down and
- 0:08Speaker 1: dropped into an unfamiliar, completely pitch black computer system.
- 0:12Speaker 2: Sounds pretty intimidating, honestly, right, you.
- 0:15Speaker 1: Have absolutely no idea where you are. You don't know
- 0:17Speaker 1: who owns the system, what kind of security trip wires
- 0:21Speaker 1: are scattered around, or even well what language the local
- 0:24Speaker 1: machine speaks.
- 0:25Speaker 2: You're just totally isolated, exactly.
- 0:27Speaker 1: You are just a tiny, isolated piece of logic floating
- 0:30Speaker 1: in a void. So what is your very first move?
- 0:34Speaker 2: Well, you need to figure out exactly where you are.
- 0:36Speaker 1: Yeah, you need to find a secure place to hide,
- 0:39Speaker 1: and then you know, wait quietly for further instructions.
- 0:42Speaker 2: Because if you make the wrong move in the dark,
- 0:44Speaker 2: I mean, you trip an alarm and then it's over. Yeah,
- 0:47Speaker 2: you get caught, quarantined, and deleted. So the survival of
- 0:50Speaker 2: that digital scout depends entirely on thoroughly understanding its environment
- 0:56Speaker 2: before taking well any significant action at all. It's a
- 1:00Speaker 2: game of absolute stealth.
- 1:01Speaker 1: Welcome to today's deep dive. Today we are going to
- 1:05Speaker 1: mentally walk through the step by step logic of creating
- 1:08Speaker 1: that exact digital scout from scratch.
- 1:12Speaker 2: And we're doing it using the C sharp programming language.
- 1:14Speaker 1: Right, we're looking at the real world programming techniques used
- 1:17Speaker 1: in cybersecurity, red teaming, and ethical hacking. We want to
- 1:23Speaker 1: see how software gathers intelligence, survives a system reboot, and
- 1:28Speaker 1: securely downloads new tools.
- 1:30Speaker 2: And the best part is we are going to do
- 1:31Speaker 2: all this purely through the underlying.
- 1:33Speaker 1: Logic, no screen required, Nope, We're.
- 1:36Speaker 2: Just going to build it block by block right here, which.
- 1:38Speaker 1: Is really I mean, it's the only way to truly
- 1:40Speaker 1: understand system architecture absolutely.
- 1:43Speaker 2: By understanding how these digital agents are built from the
- 1:45Speaker 2: ground up, you learn to think like a system administrator, sure,
- 1:49Speaker 2: but you also learn to think like an attacker.
- 1:51Speaker 1: You stop looking at the computer as just this, you know,
- 1:53Speaker 1: magic black box, right, and.
- 1:55Speaker 2: You start seeing the underlying gears and levers.
- 1:58Speaker 1: So let's start building. Our scout has just landed. Before
- 2:01Speaker 1: it can execute any kind of mission, it needs a map.
- 2:04Speaker 2: It needs to construct a central hub for gathering system data.
- 2:07Speaker 1: Yeah. So the very first piece of code we mentally
- 2:10Speaker 1: put together is a blueprint, or you know, a class
- 2:13Speaker 1: in programming.
- 2:14Speaker 2: Terms, specifically designed to gather intel. We usually call this
- 2:17Speaker 2: something like the general info class, and.
- 2:19Speaker 1: We'll use the native environment tools built right into c
- 2:22Speaker 1: sharp to start asking the operating system some basic questions, things.
- 2:26Speaker 2: Like, uh, what operating system version is this right?
- 2:30Speaker 1: What is the current username?
- 2:32Speaker 2: Or what specific directory did I just land in?
- 2:35Speaker 1: And we use the built in environment class to do
- 2:37Speaker 1: all that.
- 2:37Speaker 2: Right exactly, And we really have to think about how
- 2:39Speaker 2: we are asking these questions. I mean, we aren't hacking
- 2:43Speaker 2: into a restricted vault to get the information.
- 2:45Speaker 1: We aren't.
- 2:46Speaker 2: No, not at all. We're simply queering the operating systems
- 2:49Speaker 2: built in application programming interfaces or APIs.
- 2:53Speaker 1: Wait, let me make sure I'm following this. Sure, if
- 2:55Speaker 1: we are an unauthorized scout that just dropped into this machine,
- 3:00Speaker 1: why would the operating system just willingly hand over its
- 3:03Speaker 1: version number, the name of the user, and our location.
- 3:06Speaker 2: It seems counterintuitive, doesn't it? Yeah?
- 3:09Speaker 1: Doesn't it check our credentials first? Like who are you?
- 3:11Speaker 2: That is the core irony of system design. Honestly, the
- 3:14Speaker 2: operating system is fundamentally designed to be helpful, helpful to
- 3:18Speaker 2: who to developers. It assumes that if a program is running,
- 3:23Speaker 2: it must need this basic information to function correctly.
- 3:26Speaker 1: Oh, I see right.
- 3:28Speaker 2: Like a harmless video game needs to know your username
- 3:31Speaker 2: to save your high score, a text enitor needs to
- 3:34Speaker 2: know the current directory to save your document.
- 3:36Speaker 1: So the system wants to provide this data so software
- 3:39Speaker 1: runs smoothly, exactly.
- 3:41Speaker 2: So when our scout asks for the operating system version
- 3:43Speaker 2: using the environment class, Windows doesn't interrogate the scout, It
- 3:47Speaker 2: just politely hands over the data.
- 3:49Speaker 1: Okay, so the system is trusting by default. We ask
- 3:52Speaker 1: for the OS version and it hands it over. But
- 3:54Speaker 1: I imagine it doesn't just hand us a simple English sentence.
- 3:57Speaker 2: No, it doesn't. It hands back a complex digital object,
- 4:00Speaker 2: just a bundle of raw system data.
- 4:02Speaker 1: But humans and you know, the remote server, we eventually
- 4:05Speaker 1: want to send this INTEL back to They need readable text.
- 4:10Speaker 2: Right, So we run a very common conversion function to
- 4:13Speaker 2: translate that raw complex data object into a clean, standard
- 4:18Speaker 2: tech string.
- 4:19Speaker 1: We are standardizing our INTEL as we gather it.
- 4:22Speaker 2: That's a great way to put it.
- 4:23Speaker 1: Yeah, that makes total sense. We translate it so we
- 4:25Speaker 1: can actually read it later. So now we have the OS,
- 4:28Speaker 1: the user, and the folder we are sitting in. Next,
- 4:31Speaker 1: we need to figure out our disguise We need.
- 4:33Speaker 2: To know what process we are currently hiding inside.
- 4:37Speaker 1: Right, So we use the system diagnostics name space. Specifically,
- 4:41Speaker 1: we query the process class to grab the current process
- 4:45Speaker 1: name and the process id PID and visualizing this like
- 4:48Speaker 1: looking down at our own uniform to see what nametag
- 4:51Speaker 1: we're wearing.
- 4:51Speaker 2: It's a little deeper than just a name tag.
- 4:53Speaker 1: Actually, oh really, how so?
- 4:55Speaker 2: Well, a nametag implies you could just write whatever you
- 4:57Speaker 2: want on a sticker.
- 4:58Speaker 1: I guess so.
- 4:58Speaker 2: Yeah, But the process, the PID, that's the operating system's
- 5:02Speaker 2: absolute internal ledger. You could have five different programs running
- 5:06Speaker 2: right now, all named Google Chrome. The name is just
- 5:10Speaker 2: a label, but the system assigns a completely unique numerical
- 5:14Speaker 2: ID to every single active task.
- 5:17Speaker 1: Ah. So by querying the system for our exact PID,
- 5:22Speaker 1: the agent knows precisely which slot it occupies in the
- 5:25Speaker 1: computer's memory ledger exactly.
- 5:27Speaker 2: It knows its exact disguise on a mechanical level.
- 5:29Speaker 1: So it's checking the official roster, not just looking at
- 5:32Speaker 1: a label. That's a crucial distinction, very crucial. Okay, so
- 5:35Speaker 1: we know our identity. Now what about our location in
- 5:38Speaker 1: the broader world? We need our network address.
- 5:40Speaker 2: Right time to bring in the system that tools, So.
- 5:43Speaker 1: We use the DNS class to fetch the host name
- 5:46Speaker 1: and the IPv four address.
- 5:48Speaker 2: Think of this like the scout figuring out its exact
- 5:50Speaker 2: GPS coordinates. If it ever wants to call for an
- 5:53Speaker 2: extraction or receive a supply drop, it has to know
- 5:56Speaker 2: its own address. Makes sense, But there is a mechanical
- 5:59Speaker 2: catch here. When you ask a modern computer for its
- 6:02Speaker 2: IP address, it doesn't always have just one.
- 6:04Speaker 1: Oh, right, because I might be connected to Wi Fi,
- 6:06Speaker 1: but I also have an Ethernet port and maybe a
- 6:08Speaker 1: virtual private network running in the background.
- 6:10Speaker 2: Precisely, you've got multiple adapters, so the system might return
- 6:15Speaker 2: an entire list of addresses.
- 6:17Speaker 1: So our code has to be highly specific, right.
- 6:19Speaker 2: We have to program the logic to look at that
- 6:21Speaker 2: list of network adapters and grab the first valid active
- 6:24Speaker 2: address it finds.
- 6:25Speaker 1: And then we extract that specific coordinate, and again we
- 6:28Speaker 1: translate it into a readable text string.
- 6:31Speaker 2: You're getting the hang of it.
- 6:32Speaker 1: Yeah, we are building up quite the dossier here. But
- 6:35Speaker 1: there is one final check for our reconnaissance phase, and
- 6:39Speaker 1: I imagine it's the most important one.
- 6:40Speaker 2: It definitely is.
- 6:41Speaker 1: We need to know our clearance level, so we use
- 6:45Speaker 1: the Windows Identity and Windows principle classes to see does
- 6:50Speaker 1: our current user have administrator privileges?
- 6:53Speaker 2: This is the golden question for any piece of software.
- 6:56Speaker 1: Why is it so critical?
- 6:57Speaker 2: Because administrator privileges dictate what you can and cannot do
- 7:01Speaker 2: on a mechanical.
- 7:01Speaker 1: Level, like permissions.
- 7:03Speaker 2: Right, if you are a standard user, you are restricted
- 7:06Speaker 2: to your own little sandbox. You can change your desktop wallpaper, sure,
- 7:11Speaker 2: but you can't modify system wide files.
- 7:13Speaker 1: But if you have administrator rights, then you have.
- 7:15Speaker 2: The master key. You can turn off the antivirus, you
- 7:19Speaker 2: can read the memory of other programs. You could rewrite
- 7:21Speaker 2: the rules of the system itself.
- 7:22Speaker 1: Wow. Okay, So to recap our first moves, we dropped
- 7:26Speaker 1: into the dark, and by simply asking the operating systems
- 7:30Speaker 1: built in helpful developer tools, We've mapped out our OS,
- 7:34Speaker 1: our exact memory, ledger ID, our network, GPS coordinates, and
- 7:38Speaker 1: whether or not we hold the master key.
- 7:40Speaker 2: Not bad for a few lines of code, not bad
- 7:42Speaker 2: at all.
- 7:43Speaker 1: But right now, our scout is entirely fragile. Right, it's
- 7:46Speaker 1: just living in the computer's temporary memory, the RAM.
- 7:48Speaker 2: That's right.
- 7:49Speaker 1: What happens if the person sitting at the keyboard accidentally
- 7:52Speaker 1: kicks the power cord.
- 7:53Speaker 2: It's game over. RAM is volatile memory. The moment the
- 7:57Speaker 2: power drops or the moment the user clicks restart, that
- 8:00Speaker 2: memory is wiped, completely clean, just gone gone. If you
- 8:03Speaker 2: haven't prepared for that blackout, your digital scout is erased
- 8:07Speaker 2: from existence, which.
- 8:08Speaker 1: Means we can't just gather intel. We have to survive.
- 8:10Speaker 1: We need to build a mechanism for persistence.
- 8:13Speaker 2: Yes, persistence is key.
- 8:15Speaker 1: We need to guarantee that our agent automatically wakes back
- 8:17Speaker 1: up the moment the power comes back on and the
- 8:19Speaker 1: system restarts.
- 8:20Speaker 2: Because without persistence, any digital foothold is just temporary. You'd
- 8:25Speaker 2: have to start from scratch and find a way back
- 8:27Speaker 2: into the machine every single morning.
- 8:28Speaker 1: That sounds exhausting. So let's logically construct this persistence mechanism.
- 8:33Speaker 1: We'll create a new blueprint called the persistence class. Okay,
- 8:37Speaker 1: and we need to link our agent's executable file to
- 8:40Speaker 1: the Windows boot sequence. And to do that, we aren't
- 8:43Speaker 1: just dragging a file into a startup folder on the desktop,
- 8:46Speaker 1: are we No?
- 8:47Speaker 2: No, we are going straight into this central nervous system
- 8:50Speaker 2: of Windows, the registry.
- 8:52Speaker 1: The registry. So we pull in the Microsoft Win thirty
- 8:54Speaker 1: two registry package. What exactly is the registry for someone
- 8:58Speaker 1: who hasn't poked around in it?
- 9:00Speaker 2: The registry is this massive, highly complex, hierarchical database. It
- 9:05Speaker 2: stores the low level settings for everything, everything pretty much.
- 9:09Speaker 2: It remembers what your mouse cursor speed is, it remembers
- 9:12Speaker 2: what program to use when you open the PDF, and crucially,
- 9:15Speaker 2: it remembers exactly which programs are authorized to launch themselves
- 9:19Speaker 2: automatically when the computer turns on.
- 9:21Speaker 1: So we access the registry, we write a function using
- 9:25Speaker 1: an open subkey method that opens the specific pathway that
- 9:28Speaker 1: controls the current user's startup sequence. But as we write
- 9:32Speaker 1: this code, we have to pass a very specific command
- 9:36Speaker 1: to that open subkey method. We have to pass the
- 9:38Speaker 1: flag true. Why is that single word so important.
- 9:42Speaker 2: Because it dictates your intent.
- 9:44Speaker 1: Intent.
- 9:44Speaker 2: Yeah. By default, when any program asks to open a
- 9:48Speaker 2: registry key, Windows assumes you just want to look at it.
- 9:51Speaker 2: It grants you read.
- 9:52Speaker 1: Only access ah like a safety mechanism exactly.
- 9:55Speaker 2: It's a safety mechanism to stop clumsy programs from accidentally
- 9:59Speaker 2: deleting criticals system settings. So if you want to actually
- 10:02Speaker 2: modify the registry, you have to explicitly declare it.
- 10:04Speaker 1: So passing that true flag tells the operating system grant
- 10:08Speaker 1: me right access. I am purposely going to change the.
- 10:10Speaker 2: Setting right on the money.
- 10:12Speaker 1: Okay, so we declare our intent, we get right access.
- 10:15Speaker 1: Now we use a set value method to actually plant
- 10:18Speaker 1: the flag. First, we have to name our entry, and
- 10:21Speaker 1: obviously we don't name it something like secret recon Agent.
- 10:24Speaker 2: No, that would be a terrible idea.
- 10:26Speaker 1: We give it a boring, unassuming name that just blends
- 10:29Speaker 1: in something like Windows Update helper or I don't know,
- 10:33Speaker 1: audio drivers sing right, because.
- 10:35Speaker 2: A human administrator might eventually look at this list. You
- 10:38Speaker 2: want their eyes to just glaze right over it.
- 10:40Speaker 1: But the name isn't enough. We have to tell the
- 10:42Speaker 1: registry exactly what file to run. When the computer boots up.
- 10:46Speaker 1: We have to feed it the exact filepath of our
- 10:48Speaker 1: executable And.
- 10:49Speaker 2: Here is where the logic loops back on itself in
- 10:52Speaker 2: a really elegant way. How so well, how does our
- 10:55Speaker 2: persistence code know where the executable file is currently located?
- 10:59Speaker 1: Oh oh, we asked the general infoclass we built in
- 11:03Speaker 1: step one exactly.
- 11:04Speaker 2: It is a perfect piece of self referential logic. The
- 11:07Speaker 2: agent essentially asks itself where am I currently running from
- 11:11Speaker 2: that's brilliant. It grabs its own filepath, hands that path
- 11:15Speaker 2: to the registry and says, every time the power comes on,
- 11:18Speaker 2: go to this exact spot and wake me up.
- 11:20Speaker 1: Once that's written, we close the registry key properly to
- 11:24Speaker 1: clean up after ourselves. And if you were to open
- 11:26Speaker 1: the Windows Task Manager right then and click over to
- 11:28Speaker 1: the startup tab, there is Windows Update Helper fully authorized,
- 11:33Speaker 1: sitting right next to Spotify and Slack set to run
- 11:36Speaker 1: on the next boot.
- 11:37Speaker 2: And you did it entirely with standard C sharp commands.
- 11:39Speaker 1: You know, here's where it gets really interesting to me.
- 11:42Speaker 1: It's exactly like slipping a spare key under the doormat,
- 11:45Speaker 1: but the doormat is the core boot sequence of the
- 11:49Speaker 1: operating system.
- 11:50Speaker 2: That's a great analogy.
- 11:51Speaker 1: But if it's this easy to write a registry key
- 11:53Speaker 1: and hide in the startup sequence, shouldn't manually checking that
- 11:57Speaker 1: Task Manager startup tab be a regular security habit for
- 12:00Speaker 1: all of us?
- 12:00Speaker 2: Absolutely? If we connect this to the bigger picture, the
- 12:04Speaker 2: registry is highly trusted by the operating system.
- 12:07Speaker 1: Right.
- 12:08Speaker 2: We spend so much time worrying about firewalls and external defenses,
- 12:13Speaker 2: but security isn't just about firewalls blocking outside threats. A
- 12:17Speaker 2: firewall only keeps people out of the house.
- 12:20Speaker 1: But once someone is already inside.
- 12:22Speaker 2: The firewall is useless. Security is about regularly auditing these
- 12:27Speaker 2: internal doormats to see what has been granded persistence. You
- 12:31Speaker 2: should recognize every single program that is waking up when
- 12:34Speaker 2: your computer wakes up.
- 12:35Speaker 1: It's like checking to make sure your front door is
- 12:37Speaker 1: actually locked before you go to bed. Just a baseline
- 12:39Speaker 1: habit exactly all right. So let's look at our scout. Yeah,
- 12:43Speaker 1: it has a map of the system, it knows its disguise,
- 12:46Speaker 1: and it has safely tucked a spare key under the
- 12:49Speaker 1: registry doormat, so it survives a blackout.
- 12:51Speaker 2: Pretty capable scout so far.
- 12:52Speaker 1: But if it just sits there forever, I mean it's useless.
- 12:55Speaker 1: It needs to be able to adapt. It needs new orders, right.
- 12:57Speaker 2: An agent without a communication module is just a wormant
- 13:00Speaker 2: piece of code. It needs a way to receive instructions
- 13:03Speaker 2: and pull down new tools based on what it found
- 13:06Speaker 2: during its reconnaissance.
- 13:07Speaker 1: So we build our final logical block, the Operations class.
- 13:11Speaker 1: This handles communication.
- 13:13Speaker 2: And it needs two main functions, a command parser and
- 13:16Speaker 2: a download file function.
- 13:17Speaker 1: Let's start with the parser. Inside this block, we need
- 13:20Speaker 1: a way to make sense of the instructions we receive.
- 13:23Speaker 1: Let's say our scout receives a raw text command from
- 13:26Speaker 1: a remote server. The command says download https dot Google
- 13:31Speaker 1: dot com by index dot html. Oh. I'm thinking of
- 13:36Speaker 1: this parsing process like a tiny mail sorting room inside
- 13:40Speaker 1: the code, throwing different commands into different bins.
- 13:43Speaker 2: Actually, a mail sorting room implies you have a bunch
- 13:46Speaker 2: of different bins, and you're just tossing the whole letter
- 13:48Speaker 2: into one of them.
- 13:48Speaker 1: Oh, is it different.
- 13:49Speaker 2: The mechanism here is much more precise. It's more like
- 13:52Speaker 2: a bouncer at a secure club checking an ID.
- 13:54Speaker 1: Okay, I like that.
- 13:55Speaker 2: How So when the bouncer looks at your ID, they
- 13:58Speaker 2: are splitting the information. They look at your age that's
- 14:01Speaker 2: the action. Are you allowed in? Yes or no? Then
- 14:04Speaker 2: they look at your name. That's the target. Who exactly
- 14:06Speaker 2: are you. Our code does the exact same thing with
- 14:08Speaker 2: that text command. It uses a built in string split
- 14:11Speaker 2: function to physically chop the sentence in half the moment
- 14:14Speaker 2: it sees a space character.
- 14:16Speaker 1: Ah, I see, So it takes the string download https
- 14:19Speaker 1: doc Google dot com by a bandex dot HTML finds
- 14:22Speaker 1: the space and cuts it right exactly there.
- 14:25Speaker 2: Exactly the first word download that tells the code what
- 14:27Speaker 2: to do. The internal logic reads that word and says,
- 14:31Speaker 2: I recognize this command. I need to spin up the
- 14:34Speaker 2: download function, and.
- 14:35Speaker 1: The second part, the URL, is passed along as the target.
- 14:38Speaker 1: The bouncer has verified the action, and now it passes
- 14:40Speaker 1: the target URL into the club slightly, so the download
- 14:43Speaker 1: file function spins up. We utilize the web client class
- 14:46Speaker 1: to reach out to the Internet and grab the file
- 14:49Speaker 1: from that target URL.
- 14:50Speaker 2: But that brings up a massive operational problem.
- 14:53Speaker 1: Where do we save it?
- 14:54Speaker 2: Exactly? We are downloading a new tool into a computer
- 14:58Speaker 2: we don't own. Where on Earth do we? We can't
- 15:01Speaker 2: just drop a new file onto the user's desktop.
- 15:03Speaker 1: No stealth dictates that you never put a file where
- 15:06Speaker 1: a human actively looks. You need a place that is
- 15:08Speaker 1: naturally chaotic, a place the system itself uses to dump garbage,
- 15:13Speaker 1: like what the temporary folder. We use the path class
- 15:16Speaker 1: to quietly ask the system where its temp folder is located.
- 15:20Speaker 1: This usually lives hidden away deep in a user's app
- 15:22Speaker 1: data local temp directory. It's the digital equivalent of a
- 15:26Speaker 1: junk drawer.
- 15:26Speaker 2: And this raises an important question. Notice how the attacker
- 15:30Speaker 2: uses the temp folder specifically.
- 15:32Speaker 1: Yeah, why is that such a prime target?
- 15:34Speaker 2: Think about the life cycle of a computer. Every time
- 15:37Speaker 2: you install a program, every time a browser cache is
- 15:40Speaker 2: an image, it creates a temporary file. The system is
- 15:44Speaker 2: a space specifically designed for digital clutter.
- 15:47Speaker 1: And it rarely gets cleaned out perfectly.
- 15:49Speaker 2: Never. As a result, the temp folder becomes a massive
- 15:52Speaker 2: haystack of poorly named random files. Attackers love these noisy
- 15:57Speaker 2: folders because a newly downloaded, unoff theorized tool blends right
- 16:01Speaker 2: in with ten thousand perfectly normal system files.
- 16:05Speaker 1: It's hiding in planeside by hiding in the mess exactly.
- 16:08Speaker 1: So we know we want to drop the file in
- 16:09Speaker 1: the temp folder, But our code runs into a technical
- 16:12Speaker 1: hurdle here. When we ask the system for the temp folder,
- 16:15Speaker 1: it just gives us the pathway, It says, the drawers
- 16:17Speaker 1: over here. But to actually save the file, our web
- 16:20Speaker 1: client needs the full path, including the new file's name.
- 16:24Speaker 1: It needs to know exactly what to write on the label.
- 16:26Speaker 2: And we can't just hardcode a generic name into our
- 16:29Speaker 2: code because tomorrow the remote server might command us to
- 16:32Speaker 2: download a text file or a script or a zipped folder.
- 16:35Speaker 1: So the scout needs to dynamically figure out the name
- 16:38Speaker 1: of the file it is downloading based purely on the
- 16:41Speaker 1: URL it was given.
- 16:42Speaker 2: Yep, And how do we do that?
- 16:43Speaker 1: We use another clever string splitting trick. We take that
- 16:47Speaker 1: target URL and we tell the code to split the
- 16:49Speaker 1: sentence every single time it sees a forward slash. It
- 16:53Speaker 1: chops the URL into an array of smaller pieces, and
- 16:56Speaker 1: we just program the code to dynamically grab the very
- 16:59Speaker 1: last l based on the total length of the URL.
- 17:02Speaker 1: That last piece, like index dot html, becomes our clean,
- 17:06Speaker 1: newly saved file name.
- 17:07Speaker 2: Conceptually yes, yeah, but mechanically, how do you tell the
- 17:11Speaker 2: computer to grab the final piece? You have to count
- 17:13Speaker 2: the pieces in the array, right, And here is where
- 17:16Speaker 2: a classic programming quirk trips up almost every beginner. When
- 17:19Speaker 2: you chop a string into an array, which is basically
- 17:22Speaker 2: a digital filing cabinet, the computer does not start counting
- 17:25Speaker 2: those files at the number one. It starts counting as zero.
- 17:28Speaker 1: Wait, really, so the first piece is zero?
- 17:30Speaker 2: Yes, it has to do with how memory offsets work
- 17:34Speaker 2: under the hood, measuring the distance from the very start
- 17:37Speaker 2: of the array. Oh wow, so the first piece is
- 17:39Speaker 2: at index zero. The second piece is at index one.
- 17:42Speaker 2: So if your URL chopped up into three pieces, you
- 17:45Speaker 2: don't ask the code for piece number three. You have
- 17:48Speaker 2: to ask it for piece number two.
- 17:49Speaker 1: Oh, I see, because zero one, two, that's three items.
- 17:54Speaker 1: The last item is at position two. So to make
- 17:56Speaker 1: this dynamic, our code calculates the total length of the array,
- 18:00Speaker 1: subtracts one to account for the zero index, and grabs
- 18:03Speaker 1: whatever is sitting in that final slot.
- 18:05Speaker 2: Exactly, and that gives you your clean file name.
- 18:08Speaker 1: So what does this all mean? The program isn't just
- 18:11Speaker 1: mindlessly downloading it's self sufficiently reading the errol, chopping it
- 18:15Speaker 1: into an array where the counting starts at zero, and
- 18:17Speaker 1: stitching that final piece onto the temp folder path.
- 18:20Speaker 2: It builds the perfect customized hiding spot on the fly.
- 18:23Speaker 2: It's a completely closed, self sustaining loop.
- 18:26Speaker 1: And we built it entirely out of thin air. Our
- 18:28Speaker 1: digital scout dropped into the dark. It mapped its environment
- 18:31Speaker 1: and checked its privileges by asking the operating system for
- 18:34Speaker 1: its internal ledger. It slid a spare key under the
- 18:38Speaker 1: registry doormat so it could survive the power being cut,
- 18:41Speaker 1: and it built a bouncer to parse.
- 18:43Speaker 2: Texts right, you realize that software interacting with an operating
- 18:47Speaker 2: system is entirely agnostic. The machine doesn't know good from evil.
- 18:52Speaker 2: It just evaluates the logic and executes the blueprint.
- 18:55Speaker 1: It's just a series of levers being pulled in the
- 18:56Speaker 1: right order.
- 18:57Speaker 2: And that reality leaves us with a fascinating, lingering, philosophical
- 19:02Speaker 2: question to ponder. What's that We just spent this entire
- 19:05Speaker 2: deep dive exploring how native tools designed purely to make
- 19:09Speaker 2: software development smooth and efficient are the exact same tools
- 19:12Speaker 2: used to silently compromise a system. So how do we
- 19:16Speaker 2: as a society draw the line between a helpful system
- 19:19Speaker 2: feature and a security vulnerability.
- 19:22Speaker 1: That's definitely a provocative thought and a question that will
- 19:25Speaker 1: change how you look at your own machine. Until next time,
- 19:28Speaker 1: keep exploring the architecture of the world around you, and
- 19:31Speaker 1: remember to check your digital doormats.