Skip to content

Commit 5a1619d

Browse files
authored
Merge pull request #403 from vulncheck-oss/string2uni
Added StringToUnicodeByteArray
2 parents 69c83c2 + 9419a53 commit 5a1619d

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

framework.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ import (
7272
"time"
7373

7474
"github.com/Masterminds/semver"
75-
7675
"github.com/vulncheck-oss/go-exploit/c2"
7776
"github.com/vulncheck-oss/go-exploit/c2/channel"
7877
"github.com/vulncheck-oss/go-exploit/cli"

payload/reverse/vbs.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import (
55
"fmt"
66
)
77

8-
var (
9-
//go:embed vbs/reverse_http.vbs
10-
VBSShell string
11-
)
8+
//go:embed vbs/reverse_http.vbs
9+
var VBSShell string
1210

1311
// Generates a script that can be used to create a reverse shell via vbs (can be run with cscript)
1412
// original source: https://raw.githubusercontent.com/cym13/vbs-reverse-shell/refs/heads/master/reverse_shell.vbs

random/random_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func Test_RandLetters(t *testing.T) {
4747
}
4848

4949
for _, value := range letters {
50-
if !(int(value) >= 65 && int(value) <= 90) && !(int(value) >= 97 && int(value) <= 122) {
50+
if (int(value) < 65 || int(value) > 90) && (int(value) < 97 || int(value) > 122) {
5151
t.Error("RandLetters used value outside of ascii letter ranges.")
5252
}
5353
}
@@ -80,7 +80,7 @@ func Test_RandDigits(t *testing.T) {
8080
}
8181

8282
for _, value := range digits {
83-
if !(int(value) >= 48 && int(value) <= 57) {
83+
if int(value) < 48 || int(value) > 57 {
8484
t.Error("RandDigits used value outside of ascii digit ranges.")
8585
}
8686
}
@@ -93,7 +93,7 @@ func Test_RandHex(t *testing.T) {
9393
}
9494

9595
for _, value := range hex {
96-
if !(int(value) >= 48 && int(value) <= 57) && !(int(value) >= 97 && int(value) <= 102) {
96+
if (int(value) < 48 || int(value) > 57) && (int(value) < 97 || int(value) > 102) {
9797
t.Error("RandHex used value outside of ascii hex ranges: " + string(value))
9898
}
9999
}
@@ -106,7 +106,7 @@ func Test_RandLettersRange(t *testing.T) {
106106
}
107107

108108
for _, value := range letters {
109-
if !(int(value) >= 65 && int(value) <= 90) && !(int(value) >= 97 && int(value) <= 122) {
109+
if (int(value) < 65 || int(value) > 90) && (int(value) < 97 || int(value) > 122) {
110110
t.Error("RandLettersRange used value outside of ascii letter ranges.")
111111
}
112112
}
@@ -119,7 +119,7 @@ func Test_RandHexRange(t *testing.T) {
119119
}
120120

121121
for _, value := range hex {
122-
if !(int(value) >= 48 && int(value) <= 57) && !(int(value) >= 97 && int(value) <= 102) {
122+
if (int(value) < 48 || int(value) > 57) && (int(value) < 97 || int(value) > 102) {
123123
t.Error("RandHex used value outside of ascii hex ranges: " + string(value))
124124
}
125125
}
@@ -136,7 +136,7 @@ func Test_RandDigitsRange(t *testing.T) {
136136
}
137137

138138
for _, value := range digits {
139-
if !(int(value) >= 48 && int(value) <= 57) {
139+
if int(value) < 48 || int(value) > 57 {
140140
t.Error("RandDigits used value outside of ascii digit ranges.")
141141
}
142142
}

transform/encode.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,23 @@ import (
99
"slices"
1010
"strconv"
1111
"strings"
12+
"unicode/utf16"
1213

1314
"github.com/vulncheck-oss/go-exploit/output"
1415
"golang.org/x/text/cases"
1516
"golang.org/x/text/language"
1617
)
1718

19+
func StringToUnicodeByteArray(s string) []byte {
20+
//nolint:prealloc
21+
var byteArray []byte
22+
for _, r := range utf16.Encode([]rune(s)) {
23+
byteArray = append(byteArray, byte(r&0xFF), byte(r>>8&0xFF))
24+
}
25+
26+
return byteArray
27+
}
28+
1829
// Given gzip encoded data, return the decompressed data.
1930
func Inflate(compressed []byte) ([]byte, bool) {
2031
reader, err := gzip.NewReader(bytes.NewBuffer(compressed))

0 commit comments

Comments
 (0)