# tcpdump

## How to sniff traffic from Android emulator

Check which AVDs are present

```bash
emulator -list-avds
```

Select your AVD and run (**avoid this part if you are running the emulator yet**)

```bash
emulator -avd <non_production_avd_name> -writable-system -no-snapshot
```

Install tcpdump on the Android device (download here: <https://www.androidtcpdump.com/android-tcpdump/downloads>)

```bash
adb root
adb remount
adb push /wherever/you/put/tcpdump /system/xbin/tcpdump
adb shell chmod 6755 /system/xbin/tcpdump
```

Forward an android port to host

```bash
adb forward tcp:11111 tcp:11111
```

Start sniff traffic with tcpdump

```bash
adb shell
tcpdump -i wlan0 -s0 -w - | nc -l -p 11111
```

Connect wireshark to the forwarded port via netcat

```bash
nc localhost 11111 | wireshark -k -S -i -
```

## References

{% embed url="<https://www.tcpdump.org/>" %}


---

# 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://www.pwny.cc/so/android/tcpdump.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.
