> For the complete documentation index, see [llms.txt](https://notes.cavementech.com/pentesting-quick-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.cavementech.com/pentesting-quick-reference/boxes-machines/pwn.college-talking-web.md).

# PWN.COLLEGE Talking Web

Complete solutions for Talking web pwn college. Complete writeup of all challenges

### Challenge 1

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FR5rulWZUdsUMsGPkWJqk%2Fimage.png?alt=media&amp;token=e3b6a25f-902f-4b89-ac9d-d4961fd71474" alt=""><figcaption></figcaption></figure>

### Challenge 2

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FqzIUJLumQqByMRg6ejGZ%2Fimage.png?alt=media&amp;token=6e7ded79-7c85-4155-9711-aa5be6f5b4f6" alt=""><figcaption></figcaption></figure>

### Challenge 3

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FUO6llNn3zj82hnImX8Gp%2Fimage.png?alt=media&amp;token=b3273a0e-f60b-4a68-862a-23737e12fd6a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FRZrLCmvdt6xgXfrKR22j%2Fimage.png?alt=media&amp;token=bb7c1512-c5aa-4610-a9af-decfa6afc496" alt=""><figcaption></figcaption></figure>

### Challenge 4

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2F9NCzDPRPEJ5J1f4ecTFY%2Fimage.png?alt=media&amp;token=b9bf246a-a852-441b-a3d4-3254c83540aa" alt=""><figcaption></figcaption></figure>

### Challenge 5

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2Fyj1ecxfbwANiGZ3HS93x%2Fimage.png?alt=media&amp;token=dae6d542-dcd9-42c4-814a-e737f6876090" alt=""><figcaption><p>double enter at the end of host</p></figcaption></figure>

### Challenge 6

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2Fdj5Gtk1orVaFAxkrXwky%2Fimage.png?alt=media&amp;token=0ffb0a36-eb99-4fc5-a04a-c8d7ec68f23a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2Fz2XvY5zyXxbv9OWC1E7Y%2Fimage.png?alt=media&amp;token=c09f98ec-1453-4f20-bcc8-8a928f237d6d" alt=""><figcaption></figcaption></figure>

### Challenge 7

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FF46MX4aJleB22maJzAL9%2Fimage.png?alt=media&amp;token=3ce61e9a-2982-4609-b50b-031059be7992" alt=""><figcaption></figcaption></figure>

### Challenge 8

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2F3OUvX9dgObS5Fqx6NEkt%2Fimage.png?alt=media&amp;token=b7c0f749-51b8-4e5f-b32d-cd12476c9a2c" alt=""><figcaption></figcaption></figure>

### Challenge 9

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FjF9eW4Y4hJ6RQxcBdzSz%2Fimage.png?alt=media&amp;token=ee908c17-91ce-4ba1-b46a-d5cf6e9c04d4" alt=""><figcaption></figcaption></figure>

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FDXj8i35iIsy1X5jXjZeh%2Fimage.png?alt=media&amp;token=6dee2d3b-048d-43be-af15-0a8999211093" alt=""><figcaption></figcaption></figure>

### Challenge 10

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2F7JAdFWuof5WX6q0ILiM1%2Fimage.png?alt=media&amp;token=8b3367f5-1b34-4bdc-85ab-fe59ba823016" alt=""><figcaption></figcaption></figure>

### Challenge 11

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FF2ott2tMBujdbNqZUli5%2Fimage.png?alt=media&amp;token=e71a7fdc-78df-48c8-b5f1-b4bc8a70172f" alt=""><figcaption></figcaption></figure>

### Challenge 12

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FaJ3gpsfAGS7wuANo7jTi%2Fimage.png?alt=media&amp;token=c4c3e624-7f77-4289-a422-fbe1c7cf272e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FLjUutm2uKDrBRqeh1Kfi%2Fimage.png?alt=media&amp;token=30e582d9-3c2e-4e30-b329-ab393fbf7497" alt=""><figcaption></figcaption></figure>

### Challenge 13

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FYPAOtrvfK57blWin7dXj%2Fimage.png?alt=media&amp;token=281378d7-e916-4777-9e4a-4e71946271d2" alt=""><figcaption></figcaption></figure>

### Challenge 14

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FG9Z40TbTZNFbHFr5HNyb%2Fimage.png?alt=media&amp;token=f84673d5-eaad-4347-bfa2-0de4887f28e0" alt=""><figcaption></figcaption></figure>

### Challenge 15

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FoWKsMV1eggViYGKb9wk5%2Fimage.png?alt=media&amp;token=c9858d15-33e6-4485-8382-3d144bd60e88" alt=""><figcaption></figcaption></figure>

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FIN078PysTRgsdm6LzrEp%2Fimage.png?alt=media&amp;token=587920e9-558e-4c6f-9bf5-41e7ac41d85f" alt=""><figcaption></figcaption></figure>

### Challenge 16

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FYmepug76YMKXvEi0CnHv%2Fimage.png?alt=media&amp;token=588cd9d7-729c-4a63-a86a-5680fb699a30" alt=""><figcaption><p>url encode &#x26; , space and % in argument b</p></figcaption></figure>

### Challenge 17

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FP4RSqhgkf8AuWOa6IpcT%2Fimage.png?alt=media&amp;token=745230c9-5ab6-4d0e-8420-f0b1e03aaa52" alt=""><figcaption></figcaption></figure>

### Challenge 18

```
                                                       req4.python                                                                    
import requests

# Define the URL and headers
url = 'http://localhost?a=5c058979bd37fb3503512c58bd11c8b6&b=2ea09e1b%20c567af01%26b7e9b6c5%239a51c800'
headers = {
    'Host': '48f80bbb6183538f3d323f99d7c397fb'
}

# Send the GET request
response = requests.get(url, headers=headers)

# Print the response
print(response.text)
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FBssgISiwXpgMOxksjyqM%2Fimage.png?alt=media&amp;token=24be5dc9-7e11-4b08-bf5b-881da8dffa7a" alt=""><figcaption></figcaption></figure>

### Challenge 19

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FmgweJOqxRIN7etvRwYWc%2Fimage.png?alt=media&amp;token=07bb94a4-12c5-4007-91e6-a4ab1561acfa" alt=""><figcaption><p>-d is used to send form data</p></figcaption></figure>

### Challenge 20

```
echo -e "POST / HTTP/1.1\r\nHost: localhost\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 34\r\n\r\na=eeb6c038eac69a4a652014ff7dabc2a8\r\n" | nc localhost 80
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FMsJO4uyGJGbLshgEFjTC%2Fimage.png?alt=media&amp;token=9bcb12e9-fce2-4782-b576-cd0a83236dc7" alt=""><figcaption></figcaption></figure>

### Challenge 21

```
import requests

# Define the URL and headers
url = 'http://localhost'

data={'a':'670e4fa6103d6c493ad241b2959c0ace'}
# Send the POST request
response = requests.post(url, data=data)
# Print the response
print(response.text)
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FhH5qAtDsnWRrCZPfGjKe%2Fimage.png?alt=media&amp;token=95879ec8-07ea-461e-afda-86564e9fcd4d" alt=""><figcaption></figcaption></figure>

### Challenge 22

```
curl localhost -d'a=09084bc0ced7092b5b25fa997bf48df8&b=e3cc5d01%202802266d%2696574197%23ee3d8e3b'
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FaWstUsf1wUPUC8T1W9S1%2Fimage.png?alt=media&amp;token=726caaf9-5023-4a87-9e53-216ef816afec" alt=""><figcaption></figcaption></figure>

### Challenge 23

```
hacker@talking-web~level23:~$ echo -e "POST / HTTP/1.1\r\nHost: localhost\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 78\r\n\r\na=34418b28c1bd8f7875b9ea814fe8910f&b=712c2671%208187e24d%2639f2bac0%2399e800dc\r\n" | nc localhost 80
HTTP/1.1 200 OK
Server: Werkzeug/3.0.3 Python/3.8.10
Date: Wed, 31 Jul 2024 14:54:11 GMT
Content-Length: 58
Server: pwn.college
Connection: close

pwn.college{k0i2uG0ghQ2XEvZQJLcm85lmPMG.dBTOyMDL5QTM2QzW}
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2F2AVDCn3iBQ0AVt8pHqqI%2Fimage.png?alt=media&amp;token=4883682a-9cb9-46a8-bfd3-0192cf48afdb" alt=""><figcaption></figcaption></figure>

### Challenge 24

```
import requests

# Define the URL and headers
url = 'http://localhost'

data={'a':'03ac7b18eea1c8cdac98e2f43bdbba2b','b':'179d5171 189a9751&d671a87f#65>
# Send the POST request
response = requests.post(url, data=data)
# Print the response
print(response.text)
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FPpAQJUuJWY6qkgD3CLIQ%2Fimage.png?alt=media&amp;token=f830ff9f-6222-43b3-b981-161d5f4c8b64" alt=""><figcaption><p>no need to manually encode</p></figcaption></figure>

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2F3RLXZGaA79UIQGKvfxal%2Fimage.png?alt=media&amp;token=bac9a95d-e519-4fab-bf59-7f22fd60020f" alt=""><figcaption></figcaption></figure>

### Challenge 25

```
curl -H "Content-Type: application/json" -d '{"a":"value1"}' localhost
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2Foo66bMyfGQyH0eZP3Mmp%2Fimage.png?alt=media&amp;token=5748a140-7bf4-401c-a4d1-55897f8953ad" alt=""><figcaption></figcaption></figure>

### Challenge 26

```
echo -e "POST / HTTP/1.1\r\nHost: localhost\r\nContent-Type: application/json\r\nContent-Length: 40\r\n\r\n{\"a\":\"142c3c13b4bfc8da044d69998d75da0d\"}\r\n" | nc localhost 80
HTTP/1.1 200 OK
Server: Werkzeug/3.0.3 Python/3.8.10
Date: Wed, 31 Jul 2024 15:17:30 GMT
Content-Length: 58
Server: pwn.college
Connection: close

pwn.college{co1WKjSkwNrExurzl1L7UHonZ5p.dNTOyMDL5QTM2QzW}
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2Fo28caxOrjJHsy4qcFs2E%2Fimage.png?alt=media&amp;token=85d9cb2c-c0c7-4315-8c61-ae9934bd87b9" alt=""><figcaption></figcaption></figure>

### Challenge 27

```
import requests

# Define the URL and headers
url = 'http://localhost'

data={'a':'3d33683d50e6291b6fdb74f3cb5f9927'}
# Send the POST request
response = requests.post(url, json=data)
# Print the response
print(response.text)
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FA62CYyLdToPt2S3XCIIC%2Fimage.png?alt=media&amp;token=02c20555-1d42-4c38-9bbd-1f572b105a29" alt=""><figcaption></figcaption></figure>

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FA0fzhviV6KebvO3Tx553%2Fimage.png?alt=media&amp;token=297fd655-8ed9-4a18-9f29-077b75dcbc0a" alt=""><figcaption></figcaption></figure>

### Challenge 28

```
curl -X POST localhost -H "Content-Type: application/json" -d '{"a": "dc7f7f3347fdb41e5c5823ac1793495b", "b": {"c": "361b9f79", "d": ["9d33c82d", "7bbb9b0e 28c1d450&25ff1c63#ad0888bc"]}}'
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FLXklHN06Ze0uhX89QIiq%2Fimage.png?alt=media&amp;token=cb6d64bd-bae8-4c5a-bf53-9a6a0f1f1a9f" alt=""><figcaption></figcaption></figure>

### Challenge 29

```
echo -e "POST / HTTP/1.1\r\nHost: localhost\r\nContent-Type: application/json\r\nContent-Length: 125\r\n\r\n{\"a\": \"f4526161060c8cc0ed658b71c7bc5dd2\", \"b\": {\"c\": \"1f0da1fe\", \"d\": [\"86d7ab98\", \"8df6fc66 a482ffe5&347ce851#80bb9423\"]}}\r\n" | nc localhost 80HTTP/1.1 200 OK
Server: Werkzeug/3.0.3 Python/3.11.9
Date: Thu, 01 Aug 2024 17:09:24 GMT
Content-Length: 58
Server: pwn.college
Connection: close

pwn.college{MvnBatKEB_M0OUIiXu_H0qrECBk.dZTOyMDL5QTM2QzW}
```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2Fx1lRJgUwcKw1wHmtmbaR%2Fimage.png?alt=media&amp;token=fae49cd0-8e3e-4bad-9025-47817651a2c8" alt=""><figcaption></figcaption></figure>

### Challenge 30

```
import requests

# Define the URL and headers
url = 'http://localhost'
data = {
    "a": "8c5402a42040dda391e23b48c0a650b2", 
    "b": {
        "c": "ebf001fe", 
        "d": ["023b07b0", "b6003939 e92a012a&9a2a763c#02944590"]
    }
}

# Send the POST request
response = requests.post(url, json=data)

# Print the response
print(response.text)

```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FgX7nXuWChezDXHUBHOlE%2Fimage.png?alt=media&amp;token=89b3f13f-19bb-4551-92cf-ccd0195b3af8" alt=""><figcaption></figcaption></figure>

### Challenge 31

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FAuHYrUfAsYa2kUZMJl5x%2Fimage.png?alt=media&amp;token=f3e6f6f6-c882-4223-9a52-194ed439ae53" alt=""><figcaption><p>dash L option </p></figcaption></figure>

### Challenge 32

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2Fnvyro3bHqwVoLQdu7z5f%2Fimage.png?alt=media&amp;token=a9811a8b-a7de-4aa3-b6ab-f264bfce2ae0" alt=""><figcaption><p>Manually make 2xrequests</p></figcaption></figure>

### Challenge 33

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FFJyVyG9WXTENR1uR7ApZ%2Fimage.png?alt=media&amp;token=0298133d-39c4-46f7-9efb-e615484f0543" alt=""><figcaption><p>python auto handles redirects</p></figcaption></figure>

### Challenge 34

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FCwoNs7bNgldxP2n8u3Pu%2Fimage.png?alt=media&amp;token=af857a28-6fe3-41aa-9b63-b4cfc2f74fcf" alt=""><figcaption><p>first inspect the header to get the cookie value</p></figcaption></figure>

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FWZSdic5Q0kEuDgvvuz4r%2Fimage.png?alt=media&amp;token=ef02a6aa-211b-4ca0-8533-c80ef40e8be6" alt=""><figcaption><p>Now set the cookie</p></figcaption></figure>

### Challenge 35

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FouPRbaEIGRHYV0iOw3lc%2Fimage.png?alt=media&amp;token=d878f39b-02d1-4789-823f-691cc7312759" alt=""><figcaption><p>You do need to set the host</p></figcaption></figure>

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FG4nbK2DrgMTQoz2XJkCS%2Fimage.png?alt=media&amp;token=c9a431f2-2ad0-4879-8713-71258d0ab7cc" alt=""><figcaption></figcaption></figure>

### Challenge 36

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FHACK7MnmHBFiaraoR4wS%2Fimage.png?alt=media&amp;token=9f0ef55a-c426-4a6e-9627-370abedbdc50" alt=""><figcaption></figcaption></figure>

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FfKN894cxFU8wCLjbRVIm%2Fimage.png?alt=media&amp;token=58129575-323c-4796-bd2e-982b4baa3001" alt=""><figcaption></figcaption></figure>

### Challenge 37

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FxZPlRVgH459iD5rSU8sI%2Fimage.png?alt=media&amp;token=93ed64a0-81c4-4c5a-9475-aea1d7996833" alt=""><figcaption></figcaption></figure>

The `-b` and `-c` parameters in `curl` are used to handle cookies:

* `-b` or `--cookie`: This option specifies the file containing the cookies to be sent with the HTTP request. It can also be used to pass cookies directly in the request.
* `-c` or `--cookie-jar`: This option specifies the file where cookies received from the server should be saved after the request is completed.

### Challenge 38

```
#!/bin/bash

# Initialize the state and cookie
state=0
cookie=""

# Function to make an HTTP request and capture the response
make_request() {
    request="GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n"
    if [ -n "$cookie" ]; then
        request+="Cookie: $cookie\r\n"
    fi
    request+="\r\n"

    response=$(echo -e "$request" | nc localhost 80)
    echo "$response"
}

# Function to extract the state and cookie from the response
extract_state_and_cookie() {
    response="$1"
    state=$(echo "$response" | grep -oP '(?<=state: )\d+')
    cookie=$(echo "$response" | grep -oP '(?<=Set-Cookie: )[^;]+')
}

# Infinite loop to handle stateful interactions
while true; do
    echo "Making request with state: $state..."
    
    # Make the request and capture the response
    response=$(make_request)
    
    # Extract the state and cookie from the response
    extract_state_and_cookie "$response"
    
    # Print the response, current state, and cookie
    echo "Response: $response"
    echo "Current State: $state"
    echo "Cookie: $cookie"
    
    # Increment the state
    state=$((state + 1))
    
    # Sleep for a short time before the next request to avoid rapid polling (optional)
    sleep 1
done

```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FVynUxUGLVu7Mkr1oTbp0%2Fimage.png?alt=media&amp;token=c76d1ade-b94e-468a-baf6-5e8e6216ba73" alt=""><figcaption></figcaption></figure>

### Challenge 39

```
import requests as r

host = "http://127.0.0.1/"

# First request
response1 = r.get(host)
cookie1 = response1.cookies

# Second request using cookies from the first response
response2 = r.get(host, cookies=cookie1)
cookie2 = response2.cookies

# Third request using cookies from the second response
response3 = r.get(host, cookies=cookie2)
cookie3 = response3.cookies

# Fourth request using cookies from the third response
response4 = r.get(host, cookies=cookie3)
cookie4 = response4.cookies 

# Print the response of the fourth request
print(response4.text)

```

<figure><img src="https://755681241-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5rXMZ1JAQhUeS7TtZkM%2Fuploads%2FboA0jbXUxUtdn2vasBpj%2Fimage.png?alt=media&amp;token=0a852fa5-db7d-4cba-bb4e-f505ffa0524e" alt=""><figcaption></figcaption></figure>
