キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 
cancel
1132
閲覧回数
10
いいね!
0
コメント
hiryokoy
Cisco Employee
Cisco Employee

はじめに

RADIUSのUser-Password attributeにはUser-Name attributeの値のアカウントのpasswordが格納されますが、平文を流すわけにはいかないため暗号化して伝搬します。
弊社document(RADIUS Invalid Authenticator and Message-Authenticator Troubleshoot Guide)にpython2向けの関数定義はありましたが、本稿ではpython3でも動作するscriptを簡単に作成しましたので紹介します。

計算内容

上記の弊社documentに記載の通り、(AAA server-NAD間の)Shared SecretとAuthenticatorの和のMD5 hashとpasswordのXOR処理になります。下記scriptの
m.update(secret.encode()+authenticator)
が、Shared SecretとAuthenticatorのMD5 hash、

print(''.join(chr(ord(x) ^ ord(y)).encode('hex') for x, y in zip(password.ljust(16,'\0')[:16],m.digest()[:16])))
が、passwordとMD5 hashのXOR処理となります。python3ではこれでは動作しないため、

print(b''.join(bytes([ord(x) ^ y]) for x, y in zip(password.ljust(16,'\0')[:16],m.digest()[:16])).hex())
としています。

scriptと使い方

以下がscript全体です。

import hashlib,sys
with open(sys.argv[1],"rb") as f:
    authenticator=f.read()
secret=sys.argv[2]
m=hashlib.md5()
m.update(secret.encode()+authenticator)
password=sys.argv[3]
print('User-Password(encrypted):')
if sys.version_info[0]==2:
    print(''.join(chr(ord(x) ^ ord(y)).encode('hex') for x, y in zip(password.ljust(16,'\0')[:16],m.digest()[:16])))
else:
    print(b''.join(bytes([ord(x) ^ y]) for x, y in zip(password.ljust(16,'\0')[:16],m.digest()[:16])).hex())

例として以下のMAB(Mac Auth Bypass)のpacket captureをWiresharkで開きます。

 

2021-07-26-18-25-27.png

Authenticatorを
 右クリック -> パケットバイト列をエクスポート
したファイルをmabra.binとします。上記scriptのファイル名をuserpw.py、Shared Secretはこの環境ではcisco, passwordはMABなのでUser-Nameと同じということでこの端末のMAC address(3c08f6068243)とすると、python2,3での計算値が共にpacket captureのUser-Password attributeの値と等しいことが確認できます。

[ubuntu] ~$ python2 userpw.py /mnt/c/hiyoko/tmp/mabra.bin cisco 3c08f6068243
User-Password(encrypted):
83a1fa3b3ddc58453c3e2e5ed3b4247f
[ubuntu] ~$
[ubuntu] ~$ python3 userpw.py /mnt/c/hiyoko/tmp/mabra.bin cisco 3c08f6068243
User-Password(encrypted):
83a1fa3b3ddc58453c3e2e5ed3b4247f
[ubuntu] ~$

この方式のSecurity強度は現時点ではかなり低いものでありよく使用されるEAP方式ではUser-Password attribute自体が無いため、用途はMABやTrustSecの制御処理等に限られ実環境ではあまり見かけないかもしれませんが、お手持ちのpacket captureで該当するものがあれば試していただければと思います。

参考資料

RADIUS Invalid Authenticator and Message-Authenticator Troubleshoot Guide: Password Hiding

Getting Started

検索バーにキーワード、フレーズ、または質問を入力し、お探しのものを見つけましょう

シスコ コミュニティをいち早く使いこなしていただけるよう役立つリンクをまとめました。みなさんのジャーニーがより良いものとなるようお手伝いします