Skip to content

Instantly share code, notes, and snippets.

@diabloneo
Created September 2, 2013 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diabloneo/6411942 to your computer and use it in GitHub Desktop.
Save diabloneo/6411942 to your computer and use it in GitHub Desktop.
Calculate RADIUS packet authenticator. Input packet's hex string, output authenticator in hex form.
#!/usr/bin/env python
import hashlib
import base64
import binascii
def main():
pktstr = raw_input()
m = hashlib.md5()
m.update(base64.b16decode(pktstr.replace(' ', '').upper()))
authenticator = binascii.b2a_hex(m.digest())
print "authenticator:"
print "%s" % (authenticator)
if __name__ == "__main__":
main()
@diabloneo
Copy link
Author

Example:

~/programming/python$ ./rds_authenticator.py
28 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 0d 31 38 36 31 30 34 37 36 33 30 30 1f 0e 38 34 37 61 38 38 65 37 37 33 30 64 04 06 c0 a8 01 fa 74 65 73 74 69 6e 67 31 32 33
authenticator:
ba2d9d976315f1054c8f9a8d18ef55f1

@zfw
Copy link

zfw commented Sep 3, 2013

nice job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment