MCPcopy Create free account
hub / github.com/dreadl0ck/netcap / WhatSoftwareHTTP

Function WhatSoftwareHTTP

decoder/stream/software/software.go:355–590  ·  view source on GitHub ↗

WhatSoftwareHTTP TODO: pass in the device profile.

(flowIdent string, h *types.HTTP)

Source from the content-addressed store, hash-verified

353
354// WhatSoftwareHTTP TODO: pass in the device profile.
355func WhatSoftwareHTTP(flowIdent string, h *types.HTTP) (s []*AtomicSoftware) {
356 // Get community ID from the HTTP record for correlation
357 communityID := h.CommunityID
358
359 // HTTP User Agents
360 if h.UserAgent != "" && h.UserAgent != " " {
361
362 UserAgentParserMutex.Lock()
363
364 userInfo, ok := UserAgentCache[h.UserAgent]
365 if !ok {
366 userInfo = ParseUserAgent(h.UserAgent)
367 if userInfo != nil {
368 UserAgentCache[h.UserAgent] = userInfo
369 softwareLog.Debug("UserAgent:", zap.String("userInfo", userInfo.Full))
370 }
371 }
372
373 UserAgentParserMutex.Unlock()
374
375 if userInfo != nil {
376 if userInfo.Product != "" || userInfo.Vendor != "" || userInfo.Version != "" {
377 var communityIDs []string
378 if communityID != "" {
379 communityIDs = []string{communityID}
380 }
381 s = append(s, &AtomicSoftware{
382 Software: &types.Software{
383 Timestamp: h.Timestamp,
384 Product: userInfo.Product,
385 Vendor: userInfo.Vendor,
386 Version: userInfo.Version,
387 // DeviceProfiles: []string{dpIdent},
388 SourceName: "UserAgent",
389 SourceData: h.UserAgent,
390 Service: "HTTP",
391 Flows: []string{flowIdent},
392 Notes: userInfo.Full,
393 OS: userInfo.OS,
394 CommunityIDs: communityIDs,
395 },
396 })
397 }
398 }
399 }
400
401 // HTTP Server Name
402 if h.ServerName != "" && h.ServerName != " " {
403 values := regExpServerName.FindStringSubmatch(h.ServerName)
404
405 var communityIDs []string
406 if communityID != "" {
407 communityIDs = []string{communityID}
408 }
409 s = append(s, &AtomicSoftware{
410 Software: &types.Software{
411 Timestamp: h.Timestamp,
412 Product: values[1], // Name of the server (Apache, Nginx, ...)

Callers 5

writeHTTPFunction · 0.92
BenchmarkCMSDetect_AllFunction · 0.85

Calls 4

ParseUserAgentFunction · 0.85
cmsCandidateProductsFunction · 0.85
makeSoftwareFunction · 0.85
StringMethod · 0.45