├── Code-of-Conduct.md ├── LICENSE ├── README.md ├── contributing.md ├── spicy-noise-1.spicy ├── spicy-noise-2.spicy ├── spicy-noise-4.spicy ├── spicy-noise.evt ├── spicy-noise.hlto ├── spicy-noise.spicy ├── traces ├── list.txt ├── wireguard-ping-tcp.pcap └── wireguard-psk.pcap └── zeek ├── __load__.zeek ├── dpd.sig ├── spicy-noise.hlto └── spicy-noise.zeek /Code-of-Conduct.md: -------------------------------------------------------------------------------- 1 | # Verizon Media Open Source Code of Conduct 2 | ## Summary 3 | This Code of Conduct is our way to encourage good behavior and discourage bad behavior in our open source projects. We invite participation from many people to bring different perspectives to our projects. We will do our part to foster a welcoming and professional environment free of harassment. We expect participants to communicate professionally and thoughtfully during their involvement with this project. 4 | 5 | Participants may lose their good standing by engaging in misconduct. For example: insulting, threatening, or conveying unwelcome sexual content. We ask participants who observe conduct issues to report the incident directly to the project's Response Team at opensource-conduct@verizonmedia.com. Verizon Media will assign a respondent to address the issue. We may remove harassers from this project. 6 | 7 | This code does not replace the terms of service or acceptable use policies of the websites used to support this project. We acknowledge that participants may be subject to additional conduct terms based on their employment which may govern their online expressions. 8 | 9 | ## Details 10 | This Code of Conduct makes our expectations of participants in this community explicit. 11 | 12 | * We forbid harassment and abusive speech within this community. 13 | * We request participants to report misconduct to the project’s Response Team. 14 | * We urge participants to refrain from using discussion forums to play out a fight. 15 | 16 | ## Expected Behaviors 17 | We expect participants in this community to conduct themselves professionally. Since our primary mode of communication is text on an online forum (e.g. issues, pull requests, comments, emails, or chats) devoid of vocal tone, gestures, or other context that is often vital to understanding, it is important that participants are attentive to their interaction style. 18 | 19 | * ___Assume positive intent.___ We ask community members to assume positive intent on the part of other people’s communications. We may disagree on details, but we expect all suggestions to be supportive of the community goals. 20 | * ___Respect participants.___ We expect occasional disagreements. Open Source projects are learning experiences. Ask, explore, challenge, and then respectfully state if you agree or disagree. If your idea is rejected, be more persuasive not bitter. 21 | * ___Welcoming to new members.___ New members bring new perspectives. Some ask questions that have been addressed before. Kindly point to existing discussions. Everyone is new to every project once. 22 | * ___Be kind to beginners.___ Beginners use open source projects to get experience. They might not be talented coders yet, and projects should not accept poor quality code. But we were all beginners once, and we need to engage kindly. 23 | * ___Consider your impact on others.___ Your work will be used by others, and you depend on the work of others. We expect community members to be considerate and establish a balance their self-interest with communal interest. 24 | * ___Use words carefully.___ We may not understand intent when you say something ironic. Often, people will misinterpret sarcasm in online communications. We ask community members to communicate plainly. 25 | * ___Leave with class.___ When you wish to resign from participating in this project for any reason, you are free to fork the code and create a competitive project. Open Source explicitly allows this. Your exit should not be dramatic or bitter. 26 | 27 | ## Unacceptable Behaviors 28 | Participants remain in good standing when they do not engage in misconduct or harassment (some examples follow). We do not list all forms of harassment, nor imply some forms of harassment are not worthy of action. Any participant who feels harassed or observes harassment, should report the incident to the Response Team. 29 | 30 | * ___Don't be a bigot.___ Calling out project members by their identity or background in a negative or insulting manner. This includes, but is not limited to, slurs or insinuations related to protected or suspect classes e.g. race, color, citizenship, national origin, political belief, religion, sexual orientation, gender identity and expression, age, size, culture, ethnicity, genetic features, language, profession, national minority status, mental or physical ability. 31 | * ___Don't insult.___ Insulting remarks about a person’s lifestyle practices. 32 | * ___Don't dox.___ Revealing private information about other participants without explicit permission. 33 | * ___Don't intimidate.___ Threats of violence or intimidation of any project member. 34 | * ___Don't creep.___ Unwanted sexual attention or content unsuited for the subject of this project. 35 | * ___Don't inflame.___ We ask that victim of harassment not address their grievances in the public forum, as this often intensifies the problem. Report it, and let us address it off-line. 36 | * ___Don't disrupt.___ Sustained disruptions in a discussion. 37 | 38 | ## Reporting Issues 39 | If you experience or witness misconduct, or have any other concerns about the conduct of members of this project, please report it by contacting our Response Team at opensource-conduct@verizonmedia.com who will handle your report with discretion. Your report should include: 40 | 41 | * Your preferred contact information. We cannot process anonymous reports. 42 | * Names (real or usernames) of those involved in the incident. 43 | * Your account of what occurred, and if the incident is ongoing. Please provide links to or transcripts of the publicly available records (e.g. a mailing list archive or a public IRC logger), so that we can review it. 44 | * Any additional information that may be helpful to achieve resolution. 45 | 46 | After filing a report, a representative will contact you directly to review the incident and ask additional questions. If a member of the Verizon Media Response Team is named in an incident report, that member will be recused from handling your incident. If the complaint originates from a member of the Response Team, it will be addressed by a different member of the Response Team. We will consider reports to be confidential for the purpose of protecting victims of abuse. 47 | 48 | ## Scope 49 | Verizon Media will assign a Response Team member with admin rights on the project and legal rights on the project copyright. The Response Team is empowered to restrict some privileges to the project as needed. Since this project is governed by an open source license, any participant may fork the code under the terms of the project license. The Response Team’s goal is to preserve the project if possible, and will restrict or remove participation from those who disrupt the project. 50 | 51 | This code does not replace the terms of service or acceptable use policies that are provided by the websites used to support this community. Nor does this code apply to communications or actions that take place outside of the context of this community. Many participants in this project are also subject to codes of conduct based on their employment. This code is a social-contract that informs participants of our social expectations. It is not a terms of service or legal contract. 52 | 53 | ## License and Acknowledgment. 54 | This text is shared under the CC-BY-4.0 license. This code is based on a study conducted by the TODO Group of many codes used in the open source community. If you have feedback about this code, contact our Response Team at the address listed above. 55 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spicy-noise 2 | 3 | ## Overview 4 | This repository is a [Spicy](https://docs.zeek.org/projects/spicy/en/latest/index.html) protocol analyzer for [WireGuard](https://www.wireguard.com/protocol/). The goal is to be able to identify and analyze WireGuard traffic at wire speed with [Zeek](https://zeek.org). 5 | 6 | The analyzer is based on WireGuard's [whitepaper](https://www.wireguard.com/papers/wireguard.pdf). 7 | 8 | 9 | ## Setup development environment 10 | Spicy must be installed. Reference the [Installation documents](https://docs.zeek.org/projects/spicy/en/latest/installation.html) for additional details on setup. 11 | 12 | ## Clone the repository 13 | 14 | git clone https://github.com/theparanoids/spicy-noise 15 | cd spicy-noise 16 | 17 | ## Zeek Integration 18 | Zeek with the Spicy plugin install can load analyzers in two methods. Just-In-Time (JIT) compilation will build the parser when Zeek is started. Zeek can also load a precompiled parser, referred to as non-JIT. Both methods require a .spicy file and a .evt file. 19 | 20 | ## JIT Usage 21 | Zeek can perform just in time compilation of spicy parsers. You can test this from the directory where the repository was downloaded. Start Zeek and have it read in the wireguard-psk.pcap file and load the parser, event file, and Spicy-Noise script. 22 | 23 | ./zeek -Cr traces/wireguard-psk.pcap spicy-noise.spicy spicy-noise.evt zeek/__load__.zeek 24 | 25 | ## non JIT Usage 26 | Zeek can also load precompiled parsers. Change to the directory containing Spicy and configure with this command. 27 | 28 | ### Build Compiled Parser 29 | 30 | To build a compiled parser change into the repository's directory. Then use spicyz to create the compiled spicy-noise.hlto parser by specifying the .spicy and .evt files. 31 | 32 | spicyz -o spicy-noise.hlto spicy-noise.spicy spicy-noise.evt 33 | 34 | ### Build Zeek Plugin 35 | Reference Spicy's Installation document and configure with the disable jit for zeek option. Then make the zeek-plugin. 36 | 37 | ./configure --disable-jit-for-zeek 38 | make zeek-plugin 39 | make install 40 | 41 | This will build the [Zeek plugin](https://docs.zeek.org/projects/spicy/en/latest/zeek.html?highlight=plugin#installation) found at /zeek/plugin/Zeek_Spicy.tgz. Move the Zeek_Spicy.tgz archive to your monitoring platform. Extract contents of the archive to /lib/zeek/plugins/Zeek_Spicy. 42 | 43 | Zeek must be built with Zeek support as defined in the documentation. 44 | 45 | ## Deploy Spicy Noise 46 | 47 | Following the instructions above will install all of the requirements to deploy Spicy WireGuard parser. Copy the contents of the zeek directory from the repository and the spicy-noise.hlto file just created to /share/zeek/site/spicy-noise. Load the spicy-noise directory by adding the following line to your local.zeek file. 48 | 49 | @load spicy-noise 50 | 51 | Add the following line to /share/zeek/site/spicy-noise/__load__.bro to instruct Zeek to use the spicy-noise.hlto parser. 52 | 53 | @load ./spicy-noise.hlto 54 | 55 | Restart Zeek via zeekctl and deploy the new Spicy WireGuard parser. 56 | 57 | zeekctl stop 58 | zeekctl install 59 | zeekctl check 60 | zeekctl deploy 61 | 62 | Zeek will match packets on the monitored network to the dynamic protocol detection signature for WireGuard. The streams will be forwarded and parsed by spicy-noise.hlto and raise events which are handled by wg.zeek. Zeek will notate WireGuard traffic in conn.log with a service of wireguard. A new spicy-noise.log will be created containing details of the protocol negotiation. 63 | 64 | Sample of conn.log 65 | 66 | 1533078876.827830 C7vNhD34zEBSPh6gh4 10.9.0.1 41255 10.9.0.2 51820 udp wireguard 0.003753 148 92 SF - - 0 Dd 1 176 1 120 - 67 | 1533079228.549600 CgCeXs3AQVNtWqtggj 10.9.0.2 51820 10.9.0.1 41255 udp wireguard 0.005269 148 92 SF - - 0 Dd 1 176 1 120 - 68 | #close 2020-06-26-17-10-28 69 | 70 | Sample of spicy-noise.log 71 | 72 | 1533078876.827830 10.9.0.1 41255 10.9.0.2 51820 INITIATION c1039c02 - f30ceb67148dd27c78d52d0196b6b78b71542986f563ac898879353f022f1747 70c5b3d433cfb49fd3311688284ce67ec72111e655129fc5f6bed2e0a44b8d28c222c6e1479a0833c7a1f6417b733c1e f049fab5e451aff561ea428c2116f7d1023ccdac2b2a00ecbe0273c9 - - - f84b1c695032084b58e7d2ff9fcf19fd 00000000000000000000000000000000 - - 73 | 74 | 1533078876.831583 10.9.0.1 41255 10.9.0.2 51820 RESPONSE dce3fa01 c1039c02 394ce1067faccdff74d71ddde6450ccedb94839008a7a2c0cdb0b4abe080565b - - 96d16752c32e60baabfb5413fba24276 - - beae31ece918c01700e5dfe66ca3c7b9 00000000000000000000000000000000 - - 75 | 76 | ## Spicy-Noise Creator 77 | Jeff Atkinson. 78 | 79 | Please share your questions and suggestions by filing an issue on [Github](https://github.com/theparanoids/spicy-noise/issues). 80 | -------------------------------------------------------------------------------- /contributing.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | First, thanks for taking the time to contribute to our project! There are many ways you can help out. 3 | 4 | ## Questions 5 | If you have a question that needs an answer, create an issue, and label it as a question. 6 | 7 | ## Issues for bugs or feature requests 8 | If you encounter any bugs in the code, or want to request a new feature or enhancement, please create an issue to report it. Kindly add a label to indicate what type of issue it is. 9 | 10 | ## Contribute Code 11 | We welcome your pull requests for bug fixes. To implement something new, please create an issue first so we can discuss it together. 12 | 13 | ## Creating a Pull Request 14 | Please follow best practices for creating git commits. 15 | 16 | ## When your code is ready to be submitted, submit a pull request to begin the code review process. 17 | 18 | We only seek to accept code that you are authorized to contribute to the project. We have added a pull request template on our projects so that your contributions are made with the following confirmation: 19 | 20 | I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner. 21 | 22 | -------------------------------------------------------------------------------- /spicy-noise-1.spicy: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020, Verizon Media 3 | # Licensed under the terms of the Apache 2.0 license. See LICENSE file in github.com/theparanoids/spicy-noise root directory for terms 4 | 5 | module Wireguard; 6 | 7 | import spicy; 8 | 9 | public type Handshake_Initiation = unit { 10 | msg_type: uint8; 11 | reserved_zero: uint8[3]; 12 | sender_index: uint32 &byte-order=spicy::ByteOrder::Little; 13 | unenc_ephemeral_array: uint8[32]; 14 | enc_static_array: uint8[48]; 15 | enc_timestamp: uint8[28]; 16 | mac1: uint8[16]; 17 | mac2: uint8[16]; 18 | 19 | on %done { 20 | print "WG_TYPE: %X" % self.msg_type; 21 | print "RESERVED: %x" % self.reserved_zero; 22 | print "SENDER_INDEX: %02X" % self.sender_index; 23 | # print "UNENC_EPHEMERAL_BYTES: %x" % self.unenc_ephemeral_bytes; 24 | print "UNENC_EPHEMERAL_ARRAY: %x" % self.unenc_ephemeral_array; 25 | #print "ENC_STATIC_BYTES: %x" % self.enc_static_bytes; 26 | print "ENC_STATIC_ARRAY: %s" % self.enc_static_array; 27 | print "ENC_TIMESTAMP %X" % self.enc_timestamp; 28 | print "MAC1: %X" % self.mac1; 29 | print "MAC2: %X" % self.mac2; 30 | } 31 | }; 32 | 33 | #u8 message_type 34 | #u8 reserved_zero[3] 35 | #u32 sender_index 36 | #u8 unencrypted_ephemeral[32] 37 | #u8 encrypted_static[AEAD_LEN(32)] 38 | #u8 encrypted_timestamp[AEAD_LEN(12)] 39 | #u8 mac1[16] 40 | #u8 mac2[16] 41 | 42 | # To Test 43 | #printf '\x01\x00\x00\x00\x02\x9c\x03\xc1\xf3\x0c\xeb\x67\x14\x8d\xd2\x7c\x78\xd5\x2d\x01\x96\xb6\xb7\x8b\x71\x54\x29\x86\xf5\x63\xac\x89\x88\x79\x35\x3f\x02\x2f\x17\x47\x70\c5\b3\d4\33\cf\b4\9f\d3\31\16\88\28\4c\e6\7e\c7\21\11\e6\55\12\9f\c5\f6\be\d2\e0\a4\4b\8d\28\c2\22\c6\e1\47\9a\08\33\c7\a1\f6\41\7b\73\3c\1e\f0\49\fa\b5\e4\51\af\f5\61\ea\42\8c\21\16\f7\d1\02\3c\cd\ac\2b\2a\00\ec\be\02\73\c9\f8\4b\1c\69\50\32\08\4b\58\e7\d2\ff\9f\cf\19\fd\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00' | spicy-driver wg.spicy 44 | -------------------------------------------------------------------------------- /spicy-noise-2.spicy: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020, Verizon Media 3 | # Licensed under the terms of the Apache 2.0 license. See LICENSE file in github.com/theparanoids/spicy-noise root directory for terms 4 | 5 | module Wireguard; 6 | 7 | import spicy; 8 | 9 | public type HandShake_Reply = unit { 10 | msg_type: uint8; 11 | reserved_zero: uint8[3]; 12 | sender_index: uint32 &byte-order=spicy::ByteOrder::Little; 13 | receiver_index: uint32 &byte-order=spicy::ByteOrder::Little; 14 | unenc_ephemeral: uint8[32]; 15 | enc_nothing: uint8[16]; 16 | mac1: uint8[16]; 17 | mac2: uint8[16]; 18 | 19 | on %done { 20 | print "WG_TYPE: %x" % self.msg_type; 21 | print "RESERVED: %x" % self.reserved_zero; 22 | print "SENDER_INDEX: %02X" % self.sender_index; 23 | print "RECEIVER_INDEX: %02X" % self.receiver_index; 24 | print "UNENC_EPHEMERAL: %x" % self.unenc_ephemeral; 25 | print "ENC_NOTHING: %x" % self.enc_nothing; 26 | print "MAC1: %X" % self.mac1; 27 | print "MAC2: %X" % self.mac2; 28 | } 29 | }; 30 | 31 | #msg = handshake_response { 32 | # u8 message_type 33 | # u8 reserved_zero[3] 34 | # u32 sender_index 35 | # u32 receiver_index 36 | # u8 unencrypted_ephemeral[32] 37 | # u8 encrypted_nothing[AEAD_LEN(0)] 38 | # u8 mac1[16] 39 | # u8 mac2[16] 40 | #} 41 | 42 | # 0x0020: 01fa e3dc 029c 03c1 394c e106 7fac cdff 43 | # 0x0030: 74d7 1ddd e645 0cce db94 8390 08a7 a2c0 44 | # 0x0040: cdb0 b4ab e080 565b 96d1 6752 c32e 60ba 45 | # 0x0050: abfb 5413 fba2 4276 beae 31ec e918 c017 46 | # 0x0060: 00e5 dfe6 6ca3 c7b9 0000 0000 0000 0000 47 | # 0x0070: 0000 0000 0000 0000 48 | 49 | #To Test 50 | #printf '02\x00\x00\x00\x01\xfa\xe3\xdc\x02\x9c\x03\xc1\x39\x4c\xe1\x06\x7f\xac\xcd\xff\x74\xd7\x1d\xdd\xe6\x45\x0c\xce\xdb\x94\x83\x90\x08\xa7\xa2\xc0\xcd\xb0\xb4\xab\xe0\x80\x56\x5b\x96\xd1\x67\x52\xc3\x2e\x60\xba\xab\xfb\x54\x13\xfb\xa2\x42\x76\xbe\xae\x31\xec\xe9\x18\xc0\x17\x00\xe5\xdf\xe6\x6c\xa3\xc7\xb9\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' | spicy-driver wg-2.spicy 51 | -------------------------------------------------------------------------------- /spicy-noise-4.spicy: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020, Verizon Media 3 | # Licensed under the terms of the Apache 2.0 license. See LICENSE file in github.com/theparanoids/spicy-noise root directory for terms 4 | 5 | module WireGuard; 6 | 7 | import spicy; 8 | 9 | public type Tranport_Data = unit { 10 | msg_type: uint8; 11 | reserved_zero: uint8[3]; 12 | receiver_index: uint32 &byte-order=spicy::ByteOrder::Little; 13 | counter: uint64 &byte-order=spicy::ByteOrder::Little; 14 | enc_packet: bytes &eod; 15 | 16 | on %done { 17 | print "WG_TYPE: %x" % self.msg_type; 18 | print "RESERVED_ZERO: %x" % self.reserved_zero; 19 | print "RECEIVER_INDEX: %x" % self.receiver_index; 20 | print "COUNTER: %x" % self.counter; 21 | print "ENCRYPTED_PACKET: %x" % self.enc_packet; 22 | } 23 | 24 | }; 25 | 26 | 27 | #msg = packet_data { 28 | # u8 message_type 29 | # u8 reserved_zero[3] 30 | # u32 receiver_index 31 | # u64 counter 32 | # u8 encrypted_encapsulated_packet[] 33 | #} 34 | 35 | 36 | # TEST 37 | # printf '\x04\x00\x00\x00\xb9\x9e\xde\x26\x03\x00\x00\x00\x00\x00\x00\x00\xad\x12\x98\x79\xd3\x4f\x4e\x7a\x15\x11\xcf\x31\xde\xba\x59\x83\x65\x08\x34\xf0\xbc\x98\x64\x27\x1e\xfd\x47\x9a\x6c\xae\x5f\x9f\x2f\xff\x3d\x80\x16\x58\x1c\xbd\xa6\x8d\x3f\x42\xfb\x9e\x6d\x26\xe5\x15\x8c\x75\xd8\x28\xc6\x1d\x11\x58\x27\xda\x17\xbc\xa7\xae\x56\xec\x18\x5e\x2a\x9a\x41\x9a\xad\xe6\x29\xf4\x5e\xce\xcf\x29\x46\x98\x06\x54\xee\x32\x23\x4d\xed\xe4\x1a\x68\x9c\x66\x27\xf3\x10\xbb\xd5\x5b\x4c\x3d\x6c\x69\x05\x87\x72\xf4\x7b\x07\x36\x26\x63\xe2\x31\x93\xdf\x43\xbe\x58\xfa\xdd\x41\x32\xf5\xd1\xb7\xae\xe9\xaa\x3e\xa8\x45\xd4\x50\x3d\x61\x54\x74\x8a\x72\x98\x0e\x1a\x9f\xf1\x96\x5e\xc0\x8c\xf6\x2c\xd4\xe1\x2d\xeb\x87\xb1\x01\xf3\xbc\xa4\x57\x99\xb5\x04\xe9\xd7\xa7\x0b\xba\x23\xcd\xa8\xc9\x5d\xdc\x46\x21\xda\x9e\xe5\x17\xf4\x72\xf4\x63\xb7\x94\x1f\x6c\xa7\xf3\xc1\xe9\xc7\xd2\x38\xeb\xcb\x56\x26\x77\xc2\xc8\x82\x17\xf4\x3b\x6b\x06\x2a\x16\xe0\xab\x70\xc8\xd4\xd5\x14\x2c\xed\x13\xc6\x5b\x87\xe1\x88\x56\xb3\x97\xd3\x6c\xbd\x2b\x81\xbd\x63\x08\x23\x8f\x24\x79\x40\xad\x90\xb9\xdb\xaa\xff\x5d\x05\x93\x3b\x04\xf0\x95\x78\xf0\x30\x15\x6e\x62\x3d\x93\x9a\xee\xf9\x31\x68\xf1\x7a\xa6\xa5\x83\x4a\x04\xf0\x46\x22\xc8\x0a\x28\xb1\xe7\x04\x0b\xd1\xad\x1c\x06\x98\x0c\xc6\xbc\x8d\x0b\x19\xaf\xc9\x12\x94\xc9\x17\x68\xd5\x11\x4c\x6b\x27\xd7\x14\xea\x7e\xe8\x3a\xa6\x52\xb3\x5b\x06\xbd\xdd\x9c\x31\x84\xf3\xb5\xee\x02\x43\xa7\xc7\xd9\xbf\x0d\x1f\xf2\x04\x8f\xe2\x89\xe3\xd2\x0a\x7b\x31\x7b\x22\x55\xc2\xd0\x55\x25\xe0\xdd\xcf\x06\x40\xca\xb5\x51\xf6\xf6\x05\x7f\x25\x51\x1f\x83\x22\xad\x96\x2e\xc3\x7d\xd5\x91\x30\x3d\xf0\xe1\x17\x72\xaa\xdd\x4d\x23\xaf\xb1\x39\xf4\xe0\x92\xff\xd4\x39\x8a\x4e\x37\x63\xf0\x71\xe3\xb6\xe0\x62\xb2\x6e\xaf\x3a\x87\xdd\xac\x54\x66\x55\x24\x44\x02\x21\x39\xb4\x8e\x07\x79\xc2\x24\x65\x5f\xe2\xbb\x6d\xf8\xe4\x92\x1e\xf0\x54\xd6\x65\x95\x5f\xbc\x85\x46\xf5\x56\xa6\x90\x73\xcb\x7b\x48\x01\x41\x1e\x1e\x78\xb7\xd4\x58\x89\x51\x42\xb5\x3e\x6a\x25\x90\x05\xa6\x4a\x33\x1a\x28\xc9\x8c\x19\x3d\x91\x93\x95\x4b\x4a\x99\x4f\xd0\xd7\xf7\x09\xf4\x67\x81\x2a\xe0\xfa\x4f\x18\x1e\xfb\xfa\x24\x3a\x5a\xaf\x3d\x78\x02\x1d\xec\xa2\x02\x24\x87\x54\x9f\xf6\x95\x61\xd3\x2b\xb0\x4f\xc8\xfc\x1c\x22\x29\x37\xab\xe7\x48\x52\x92\x30\x2f\x9f\xfb\x76\x86\x03\x71\xec\xe9\x9e\xc7\x01\xe6\x8f\xca\x8c\x0b\xc1\xc3\x76\x30\xa8\x0b\x8d\x2f\x25\x6e\xa8\x5a\xcc\x1a\xd8\xb5\x78\x24\xe2\xd6\x59\x74\xd7\xab\x25\x08\x46\xc3\x19\x1b\xc7\x62\x27\xa5\x0a\xd7\x73\x93\x0e\xef\x62\x12\x0f\x13\xe9\x37\xec\x5c\x57\x07\x2a\x09\xde\x38\x39\x36\x53\xab\x6d\x1a\x15\xbc\xed\xb9\x1f\x2d\xab\x3f\x84\x98\x32\x64\x37\x74\x44\x0d\x44\x35\x64\x0b\x2f\x32\xbd\x04\x52\x00\x8d\x54\x3a\x49\xd7\x9e\x90\xe8\xf9\x25\x39\xd0\x52\x9c\x99\xd0\x7d\xe2\x1b\x69\x44\xcf\x9d\x74\x00\xcd\x52\x62\x4f\x0f\xb2\x49\x00\x8f\x00\x16\x09\x0c\x37\xb6\x6e\x8e\x0a\xbb\xbf\x66\x52\x5c\xd8\x69\x0d\x7d\x4c\x0f\xee\xf3\x75\x85\x30\xbb\xc1\xac\x95\xd3\x0a\x4d\x8b\x73\xf8\x16\x92\x86\x82\x6d\x71\x24\xa6\x5d\x87\x40\xba\x9f\x22\xd7\x69\x46\x06\xd2\x49\x7f\xb1\x71\x00\xd4\xb0\x7a\x0e\x5b\x1e\x0a\xf7\x38\x4f\x55\x2c\x96\x6a\xe4\x92\x0a\x85\x8f\xb4\x70\x82\x91\x17\xcc\xa6\x23\x9a\x1f\xf6\xf5\xc4\x4c\x64\xfb\x25\x07\xb6\xe9\x05\x67\xf3\x37\xa4\x7a\xf2\x35\xf3\x7c\xa2\xa9\x2e\x6a\x6f\x1a\x9d\xb7\xde\x9e\x4f\x5f\xd6\xf2\x61\x7f\xd9\x33\x42\x60\x18\x22\x3f\x5d\xf9\x80\xac\x15\xa1\x2d\xd9\x63\xfd\x24\x5a\xbc\x79\xa0\xdd\x13\x5d\x21\xa3\x32\x44\x67\x86\xe7\x04\x8e\xcc\x39\x5b\x5f\x02\x14\x9a\x3e\x95\xa6\xc7\x92\x6b\x99\x50\x9f\xab\x75\x57\xc4\xbe\x26\x9d\xcb\x6e\xc4\xc2\x02\x1c\x53\x6b\x06\x58\xf5\xa7\xee\x3c\x3e\x58\xf3\x86\xfb\xbd\x3d\x08\x11\xad\x7f\x0e\xff\x2d\xde\x8c\x0e\x63\x6c\xbd\x3f\x66\xee\x6b\xd3\x28\xe5\x48\x1f\x12\x72\x6a\x20\x3d\xf7\xbc\xbd\x3f\x81\x43\xe2\x68\xe3\x94\x76\xed\x9d\xc2\x51\xb5\x47\xaa\xad\x6e\x06\x5e\xb4\x28\xb8\x5f\x6e\xaf\x6f\x8e\x20\xc0\x24\x9a\x8d\x63\xcf\x9d\x63\xe9\x46\xf2\x4f\x64\x54\xc2\xbf\x80\x05\x67\xf0\x7c\x75\x31\x0f\x3c\x31\x46\xe8\x63\xd2\xba\x1d\xc3\x76\xb7\x66\x21\x6d\x1a\xa2\x17\x61\xe0\xda\xbc\xc3\x84\xdc\xe9\x27\xff\x34\x86\x11\x32\x07\x3a\x77\xd3\xb9\xf1\x81\x75\xdc\x52\x45\xa3\x94\x18\x63\x2f\xeb\x10\x57\xcf\x3a\xbe\xaa\x36\xba\x24\xc2\xf1\xfc\xcd\x79\xca\x14\xd0\x13\x63\x69\x56\xb3\x5e\xbd\xba\xcc\x04\x11\x3b\x4d\xd3\x95\xc9\x93\xf8\x01\xdb\xd0\x38\x1c\x8e\xd4\x07\x13\x8c\xab\x4e\x80\xa6\x8f\x7d\x44\x1e\x1e\x39\xf6\xd7\xfe\x37\x54\xef\x55\x86\x73\x6a\xa3\x39\x54\xe6\x7d\x6e\x77\xec\x71\x13\xe0\x8a\xc2\xde\xe4\x43\xd4\xce\x9f\x85\x15\x17\xfc\x78\xa6\x82\x09\x75\x5f\x39\xd6\x32\x1e\x84\x16\x4d\x47\xe9\xed\x58\x53\xeb\xe3\x07\x3a\x58\xc8\x20\x38\x9d\xff\xfd\x45\x8a\x88\x0b\xca\x5e\xbb\x0a\x93\x76\x2c\x24\xb7\x55\x28\x8a\x81\x9d\x70\xf7\xb5\xec\x29\x6f\x7d\xb8\x2d\x59\x22\xcc\x86\x94\x34\x7d\x59\x59\x60\x31\x65\xaf\xc1\xd5\x19\xf7\x2b\xc7\xf0\x2a\x5e\xf7\x1b\xe7\x7a\x23\xab\x8d\x73\x3d\x11\x8a\x20\x04\x60\xaa\x04\x90\xde\xd6\x79\xbd\xca\x98\x84\x18\x23\x24\xf8\x50\xdd\x88\xe0\x77\xe3\x47\x2d\x22\xd2\xb5\xc4\xb8\x47\xaf\x0d\xaa\xc1\x6d\xfc\x30\xf9\xf8\x1e\x7d\x87\xfd\x96\xed\xe1\x82\xb7\xb8\xfd\x73\x2e\xba\xe0\x67\x8c\xa2\xb8\xfb\x70\x4d\x91\x3f\x62\xa6\x63\xb3\x9b\x48\x07\xdc\xb4\xf8\xef\x43\x96\x10\x31\x6a\x9b\xe4\x9a\x21\x55\xbf\xfd\x57\x62\x8c\x7b\x16\x26\x41\x62\x49\xd0\xfc\x40\x56\x10\xb6\x38\x08\x23\x5f\x9d\xd5\x75\x97\x99\x97\x68\x71\x69\xb6\x88\x38\xde\xfb\x80\x97\xff\x5e\x1b\xf9\x94\x20\xa5\x65\xa0\x1c\x9f\x91\x89\x83\xa3\x11\x69\xcd\xcd\x1b\x4d\xcb\x2f\x45\xae\x44\x31\xcf\x39\x42\x22\x0c\xfa\x86\xef\x84\xf1\xe0\xd0\x13\x13\xfb\xaa\xe9\xe7\x88\x1e\x94\x04\xf4\xe4\x9a\xeb\x5a\x68\xd5\xe1\xac\x6e\x3f\xa1\x64\xf8\xc8\x1c\x74\x1c\x09\x88\xfd\x5a\xc0\xfc\xcf\xc0\x9a\xc0\xe5\x46\x9a\x7c\x30\xed\x33\xc0\x54\x2e\x2d\xb6\xfa\x69\x79\xb5\x08\xef\x3c\x4c\x87\x82\x91\x76\xc2\xb1\x88\xb2\xd7\x77\x9d\x7c\x96\xdf\xd0\x5b\x0b\x84\x8a\x78\x3f\xd6\x6a\x5f\x4e\xd4\x83\xa4\x8a\x71\x3f\x19\x8c\x79\x1c' | spicy-driver wg-4.spicy 38 | -------------------------------------------------------------------------------- /spicy-noise.evt: -------------------------------------------------------------------------------- 1 | # This Spicy EVT file defines events which will be passed to Zeek. 2 | # 3 | # Copyright 2020, Verizon Media 4 | # Licensed under the terms of the Apache 2.0 license. See LICENSE file in github.com/theparanoids/spicy-noise root directory for terms 5 | 6 | protocol analyzer spicy::WireGuard over UDP: 7 | parse with WireGuard::WG_MSG; 8 | 9 | on WireGuard::WG_MSG -> event WireGuard::wg_msg($conn, self.msg_type, self.reserved_zero); 10 | on WireGuard::INITIATION -> event WireGuard::initiation($conn, self.sender_index, self.unenc_ephemeral, self.enc_static, self.enc_timestamp, self.mac1, self.mac2 ); 11 | on WireGuard::RESPONSE -> event WireGuard::response($conn, self.sender_index, self.receiver_index, self.unenc_ephemeral, self.enc_nothing, self.mac1, self.mac2 ); 12 | on WireGuard::COOKIE -> event WireGuard::cookie($conn, self.receiver_index, self.nonce, self.encrypted_cookie ); 13 | on WireGuard::TRANSPORT -> event WireGuard::transport($conn, self.receiver_index, self.counter, self.enc_packet ); 14 | -------------------------------------------------------------------------------- /spicy-noise.hlto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theparanoids/spicy-noise/d63bf4b281660d33d7c8d8a7352659428b7313cf/spicy-noise.hlto -------------------------------------------------------------------------------- /spicy-noise.spicy: -------------------------------------------------------------------------------- 1 | # This Spicy protocol analyzer will identify WireGuard traffic and extract details for Initiation, Respoinse, Cookie, and Transport packets. 2 | # 3 | # 4 | # Copyright 2020, Verizon Media 5 | # Licensed under the terms of the Apache 2.0 license. See LICENSE file in github.com/theparanoids/spicy-noise root directory for terms 6 | 7 | module WireGuard; 8 | 9 | import spicy; 10 | 11 | 12 | public type WG_MSG = unit { 13 | msg_type: uint8; 14 | reserved_zero: bytes &size=3; 15 | 16 | #on %done { 17 | # print "WG_TYPE: %X" % self.msg_type; 18 | # print "RESERVED: %x" % self.reserved_zero; 19 | # print ""; 20 | #} 21 | 22 | switch ( self.msg_type) { 23 | 1 -> wg1: INITIATION; 24 | 2 -> wg2: RESPONSE; 25 | 3 -> wg3: COOKIE; 26 | 4 -> wg4: TRANSPORT; 27 | }; 28 | 29 | }; 30 | 31 | type INITIATION = unit { 32 | sender_index: uint32 &byte-order=spicy::ByteOrder::Little; 33 | unenc_ephemeral: bytes &size=32; 34 | enc_static: bytes &size=48; 35 | enc_timestamp: bytes &size=28; 36 | mac1: bytes &size=16; 37 | mac2: bytes &size=16; 38 | 39 | #on %done { 40 | # print ""; 41 | # print "SPICY - INITIATION"; 42 | # print "SENDER_INDEX: %02X" % self.sender_index; 43 | # print "UNENC_EPHEMERAL: %x" % self.unenc_ephemeral; 44 | # print "ENC_STATIC_ARRAY: %s" % self.enc_static; 45 | # print "ENC_TIMESTAMP %X" % self.enc_timestamp; 46 | # print "MAC1: %X" % self.mac1; 47 | # print "MAC2: %X" % self.mac2; 48 | #} 49 | }; 50 | 51 | type RESPONSE = unit { 52 | sender_index: uint32 &byte-order=spicy::ByteOrder::Little; 53 | receiver_index: uint32 &byte-order=spicy::ByteOrder::Little; 54 | unenc_ephemeral: bytes &size=32; 55 | enc_nothing: bytes &size=16; 56 | mac1: bytes &size=16; 57 | mac2: bytes &size=16; 58 | 59 | #on %done { 60 | # print ""; 61 | # print "SPICY - RESPONSE"; 62 | # print "RESPONSE"; 63 | # print "SENDER_INDEX: %02X" % self.sender_index; 64 | # print "RECEIVER_INDEX: %02X" % self.receiver_index; 65 | # print "UNENC_EPHEMERAL: %x" % self.unenc_ephemeral; 66 | # print "ENC_NOTHING: %x" % self.enc_nothing; 67 | # print "MAC1: %X" % self.mac1; 68 | # print "MAC2: %X" % self.mac2; 69 | #} 70 | }; 71 | 72 | type COOKIE = unit { 73 | receiver_index: uint32 &byte-order=spicy::ByteOrder::Little; 74 | nonce: uint8[24]; 75 | encrypted_cookie: uint8[32]; 76 | }; 77 | 78 | type TRANSPORT = unit { 79 | receiver_index: uint32 &byte-order=spicy::ByteOrder::Little; 80 | counter: uint64 &byte-order=spicy::ByteOrder::Little; 81 | enc_packet: bytes &eod; 82 | 83 | #on %done { 84 | # print ""; 85 | # print "SPICY - TRANSPORT"; 86 | # print "RECEIVER_INDEX: %x" % self.receiver_index; 87 | # print "COUNTER: %x" % self.counter; 88 | # print "ENCRYPTED_PACKET: %x" % self.enc_packet; 89 | #} 90 | }; 91 | 92 | 93 | # To Test HANDSHAKE_INITIATION 94 | #printf '\x01\x00\x00\x00\x02\x9c\x03\xc1\xf3\x0c\xeb\x67\x14\x8d\xd2\x7c\x78\xd5\x2d\x01\x96\xb6\xb7\x8b\x71\x54\x29\x86\xf5\x63\xac\x89\x88\x79\x35\x3f\x02\x2f\x17\x47\x70\c5\b3\d4\33\cf\b4\9f\d3\31\16\88\28\4c\e6\7e\c7\21\11\e6\55\12\9f\c5\f6\be\d2\e0\a4\4b\8d\28\c2\22\c6\e1\47\9a\08\33\c7\a1\f6\41\7b\73\3c\1e\f0\49\fa\b5\e4\51\af\f5\61\ea\42\8c\21\16\f7\d1\02\3c\cd\ac\2b\2a\00\ec\be\02\73\c9\f8\4b\1c\69\50\32\08\4b\58\e7\d2\ff\9f\cf\19\fd\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00' | spicy-driver wg.spicy 95 | 96 | #To Test HANDSHAKE_RESPONSE 97 | #printf '\x02\x00\x00\x00\x01\xfa\xe3\xdc\x02\x9c\x03\xc1\x39\x4c\xe1\x06\x7f\xac\xcd\xff\x74\xd7\x1d\xdd\xe6\x45\x0c\xce\xdb\x94\x83\x90\x08\xa7\xa2\xc0\xcd\xb0\xb4\xab\xe0\x80\x56\x5b\x96\xd1\x67\x52\xc3\x2e\x60\xba\xab\xfb\x54\x13\xfb\xa2\x42\x76\xbe\xae\x31\xec\xe9\x18\xc0\x17\x00\xe5\xdf\xe6\x6c\xa3\xc7\xb9\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' | spicy-driver wg.spicy 98 | 99 | 100 | # TEST ENCRYPTED_ENCODED_PACKET 101 | # printf '\x04\x00\x00\x00\xb9\x9e\xde\x26\x03\x00\x00\x00\x00\x00\x00\x00\xad\x12\x98\x79\xd3\x4f\x4e\x7a\x15\x11\xcf\x31\xde\xba\x59\x83\x65\x08\x34\xf0\xbc\x98\x64\x27\x1e\xfd\x47\x9a\x6c\xae\x5f\x9f\x2f\xff\x3d\x80\x16\x58\x1c\xbd\xa6\x8d\x3f\x42\xfb\x9e\x6d\x26\xe5\x15\x8c\x75\xd8\x28\xc6\x1d\x11\x58\x27\xda\x17\xbc\xa7\xae\x56\xec\x18\x5e\x2a\x9a\x41\x9a\xad\xe6\x29\xf4\x5e\xce\xcf\x29\x46\x98\x06\x54\xee\x32\x23\x4d\xed\xe4\x1a\x68\x9c\x66\x27\xf3\x10\xbb\xd5\x5b\x4c\x3d\x6c\x69\x05\x87\x72\xf4\x7b\x07\x36\x26\x63\xe2\x31\x93\xdf\x43\xbe\x58\xfa\xdd\x41\x32\xf5\xd1\xb7\xae\xe9\xaa\x3e\xa8\x45\xd4\x50\x3d\x61\x54\x74\x8a\x72\x98\x0e\x1a\x9f\xf1\x96\x5e\xc0\x8c\xf6\x2c\xd4\xe1\x2d\xeb\x87\xb1\x01\xf3\xbc\xa4\x57\x99\xb5\x04\xe9\xd7\xa7\x0b\xba\x23\xcd\xa8\xc9\x5d\xdc\x46\x21\xda\x9e\xe5\x17\xf4\x72\xf4\x63\xb7\x94\x1f\x6c\xa7\xf3\xc1\xe9\xc7\xd2\x38\xeb\xcb\x56\x26\x77\xc2\xc8\x82\x17\xf4\x3b\x6b\x06\x2a\x16\xe0\xab\x70\xc8\xd4\xd5\x14\x2c\xed\x13\xc6\x5b\x87\xe1\x88\x56\xb3\x97\xd3\x6c\xbd\x2b\x81\xbd\x63\x08\x23\x8f\x24\x79\x40\xad\x90\xb9\xdb\xaa\xff\x5d\x05\x93\x3b\x04\xf0\x95\x78\xf0\x30\x15\x6e\x62\x3d\x93\x9a\xee\xf9\x31\x68\xf1\x7a\xa6\xa5\x83\x4a\x04\xf0\x46\x22\xc8\x0a\x28\xb1\xe7\x04\x0b\xd1\xad\x1c\x06\x98\x0c\xc6\xbc\x8d\x0b\x19\xaf\xc9\x12\x94\xc9\x17\x68\xd5\x11\x4c\x6b\x27\xd7\x14\xea\x7e\xe8\x3a\xa6\x52\xb3\x5b\x06\xbd\xdd\x9c\x31\x84\xf3\xb5\xee\x02\x43\xa7\xc7\xd9\xbf\x0d\x1f\xf2\x04\x8f\xe2\x89\xe3\xd2\x0a\x7b\x31\x7b\x22\x55\xc2\xd0\x55\x25\xe0\xdd\xcf\x06\x40\xca\xb5\x51\xf6\xf6\x05\x7f\x25\x51\x1f\x83\x22\xad\x96\x2e\xc3\x7d\xd5\x91\x30\x3d\xf0\xe1\x17\x72\xaa\xdd\x4d\x23\xaf\xb1\x39\xf4\xe0\x92\xff\xd4\x39\x8a\x4e\x37\x63\xf0\x71\xe3\xb6\xe0\x62\xb2\x6e\xaf\x3a\x87\xdd\xac\x54\x66\x55\x24\x44\x02\x21\x39\xb4\x8e\x07\x79\xc2\x24\x65\x5f\xe2\xbb\x6d\xf8\xe4\x92\x1e\xf0\x54\xd6\x65\x95\x5f\xbc\x85\x46\xf5\x56\xa6\x90\x73\xcb\x7b\x48\x01\x41\x1e\x1e\x78\xb7\xd4\x58\x89\x51\x42\xb5\x3e\x6a\x25\x90\x05\xa6\x4a\x33\x1a\x28\xc9\x8c\x19\x3d\x91\x93\x95\x4b\x4a\x99\x4f\xd0\xd7\xf7\x09\xf4\x67\x81\x2a\xe0\xfa\x4f\x18\x1e\xfb\xfa\x24\x3a\x5a\xaf\x3d\x78\x02\x1d\xec\xa2\x02\x24\x87\x54\x9f\xf6\x95\x61\xd3\x2b\xb0\x4f\xc8\xfc\x1c\x22\x29\x37\xab\xe7\x48\x52\x92\x30\x2f\x9f\xfb\x76\x86\x03\x71\xec\xe9\x9e\xc7\x01\xe6\x8f\xca\x8c\x0b\xc1\xc3\x76\x30\xa8\x0b\x8d\x2f\x25\x6e\xa8\x5a\xcc\x1a\xd8\xb5\x78\x24\xe2\xd6\x59\x74\xd7\xab\x25\x08\x46\xc3\x19\x1b\xc7\x62\x27\xa5\x0a\xd7\x73\x93\x0e\xef\x62\x12\x0f\x13\xe9\x37\xec\x5c\x57\x07\x2a\x09\xde\x38\x39\x36\x53\xab\x6d\x1a\x15\xbc\xed\xb9\x1f\x2d\xab\x3f\x84\x98\x32\x64\x37\x74\x44\x0d\x44\x35\x64\x0b\x2f\x32\xbd\x04\x52\x00\x8d\x54\x3a\x49\xd7\x9e\x90\xe8\xf9\x25\x39\xd0\x52\x9c\x99\xd0\x7d\xe2\x1b\x69\x44\xcf\x9d\x74\x00\xcd\x52\x62\x4f\x0f\xb2\x49\x00\x8f\x00\x16\x09\x0c\x37\xb6\x6e\x8e\x0a\xbb\xbf\x66\x52\x5c\xd8\x69\x0d\x7d\x4c\x0f\xee\xf3\x75\x85\x30\xbb\xc1\xac\x95\xd3\x0a\x4d\x8b\x73\xf8\x16\x92\x86\x82\x6d\x71\x24\xa6\x5d\x87\x40\xba\x9f\x22\xd7\x69\x46\x06\xd2\x49\x7f\xb1\x71\x00\xd4\xb0\x7a\x0e\x5b\x1e\x0a\xf7\x38\x4f\x55\x2c\x96\x6a\xe4\x92\x0a\x85\x8f\xb4\x70\x82\x91\x17\xcc\xa6\x23\x9a\x1f\xf6\xf5\xc4\x4c\x64\xfb\x25\x07\xb6\xe9\x05\x67\xf3\x37\xa4\x7a\xf2\x35\xf3\x7c\xa2\xa9\x2e\x6a\x6f\x1a\x9d\xb7\xde\x9e\x4f\x5f\xd6\xf2\x61\x7f\xd9\x33\x42\x60\x18\x22\x3f\x5d\xf9\x80\xac\x15\xa1\x2d\xd9\x63\xfd\x24\x5a\xbc\x79\xa0\xdd\x13\x5d\x21\xa3\x32\x44\x67\x86\xe7\x04\x8e\xcc\x39\x5b\x5f\x02\x14\x9a\x3e\x95\xa6\xc7\x92\x6b\x99\x50\x9f\xab\x75\x57\xc4\xbe\x26\x9d\xcb\x6e\xc4\xc2\x02\x1c\x53\x6b\x06\x58\xf5\xa7\xee\x3c\x3e\x58\xf3\x86\xfb\xbd\x3d\x08\x11\xad\x7f\x0e\xff\x2d\xde\x8c\x0e\x63\x6c\xbd\x3f\x66\xee\x6b\xd3\x28\xe5\x48\x1f\x12\x72\x6a\x20\x3d\xf7\xbc\xbd\x3f\x81\x43\xe2\x68\xe3\x94\x76\xed\x9d\xc2\x51\xb5\x47\xaa\xad\x6e\x06\x5e\xb4\x28\xb8\x5f\x6e\xaf\x6f\x8e\x20\xc0\x24\x9a\x8d\x63\xcf\x9d\x63\xe9\x46\xf2\x4f\x64\x54\xc2\xbf\x80\x05\x67\xf0\x7c\x75\x31\x0f\x3c\x31\x46\xe8\x63\xd2\xba\x1d\xc3\x76\xb7\x66\x21\x6d\x1a\xa2\x17\x61\xe0\xda\xbc\xc3\x84\xdc\xe9\x27\xff\x34\x86\x11\x32\x07\x3a\x77\xd3\xb9\xf1\x81\x75\xdc\x52\x45\xa3\x94\x18\x63\x2f\xeb\x10\x57\xcf\x3a\xbe\xaa\x36\xba\x24\xc2\xf1\xfc\xcd\x79\xca\x14\xd0\x13\x63\x69\x56\xb3\x5e\xbd\xba\xcc\x04\x11\x3b\x4d\xd3\x95\xc9\x93\xf8\x01\xdb\xd0\x38\x1c\x8e\xd4\x07\x13\x8c\xab\x4e\x80\xa6\x8f\x7d\x44\x1e\x1e\x39\xf6\xd7\xfe\x37\x54\xef\x55\x86\x73\x6a\xa3\x39\x54\xe6\x7d\x6e\x77\xec\x71\x13\xe0\x8a\xc2\xde\xe4\x43\xd4\xce\x9f\x85\x15\x17\xfc\x78\xa6\x82\x09\x75\x5f\x39\xd6\x32\x1e\x84\x16\x4d\x47\xe9\xed\x58\x53\xeb\xe3\x07\x3a\x58\xc8\x20\x38\x9d\xff\xfd\x45\x8a\x88\x0b\xca\x5e\xbb\x0a\x93\x76\x2c\x24\xb7\x55\x28\x8a\x81\x9d\x70\xf7\xb5\xec\x29\x6f\x7d\xb8\x2d\x59\x22\xcc\x86\x94\x34\x7d\x59\x59\x60\x31\x65\xaf\xc1\xd5\x19\xf7\x2b\xc7\xf0\x2a\x5e\xf7\x1b\xe7\x7a\x23\xab\x8d\x73\x3d\x11\x8a\x20\x04\x60\xaa\x04\x90\xde\xd6\x79\xbd\xca\x98\x84\x18\x23\x24\xf8\x50\xdd\x88\xe0\x77\xe3\x47\x2d\x22\xd2\xb5\xc4\xb8\x47\xaf\x0d\xaa\xc1\x6d\xfc\x30\xf9\xf8\x1e\x7d\x87\xfd\x96\xed\xe1\x82\xb7\xb8\xfd\x73\x2e\xba\xe0\x67\x8c\xa2\xb8\xfb\x70\x4d\x91\x3f\x62\xa6\x63\xb3\x9b\x48\x07\xdc\xb4\xf8\xef\x43\x96\x10\x31\x6a\x9b\xe4\x9a\x21\x55\xbf\xfd\x57\x62\x8c\x7b\x16\x26\x41\x62\x49\xd0\xfc\x40\x56\x10\xb6\x38\x08\x23\x5f\x9d\xd5\x75\x97\x99\x97\x68\x71\x69\xb6\x88\x38\xde\xfb\x80\x97\xff\x5e\x1b\xf9\x94\x20\xa5\x65\xa0\x1c\x9f\x91\x89\x83\xa3\x11\x69\xcd\xcd\x1b\x4d\xcb\x2f\x45\xae\x44\x31\xcf\x39\x42\x22\x0c\xfa\x86\xef\x84\xf1\xe0\xd0\x13\x13\xfb\xaa\xe9\xe7\x88\x1e\x94\x04\xf4\xe4\x9a\xeb\x5a\x68\xd5\xe1\xac\x6e\x3f\xa1\x64\xf8\xc8\x1c\x74\x1c\x09\x88\xfd\x5a\xc0\xfc\xcf\xc0\x9a\xc0\xe5\x46\x9a\x7c\x30\xed\x33\xc0\x54\x2e\x2d\xb6\xfa\x69\x79\xb5\x08\xef\x3c\x4c\x87\x82\x91\x76\xc2\xb1\x88\xb2\xd7\x77\x9d\x7c\x96\xdf\xd0\x5b\x0b\x84\x8a\x78\x3f\xd6\x6a\x5f\x4e\xd4\x83\xa4\x8a\x71\x3f\x19\x8c\x79\x1c' | spicy-driver wg.spicy 102 | -------------------------------------------------------------------------------- /traces/list.txt: -------------------------------------------------------------------------------- 1 | This directory contains list of trace files used. 2 | 3 | https://github.com/wireshark/wireshark/blob/master/test/captures/wireguard-psk.pcap 4 | 5 | https://github.com/wireshark/wireshark/blob/master/test/captures/wireguard-ping-tcp.pcap 6 | -------------------------------------------------------------------------------- /traces/wireguard-ping-tcp.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theparanoids/spicy-noise/d63bf4b281660d33d7c8d8a7352659428b7313cf/traces/wireguard-ping-tcp.pcap -------------------------------------------------------------------------------- /traces/wireguard-psk.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theparanoids/spicy-noise/d63bf4b281660d33d7c8d8a7352659428b7313cf/traces/wireguard-psk.pcap -------------------------------------------------------------------------------- /zeek/__load__.zeek: -------------------------------------------------------------------------------- 1 | @load-sigs ./dpd.sig 2 | 3 | @load ./spicy-noise.zeek 4 | -------------------------------------------------------------------------------- /zeek/dpd.sig: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020, Verizon Media 3 | # Licensed under the terms of the Apache 2.0 license. See LICENSE file in github.com/theparanoids/spicy-noise root directory for terms 4 | 5 | # Dynamic protocol Signature for Wireguard to attach to stream. 6 | 7 | signature dpd_wg_initiation { 8 | ip-proto = udp 9 | payload /^\x01\x00\x00\x00/ 10 | enable "spicy_WireGuard" 11 | event "WireGuard Handshake Initiation" 12 | } 13 | -------------------------------------------------------------------------------- /zeek/spicy-noise.hlto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theparanoids/spicy-noise/d63bf4b281660d33d7c8d8a7352659428b7313cf/zeek/spicy-noise.hlto -------------------------------------------------------------------------------- /zeek/spicy-noise.zeek: -------------------------------------------------------------------------------- 1 | # This Zeek scritp will log out details of WireGuard sessions. 2 | # 3 | # Copyright 2020, Verizon Media 4 | # Licensed under the terms of the Apache 2.0 license. See LICENSE file in github.com/theparanoids/spicy-noise root directory for terms 5 | 6 | module WireGuard; 7 | 8 | export { 9 | 10 | redef enum Log::ID += {WGLOG}; 11 | 12 | type Info: record { 13 | ts: time &log; 14 | uid: string &log; 15 | id: conn_id &log; 16 | msg_type: string &log &optional; 17 | sender: string &log &optional; 18 | receiver: string &log &optional; 19 | unenc_ephemeral: string &log &optional; 20 | enc_static: string &log &optional; 21 | enc_timestamp: string &log &optional; 22 | enc_nothing: string &log &optional; 23 | nonce: string &log &optional; 24 | enc_cookie: string &log &optional; 25 | mac1: string &log &optional; 26 | mac2: string &log &optional; 27 | enc_payload_len: int &log &optional; 28 | enc_payload: string &log &optional; 29 | }; 30 | 31 | } 32 | 33 | event zeek_init() { 34 | 35 | Log::create_stream(WireGuard::WGLOG, [$columns=Info, $path="spicy-noise"] ); 36 | 37 | } 38 | 39 | event WireGuard::initiation(c: connection, sender_index: int, unenc_ephemeral: string, enc_static: string, enc_timestamp: string, mac1: string, mac2: string ) 40 | { 41 | #print ""; 42 | #print "ZEEK - Initiation"; 43 | 44 | local rec: WireGuard::Info = [ $ts = network_time(), $uid = c$uid, $id = c$id ]; 45 | add c$service["WireGuard"]; 46 | rec$sender = fmt("%x",sender_index); 47 | rec$unenc_ephemeral = bytestring_to_hexstr(unenc_ephemeral); 48 | rec$enc_static = bytestring_to_hexstr(enc_static); 49 | rec$enc_timestamp = bytestring_to_hexstr(enc_timestamp); 50 | rec$mac1 = bytestring_to_hexstr(mac1); 51 | rec$mac2 = bytestring_to_hexstr(mac2); 52 | rec$msg_type = "INITIATION"; 53 | Log::write(WireGuard::WGLOG, rec); 54 | } 55 | 56 | event WireGuard::response(c: connection, sender_index: int, receiver_index: int, unenc_ephemeral: string, enc_nothing: string, mac1: string, mac2: string) 57 | { 58 | #print ""; 59 | #print "ZEEK - RESPONSE"; 60 | 61 | local rec: WireGuard::Info = [ $ts = network_time(), $uid = c$uid, $id = c$id ]; 62 | rec$msg_type = "RESPONSE"; 63 | rec$sender = fmt("%x", sender_index); 64 | rec$receiver = fmt("%x",receiver_index); 65 | rec$unenc_ephemeral = bytestring_to_hexstr(unenc_ephemeral); 66 | rec$enc_nothing = bytestring_to_hexstr(enc_nothing); 67 | rec$mac1 = bytestring_to_hexstr(mac1); 68 | rec$mac2 = bytestring_to_hexstr(mac2); 69 | Log::write(WireGuard::WGLOG, rec); 70 | } 71 | 72 | event WireGuard::cookie(c: connection, receiver_index: int, nonce: vector of int , encrypted_cookie: vector of int ) 73 | { 74 | print "COOKIE"; 75 | } 76 | 77 | event WireGuard::transport(c: connection, receiver_index: int, num_pkts: int, enc_packet: string ) 78 | { 79 | #print ""; 80 | #print "ZEEK - TRANSPORT"; 81 | 82 | local rec: WireGuard::Info = [ $ts = network_time(), $uid = c$uid, $id = c$id ]; 83 | rec$msg_type = "TRANSPORT"; 84 | rec$receiver = fmt("%x",receiver_index); 85 | rec$enc_payload_len = |enc_packet|; 86 | rec$enc_payload = enc_packet; 87 | Log::write(WireGuard::WGLOG, rec); 88 | } 89 | --------------------------------------------------------------------------------