Skip to content

Commit

Permalink
fixed missing chunk removal for invalid certificate table, fixed logi…
Browse files Browse the repository at this point in the history
…c for adding cert records to uconns (#634)

Co-authored-by: Logan Lembke <[email protected]>
  • Loading branch information
lisaSW and Zalgo2462 authored Apr 28, 2021
1 parent 1c07e04 commit a4726f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
36 changes: 20 additions & 16 deletions parser/fsimporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ func (fs *FSImporter) parseFiles(indexedFiles []*fpt.IndexedFile, parsingThreads
// Safely store ja3 information
mutex.Lock()

// create record if it doesn't exist
// create useragent record if it doesn't exist
if _, ok := useragentMap[ja3Hash]; !ok {
useragentMap[ja3Hash] = &useragent.Input{
Name: ja3Hash,
Expand All @@ -785,22 +785,25 @@ func (fs *FSImporter) parseFiles(indexedFiles []*fpt.IndexedFile, parsingThreads
}
}

//if there's any problem in the certificate, mark it invalid
if certStatus != "ok" && certStatus != "-" && certStatus != "" && certStatus != " " {
// Run conn pair through filter to filter out certain connections
ignore := fs.filterConnPair(srcIP, dstIP)
if !ignore {
// create uconn and cert records
// Run conn pair through filter to filter out certain connections
ignore := fs.filterConnPair(srcIP, dstIP)
if !ignore {

// Check if uconn map value is set, because this record could
// come before a relevant uconns record
if _, ok := uconnMap[srcDstKey]; !ok {
// create new uconn record if it does not exist
uconnMap[srcDstKey] = &uconn.Input{
Hosts: srcDstPair,
IsLocalSrc: util.ContainsIP(fs.GetInternalSubnets(), srcIP),
IsLocalDst: util.ContainsIP(fs.GetInternalSubnets(), dstIP),
}
// Check if uconn map value is set, because this record could
// come before a relevant uconns record (or may be the only source
// for the uconns record)
if _, ok := uconnMap[srcDstKey]; !ok {
// create new uconn record if it does not exist
uconnMap[srcDstKey] = &uconn.Input{
Hosts: srcDstPair,
IsLocalSrc: util.ContainsIP(fs.GetInternalSubnets(), srcIP),
IsLocalDst: util.ContainsIP(fs.GetInternalSubnets(), dstIP),
}
}

//if there's any problem in the certificate, mark it invalid
if certStatus != "ok" && certStatus != "-" && certStatus != "" && certStatus != " " {
// mark as having invalid cert
uconnMap[srcDstKey].InvalidCertFlag = true

Expand Down Expand Up @@ -829,6 +832,7 @@ func (fs *FSImporter) parseFiles(indexedFiles []*fpt.IndexedFile, parsingThreads
certMap[dstKey].OrigIps.Insert(srcUniqIP)
}
}

mutex.Unlock()
}
}
Expand Down Expand Up @@ -877,7 +881,7 @@ func (fs *FSImporter) buildCertificates(certMap map[string]*certificate.Input) {
}
certificateRepo.Upsert(certMap)
} else {
fmt.Println("\t[!] No certificate data to analyze")
fmt.Println("\t[!] No invalid certificate data to analyze")
}

}
Expand Down
1 change: 1 addition & 0 deletions pkg/remover/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (r *remover) removeOutdatedCIDs(cid int) error {
r.res.Config.T.Structure.UniqueConnTable,
r.res.Config.T.DNS.ExplodedDNSTable,
r.res.Config.T.DNS.HostnamesTable,
r.res.Config.T.Cert.CertificateTable,
r.res.Config.T.UserAgent.UserAgentTable,
}

Expand Down

0 comments on commit a4726f1

Please sign in to comment.