-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
add method GetServiceTicket to the kerberos module #4422
Conversation
I realized I left out a change from the pull request, I'm sorry. As I already pushed it on my fork, the commit should appear here soon, but in the meantime here's the diff: |
if err != nil { | ||
return tgs, err | ||
} | ||
cl := kclient.NewWithPassword(username, opts.realm, password, opts.config, kclient.DisablePAFXFAST(true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice kclient
is never destroyed, is this intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is intentional, I assumed there was a reason, as the EnumerateUser
function does not destroy the client.
nuclei/pkg/js/libs/kerberos/kerberos.go
Lines 86 to 136 in 984dfaf
func (c *KerberosClient) EnumerateUser(domain, controller string, username string) (EnumerateUserResponse, error) { | |
resp := EnumerateUserResponse{} | |
if !protocolstate.IsHostAllowed(domain) { | |
// host is not valid according to network policy | |
return resp, protocolstate.ErrHostDenied.Msgf(domain) | |
} | |
opts, err := newKerbrosEnumUserOpts(domain, controller) | |
if err != nil { | |
return resp, err | |
} | |
cl := kclient.NewWithPassword(username, opts.realm, "foobar", opts.config, kclient.DisablePAFXFAST(true)) | |
req, err := messages.NewASReqForTGT(cl.Credentials.Domain(), cl.Config, cl.Credentials.CName()) | |
if err != nil { | |
return resp, err | |
} | |
b, err := req.Marshal() | |
if err != nil { | |
return resp, err | |
} | |
rb, err := cl.SendToKDC(b, opts.realm) | |
if err == nil { | |
var ASRep messages.ASRep | |
err = ASRep.Unmarshal(rb) | |
if err != nil { | |
// something went wrong, it's not a valid response | |
return resp, err | |
} | |
hashcatString, _ := asRepToHashcat(ASRep) | |
resp.Valid = true | |
resp.ASREPHash = hashcatString | |
return resp, nil | |
} | |
e, ok := err.(messages.KRBError) | |
if !ok { | |
return resp, nil | |
} | |
switch e.ErrorCode { | |
case errorcode.KDC_ERR_C_PRINCIPAL_UNKNOWN: | |
return resp, nil | |
case errorcode.KDC_ERR_PREAUTH_REQUIRED: | |
resp.Valid = true | |
return resp, nil | |
default: | |
return resp, err | |
} | |
} |
Should I add the relevant change? If so, should I add the Destroy()
to EnumerateUser
too or that's a different PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think it would be best practice to do that. I'm sure the resources will get cleaned up eventually but it would be best not to leave them dangling.
I'm adding @pussycat0x to share test results |
@dogancanbakir GetServiceTicket Method Working Fine 🚀
|
Proposed changes
Closes #4421
With this change, a new method is exposed in the kerberos module of the Javascript Protocol:
GetServiceTicket()
. This method returns aTGS
struct, which looks like this:Hash
contains the Hashcat formatted string representing the ticket, ready to be cracked. To test this feature I used the same environment of #4420. And used this template:And executed nuclei like this:
go run cmd/nuclei/main.go -u 192.168.56.10 -var Username=victim -var Password=Trust_Me_Br0 -var Domain=LAB.LOCAL -var TargetUser=roastme -var SPN=DC01/cifs -t .\test-krb5.yaml
Which returns an hash understandable by hashcat:
Checklist