---
title: "When you don't have curl..."
url: 'https://kb.hills-family.uk/blog/when-you-dont-have-curl'
markdown: 'https://kb.hills-family.uk/blog/when-you-dont-have-curl.md'
date: '2021-05-13'
description: 'I’ve been needing to use an embedded system that had network support but lacked many of the (useful) utilities that we’ve gotten used to. I needed this device to talk to an HTTP endpoint (an array of relays accessible via Ethernet) that was configured with basic authentication. With curl, this is a simple case of running: curl username:password@10.0.3.20/outs.cgi?out0=0 curl happily understand this syntax and correctly negotiates basic auth. Without curl, this task gets a little more involved… The layer down would probably be nc, or netcat that can be used to send raw data over a network. U'
taxonomy:
  tag:
    - Linux
    - Network
    - netcat
---

# When you don't have curl...

[ Home ](https://kb.hills-family.uk/)     [ Blog ](https://kb.hills-family.uk/blog)      When you don't have curl...    

   13 *May*   
#### [When you don't have curl...](https://kb.hills-family.uk/blog/when-you-dont-have-curl)

  [Linux](https://kb.hills-family.uk/blog/tag:Linux) [Network](https://kb.hills-family.uk/blog/tag:Network) [netcat](https://kb.hills-family.uk/blog/tag:netcat)  

I’ve been needing to use an embedded system that had network support but lacked many of the (useful) utilities that we’ve gotten used to. I needed this device to talk to an HTTP endpoint (an array of relays accessible via Ethernet) that was configured with basic authentication. With `curl`, this is a simple case of running:

```bash
curl username:password@10.0.3.20/outs.cgi?out0=0
```

`curl` happily understand this syntax and correctly negotiates basic auth. Without `curl`, this task gets a little more involved…

The *layer down* would probably be `nc`, or *netcat* that can be used to send raw data over a network. Unfortunately, talking to a HTTP server means you’ve also got to send HTTP headers. Pair `nc` with `printf` to write the HTTP `GET` request:

```bash
printf "GET /outs.cgi?out0=0 HTTP/1.1\r\n\r\n" | nc -v 10.0.3.20 80
```

[Adding basic HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization) is fairly straightforward. Basic authentication requires `username:password` to be encoded using Base64. Unfortunately, the `base64` app was unavailable on my embedded device, but was available on my desktop environment:

```bash
echo -n "username:password" | base64
```

The use of `-n` in the echo is required as it prevents the new line character from being appended to the string, thus causing the wrong password to be produced. The output can then be copied into the previous string with the added basic authorisation added:

```bash
printf "GET /outs.cgi?out0=0 HTTP/1.1\r\nAuthorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=\r\n\r\n" | nc -v 10.0.3.20 80
```

At this point, I received a sensible answer back from the web server. An example of a bad answer would be, say, an incorrect password, which would appear as:

```text
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="Protected"
Connection: close

401 Unauthorized: Password required
```

The things you do when you don’t have access to `curl`…

 [ Next Post](https://kb.hills-family.uk/blog/wireshark-for-cli) [Previous Post ](https://kb.hills-family.uk/blog/use-ssh-as-socks-5-proxy)

#### Knowledge Base

Tips, tricks and how-to guides on various topics.

#### Popular Tags

  [Linux](https://kb.hills-family.uk/blog/tag:Linux) [Dynamics AX](https://kb.hills-family.uk/blog/tag:Dynamics%20AX) [D365 Finance and Operations](https://kb.hills-family.uk/blog/tag:D365%20Finance%20and%20Operations) [Network](https://kb.hills-family.uk/blog/tag:Network) [Data Management Framework](https://kb.hills-family.uk/blog/tag:Data%20Management%20Framework) [Logic Apps](https://kb.hills-family.uk/blog/tag:Logic%20Apps) [JavaScript](https://kb.hills-family.uk/blog/tag:JavaScript) [netcat](https://kb.hills-family.uk/blog/tag:netcat) [SSH](https://kb.hills-family.uk/blog/tag:SSH) [PowerShell](https://kb.hills-family.uk/blog/tag:PowerShell) [Virtual Machines](https://kb.hills-family.uk/blog/tag:Virtual%20Machines) [VMware](https://kb.hills-family.uk/blog/tag:VMware) [SQL Server](https://kb.hills-family.uk/blog/tag:SQL%20Server) [Wireshark](https://kb.hills-family.uk/blog/tag:Wireshark) [Python](https://kb.hills-family.uk/blog/tag:Python) [Licensing](https://kb.hills-family.uk/blog/tag:Licensing) [Ubuntu](https://kb.hills-family.uk/blog/tag:Ubuntu)

---

## Navigation

- Parent: [Blog](https://kb.hills-family.uk/blog.md)
- Previous: [Wireshark for CLI](https://kb.hills-family.uk/blog/wireshark-for-cli.md)
- Next: [Use SSH as SOCKS 5 proxy](https://kb.hills-family.uk/blog/use-ssh-as-socks-5-proxy.md)
