@@ -48,15 +48,15 @@ type Fingerprint struct {
4848 URL []string `json:"url"`
4949 Devicetype string `json:"devicetype,omitempty"` // 硬件类型: router, printer, camera, nas, server 等
5050 Tags []string `json:"tags,omitempty"` // 服务标签: database, webserver, monitoring 等
51- vendor string `json:"vendor,omitempty"`
51+ Vendor string `json:"vendor,omitempty"`
5252 Ports []int `json:"ports,omitempty"`
5353}
5454
5555// RawFingerprint represents a raw service fingerprint
5656type RawFingerprint struct {
5757 Devicetype string `json:"devicetype,omitempty"` // 硬件类型
5858 Tags []string `json:"tags,omitempty"` // 服务标签
59- vendor string `json:"vendor,omitempty"`
59+ Vendor string `json:"vendor,omitempty"`
6060 OS string `json:"os,omitempty"` // 操作系统
6161 Patterns []string `json:"patterns"`
6262}
@@ -70,7 +70,7 @@ type ServiceAnalyzer interface {
7070type PortFingerprint struct {
7171 Devicetype string `json:"devicetype,omitempty"` // 硬件类型
7272 Tags []string `json:"tags,omitempty"` // 服务标签
73- vendor string `json:"vendor,omitempty"`
73+ Vendor string `json:"vendor,omitempty"`
7474 OS string `json:"os,omitempty"`
7575}
7676
@@ -443,8 +443,8 @@ func (sd *ServiceDetector) checkURL(url string, port int) *ServiceInfo {
443443 if portFp .Devicetype != "" {
444444 info .Devicetype = portFp .Devicetype
445445 }
446- if portFp .vendor != "" {
447- info .vendor = portFp .vendor
446+ if portFp .Vendor != "" {
447+ info .Vendor = portFp .Vendor
448448 }
449449 if portFp .OS != "" {
450450 info .OS = portFp .OS
@@ -594,8 +594,8 @@ func (sd *ServiceDetector) matchFingerprint(ctx *detectionContext) *ServiceInfo
594594 if info .Devicetype == "" && fingerprint .Devicetype != "" {
595595 info .Devicetype = fingerprint .Devicetype
596596 }
597- if info .vendor == "" && fingerprint .vendor != "" {
598- info .vendor = fingerprint .vendor
597+ if info .Vendor == "" && fingerprint .Vendor != "" {
598+ info .Vendor = fingerprint .Vendor
599599 }
600600 }
601601 }
@@ -761,8 +761,8 @@ func (sd *ServiceDetector) detectTCP(ip string, port int) []ServiceInfo {
761761
762762 // 针对特定端口发送探测包
763763 if probe , exists := tcpProbes [port ]; exists && len (probe ) > 0 {
764- conn .SetWriteDeadline (time .Now ().Add (3 * time .Second ))
765- conn .Write (probe )
764+ _ = conn .SetWriteDeadline (time .Now ().Add (3 * time .Second ))
765+ _ , _ = conn .Write (probe )
766766 // 发送后等待一小会儿让服务响应
767767 time .Sleep (200 * time .Millisecond )
768768 }
@@ -798,7 +798,7 @@ func (sd *ServiceDetector) detectTCP(ip string, port int) []ServiceInfo {
798798 info := ServiceInfo {
799799 Types : []string {name },
800800 Banner : cleanedBanner ,
801- vendor : fp .vendor ,
801+ Vendor : fp .Vendor ,
802802 Devicetype : fp .Devicetype ,
803803 OS : fp .OS ,
804804 }
@@ -829,7 +829,7 @@ func (sd *ServiceDetector) detectTCP(ip string, port int) []ServiceInfo {
829829 info .Types = append (info .Types , portFp .Tags ... )
830830 }
831831 info .Devicetype = portFp .Devicetype
832- info .vendor = portFp .vendor
832+ info .Vendor = portFp .Vendor
833833 info .OS = portFp .OS
834834 }
835835
@@ -936,7 +936,7 @@ func (sd *ServiceDetector) detectUDP(ip string, port int) []ServiceInfo {
936936 info := ServiceInfo {
937937 Types : []string {name },
938938 Banner : cleanedBanner ,
939- vendor : fp .vendor ,
939+ Vendor : fp .Vendor ,
940940 Devicetype : fp .Devicetype ,
941941 OS : fp .OS ,
942942 }
@@ -967,7 +967,7 @@ func (sd *ServiceDetector) detectUDP(ip string, port int) []ServiceInfo {
967967 info .Types = append (info .Types , portFp .Tags ... )
968968 }
969969 info .Devicetype = portFp .Devicetype
970- info .vendor = portFp .vendor
970+ info .Vendor = portFp .Vendor
971971 info .OS = portFp .OS
972972 }
973973
@@ -1014,7 +1014,6 @@ func (sd *ServiceDetector) detectOS(info ServiceInfo) string {
10141014func (sd * ServiceDetector ) detectOSFromBanner (banner string ) string {
10151015 lowerBanner := strings .ToLower (banner )
10161016
1017-
10181017 if strings .Contains (lowerBanner , "ubuntu" ) {
10191018 return "ubuntu"
10201019 }
@@ -1046,7 +1045,6 @@ func (sd *ServiceDetector) detectOSFromBanner(banner string) string {
10461045 return "raspbian"
10471046 }
10481047
1049-
10501048 if strings .Contains (lowerBanner , "freebsd" ) {
10511049 return "freebsd"
10521050 }
@@ -1057,7 +1055,6 @@ func (sd *ServiceDetector) detectOSFromBanner(banner string) string {
10571055 return "netbsd"
10581056 }
10591057
1060-
10611058 if strings .Contains (lowerBanner , "cisco" ) {
10621059 if strings .Contains (lowerBanner , "ios-xe" ) || strings .Contains (lowerBanner , "ios xe" ) {
10631060 return "cisco-ios-xe"
@@ -1074,42 +1071,35 @@ func (sd *ServiceDetector) detectOSFromBanner(banner string) string {
10741071 return "cisco-ios"
10751072 }
10761073
1077-
10781074 if strings .Contains (lowerBanner , "huawei" ) || strings .Contains (lowerBanner , "vrp" ) {
10791075 return "huawei-vrp"
10801076 }
10811077
1082-
10831078 if strings .Contains (lowerBanner , "comware" ) || strings .Contains (lowerBanner , "h3c" ) {
10841079 return "h3c-comware"
10851080 }
10861081
1087-
10881082 if strings .Contains (lowerBanner , "junos" ) || strings .Contains (lowerBanner , "juniper" ) {
10891083 return "juniper-junos"
10901084 }
10911085
1092-
10931086 if strings .Contains (lowerBanner , "fortigate" ) || strings .Contains (lowerBanner , "fortios" ) {
10941087 return "fortinet-fortios"
10951088 }
10961089
1097-
10981090 if strings .Contains (lowerBanner , "pan-os" ) || strings .Contains (lowerBanner , "palo alto" ) {
10991091 return "paloalto-panos"
11001092 }
11011093
1102-
1094+ //nolint:misspell // routeros is the correct product name
11031095 if strings .Contains (lowerBanner , "mikrotik" ) || strings .Contains (lowerBanner , "routeros" ) {
1104- return "mikrotik-routeros"
1096+ return "mikrotik-routeros" //nolint:misspell
11051097 }
11061098
1107-
11081099 if strings .Contains (lowerBanner , "arista" ) || strings .Contains (lowerBanner , "eos" ) {
11091100 return "arista-eos"
11101101 }
11111102
1112-
11131103 if strings .Contains (lowerBanner , "ruijie" ) || strings .Contains (lowerBanner , "锐捷" ) {
11141104 return "ruijie"
11151105 }
@@ -1150,7 +1140,6 @@ func (sd *ServiceDetector) detectOSFromBanner(banner string) string {
11501140 return "citrix-netscaler"
11511141 }
11521142
1153-
11541143 if strings .Contains (lowerBanner , "linux" ) {
11551144 return "linux"
11561145 }
@@ -1199,7 +1188,7 @@ func (sd *ServiceDetector) detectOSFromHTTP(info ServiceInfo) string {
11991188 return "fortinet-fortios"
12001189 }
12011190 if strings .Contains (lowerServer , "mikrotik" ) {
1202- return "mikrotik-routeros"
1191+ return "mikrotik-routeros" // nolint:misspell
12031192 }
12041193 }
12051194
@@ -1580,8 +1569,8 @@ func (sd *ServiceDetector) updateServiceInfoFromLua(info *ServiceInfo, tbl *lua.
15801569 if v := tbl .RawGetString ("OS" ); v != lua .LNil {
15811570 info .OS = v .String ()
15821571 }
1583- if v := tbl .RawGetString ("vendor " ); v != lua .LNil {
1584- info .vendor = v .String ()
1572+ if v := tbl .RawGetString ("Vendor " ); v != lua .LNil {
1573+ info .Vendor = v .String ()
15851574 }
15861575 if v := tbl .RawGetString ("Devicetype" ); v != lua .LNil {
15871576 info .Devicetype = v .String ()
0 commit comments