Tweaking EAP’s weak link – sucking WiFi PMKs out of RADIUS with pmkXtract

When faced with a WiFi network using WPA2/EAP-TLS, options for a direct attack are limited. You can’t feasibly attack the encryption (most likely CCMP), and if the client devices are configured properly attacking the authentication mechanism directly isn’t likely to bear fruit either.

One of the advantages of the “enterprise” variants of WPA is that the Pairwise Master Keys are specific to a client device and to a single association (WPA Personal has the same PMK shared amongst all devices). To oversimplify somewhat, with WPA Enterprise the PMK for a given device is negotiated between the device and the RADIUS server as part of the EAP process. The PMK is subsequently delivered to the access point via RADIUS. Once both the client device and the AP have the PMK the normal WPA four-way handshake can complete, the output of which is a Pairwise Transient Key which is used to encrypt the session. There’s a nice diagram of the process here.

However, there is a weak link in the chain. Hacking Exposed Wireless, 2nd edition describes a possible attack against the delivery of the PMK from the RADIUS server to the access point. The theory of operation is as follows:

  1. Start capturing the wireless traffic of interest.
  2. Start capturing the RADIUS traffic between the RADIUS server and the access point.
  3. Using an obtained RADIUS shared secret, decrypt the RADIUS traffic that contains the PMKs.
  4. Use the extracted PMKs and the captured four-way handshakes to derive each device’s PTK.
  5. Decrypt every single data frame you’ve captured from the wireless network 🙂

The book didn’t cite any tools capable of extracting the PMKs from the RADIUS conversation, so I thought I’d have a go at writing one myself. The reason the book didn’t cite any tools is probably that if an attacker is in a position to capture your RADIUS traffic, you probably have bigger things to worry about. Nevertheless, it seemed like a challenge worth attempting.

Of the five points above, 1 and 2 are straightforward (assuming the attacker is well placed). 4 and 5 can be easily carried out with Wireshark. Step 3 breaks down into obtaining the shared secret and decrypting the PMKs.

Obtaining the RADIUS shared secret

As noted in Hacking Exposed Wireless, a brute force attack on the shared secret is quite feasible. Alternatively, one can just poke around the RADIUS server and find the list of secrets. For example:

  • FreeRADIUS stores all of this in clients.conf
  • Internet Authentication Service on Windows 2K3 stores everything in system32\ias\ias.mdb which you can open in MS Access (look in the Objects table)
  • Network Policy Server on Windows 2k8 stores everything in system32\ias\ias.xml in plaintext.

Secrets in hand, we can move on to…

Decrypting the PMKs

We first need to start capturing the WiFi traffic of interest. We can do this with airodump-ng:

airmon-ng start wlan0
airodump-ng –channel 1 –bssid 00:1c:df:8b:50:66 –write pmkXtract mon0

Now we can turn our attention to capturing the PMKs. The PMKs are transmitted in the final RADIUS message of the transaction (the Access-Accept message), and they’re stored encrypted in a vendor-specific attribute, MS-MPPE-Recv-Key:

Given the correct shared secret, Wireshark is apparently capable of decrypting RADIUS traffic but I couldn’t make it work for MS-MPPE-Recv-Key. Shying away from actually writing decryption code from scratch, I invoked the age-old software engineering tradition of “code re-use”, aka pinching someone else’s stuff.

hostapd is a user-space access point daemon, and has full support for EAP-TLS. After nosing around and debugging the code, I found the procedure that does the decryption – decrypt_ms_key() in radius.c.


pmkXtract is a quick and dirty hack that wraps up decrypt_ms_key(); all we need to do is feed it:

  • The RADIUS shared secret
  • The request authenticator from the final Access-Request message
  • The MS-MPPE-Recv-Key from the following Access-Accept message

A neater, future version of pmkXtract would capture the latter two straight off the wire, but for now they are CLI parameters. The most convenient way to get these values is with tshark, supplying the appropriate capture filter:

tshark -T fields -e radius.code -e -e radius.authenticator -e radius.MS_MPPE_Recv_Key -E separator=! ip host access.point.ip.addr

This will produce output like this:


What we’re looking for is a pair of code1/code2 messages with the same ID, as is the case with the last two lines above with ID 12. Code 1 denotes Access-Request, code 2 is Access-Accept. Now we can pass the message authenticator from the access-request and the MS-MPPE-Recv-Key from the access-accept to pmkXtract, along with the shared secret:

C:\>pmkXtract secret 5d:5c:<snip>:69:5d 80:8a:<snip>:7d:79
PMK is:c8cad1f342e431bdf97b3fd1c37bf2fe

Score! We’ve got the PMK.

Decrypting the captured WiFi traffic

The first thing we need to do is look through our airodump capture for the WPA four-way handshake:

Frames 134, 136, 138, and 140 are the four-way handshake

As we might expect, the contents of the capture is unintelligible:

Now we can enter the PMK that pmkXtract gave us, by going Edit->Preferences, and selecting IEEE802.11 under Protocols:

And hey presto, we have decrypted the traffic. Note the “Decrypted CCMP data” sub-tab at the bottom of the window:

As I’ve already said, if an attacker can pull this off, they already have a deep foothold in your infrastructure. Use strong RADIUS secrets, secure the list of secrets on the server (clients.conf, ias.mdb, etc) as well as you can, and if it’s possible, protect the RADIUS exchange with IPSec.

Alec Waters is responsible for all things security at Dataline Software, and can be emailed at

16 Responses to “Tweaking EAP’s weak link – sucking WiFi PMKs out of RADIUS with pmkXtract”

  1. […] When faced with a WiFi network using WPA2/EAP-TLS, options for a direct attack are limited. You can’t feasibly attack the encryption (most likely CCMP), and if the client devices are configured properly attacking the authentication … View original post here: Tweaking EAP's weak link – sucking WiFi PMKs out of RADIUS with … […]

  2. […] EAP authentication via remote RADIUS server ! Knowing the RADIUS server’s secret can be very useful! radius-server host auth-port 1645 acct-port 1646 key mySecret aaa new-model aaa group […]

  3. Hi,

    This is a great article.

    Could you please let me know how did you change the decrypt_ms_key(); procedure in order to feed it with Radius shared secret and the other ttwo “burgers”?

    My programing skill is very low.

    Thanks a lot for your help,

  4. How to get your pmkXtract code?

    • Hi,

      I’ll see if I can dig it out – it wasn’t particularly polished though!


      • It would be nice of you!

      • I’m trying to write my own. But I can get nothing but “failed to decrypt mope key”

      • Don’t want to be annoying, but
        Did you succeed?

      • Hi Els,

        You can download it from here:

        It’s a bit rough and ready, but it worked for me. You may need to tweak it a little if you’re not building on a Windows platform, but it should compile OK for you.

        Good luck,

      • I put together a python implementation. A bit rough, but should do the job!

      • Thanks Robert 🙂

      • Robert Rusk Says:

        For posterity:

        from hashlib import md5
        from binascii import unhexlify, hexlify

        seq_xor = lambda c, b: ”.join(
        chr(x) for x in map(lambda X: ord(X[0]) ^ ord(X[1]), zip(c, b))

        # RFC-2548: 2.4.3. MS-MPPE-Recv-Key
        # C: Cyphertext
        # S: Secret
        # R: Request Authenticator
        # A: Salt field
        # P: Plaintext – key-len + key + padding
        def rad_tunnel_pwdecode(C, S, R, A):

        c = [C[i:i+16] for i in range(0, len(C), 16)]
        p = [‘\0’] * len(c)
        b = [‘\0′] * len(c)

        b[0] = md5(S + R + A).digest()
        p[0] = seq_xor(c[0], b[0])

        for i in range(1, len(p)):

        b[i] = md5(S + c[i-1]).digest()
        p[i] = seq_xor(c[i], b[i])

        P = ”.join(p)
        return P

        Secret = “my_radius_shared_secret”
        RequestAuthenticator = “\0” * 16
        RequestAuthenticator = “abcdefd7f69b22662fd752c39f97e81e”

        Cyphertext =’abcdef5c56144a4b63f591cbcc7d3d9be8f317f811f5009c57d6706e68238948685836ff4c19127c190218198c6f998830a7’

        print “Cypher:%s” % Cyphertext

        Salt = Cyphertext[:4]

        Plaintext = rad_tunnel_pwdecode(

        Plaintext = hexlify(Plaintext)

        print “Plain: %s”%Plaintext

  5. Thanks! It worked fine for me

  6. oposum Says:

    Thank you very much. This helped me, too.
    It was kinda tricky, but finally managed to get the PMK out of the traffic between the AP and the RADIUS-Server.
    Hint: Freeradius prints the PMK as plaintext, if you enable logging as:

    Sending Access-Accept of id 183 to port 3072
    MS-MPPE-Recv-Key = 0x980b92b88b6c2000d37643811e3f33a6f1ea2490e56db1d830931b2a114a5552

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: