Latest / CyberCode Academy / Course 14 - Wi-Fi Pentesting | Episode 4: Cracking WEP Encryption: Gaining Network Access
Transcript
- 0:00Speaker 1: Welcome back to the deep dive. Our mission today is
- 0:03Speaker 1: as a really crucial leap. We're moving you from just
- 0:07Speaker 1: passive network observation, you know, just listening to the chatter,
- 0:11Speaker 1: to active participation.
- 0:13Speaker 2: And that passive phase which we've covered is absolutely essential
- 0:17Speaker 2: for gathering data. But the real intelligence, the real action,
- 0:20Speaker 2: lies inside the network.
- 0:22Speaker 1: Right.
- 0:22Speaker 2: The difference between just watching traffic go by and actually
- 0:25Speaker 2: being part of that conversation, well, it's like the difference
- 0:28Speaker 2: between reading a headline and getting the full intelligence dots exactly.
- 0:33Speaker 1: Once you actually connect, the scope of what you can
- 0:36Speaker 1: do just changes dramatically. We're talking about gathering massive amounts
- 0:39Speaker 1: of information, intercepting connections and.
- 0:42Speaker 2: Potentially seeing everything user names, passwords, sensitive URLs.
- 0:46Speaker 1: And the ultimate goal maybe even modifying the data that's
- 0:48Speaker 1: flowing through.
- 0:49Speaker 2: But there's always a gatekeeper, and usually it's encryption. Now,
- 0:53Speaker 2: if you're dealing with a wired connection or a really
- 0:56Speaker 2: negligent Wi Fi network with no encryption at all, connecting
- 0:59Speaker 2: is trivial.
- 1:00Speaker 1: You just plug in our click connect, right.
- 1:02Speaker 2: The real challenge and our focus for this deep dive
- 1:05Speaker 2: is bypassing encrypted wireless.
- 1:07Speaker 1: Networks, and we're going to start at the very beginning
- 1:10Speaker 1: by going right for the weakest link Wired Equivalent privacy
- 1:14Speaker 1: or WEP.
- 1:15Speaker 2: Now, WEP is largely a thing of the past, but
- 1:18Speaker 2: you do still occasionally find it, maybe in older industrial systems,
- 1:22Speaker 2: legacy devices, things that.
- 1:23Speaker 1: Haven't been updated in years.
- 1:25Speaker 2: Precisely, but more importantly for you, the learner, it's the
- 1:28Speaker 2: perfect simplest example of how network security can just catastrophically fail.
- 1:32Speaker 2: If you understand how WEP breaks, you really get the
- 1:36Speaker 2: foundational principles that all the stronger protocols had to solve.
- 1:39Speaker 1: Okay, so let's unpack this. We need to understand how
- 1:42Speaker 1: WEP is supposed to work, and then more importantly, find
- 1:45Speaker 1: that one design choice that just turned it into tissue paper.
- 1:48Speaker 2: So WP uses a well known algorithm called RC four
- 1:52Speaker 2: to encrypt the data. The concept itself is pretty sound.
- 1:55Speaker 2: A device encrypt's plain texts with the secret key, turns
- 1:57Speaker 2: it into jibbers and crypto packet, and sends it out.
- 2:01Speaker 1: And the receiver who has the same key can just
- 2:04Speaker 1: decrypt it back exactly.
- 2:06Speaker 2: Anyone else who captures that packet midair without the key
- 2:09Speaker 2: just sees the gibberish.
- 2:10Speaker 1: So the cipher itself, RC four is actually fine, it's
- 2:13Speaker 1: the architecture around it that fails.
- 2:14Speaker 2: That's it, one hundred percent. The fatal flaw isn't in
- 2:17Speaker 2: the math of RC four. It's entirely in WP's implementation,
- 2:22Speaker 2: the specific rules it uses for handling the keys.
- 2:25Speaker 1: What was it trying to do?
- 2:26Speaker 2: It was actually trying to be more secure. The idea
- 2:28Speaker 2: was that every single packet transmitted would use a slightly
- 2:31Speaker 2: different unique encryption key.
- 2:33Speaker 1: Okay, and how did it try to achieve that uniqueness.
- 2:37Speaker 2: By creating a kind of hybrid key. It would take
- 2:40Speaker 2: the permanent network password, the shared key that you type in,
- 2:43Speaker 2: and combine it with a seemingly random twenty four bit number.
- 2:46Speaker 2: That number is called the initialization vector or five.
- 2:49Speaker 1: To nine, and that combination creates the unique key for
- 2:53Speaker 1: just that one packet.
- 2:54Speaker 2: Yes, it generates a unique stream of bits the keystream
- 2:57Speaker 2: used only for that specific packet.
- 2:59Speaker 1: A twenty four bit number. Help me quantify that. Twenty
- 3:01Speaker 1: four bits sounds like a lot, But in computing terms,
- 3:04Speaker 1: how big is it really?
- 3:05Speaker 2: Well, twenty four bits gives you exactly sixteen million, seven
- 3:08Speaker 2: hundred and seven two hundred and sixteen unique combination.
- 3:11Speaker 1: Okay, that sounds like a big number.
- 3:13Speaker 2: It sounds big, but think about a busy corporate Wi
- 3:15Speaker 2: Fi network, or even just a home network where someone
- 3:18Speaker 2: is streaming a movie. You can easily generate thousands of
- 3:22Speaker 2: packets every single second.
- 3:24Speaker 1: So you'd burn through those sixteen point seven million combination.
- 3:27Speaker 2: Very very quickly. And that's the first major problem, the
- 3:31Speaker 2: IV shortage. They start recycling those keys way too often.
- 3:36Speaker 1: We call that a collision, right, that's right.
- 3:38Speaker 2: A collision. But even that repetition wouldn't be completely fatal
- 3:42Speaker 2: if it wasn't for the second critical vulnerability, which is
- 3:45Speaker 2: the IV visibility.
- 3:46Speaker 1: Okay, what's that.
- 3:47Speaker 2: To let the receiver the router know how to decrypt
- 3:49Speaker 2: the packet, WEP had to stick that twenty four bit
- 3:53Speaker 2: IV onto the packet and send it out in plain text.
- 3:55Speaker 1: Wait, hold on, they sent the random part, the piece
- 3:58Speaker 1: that's supposed to make e key unique, right alongside the
- 4:02Speaker 1: encrypted data completely unencrypted.
- 4:04Speaker 2: They did that is the single implementation error that makes
- 4:07Speaker 2: the entire system just fall apart. As the attacker you
- 4:09Speaker 2: capture the encrypted packet and the exact random number used
- 4:13Speaker 2: to create its key stream.
- 4:14Speaker 1: Why would they do that and what was the thinking there?
- 4:17Speaker 2: Because the IV needed a change for every packet, the
- 4:20Speaker 2: receiver had to know which one was used to start
- 4:22Speaker 2: the decryption. They treated the IV as public and the
- 4:26Speaker 2: shared key is secret. They just didn't realize that when
- 4:29Speaker 2: you combine a visible repeating IV with known weaknesses in
- 4:33Speaker 2: RC four, you create the perfect recipe for a statistical attack.
- 4:37Speaker 1: So the combination of a visible repeating IV, let's an
- 4:40Speaker 1: attacker gather enough data, do some analysis, and eventually figure
- 4:44Speaker 1: out the static network password itself.
- 4:46Speaker 2: That's it.
- 4:46Speaker 1: So the weakness isn't the luck. It's the fact that
- 4:48Speaker 1: the combination to the safe is written on a short,
- 4:51Speaker 1: frequently recycled slip of paper that's taped to the front
- 4:54Speaker 1: of the door.
- 4:54Speaker 2: That is a perfect analogy. That short visible IV is
- 4:58Speaker 2: the undoing of WVP.
- 4:59Speaker 1: All right, let's move this from theory into practice. We'll
- 5:02Speaker 1: start with the easiest scenario, a busy network. Let's say
- 5:06Speaker 1: a busy coffee shop or university campus. The IV count
- 5:09Speaker 1: should be climbing really fast. What's our strategy.
- 5:12Speaker 2: It's actually very simple, just passive collection. We just need
- 5:15Speaker 2: to capture enough packets with those repeating ivs for our
- 5:18Speaker 2: statistical attack to work. We don't have to do anything
- 5:21Speaker 2: to the network it's doing all the work for us.
- 5:23Speaker 1: Okay. For the practical process, you're going to need a
- 5:26Speaker 1: suite of tools. The most common one is the air
- 5:28Speaker 1: crapping suite. Step one is getting your wireless adapter into
- 5:32Speaker 1: what's called monitor mode, which.
- 5:33Speaker 2: Lets it see all the Wi Fi traffic in the air,
- 5:36Speaker 2: not just the traffic men for your computer.
- 5:38Speaker 1: Right. Then we use the capturing tool it's often called
- 5:41Speaker 1: aero dumping to target our specific network. We'll need its BSSID,
- 5:45Speaker 1: which is basically the router's MC address, and its channel number.
- 5:50Speaker 2: You point the tool at that target and tell it
- 5:52Speaker 2: to save all the captured traffic into a file.
- 5:54Speaker 1: As you're watching the screen, there's one key metric to
- 5:56Speaker 1: look for, the data column. This number represents the count
- 6:01Speaker 1: of packets you've captured that have unique ivs, and on.
- 6:04Speaker 2: A busy network, you'll see that data number just increasing
- 6:08Speaker 2: at an incredible rate. You're just waiting for enough of
- 6:10Speaker 2: those ivs to give you statistical redundancy for a standard
- 6:14Speaker 2: WEP key. You might only need, say a few tens
- 6:17Speaker 2: of thousands of them.
- 6:18Speaker 1: Once that iv count is high enough, we move on
- 6:20Speaker 1: to step two, the final step the cracking program. We
- 6:24Speaker 1: run another tool from the suite air cracking against the
- 6:28Speaker 1: file we just saved.
- 6:29Speaker 2: And this is where the magic the statistics kicks in.
- 6:32Speaker 2: The program analyzes that file. It looks for all those collisions,
- 6:37Speaker 2: those repeating ivs, and it uses some really clever analysis
- 6:41Speaker 2: to work backward and figure out the keystream.
- 6:43Speaker 1: And since the keystream is made from the static password
- 6:46Speaker 1: and the IV, figuring out one basically reveals the other exactly.
- 6:50Speaker 2: The program eventually just spins out the network key for you.
- 6:53Speaker 1: It'll usually appear as a long hexadecimal string, sometimes with
- 6:57Speaker 1: colons separating the bytes. Now, for the real world art,
- 7:00Speaker 1: once you have that key, you need to format it
- 7:03Speaker 1: correctly to actually connect.
- 7:05Speaker 2: That's a good point. Most operating systems they want the
- 7:07Speaker 2: raw string. So you just copy that key, you give
- 7:10Speaker 2: it to the call ons or any dashes, and you're
- 7:12Speaker 2: left with one long string of characters.
- 7:14Speaker 1: And that string is your WEP network password. You paste
- 7:18Speaker 1: that in and just like that, the gate is open.
- 7:20Speaker 2: You've gone from being an outsider to an insider.
- 7:23Speaker 1: That's the textbook case. Well, let's talk about a more
- 7:26Speaker 1: challenging scenario. What if the target network is idle, You know,
- 7:30Speaker 1: a small home network at three in the morning.
- 7:32Speaker 2: Ah yeah, the idle network. That's a real challenge because
- 7:35Speaker 2: that IV count increases so slowly. If you just wait,
- 7:39Speaker 2: you could be sitting there for hours, maybe even days,
- 7:43Speaker 2: just to gather enough data.
- 7:44Speaker 1: We can't rely on natural traffic. We have to provoke
- 7:48Speaker 1: the access point the router to generate new traffic for us.
- 7:52Speaker 2: Exactly, we need to force it to create new packets
- 7:54Speaker 2: on our schedule. But you can't just send it things, right.
- 7:58Speaker 2: The router is designed to ignore packets from random, unknown devices.
- 8:02Speaker 1: So we need to introduce ourselves first.
- 8:04Speaker 2: We do this requires a preliminary step called association. See
- 8:08Speaker 2: by default, and AP just treats your device like background noise.
- 8:12Speaker 2: Association is a low level handshake where we basically tell
- 8:15Speaker 2: the AP, hey I exist, I'd like to be a client.
- 8:18Speaker 1: It's like saying, please don't ignore my future requests.
- 8:20Speaker 2: That's it.
- 8:20Speaker 1: So let's be really clear for the listener. Association is
- 8:23Speaker 1: not a connection, right, we still don't have the password.
- 8:25Speaker 1: We can't get on the internet.
- 8:26Speaker 2: Absolutely not. It's a crucial distinction. We are not authenticated,
- 8:30Speaker 2: we're merely associated. We've just registered our MSc address with
- 8:34Speaker 2: the AP, which is something wep's trust model allows us
- 8:39Speaker 2: to do far too easily.
- 8:40Speaker 1: Okay, so how do we force that association without having
- 8:43Speaker 1: the key?
- 8:44Speaker 2: We use another tool, airplane to perform what's called a
- 8:47Speaker 2: fake authentication attack. We're essentially exploiting that weak association process
- 8:52Speaker 2: in WEP to.
- 8:53Speaker 1: Trick the router, and to run this attack, we need
- 8:56Speaker 1: to give the tool a few specific pieces of information.
- 8:59Speaker 2: That's right. You have to specify by the attack type,
- 9:00Speaker 2: which is fake authentication. You give the MSc address of
- 9:04Speaker 2: the target AP, and critically, you supply the MAAC address
- 9:08Speaker 2: of your own attacking wireless adapter.
- 9:10Speaker 1: And that command basically tells the AP, Hey, I'm a
- 9:13Speaker 1: new device, please register me.
- 9:14Speaker 2: And when you run it, the attack spoofs the necessary
- 9:17Speaker 2: packets and the AP is tricked into adding our adapter
- 9:21Speaker 2: to its list of associated clients. You can actually see
- 9:23Speaker 2: your mtesay address pop up in the client list even
- 9:26Speaker 2: without the key.
- 9:27Speaker 1: Okay, so we're associated. How does this help us speed
- 9:30Speaker 1: things up?
- 9:30Speaker 2: This is the whole point. Once we're associated, our device
- 9:33Speaker 2: is now trusted enough to actually communicate with the network.
- 9:36Speaker 2: We can leverage that to inject our own packets into
- 9:39Speaker 2: the network, and.
- 9:40Speaker 1: By injecting specific kinds of traffic.
- 9:42Speaker 2: We force the AP to reply, and every reply is
- 9:45Speaker 2: a new packet with a new IV we can create
- 9:48Speaker 2: a massive fire hose like volume of new packets with
- 9:52Speaker 2: new ivs.
- 9:53Speaker 1: So we are manufacturing the exact traffic we need. Instead
- 9:56Speaker 1: of waiting for days for one hundred thousand ivs to
- 9:59Speaker 1: slowly trick in, we can inject packets and gather all
- 10:02Speaker 1: the data we need in just minutes.
- 10:04Speaker 2: It's the difference between waiting for the tide to bring
- 10:06Speaker 2: you driftwood and actively chopping down the forest. It just
- 10:10Speaker 2: shows how understanding of protocol's procedures allows you to manipulate
- 10:14Speaker 2: it for speed.
- 10:15Speaker 1: This has been a complete journey through WEP. We've gone
- 10:18Speaker 1: from passively listening to actively breaking in and understanding that
- 10:21Speaker 1: wep's failure wasn't about the core math of RC four,
- 10:24Speaker 1: not at all. It was entirely in the implementation, exposing
- 10:27Speaker 1: those short, repeating twenty four bit initialization vectors and plaintexts.
- 10:32Speaker 2: And if you connect this to the bigger picture, the
- 10:35Speaker 2: lesson here is so critical for anyone building or defending technology.
- 10:39Speaker 2: Security is so often broken by poor implementation, not by
- 10:43Speaker 2: some core theoretical mistake. WEP proves that one tiny detail,
- 10:48Speaker 2: a short number cent unencrypted, can make sophisticated encryption completely meaningless.
- 10:53Speaker 1: That's a really powerful takeaway. So for you, the learner
- 10:56Speaker 1: who has followed this deep dive and now understands the
- 10:58Speaker 1: total failure of WIS, we want to leave you with
- 11:01Speaker 1: one final thought to explore on your own. Given that
- 11:04Speaker 1: WP's critical vulnerability was that short plain text initialization vector,
- 11:09Speaker 1: what specific changes do you think the stronger protocols that
- 11:11Speaker 1: came later, like WPA or WPA two must have introduced
- 11:15Speaker 1: to fundamentally protect the IV and improve that whole key
- 11:18Speaker 1: generation process. That's your next research
- 11:20Speaker 2: Mission until the next deep dive, Keep learning,