Skip to content

Commit

Permalink
user: fixed #542, masterkey being written to pcapng multiple times. (#…
Browse files Browse the repository at this point in the history
…546)

Signed-off-by: CFC4N <[email protected]>
  • Loading branch information
cfc4n committed May 19, 2024
1 parent 5e666ac commit 11a498a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions user/module/probe_openssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func (m *MOpenSSLProbe) saveMasterSecret(secretEvent *event.MasterSecretEvent) {
}

// save to file
var b *bytes.Buffer
var b = bytes.NewBuffer(nil)
switch secretEvent.Version {
case event.Tls12Version:
length := event.MasterSecretMaxLen
Expand Down Expand Up @@ -636,7 +636,6 @@ func (m *MOpenSSLProbe) Dispatcher(eventStruct event.IEventStruct) {
case *event.SSLDataEvent:
m.dumpSslData(eventStruct.(*event.SSLDataEvent))
}
m.logger.Debug().Msg("Dispatcher eventStruct")
}

func (m *MOpenSSLProbe) dumpSslData(eventStruct *event.SSLDataEvent) {
Expand Down
5 changes: 4 additions & 1 deletion user/module/probe_pcap.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (t *MTCProbe) dumpTcSkb(tcEvent *event.TcSkbEvent) error {
err, p := t.writePid(tcEvent)
if err == nil {
payload = p
t.logger.Debug().Uint32("pid", tcEvent.Pid).Str("comm", fmt.Sprintf("%s", tcEvent.Comm)).Str("cmdline", fmt.Sprintf("%s", tcEvent.Cmdline)).Msg("dumpTcSkb")
//t.logger.Debug().Uint32("pid", tcEvent.Pid).Str("comm", fmt.Sprintf("%s", tcEvent.Comm)).Str("cmdline", fmt.Sprintf("%s", tcEvent.Cmdline)).Msg("dumpTcSkb")
}
}
return t.writePacket(uint32(len(payload)), time.Unix(0, int64(timeStamp)), payload)
Expand Down Expand Up @@ -153,6 +153,9 @@ func (t *MTCProbe) savePcapng() (i int, err error) {
if err != nil {
return
}

// reset master key buffer, fix issue #542
t.masterKeyBuffer.Reset()
t.tcPacketLocker.Lock()
defer func() {
t.tcPacketLocker.Unlock()
Expand Down

0 comments on commit 11a498a

Please sign in to comment.