Skip to content

Commit

Permalink
Refactor: extract struct
Browse files Browse the repository at this point in the history
  • Loading branch information
CristianQS committed Nov 11, 2021
1 parent 861748b commit 1e154d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 4 additions & 7 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"aad-sso-enum-brute-spray/pkg/dto"
"bufio"
"encoding/xml"
"flag"
Expand Down Expand Up @@ -72,10 +73,6 @@ func main() {
wg.Wait()
}

type xmlStruct struct {
Dtext string `xml:"Body>Fault>Detail>error>internalerror>text"`
}

func requestAzureActiveDirectory(domain string, user string, password string) {
requestid := uuid.New()
MessageID := uuid.New()
Expand Down Expand Up @@ -198,9 +195,9 @@ func enumUsers(usersFile string, password string) {

func getErrorCode(xmlcode string) string {
// Extract error code from xml response
x := xmlStruct{}
_ = xml.Unmarshal([]byte(xmlcode), &x)
errorCode := strings.Split(x.Dtext, ":")[0]
azureErrorResponseDto := dto.AzureErrorResponseDto{}
_ = xml.Unmarshal([]byte(xmlcode), &azureErrorResponseDto)
errorCode := strings.Split(azureErrorResponseDto.Error, ":")[0]
return errorCode
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/dto/AzureErrorResponseDto.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package main

type AzureErrorResponseDto struct {
Code string `xml:"Body>Fault>Detail>error>internalerror>text"`
}

0 comments on commit 1e154d2

Please sign in to comment.