Latest / CyberCode Academy / Course 14 - Wi-Fi Pentesting | Episode 8: WPA/WPA2 Hacking: Handshake Capture, Wordlist Attack, and Progress Management
Transcript
- 0:00Speaker 1: When you connect to a modern Wi Fi network, when
- 0:02Speaker 1: secured with WPA or WPA two, you're really trusting decades
- 0:06Speaker 1: of cryptographic development. I mean, developers worked hard to patch
- 0:10Speaker 1: those huge obvious holes that older standards like WBP had.
- 0:15Speaker 2: Oh. Absolutely, that whole era of simple quick cracking is
- 0:18Speaker 2: just it's completely obsolete now.
- 0:21Speaker 1: So what was the core problem it solved?
- 0:23Speaker 2: The big thing with WPA two was making sure that
- 0:25Speaker 2: the data you send over the air, even if someone
- 0:28Speaker 2: captures millions of packets of it, right, it just doesn't
- 0:31Speaker 2: contain any key information you can actually use. The keys
- 0:35Speaker 2: are temporary, they're unique for every single session, and they
- 0:38Speaker 2: use these really robust mechanisms.
- 0:40Speaker 1: You're talking about, things like PBKDF two.
- 0:42Speaker 2: Right, exactly, the password based key derivation function two. It's
- 0:45Speaker 2: a mouthful, but the concept is brilliant.
- 0:47Speaker 1: It's called key stretching. That's the technical why behind the difficulty.
- 0:51Speaker 2: Isn't it. That's exactly. PBKDF two takes the password you
- 0:55Speaker 2: typed in and runs it through this this intentionally slow
- 0:58Speaker 2: cryptographic function thousands.
- 1:00Speaker 1: Of times intentionally slow.
- 1:02Speaker 2: Yes, that's the key. This key stretching ensures that if
- 1:06Speaker 2: an attacker tries to guess, millions of passwords each individual
- 1:10Speaker 2: guest takes just enough processing time to make the whole
- 1:13Speaker 2: attack well computationally infeasible in any short amount of time.
- 1:18Speaker 1: Okay, So we can't just listen to the network and
- 1:20Speaker 1: pull out the key. It's hidden, It's protected by this
- 1:22Speaker 1: intentional slowness. So if all that data is useless, what's
- 1:27Speaker 1: the one tiny piece of information we can use?
- 1:29Speaker 2: It really is like a needle in a haystack. Yeah,
- 1:32Speaker 2: and that needle is the four packet handshake A handshake, yep,
- 1:35Speaker 2: it's that little cryptographic conversation that happens between your device,
- 1:38Speaker 2: your laptop, your phone, and the router right when you
- 1:41Speaker 2: first connect. That four packet exchange is the only thing
- 1:44Speaker 2: that's useful for cracking WPA or WPA two.
- 1:47Speaker 1: And that really sets our mission for this deep dive.
- 1:50Speaker 1: We need to explore how to capture this critical handshake,
- 1:54Speaker 1: why it doesn't just give us the key, and then
- 1:56Speaker 1: walk through the practical steps of a wordless attack that
- 1:58Speaker 1: could take you know, our or even days to finish.
- 2:01Speaker 1: So let's start with that capture. We need the handshake,
- 2:05Speaker 1: but that only happens when a client connects. If we're
- 2:08Speaker 1: running a tool, say era dumping on a network. How
- 2:11Speaker 1: do we get those four packets without just sitting around
- 2:14Speaker 1: waiting for someone to come home.
- 2:16Speaker 2: Well, the passive approach is, like you said, slow, you
- 2:19Speaker 2: can run the capture, you specify the router's MX address,
- 2:22Speaker 2: the BSID in the channel, and save it all to
- 2:25Speaker 2: a file, and then.
- 2:27Speaker 1: You wait, which is not ideal. Time is usually not
- 2:29Speaker 1: on our.
- 2:29Speaker 2: Side, not at all, and that's why we need a
- 2:31Speaker 2: more surgical approach, the de authentication attack.
- 2:34Speaker 1: Okay, the active method correct.
- 2:36Speaker 2: We use a separate tool, maybe airplane, to briefly and
- 2:39Speaker 2: I mean very briefly disconnect a client that's already on
- 2:42Speaker 2: the network.
- 2:43Speaker 1: So explain that for us. How does sending just a
- 2:45Speaker 1: few packets, maybe four of them, force a disconnect like that?
- 2:49Speaker 2: It's actually an exploit of the Wi Fi protocol itself.
- 2:53Speaker 2: De authentication is a totally legitimate type of packet, a
- 2:56Speaker 2: management frame that's used to gratefully end a session. The
- 3:00Speaker 2: problem is these frames aren't authenticated, so.
- 3:03Speaker 1: You can fake one.
- 3:04Speaker 2: You can fake one. You can send a packet that
- 3:06Speaker 2: looks like it's from the router telling a specific client, hey,
- 3:09Speaker 2: you're disconnected, and.
- 3:10Speaker 1: Because we're only sending a handful of them.
- 3:11Speaker 2: It's just enough to cause a tiny interruption. But what
- 3:15Speaker 2: do our devices do this second they lose a Wi Fi.
- 3:18Speaker 3: Connection, They try to reconnect immediately, instantly and automatically, and
- 3:22Speaker 3: that automatic reconnection forces the four packet handshake to be
- 3:25Speaker 3: sent over the air right where our capture tool is listening.
- 3:29Speaker 2: We basically manufacture the exact event we need right on demand.
- 3:33Speaker 1: That's a clever mechanical trick. And once our tool says YEP,
- 3:36Speaker 1: got the handshake, that's phase one done, we can stop
- 3:39Speaker 1: monitoring and move on to the real attack.
- 3:41Speaker 2: Exactly. The first part is over. Now the real cryptographic
- 3:45Speaker 2: work begins.
- 3:46Speaker 1: And this is the critical distinction, isn't it the thing
- 3:48Speaker 1: that separates WPA two from the old broken protocols. We
- 3:54Speaker 1: have the handshake file, but we still don't actually have
- 3:56Speaker 1: the key. Why can't we just pull it out of
- 3:58Speaker 1: the data.
- 3:58Speaker 2: Because the entire handha is designed for verification, not for recovery.
- 4:04Speaker 2: If you were to open that capture file, the key
- 4:06Speaker 2: is just it's not in there. What is in there
- 4:10Speaker 2: is the information you need to check if a password
- 4:13Speaker 2: you guess is the right one.
- 4:15Speaker 1: So what part of the handshake lets us do that checking.
- 4:18Speaker 2: That functionality is all thanks to something called the message
- 4:20Speaker 2: integrity code or MIC.
- 4:23Speaker 1: The MIC.
- 4:24Speaker 2: Yeah, you can think of the MIC as a kind
- 4:26Speaker 2: of digital fingerprint. When you connect, the router takes the password,
- 4:29Speaker 2: the network name, a few other things, runs them through
- 4:31Speaker 2: that key derivation function we mentioned PVKDF two right, and
- 4:35Speaker 2: it generates a specific MIC. Your device has to generate
- 4:39Speaker 2: the exact same MIC to prove it knows the password.
- 4:42Speaker 1: So our logic completely flips. We're not trying to recover anything,
- 4:45Speaker 1: we're just guessing. The system doesn't tell us the password.
- 4:47Speaker 1: It only tells us if our guests generates the same
- 4:49Speaker 1: digital fingerprint.
- 4:51Speaker 2: Precisely, which means we have to use a word list
- 4:54Speaker 2: basically a giant dictionary file of potential passwords, and try
- 4:58Speaker 2: to recreate that fingerprint, one guess at a time. If
- 5:02Speaker 2: our generated MIIC matches the captured one, we know we
- 5:06Speaker 2: have the right password.
- 5:07Speaker 1: Which makes the quality of your word list the single
- 5:09Speaker 1: most important factor for success. If the password isn't in
- 5:13Speaker 1: your list, the attack will fail. It doesn't matter how
- 5:15Speaker 1: much computing power you throw at it.
- 5:17Speaker 2: It really is the whole game, and that's why custom
- 5:19Speaker 2: word list creation is such a crucial skill. You need
- 5:22Speaker 2: intelligent generation tools, something like Crunch exactly. Crunch is a
- 5:26Speaker 2: perfect example. It's used to generate password combinations based on
- 5:29Speaker 2: very specific rules, so you can avoid using those generic,
- 5:33Speaker 2: pre made lists you find online.
- 5:34Speaker 1: So what are the basic levers you can pull on
- 5:36Speaker 1: a tool like Crunch to build a custom list?
- 5:38Speaker 2: You start with three main constraints the minimum password length,
- 5:42Speaker 2: the maximum length, and the character set. Are you using
- 5:46Speaker 2: just lowercase letters or are you mixing in upcase numbers, symbols.
- 5:50Speaker 1: And a ten character password with all four of those
- 5:52Speaker 1: sets is just astronomical.
- 5:55Speaker 2: The possibilities are huge. But what if you have a
- 5:58Speaker 2: little bit of information, say you know the person always
- 6:01Speaker 2: starts their password with two numbers and includes a certain
- 6:04Speaker 2: symbol somewhere.
- 6:05Speaker 1: Ah, that's where the pattern optimization comes in.
- 6:08Speaker 2: The eight option, That's where it becomes essential. You can
- 6:11Speaker 2: define a template. You can say, okay, the first two
- 6:13Speaker 2: characters must be digits followed by some pattern of letters.
- 6:17Speaker 2: This just dramatically cuts down the search space. You're not
- 6:20Speaker 2: testing random combinations anymore, you're testing smart ones.
- 6:24Speaker 1: And there was a fantastic feature you mentioned for optimizing
- 6:26Speaker 1: even further related to repetitive characters.
- 6:30Speaker 2: Yes, this is a beautiful little detail. Normally, the number
- 6:33Speaker 2: of possibilities is your character set size raised to the
- 6:37Speaker 2: power of the password length. That includes things like ah
- 6:40Speaker 2: or eleven to one to eleven.
- 6:41Speaker 1: Which are pretty low value guesses most of the time.
- 6:44Speaker 2: Right. But if you use the ap option, you tell
- 6:47Speaker 2: Crunch to skip any combination where characters repeat.
- 6:51Speaker 1: And the mathematical impact of that is huge.
- 6:53Speaker 2: It's enormous. You shift the calculation from a power function
- 6:57Speaker 2: to a factorial function, drastically reducing the total number of
- 7:02Speaker 2: passwords that need to be generated and checked. It's a
- 7:04Speaker 2: perfect example of how knowing the math behind your tool
- 7:08Speaker 2: optimizes the whole operation.
- 7:10Speaker 1: Okay, so we have our captured handshake. We have our
- 7:13Speaker 1: highly optimized custom word list. Now let's talk about the
- 7:17Speaker 1: cracking tool itself air cracking. How does it actually run
- 7:21Speaker 1: through that list and check the mics.
- 7:23Speaker 2: The process is basically a high speed assembly line. First,
- 7:27Speaker 2: the tool poles that captured mic out of the handshake
- 7:29Speaker 2: file that's its target. Then for every single entry in
- 7:33Speaker 2: your word list, it does the same thing over and over.
- 7:35Speaker 1: It takes the password guess and the other info.
- 7:37Speaker 2: From the handshake correct, It combines them, runs them through
- 7:40Speaker 2: the whole key derivation function, and generates a new message integrity.
- 7:44Speaker 1: Code, a brand new one for that guess, a.
- 7:46Speaker 2: Brand new one, and then it compares that new MIC
- 7:49Speaker 2: against the captured one. If they match, it stops you
- 7:52Speaker 2: found the key. If they don't, it discards the guests
- 7:54Speaker 2: and immediately moves to the next word in the list.
- 7:56Speaker 1: And the speed of that the number of guesses per
- 7:58Speaker 1: second is totally dependent on your machine's hardware.
- 8:02Speaker 2: Absolutely. The biggest constraint is throughput. A standard CPU is fine,
- 8:07Speaker 2: it'll work, but CPUs are a general purpose processors. If
- 8:11Speaker 2: you want to really accelerate this attack, you have to
- 8:14Speaker 2: use a GPU, a graphics processing unit.
- 8:17Speaker 1: Can you give us a sense of that performance jump.
- 8:19Speaker 1: Why is a GPU so much better for.
- 8:21Speaker 2: This because password hashing is what we call an embarrassingly
- 8:24Speaker 2: parallel processing, meaning each password guess is completely independent of
- 8:29Speaker 2: the last one. A modern CPU might have what eight,
- 8:32Speaker 2: maybe sixteen cores, but a modern GPU has thousands of
- 8:36Speaker 2: tiny processing units. It's common to see a fifty or
- 8:39Speaker 2: even one hundred times speeding crace.
- 8:40Speaker 1: Wow, one hundred times.
- 8:42Speaker 2: Easily, you can turn an attack that might take weeks
- 8:45Speaker 2: on a CPU into one that takes just a few
- 8:47Speaker 2: hours on a good GPU. It's how you overcome that
- 8:49Speaker 2: intentional slowness that PBKDF two forces on you.
- 8:52Speaker 1: That makes a huge difference. But what if even with
- 8:55Speaker 1: a great word list and a GPU, the crack is
- 8:58Speaker 1: still projected to take, say four forty eight hours. You
- 9:00Speaker 1: can't just stop and come back tomorrow. You'd lose all
- 9:03Speaker 1: your progress.
- 9:04Speaker 2: That is the major practical hurdle session management. The standard
- 9:08Speaker 2: cracking tool air cracking doesn't save his progress. You stop it,
- 9:11Speaker 2: you're back at square one.
- 9:13Speaker 1: So what's the solution.
- 9:14Speaker 2: The solution is an elegant little technique called piping. Piping.
- 9:18Speaker 1: Okay, let's use an analogy. If the command line is
- 9:21Speaker 1: a workshop, what is the pipe that vertical bar character.
- 9:26Speaker 2: Think of it like a digital conveyor belt, or maybe
- 9:29Speaker 2: a funnel. It lets the output one program flow immediately
- 9:32Speaker 2: into the input of a second program. You don't need
- 9:35Speaker 2: to save any intermediate files.
- 9:36Speaker 1: And how does that help us save our progress?
- 9:39Speaker 2: We bring in a second tool, John the Ripper.
- 9:42Speaker 1: John the Ripper is famous for password cracking, but we're
- 9:45Speaker 1: not using it for that here.
- 9:46Speaker 2: No, we're using it for it's amazing session management. We
- 9:49Speaker 2: tell johndre read our word list and just print the
- 9:51Speaker 2: passwords out by one. But crucially we also tell it
- 9:54Speaker 2: to start a name session something like cracking forty eight h.
- 9:58Speaker 2: John will then keep track of exactly which word it
- 10:00Speaker 2: sent last.
- 10:01Speaker 1: So John is spinning out the word list and we
- 10:03Speaker 1: pipe that output directly into air cracking. What's the key
- 10:06Speaker 1: detail on the air cracking side of the command?
- 10:08Speaker 2: The key detail is it where you would normally type
- 10:11Speaker 2: the word list file name after the W, you just
- 10:14Speaker 2: replace it with a single dash wbar. That dash is
- 10:18Speaker 2: the universal signal for take your input from the pipe.
- 10:21Speaker 1: So air Cracking is being fed the words one at
- 10:23Speaker 1: a time from John.
- 10:24Speaker 2: Exactly, So if you need to stop, you just quit.
- 10:27Speaker 2: John automatically saves his progress in that session file.
- 10:30Speaker 1: And to resume the next day.
- 10:31Speaker 2: You just run the genrestore command John restore with a
- 10:34Speaker 2: session name. It instantly jumps to the exact word where
- 10:37Speaker 2: you left off and starts spitting them out again. You
- 10:40Speaker 2: pipe that right back into air cracking, and the attack
- 10:42Speaker 2: resumes at say thirty five percent, without losing a single guess.
- 10:47Speaker 1: That piping technique sounds invaluable. It takes two powerful specialized
- 10:51Speaker 1: tools and just links them together to solve a really
- 10:54Speaker 1: significant problem.
- 10:55Speaker 2: It's a fundamental skill really. It makes the difference between
- 10:58Speaker 2: a proof of concept attack and the successful multi day operation.
- 11:01Speaker 1: So to wrap up our deep dive here, we've seen
- 11:04Speaker 1: that the only exploitable data is that four packet handshake,
- 11:08Speaker 1: which we can capture surgically with a death attack. The
- 11:11Speaker 1: whole methodology then hinges on verification not recovery, which means
- 11:16Speaker 1: we need smart optimized word.
- 11:18Speaker 2: Lists often build with a tool like crunch.
- 11:21Speaker 1: Right, and then the execution relies on air cracking for
- 11:24Speaker 1: the heavy lifting. But for any long attack we need
- 11:26Speaker 1: that clever session management using John the ripper and piping.
- 11:30Speaker 2: And at the end of the day, the entire technical
- 11:33Speaker 2: success of this complex accelerated attack is bottlenecked by one
- 11:37Speaker 2: totally non.
- 11:38Speaker 1: Technical thing, whether the actual taskword is in your list exactly,
- 11:41Speaker 1: Which leaves you with this final thought. If you are
- 11:43Speaker 1: tasked with defending a large network against this very attack,
- 11:47Speaker 1: knowing how focused and optimized these word lists can be,
- 11:51Speaker 1: how would you coach your users to create passwords that
- 11:53Speaker 1: would maximize the time to crack? What kinds of patterns
- 11:56Speaker 1: or substitutions would be the hardest to build into a
- 11:59Speaker 1: custom word list.
- 12:00Speaker 2: It's the ultimate intersection of human behavior and technical defense.
- 12:03Speaker 1: A fascinating problem to think about. Thank you for joining
- 12:06Speaker 1: us on this deep dive into WPA security. Until next time,
- 12:10Speaker 1: keep learning