MCPcopy Create free account
hub / github.com/shadow1ng/fscan / readMySQLBanner

Method readMySQLBanner

plugins/services/mysql.go:172–197  ·  view source on GitHub ↗
(conn net.Conn, config *common.Config)

Source from the content-addressed store, hash-verified

170}
171
172func (p *MySQLPlugin) readMySQLBanner(conn net.Conn, config *common.Config) string {
173 _ = conn.SetReadDeadline(time.Now().Add(config.Timeout))
174
175 handshake := make([]byte, 256)
176 n, err := conn.Read(handshake)
177 if err != nil || n < 10 {
178 return ""
179 }
180
181 if handshake[4] != 10 {
182 return ""
183 }
184
185 versionStart := 5
186 versionEnd := versionStart
187 for versionEnd < n && handshake[versionEnd] != 0 {
188 versionEnd++
189 }
190
191 if versionEnd <= versionStart {
192 return ""
193 }
194
195 versionStr := string(handshake[versionStart:versionEnd])
196 return fmt.Sprintf("MySQL %s", versionStr)
197}
198
199func init() {
200 RegisterPluginWithPorts("mysql", func() Plugin {

Callers 1

identifyServiceMethod · 0.95

Calls 3

SetReadDeadlineMethod · 0.80
ReadMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected