Skip to content

Commit

Permalink
test if we got ASREP if no error (#6)
Browse files Browse the repository at this point in the history
* test if we got ASREP if no error

* check if err is not nil before handling

* adding more debug statements

* rebuild all in Makefile

* Revert "adding more debug statements"

This reverts commit 97615a4.
  • Loading branch information
ropnop authored Apr 11, 2019
1 parent 12a4c92 commit 385cb2b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,27 @@ help: ## Show this help.
windows: ## Make Windows x86 and x64 Binaries
@for ARCH in ${ARCHS}; do \
echo "Building for windows $${ARCH}.." ;\
GOOS=windows GOARCH=$${ARCH} go build -ldflags ${LDFLAGS} -o ${TARGET}/kerbrute_windows_$${ARCH}.exe ;\
GOOS=windows GOARCH=$${ARCH} go build -a -ldflags ${LDFLAGS} -o ${TARGET}/kerbrute_windows_$${ARCH}.exe ;\
done; \
echo "Done."

linux: ## Make Linux x86 and x64 Binaries
@for ARCH in ${ARCHS}; do \
echo "Building for linux $${ARCH}..." ; \
GOOS=linux GOARCH=$${ARCH} go build -ldflags ${LDFLAGS} -o ${TARGET}/kerbrute_linux_$${ARCH} ;\
GOOS=linux GOARCH=$${ARCH} go build -a -ldflags ${LDFLAGS} -o ${TARGET}/kerbrute_linux_$${ARCH} ;\
done; \
echo "Done."

mac: ## Make Darwin (Mac) x86 and x64 Binaries
@for ARCH in ${ARCHS}; do \
echo "Building for mac $${ARCH}..." ; \
GOOS=darwin GOARCH=$${ARCH} go build -ldflags ${LDFLAGS} -o ${TARGET}/kerbrute_darwin_$${ARCH} ;\
GOOS=darwin GOARCH=$${ARCH} go build -a -ldflags ${LDFLAGS} -o ${TARGET}/kerbrute_darwin_$${ARCH} ;\
done; \
echo "Done."

clean: ## Delete any binaries
@rm -f ${TARGET}/* ; \
go clean -i -n github.com/ropnop/kerbrute ; \
echo "Done."

all: ## Make Windows, Linux and Mac x86/x64 Binaries
Expand Down
7 changes: 5 additions & 2 deletions cmd/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ func testLogin(ctx context.Context, username string, password string) {
func testUsername(ctx context.Context, username string) {
atomic.AddInt32(&counter, 1)
usernamefull := fmt.Sprintf("%v@%v", username, domain)
if ok, err := kSession.TestUsername(username); ok {
valid, err := kSession.TestUsername(username)
if valid {
atomic.AddInt32(&successes, 1)
logger.Log.Notice("[+] VALID USERNAME:\t %s", usernamefull)
} else {
} else if err != nil {
// This is to determine if the error is "okay" or if we should abort everything
ok, errorString := kSession.HandleKerbError(err)
if !ok {
Expand All @@ -88,5 +89,7 @@ func testUsername(ctx context.Context, username string) {
} else {
logger.Log.Debugf("[!] %v - %v", usernamefull, errorString)
}
} else {
logger.Log.Debug("[!] Unknown behavior - %v", usernamefull)
}
}
12 changes: 10 additions & 2 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,23 @@ func (k KerbruteSession) TestUsername(username string) (bool, error) {
if err != nil {
return false, err
}
_, err = cl.SendToKDC(b, k.Realm)
rb, err := cl.SendToKDC(b, k.Realm)
if err != nil {
if e, ok := err.(messages.KRBError); ok {
if e.ErrorCode == errorcode.KDC_ERR_PREAUTH_REQUIRED {
return true, nil
}
}
}
return false, err
// if we made it here, we got an AS REP, meaning pre-auth was probably not required. try to unmarshal it to make sure format is right
var ASRep messages.ASRep
err = ASRep.Unmarshal(rb)
if err != nil {
return false, err
}
// AS REP was valid, user therefore exists (don't bother trying to decrypt)
return true, err

}

func (k KerbruteSession) HandleKerbError(err error) (bool, string) {
Expand Down

0 comments on commit 385cb2b

Please sign in to comment.