# Curl Commands

<details>

<summary><mark style="color:purple;"><strong><code>Requests</code></strong></mark></summary>

{% code title="Send POST request" %}
```bash
curl -d "enter data here" http://IP:PORT
```
{% endcode %}

{% code title="Retrieve Headers + body" %}
```bash
curl -i https://example.com
```
{% endcode %}

{% code title="Retrieve Only Headers" %}
```bash
curl -I https://example.com
```
{% endcode %}

{% code title="Manipulate Headers" %}
```bash
curl -H 'HEADER:VALUE' https://example.com
```
{% endcode %}

{% code title="Set User-Agent header" %}
```bash
curl https://example.com -A 'Mozilla/5.0'
```
{% endcode %}

{% code title="Credentials" %}
```bash
curl -u user:pass https://example.com
```
{% endcode %}

{% code title="Credentials Within URL" %}
```bash
curl http://username:password@example.com:PORT
```
{% endcode %}

</details>

<details>

<summary><mark style="color:purple;"><strong><code>Cookies</code></strong></mark></summary>

{% hint style="info" %}
{% code title="Set Specific Cookie" overflow="wrap" %}
```bash
curl -b 'PHPSESSID=c1nsa6op7vtk7kdis7bcnbadf1' http://www.example.net:PORT
```
{% endcode %}

{% code title="Save Cookie in to a file" overflow="wrap" %}
```bash
curl -X POST -d "flag=UHC{F1rst_5tep_2_Qualify}" -c cookies.txt -v http://10.10.11.128/challenge.php
```
{% endcode %}

{% code title="Use cookie from the file" overflow="wrap" %}
```bash
curl -H "X-FORWARDED-FOR: 1.1.1.1; ping -c 1 10.10.16.7;" -b cookies.txt -v http://10.10.11.128/firewall.php
```
{% endcode %}
{% endhint %}

</details>

<details>

<summary><mark style="color:purple;"><strong><code>Certificates</code></strong></mark></summary>

{% hint style="info" %}
{% code title="Skip SSL Certificate validation" overflow="wrap" %}
```bash
curl -k -v https://example.com
```
{% endcode %}

{% code title="Specify a CA file" overflow="wrap" %}
```bash
curl --cacert /path/to/ca-cert.pem https://secure.example.com
```
{% endcode %}

{% code title="Specify a CA directory" overflow="wrap" %}
```bash
curl --capath /path/to/cacerts https://secure.example.com
```
{% endcode %}

{% code title="Specify a Client Certificate" overflow="wrap" %}
```bash
curl -E /path/to/client-cert.pem https://secure.example.com
```
{% endcode %}

{% code title="Specify the Certificate format" overflow="wrap" %}
```bash
curl -E /path/to/client-cert.pem --cert-type PEM|DER|ENG https://secure.example.com
```
{% endcode %}

{% code title="Skip SSL + verbose + Client Certificate" overflow="wrap" %}
```bash
curl -k -v -E /path/to/client_certificate.pem https://example.com
```
{% endcode %}

{% code title="Skip SSL + Verbose + Specific Certificate" overflow="wrap" %}
```bash
curl -k -v --cacert /path/to/ca_certificate.crt https://example.com
```
{% endcode %}

{% code title="Skip SSL + verbose + Client Certificate & Key" overflow="wrap" %}
```bash
curl -k -v --cert client_cert_and_key.pem --cert-type PEM https://test.me
```
{% endcode %}
{% endhint %}

</details>
