diff --git a/README.md b/README.md index bf81be6..a51be06 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +![mshark_new](https://github.com/user-attachments/assets/ee1b9526-dcae-4ff8-962d-315897e49ed0) # mShark - Mini [Wireshark](https://www.wireshark.org/) written in Go @@ -77,3 +78,28 @@ With `-v` flag enabled, you will see more detailed information: ![Screenshot from 2024-09-17 09-56-20](https://github.com/user-attachments/assets/11539ea7-779e-4faf-8fce-2eea9ab653c7) ![Screenshot from 2024-09-17 09-56-47](https://github.com/user-attachments/assets/26b6353d-d312-40c5-9917-3f2f7bb8abdc) + +## Supported layers + +- [Ethernet](https://en.wikipedia.org/wiki/Ethernet_frame) +- [IPv4](https://en.wikipedia.org/wiki/IPv4) +- [IPv6](https://en.wikipedia.org/wiki/IPv6) +- [ARP](https://en.wikipedia.org/wiki/Address_Resolution_Protocol) +- [ICMP](https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol) +- [ICMPv6](https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol_for_IPv6) +- [TCP](https://en.wikipedia.org/wiki/Transmission_Control_Protocol) +- [UDP](https://en.wikipedia.org/wiki/User_Datagram_Protocol) +- [DNS](https://en.wikipedia.org/wiki/Domain_Name_System) +- [HTTP](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol) +- [SNMP](https://en.wikipedia.org/wiki/Simple_Network_Management_Protocol) +- [FTP](https://en.wikipedia.org/wiki/File_Transfer_Protocol) +- [SSH](https://en.wikipedia.org/wiki/Secure_Shell) +- [TLS](https://en.wikipedia.org/wiki/Transport_Layer_Security) + + +## Roadmap + +- [x] Online packet capture to `stdout`, `txt`, `pcap` and `pcapng` files +- [ ] Offline packet capture from `pcap` and `pcapng` files +- [ ] Add proper parsing for `SNMP` messages +- [ ] Add packet generation and packet injection functionality diff --git a/layers/layers.go b/layers/layers.go index b1aa117..1cc1c53 100644 --- a/layers/layers.go +++ b/layers/layers.go @@ -43,27 +43,6 @@ type Layer interface { Summary() string } -func nextAppLayer(src, dst uint16) string { - var layer string - switch { - case src == 20 || dst == 20 || src == 21 || dst == 21: - layer = "FTP" - case src == 22 || dst == 22: - layer = "SSH" - case src == 53 || dst == 53: - layer = "DNS" - case src == 80 || dst == 80: - layer = "HTTP" - case src == 161 || dst == 161 || src == 162 || dst == 162: - layer = "SNMP" - case src == 443 || dst == 443: - layer = "TLS" - default: - layer = "" - } - return layer -} - func bytesToStr(b []byte) string { return unsafe.String(unsafe.SliceData(b), len(b)) } diff --git a/layers/tcp.go b/layers/tcp.go index a3d7387..790c814 100644 --- a/layers/tcp.go +++ b/layers/tcp.go @@ -130,3 +130,24 @@ func (t *TCPSegment) Parse(data []byte) error { func (t *TCPSegment) NextLayer() (string, []byte) { return nextAppLayer(t.SrcPort, t.DstPort), t.payload } + +func nextAppLayer(src, dst uint16) string { + var layer string + switch { + case src == 20 || dst == 20 || src == 21 || dst == 21: + layer = "FTP" + case src == 22 || dst == 22: + layer = "SSH" + case src == 53 || dst == 53: + layer = "DNS" + case src == 80 || dst == 80: + layer = "HTTP" + case src == 161 || dst == 161 || src == 162 || dst == 162: + layer = "SNMP" + case src == 443 || dst == 443: + layer = "TLS" + default: + layer = "" + } + return layer +}