Skip to content

Commit 05976d7

Browse files
authored
Merge pull request #294 from vulncheck-oss/tcpReadBlind
TCP Read for bruteforcing
2 parents 13fb2ce + 4d21453 commit 05976d7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

protocol/tcpsocket.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,23 @@ func TCPReadAmount(conn net.Conn, amount int) ([]byte, bool) {
109109

110110
return reply, true
111111
}
112+
113+
// Read an amount and dont log errors if we fail to read from the socket
114+
func TCPReadAmountBlind(conn net.Conn, amount int) ([]byte, bool) {
115+
reply := make([]byte, amount)
116+
totalRead := 0
117+
118+
// keep reading until we hit the desired amount (or an error occurs)
119+
for totalRead < amount {
120+
count, err := conn.Read(reply[totalRead:])
121+
if err != nil {
122+
return nil, false
123+
}
124+
if count == 0 {
125+
return nil, false
126+
}
127+
totalRead += count
128+
}
129+
130+
return reply, true
131+
}

0 commit comments

Comments
 (0)