Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added basic PCAP capture and validation functionality. #24

Merged
merged 4 commits into from
Feb 8, 2021
Merged

Conversation

xvzcf
Copy link
Owner

@xvzcf xvzcf commented Jan 22, 2021

No description provided.

@xvzcf xvzcf requested review from chris-wood and cjpatton January 22, 2021 16:55
clientKeyLog, err := os.OpenFile("/logs/client_keylog", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
log.Fatal(err)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this is a dumb question, but here goes. Since the Go standard library is able to produce this output, it's conceivable that there's also code somewhere that consumes it. Asking another way: might there be a Go-native way to read and interpret this log? This would be better than calling tshark on the command line.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, Go crypto/tls only supports writing this secret. The callback was specifically added to support decryption in Wireshark. There is no way to feed these derived keys to Go crypto/tls and decrypt records.

Dissection (as is done by Wireshark) is a different use case than a client/server implementation. The former needs to play both the client and server at the same time, and try its best to interpret the data.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking at this @Lekensteyn. I'm thinking in the long term we might want to write a custom Wireshark dissector based on the stock TLS one, in order to handle experimental features (such as KEMTLS) that diverge from ordinary TLS to varying degrees. I believe the current dissector does not handle delegated credentials properly.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DC is partially supported in Wireshark git master. I have a local patch to dissect the TLS Certificate handshake message properly, but it does not perform actual (DC) certificate chain validation.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After talking to @chris-wood, we've decided to just do basic best-effort transcript validation for now, but I will get back to you on that.

func parsePcap(tsharkPath string, pcapPath string, keylogPath string) Transcript {
rawJSON, err := exec.Command(tsharkPath,
"-r", pcapPath,
"-d", "tcp.port==4433,ssl",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed, TLS is explicitly recognized through a heuristic if there is no other port override. It does not hurt though. I would however suggest changing the deprecated ssl to tls. The arguments can also be joined, whether you want to do it is a style question:

Suggested change
"-d", "tcp.port==4433,ssl",
"-dtcp.port==4433,tls",

@xvzcf xvzcf marked this pull request as ready for review February 5, 2021 17:32
@xvzcf
Copy link
Owner Author

xvzcf commented Feb 5, 2021

This PR is ready for review. I think there's scope for more cleanup/API changes depending on how the CI runner is built, but I'll leave those for when I get to the runner.

Copy link
Collaborator

@cjpatton cjpatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a bit of work I think.

@cjpatton cjpatton self-requested a review February 8, 2021 22:17
@xvzcf xvzcf merged commit ad65a5d into main Feb 8, 2021
@xvzcf xvzcf deleted the packet-capture branch February 8, 2021 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants