我在哪里獲得 Golang 的 Radius MSCHAPv2 中的密碼?
我無法弄清楚如何編輯此 Radius MSCHAPv2 示例并從 radius 客戶端獲取密碼。我正在使用的 go 庫是https://github.com/layeh/radius。MSCHAPv2 是否發(fā)送帶有密碼的用戶名?如何從客戶端獲取密碼到服務(wù)器?package microsoftimport ( "log" "reflect" "layeh.com/radius" "layeh.com/radius/rfc2759" "layeh.com/radius/rfc2865" "layeh.com/radius/rfc2868" "layeh.com/radius/rfc2869" "layeh.com/radius/rfc3079")const ( radiusSecret = "secret")func RunRadiusServer() { handler := func(w radius.ResponseWriter, r *radius.Request) { username := rfc2865.UserName_GetString(r.Packet) challenge := MSCHAPChallenge_Get(r.Packet) response := MSCHAP2Response_Get(r.Packet) // TODO: look up user in local database. // The password must be stored in the clear for CHAP mechanisms to work. // In theory, it would be possible to use a password hashed with MD4 as // all the functions in MSCHAPv2 use the MD4 hash of the password anyway, // but given that MD4 is so vulerable that breaking a hash is almost as // fast as computing it, it's just not worth it. password := "password-from-database" if len(challenge) == 16 && len(response) == 50 { // See rfc2548 - 2.3.2. MS-CHAP2-Response ident := response[0] peerChallenge := response[2:18] peerResponse := response[26:50] ntResponse, err := rfc2759.GenerateNTResponse(challenge, peerChallenge, username, password) if err != nil { log.Printf("Cannot generate ntResponse for %s: %v", username, err) w.Write(r.Response(radius.CodeAccessReject)) return }我編輯了函數(shù)的頂部:username := rfc2865.UserName_GetString(r.Packet)password := rfc2865.UserPassword_GetString(r.Packet)log.Printf("bytes %+v", r.Get(1), string(r.Get(1)))log.Printf("bytes %+v", r.Get(2), string(r.Get(2)))log.Printf("u/p %v, %v\n", username, password)用戶名正確。密碼為空。1 是用戶名。我無法對 2 進(jìn)行排序,因為它不會將字節(jié)轉(zhuǎn)換為字符串。這里有一個類似但不是 Go 特定的問題,也沒有正確回答。謝謝!
查看完整描述