# 🔬Tshark, ARP, WiFi

## Lab 1

> 🔬 [Getting Started: Tshark](https://attackdefense.com/challengedetails?cid=1)
>
> * **Tshark** usage

```bash
tshark -v
```

```bash
TShark (Wireshark) 2.6.1 (Git v2.6.1 packaged as 2.6.1-0ubuntu2~16.04.0)
```

> 📌 Running Tshark version is `2.6.1`

```bash
tshark -D
```

* These are all supported network interfaces for monitoring

![tshark -D](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-a5daba20a78c789cf5a89c579e1b281a0437189b%2Fimage-20230324111823330.png?alt=media)

* Sniff some traffic on `eth0`

```bash
tshark -i eth0
```

![tshark -i eth0](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-0be41ca0affab494e65ed00779dc8395ce4253e4%2Fimage-20230324112011882.png?alt=media)

> 📌 `student` user don't have permission to capture on `eth0` interface

* Display the packet list of the `.pcap` file

```bash
tshark -r HTTP_traffic.pcap
```

* Count `.pcap` file number of lines to find total number of packets

```bash
tshark -r HTTP_traffic.pcap | wc -l
	30418 # lines in the file
```

![tshark -r HTTP\_traffic.pcap](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-a015f7d27fc1bdc424709e75bbf2191e5b27fbec%2F2025-04-07_22-05-18_970.png?alt=media)

* Read first 100 packets from the `.pcap` file

```bash
tshark -r HTTP_traffic.pcap -c 100
```

* List the Protocol Hierarchy Statistics from the `.pcap` file

```bash
tshark -r HTTP_traffic.pcap -z io,phs -q
```

![tshark -r HTTP\_traffic.pcap -z io,phs -q](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-78fadd7ae2e95100b8e1fd15065f9a761bc2e861%2Fimage-20230324113306740.png?alt=media)

***

## Lab 2

> 🔬 [Filtering Basics: HTTP](https://attackdefense.com/challengedetails?cid=2)
>
> * **Tshark** usage and filtering

### Filtering

* Show the `HTTP` traffic from a `.pcap` file

```bash
tshark -r HTTP_traffic.pcap -Y 'http'
tshark -r HTTP_traffic.pcap -Y 'http' | more
```

![tshark -r HTTP\_traffic.pcap -Y 'http'](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-e7ac539edaa5cdacfbd4d1af2829c27abaaf797d%2Fimage-20230324115801714.png?alt=media)

* Show only the IP packets sent from IP address `192.168.252.128` to IP address `52.32.74.91`

```bash
tshark -r HTTP_traffic.pcap -Y "ip.src==192.168.252.128 && ip.dst==52.32.74.91"
```

![tshark -r HTTP\_traffic.pcap -Y "ip.src==192.168.252.128 && ip.dst==52.32.74.91"](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-0de17cdcc5a1f3caf79a0845c9c175d2da320f73%2Fimage-20230324120102950.png?alt=media)

* Print only packets containing GET requests

```bash
tshark -r HTTP_traffic.pcap -Y "http.request.method==GET"
```

![tshark -r HTTP\_traffic.pcap -Y "http.request.method==GET"](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-5361a738509141d3368bd349b72bb5b88ddeb19e%2Fimage-20230324120221796.png?alt=media)

* Print only packets with frame time, source IP and URL for all GET requests

```bash
tshark -r HTTP_traffic.pcap -Y "http.request.method==GET" -Tfields -e frame.time -e ip.src -e http.request.full_uri
```

![tshark -r HTTP\_traffic.pcap -Y "http.request.method==GET" -Tfields -e frame.time -e ip.src -e http.request.full\_uri](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-9e2a5d82a8f439a9c94add5000dcc13f1594fecb%2Fimage-20230324120636235.png?alt=media)

* Print packets containing a string

```bash
tshark -r HTTP_traffic.pcap -Y "http contains password"
```

![tshark -r HTTP\_traffic.pcap -Y "http contains password"](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-194550b2c194465ee54ff380d4b5da499fead328%2Fimage-20230324120756645.png?alt=media)

> 📌 `4` HTTP packets contain the `password` string

* Check the **destination IP** for `GET` requests sent to `www.nytimes.com`

```bash
tshark -r HTTP_traffic.pcap -Y "http.request.method==GET && http.host==www.nytimes.com" -Tfields -e ip.dst
```

![tshark -r HTTP\_traffic.pcap -Y "http.request.method==GET && http.host==www.nytimes.com" -Tfields -e ip.dst](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-ee28719132af5d5e92d12bae697c216916d14792%2Fimage-20230324121036977.png?alt=media)

> 📌 `170.149.159.130` is the destination IP of `www.nytimes.com`

* Check the **session ID** used by `192.168.252.128` for `amazon.in`

```bash
tshark -r HTTP_traffic.pcap -Y "ip contains amazon.in && ip.src==192.168.252.128" -Tfields -e ip.src -e http.cookie
```

![tshark -r HTTP\_traffic.pcap -Y "ip contains amazon.in && ip.src==192.168.252.128" -Tfields -e ip.src -e http.cookie](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-c77470b1c0c99cfe32e98464c1596d620a25b287%2Fimage-20230324121407664.png?alt=media)

> 📌 `278-7381968-4337153` is the session ID

* Find the **OS** type on the machine with IP `192.168.252.128`

```bash
tshark -r HTTP_traffic.pcap -Y "ip.src==192.168.252.128 && http" -Tfields -e http.user_agent
```

![tshark -r HTTP\_traffic.pcap -Y "ip.src==192.168.252.128 && http" -Tfields -e http.user\_agent](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-b006c1650af62c8d22ecd019b9571bf5417f16a9%2Fimage-20230324121744533.png?alt=media)

* Use the `User_agent` string to find the specific distribution

`Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.8.0`

> 📌 The OS is `Linux x86_64; rv:31.0` - [user-agents.net](https://user-agents.net/string/mozilla-5-0-x11-linux-x86-64-rv-31-0-gecko-20100101-firefox-31-0-iceweasel-31-8-0)

***

## Lab 3 - ARP Poisoning

> 🔬 *INE Platform Lab*
>
> * **ARP Poisoning** attack to a `telnet` server
>   * the client machine authenticates with the `telnet` server every 30sec
> * Find the `telnet` login credentials
> * Tools: **`arpspoof`** & **`Wireshark`**

* Monitor the traffic on `eth1` interface of the Kali Attacker machine.

```bash
ip -br -c a
	eth1  UP  10.100.13.140/24
```

### Enumeration

```bash
nmap 10.100.13.0/24
```

```bash
Nmap scan report for 10.100.13.1
    22/tcp   open  ssh
    3389/tcp open  ms-wbt-server
# ^^ Gateway machine, do not attack

Nmap scan report for 10.100.13.36
    22/tcp open  ssh
    23/tcp open  telnet
# ^^ Telnet server machine

Nmap scan report for 10.100.13.140
    3389/tcp open  ms-wbt-server
    5910/tcp open  cm
# ^^ Client machine
```

![nmap 10.100.13.0/24](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-18c8672580dd1af7952f7f05ceeb68eacb1f14cc%2Fimage-20230324125014246.png?alt=media)

### ARP Poisoning Attack

* To see traffic of other machines, configure Kali Attacker VM to forward IP packets

```bash
echo 1 > /proc/sys/net/ipv4/ip_forward
```

* Start the ARP poisoning attack with the [**`arpspoof`**](https://www.kali.org/tools/dsniff/#arpspoof) tool

```bash
arpspoof -i eth1 -t 10.100.13.37 -r 10.100.13.36
# -t = target
# -r = host
```

* Open `Wireshark` and start capture `eth1` traffic
  * Apply `telnet` filter

![](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-fd540a22e9519fbba95d8ab08e3fbd0cbf6edd07%2Fimage-20230324130442438.png?alt=media)

* Follow the **TCP stream** and find the `telnet` credentials
  * Stop the capture and the `arpspoof` tool

![](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-ff85b5347d4e4af5e92f90a366cd41ae6a01f3a1%2Fimage-20230324130614957.png?alt=media)

> 📌 `Telnet` credentials are `admin`:`MyS3cr3tP455`

```bash
telnet 10.100.13.36
```

![](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-1e9b4006d8e9f429e685139d4b8536b3f52f08d7%2F2023-03-24_13-11.png?alt=media)

***

## Lab 4 - WiFi Traffic Analysis

> 🔬 [WiFi Security: Traffic Analysis I](https://attackdefense.com/challengedetails?cid=1141)
>
> * **WiFi** basic traffic analysis with `Wireshark`

* Find the name of the Open SSID in the packet dump, using the filter
  * Beacon frame = `0x0008`
  * Wlan tag `48` = [**RSN-IE**](https://mrncciew.com/2014/08/21/cwsp-rsn-information-elements/) (Robust Security Network Information Element)

```bash
(wlan.fc.type_subtype == 0x0008) && (!(wlan.wfa.ie.wpa.version == 1)) &&
!(wlan.tag.number == 48)
```

![](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-3e7dd4705d24ff9f3d28f0dc414735bd9fe78f84%2Fimage-20230324134003319.png?alt=media)

<details>

<summary>Reveal Flag - The name of the Open SSID is: 🚩</summary>

`SecurityTube_Open`

</details>

* Find the channel `Home_Network` is operating

```bash
wlan contains Home_Network
```

![](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-99d5d3c91577cd66f2a838e3d3667277b372d0c3%2Fimage-20230324134539505.png?alt=media)

<details>

<summary>Reveal Flag - Home_Network operates on channel: 🚩</summary>

`6`

</details>

* Find which security mechanism has `LazyArtists` SSID

```bash
wlan contains LazyArtists
```

![](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-5e5a1afc05fc925c3aa806d988eea80fddd9e8e4%2Fimage-20230324134946480.png?alt=media)

<details>

<summary>Reveal Flag - LazyArtists configured security is: 🚩</summary>

`WPA2-PSK`

</details>

* Check the **WPS** setup for `Amazon Wood` SSID

```bash
(wlan.ssid contains "Amazon") && (wlan.fc.type_subtype == 0x0008)
```

> 📌 WPS is enabled

![](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-3ad970a7db12970c971ecd2ff6d09dff7a503dbe%2Fimage-20230324142851202.png?alt=media)

* Count the packets of the device with MAC `e8:de:27:16:87:18`
  * wlan.ta = transmitted
  * wlan.ra = received

```bash
(wlan.ta == e8:de:27:16:87:18)  ||  (wlan.ra == e8:de:27:16:87:18)
```

![](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-42a3494b466a437ebd18d445397ab2d46f12dbb3%2Fimage-20230324143309045.png?alt=media)

<details>

<summary>Reveal Flag - Total packets number is: 🚩</summary>

`5701`

</details>

* Find a **specific MAC address** which exchange data with `SecurityTube_Open` SSID
  * `SecurityTube_Open` is hosted on BSSID `e8:de:27:16:87:18`

```bash
(wlan.bssid == e8:de:27:16:87:18) && (wlan.fc.type_subtype == 0x0020)
```

![](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-75f699504b8e22f5c40f5a2ccacfbb3251b9b804%2Fimage-20230324143952217.png?alt=media)

<details>

<summary>Reveal Flag - The MAC address is: 🚩</summary>

`5c:51:88:31:a0:3b`

</details>

* Find TSF timestamp of the **Association Response** sent from the `SecurityTube_Open` access point to a station

```bash
((wlan.bssid == e8:de:27:16:87:18) && (wlan.addr==5c:51:88:31:a0:3b)) &&
(wlan.fc.type_subtype == 0x0001)
```

![](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-9a7ff97fbb512deb45ca02d8e1b2973c22829e86%2Fimage-20230324144333613.png?alt=media)

<details>

<summary>Reveal Flag - The TSF timestamp is: 🚩</summary>

`115152625`

</details>

***

## Lab 5 - WiFi Traffic Filtering

> 🔬 [Filtering Advanced: WiFi](https://attackdefense.com/challengedetails?cid=4)
>
> * **Tshark** usage and filtering

* Show only WiFi traffic

```bash
tshark -r WiFi_traffic.pcap -Y "wlan"
```

![tshark -r WiFi\_traffic.pcap -Y "wlan" | more](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-b85104862aa101786cadf00385e7dfca564301d2%2Fimage-20230324145113459.png?alt=media)

* Show only the deauthentication packets
  * *Every management frame in WiFi has can be classified under a **type** and **subtype***
  * `wlan.fc.type_subtype == 0x000c` - AP sends deauthentication frames

```bash
tshark -r WiFi_traffic.pcap -Y "wlan.fc.type_subtype==0x000c"
```

![tshark -r WiFi\_traffic.pcap -Y "wlan.fc.type\_subtype==0x000c"](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-db4350d29659fddfa5f63301b62834a18b4185e9%2Fimage-20230324145545783.png?alt=media)

* Show only the `WPA handshake` packets
  * **EAPoL** (Extensible Authentication Protocol over LAN) is used for WPA handshake

```bash
tshark -r WiFi_traffic.pcap -Y "eapol"
```

![tshark -r WiFi\_traffic.pcap -Y "eapol"](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-8d74cb41b130998af5564204478d0506bbfd8686%2Fimage-20230324145657998.png?alt=media)

* Show only **SSID** and **BSSID** values of all beacon frames

```bash
tshark -r WiFi_traffic.pcap -Y "wlan.fc.type_subtype==8" -Tfields -e wlan.ssid -e wlan.bssid
```

![tshark -r WiFi\_traffic.pcap -Y "wlan.fc.type\_subtype==8" -Tfields -e wlan.ssid -e wlan.bssid](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-8ded289a23c8b31130d80d04ed2c4661cca1ac02%2Fimage-20230324150035789.png?alt=media)

* Check the BSSID of `LazyArtists` SSID

```bash
tshark -r WiFi_traffic.pcap -Y "wlan.ssid==LazyArtists" -Tfields -e wlan.bssid
```

![tshark -r WiFi\_traffic.pcap -Y "wlan.ssid==LazyArtists" -Tfields -e wlan.bssid](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-cb8d87d5afc8b972dcac2f5ba188555f61428989%2Fimage-20230324150413400.png?alt=media)

> 📌 `LazyArtists` BSSID is **`fc:b0:c4:91:71:e0`**.

* Show the channel on which `Home_Network` operates

```bash
tshark -r WiFi_traffic.pcap -Y "wlan.ssid==Home_Network" -Tfields -e wlan_radio.channel
```

![tshark -r WiFi\_traffic.pcap -Y "wlan.ssid==Home\_Network" -Tfields -e wlan\_radio.channel](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-450932f31dad49fb0e6bcc9df2c915387ecafc28%2Fimage-20230324150612379.png?alt=media)

> 📌 `Home_Network` operating channel is **`6`**.

* Show the two devices that received the deauth messages

```bash
tshark -r WiFi_traffic.pcap -Y "wlan.fc.type_subtype==0x000c" -Tfields -e wlan.ra
```

![tshark -r WiFi\_traffic.pcap -Y "wlan.fc.type\_subtype==0x000c" -Tfields -e wlan.ra](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-72fbc79aaa85034aaecbafaaec305ff0779f4dba%2Fimage-20230324150852601.png?alt=media)

> 📌 The MAC address of the two devices are `6c:19:8f:5f:81:74` and `bc:ae:c5:c3:5e:01`.

* Check vendor and model of the device with MAC `5c:51:88:31:a0:3b`

```bash
tshark -r WiFi_traffic.pcap -Y "wlan.ta==5c:51:88:31:a0:3b && http" -Tfields -e http.user_agent
```

![tshark -r WiFi\_traffic.pcap -Y "wlan.ta==5c:51:88:31:a0:3b && http" -Tfields -e http.user\_agent](https://1996978447-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhjuckuLbvBn36EoFL7P%2Fuploads%2Fgit-blob-4d9c81b74bbf67a2ddb199dc6f9d9b27ee4393db%2Fimage-20230324151147182.png?alt=media)

> 📌 The device is a **Motorola MotoG3**.

***
