Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status-server request and Message-Authenticator #47

Closed
ilyam8 opened this issue Dec 25, 2018 · 8 comments
Closed

Status-server request and Message-Authenticator #47

ilyam8 opened this issue Dec 25, 2018 · 8 comments
Labels

Comments

@ilyam8
Copy link

ilyam8 commented Dec 25, 2018

Hi. I need to send status-server req to freeradius server.

via radclient

xxx@yyy[~]cat rad
Message-Authenticator = 0x00
FreeRADIUS-Statistics-Type = 15
Response-Packet-Type = Access-Accept

xxx@yyy[~]radclient -t 1 -r 1 127.0.0.1:18121 status adminsecret -x -f rad
Sending Status-Server of id 2 to 127.0.0.1 port 18121
	Message-Authenticator = 0x00000000000000000000000000000000
	FreeRADIUS-Statistics-Type = 15
rad_recv: Access-Accept packet from host 127.0.0.1 port 18121, id=2, length=428
	FreeRADIUS-Total-Access-Requests = 7706
	FreeRADIUS-Total-Access-Accepts = 7691
	FreeRADIUS-Total-Access-Rejects = 9
        ...

I feel like i am missing something, but I can't figure out how to do this using this library and whether it can be done at all.

Please help 🙏

@ghost
Copy link

ghost commented Dec 25, 2018

What specifically are you having trouble with? I don't see any Go code in your question.

@ilyam8
Copy link
Author

ilyam8 commented Dec 26, 2018

i am having trouble with creating a packet.

i understand that i need to:

  • create a new packet with status server code
  • add/set FreeRADIUS-Statistics-Type = 15
  • add/set encoded Message-Authenticator = 0x00

i found that

  • 80 | Message-Authenticator | string
  • 127| FreeRADIUS-Statistics-Type| integeer
	packet := radius.New(radius.CodeStatusServer, []byte(`adminsecret`))
       // VALUE	    FreeRADIUS-Statistics-Type	Authentication		 1
	packet.Set(radius.Type(127), radius.NewInteger(1))

i don;t know how to correctly add Message-Authenticator = 0x00 (my attempts end with WARNING: Malformed RADIUS packet from host)

@ghost
Copy link

ghost commented Dec 26, 2018

The library does not automatically populate Message-Authenticator with the packet's HMAC. See #43 (comment).

@ilyam8
Copy link
Author

ilyam8 commented Dec 26, 2018

Nice! It works.

btw why all imports layeh.com/radius and not github.com/layeh/radius ?

i can't use the library with go mod.

what i did:

  • add imports "layeh.com/radius", "layeh.com/radius/rfc2865". Executed go mod tidy. No effect.
  • changed imports to "github.com/layeh/radius", "github.com/layeh/radius/rfc2865". Executed go mod tidy. Success.

But since rfc2865 uses layeh/radius i can't build my program.

build github.com/ilyam8/playground: cannot find module for path layeh.com/radius

@ilyam8
Copy link
Author

ilyam8 commented Dec 26, 2018

if someone will be looking for the wroking code (no error handling because of example)

packet := radius.New(radius.CodeStatusServer, []byte(secret))

_ = PacketType_Set(packet, PacketType_Value_AccessAccept)
_ = FreeRADIUSStatisticsType_Set(packet, FreeRADIUSStatisticsType_Value_Authentication)
_ = rfc2869.MessageAuthenticator_Set(packet, make([]byte, 16))

hash := hmac.New(md5.New, packet.Secret)
encode, _ := packet.Encode()
hash.Write(encode)

_ = rfc2869.MessageAuthenticator_Set(packet, hash.Sum(nil))

@ilyam8 ilyam8 closed this as completed Dec 26, 2018
@ghost
Copy link

ghost commented Dec 26, 2018

All of your references, including the ones in go.mod and go.sum, file should be to layeh.com/radius, not github.com/layeh/radius.

@ghost ghost added the question label Dec 26, 2018
@ghost ghost changed the title status-server request Status-server request and Message-Authenticator Dec 26, 2018
@ilyam8
Copy link
Author

ilyam8 commented Dec 26, 2018

Oh, i got it, 159.203.9.79 is blocked in my f country
https://isitblockedinrussia.com/?host=159.203.9.79

@ilyam8
Copy link
Author

ilyam8 commented Dec 26, 2018

this is the problem i guess

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

No branches or pull requests

1 participant