# Wireshark

> Wireshark is a free and open-source packet analyzer. It is used for network troubleshooting, analysis, software and communications protocol development, and education. Originally named Ethereal, the project was renamed Wireshark in May 2006 due to trademark issues.
>
> \-- [*Wikipedia*](https://en.wikipedia.org/wiki/Wireshark)

## Packet filtering

* [Building Display Filter Expressions](https://www.wireshark.org/docs/wsug_html_chunked/ChWorkBuildDisplayFilterSection.html)

### Operators:

* [Display Filter comparison operators](https://www.wireshark.org/docs/wsug_html_chunked/ChWorkBuildDisplayFilterSection.html#DispCompOps)
* [Display Filter Logical Operations](https://www.wireshark.org/docs/wsug_html_chunked/ChWorkBuildDisplayFilterSection.html#FiltLogOps)

### Examples

IP address (any)

```
ip.addr == <ip-address>
```

Source and destination IP addresses

```
ip.src == <src-ip-address> and ip.dst == <dst-ip-address>
```

Protocol

```
<protocol>
http
```

Protocol contains string

```
<protocol> contains <string>
http contains google.com
```

TCP port

```
tcp.port eq <port>
```

UDP port

```
udp.port eq <port>
```

Negation

```
not <expression>
```

## Capture packets

```bash
ssh <user>@<ip> "/usr/sbin/tcpdump -i ens33 -U -s0 -w - 'not port 22'" > bla.cap
wireshark bla.cap
```

Alternative approach

```bash
ssh <user>@<ip> "/usr/sbin/tcpdump -i lo -U -s0 -w - 'not port 22'" | wireshark -k -i -
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://d4rk1337.gitbook.io/the-pentesters-cheat-sheet/misc/wireshark.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
