MCPcopy Index your code
hub / github.com/shadow1ng/fscan / identifyService

Method identifyService

plugins/services/mysql.go:142–170  ·  view source on GitHub ↗
(ctx context.Context, info *common.HostInfo, session *common.ScanSession)

Source from the content-addressed store, hash-verified

140}
141
142func (p *MySQLPlugin) identifyService(ctx context.Context, info *common.HostInfo, session *common.ScanSession) *ScanResult {
143 target := info.Target()
144
145 conn, err := session.DialTCP(ctx, "tcp", target, session.Config.Timeout)
146 if err != nil {
147 return &ScanResult{
148 Success: false,
149 Service: "mysql",
150 Error: err,
151 }
152 }
153 defer func() { _ = conn.Close() }()
154
155 if banner := p.readMySQLBanner(conn, session.Config); banner != "" {
156 common.LogSuccess(i18n.Tr("mysql_service", target, banner))
157 return &ScanResult{
158 Type: plugins.ResultTypeService,
159 Success: true,
160 Service: "mysql",
161 Banner: banner,
162 }
163 }
164
165 return &ScanResult{
166 Success: false,
167 Service: "mysql",
168 Error: fmt.Errorf("无法识别为MySQL服务"),
169 }
170}
171
172func (p *MySQLPlugin) readMySQLBanner(conn net.Conn, config *common.Config) string {
173 _ = conn.SetReadDeadline(time.Now().Add(config.Timeout))

Callers 1

ScanMethod · 0.95

Calls 6

readMySQLBannerMethod · 0.95
LogSuccessFunction · 0.92
TrFunction · 0.92
TargetMethod · 0.80
DialTCPMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected