diff options
author | Bryan McNulty <bryanmcnulty@protonmail.com> | 2025-03-07 08:52:48 -0600 |
---|---|---|
committer | Bryan McNulty <bryanmcnulty@protonmail.com> | 2025-03-07 08:52:48 -0600 |
commit | e87dd341dde93c289b6774f636e6767476b84a79 (patch) | |
tree | 3181b18f79b587bd04d98ed886f3505f37faeb2d /internal/util | |
parent | a5c860b8ab24c198b7390fbde90044754e35c1c5 (diff) | |
download | goexec-e87dd341dde93c289b6774f636e6767476b84a79.tar.gz goexec-e87dd341dde93c289b6774f636e6767476b84a79.zip |
Added wmiexec module + updated TODO
Diffstat (limited to 'internal/util')
-rw-r--r-- | internal/util/util.go | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/internal/util/util.go b/internal/util/util.go index 252815e..36d7ea2 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -1,35 +1,35 @@ package util import ( - "math/rand" // not crypto secure - "regexp" + "math/rand" // not crypto secure + "regexp" ) const randHostnameCharset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-" const randStringCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" var ( - // Up to 15 characters; only letters, digits, and hyphens (with hyphens not at the start or end). - randHostnameRegex = regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9-]{0,14}[a-zA-Z0-9]$`) + // Up to 15 characters; only letters, digits, and hyphens (with hyphens not at the start or end). + randHostnameRegex = regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9-]{0,14}[a-zA-Z0-9]$`) ) func RandomHostname() (hostname string) { - for { - // between 2 and 10 characters - if hostname = RandomStringFromCharset(randHostnameCharset, rand.Intn(8)+2); randHostnameRegex.MatchString(hostname) { - return - } - } + for { + // between 2 and 10 characters + if hostname = RandomStringFromCharset(randHostnameCharset, rand.Intn(8)+2); randHostnameRegex.MatchString(hostname) { + return + } + } } func RandomString() string { - return RandomStringFromCharset(randStringCharset, rand.Intn(10)+6) + return RandomStringFromCharset(randStringCharset, rand.Intn(10)+6) } func RandomStringFromCharset(charset string, length int) string { - b := make([]byte, length) - for i := range length { - b[i] = charset[rand.Intn(len(charset))] - } - return string(b) + b := make([]byte, length) + for i := range length { + b[i] = charset[rand.Intn(len(charset))] + } + return string(b) } |