Skip to content

Commit acee867

Browse files
committed
add fix for unicode strings: #122
1 parent 19abcd8 commit acee867

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

mapi/datastructs.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,8 +1864,8 @@ func (queryRows *RopQueryRowsResponse) Unmarshal(resp []byte, properties []Prope
18641864
queryRows.RowCount, pos = utils.ReadUint16(pos, resp)
18651865

18661866
rows := make([][]PropertyRow, queryRows.RowCount)
1867-
//check if flagged properties
18681867

1868+
//loop through the rows
18691869
for k := 0; k < int(queryRows.RowCount); k++ {
18701870
trow := PropertyRow{}
18711871
//check if has flag (is flaggedpropertyrow)
@@ -1887,9 +1887,6 @@ func (queryRows *RopQueryRowsResponse) Unmarshal(resp []byte, properties []Prope
18871887
} else if property.PropertyType == PtypString {
18881888
trow.ValueArray, pos = utils.ReadUnicodeString(pos, resp)
18891889
rows[k] = append(rows[k], trow)
1890-
if len(trow.ValueArray) > 0 { //empty string means no extra null byte.
1891-
pos++
1892-
}
18931890
} else if property.PropertyType == PtypBinary {
18941891
cnt, p := utils.ReadUint16(pos, resp)
18951892
pos = p

utils/utils.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ func ReadUnicodeString(pos int, buff []byte) ([]byte, int) {
233233
//stupid hack as using bufio and ReadString(byte) would terminate too early
234234
//would terminate on 0x00 instead of 0x0000
235235
index := bytes.Index(buff[pos:], []byte{0x00, 0x00})
236+
// https://github.com/sensepost/ruler/issues/122
237+
// as pointed out by l0kihardt non-english servers
238+
// respond with 0x00,0x00 - english 0x00,0x00,0x00
239+
if buff[pos+index+2] == 0x00 {
240+
index++ //unicode string end with 0x00 0x00 0x00
241+
}
236242
if index == -1 {
237243
return nil, 0
238244
}

0 commit comments

Comments
 (0)