ncat / netcat


Ncat is a feature-packed networking utility which reads and writes data across networks from the command line. It uses both TCP and UDP for communication and is designed to be a reliable back-end tool to instantly provide network connectivity to other applications and users. Ncat will not only work with IPv4 and IPv6 but provides the user with a virtually limitless number of potential uses.

project page

https://nmap.org/ncat/

simple get call

netcat -C michalszalkowski.com 80
GET / HTTP/1.0
PRESS ENTER PRESS ENTER PRESS ENTER 

serve static file from server

sudo netcat -l 127.0.0.1 81 < /etc/passwd

small server

echo '#!/usr/bin/env bash
while true; do
  echo -e "HTTP/1.1 200 OK\n\n $(date)" | nc -l -p 81 -q 1
done
' > server.sh && chmod +x server.sh
sudo ./server.sh

small server with static file

echo '#!/usr/bin/env bash
while true; do
  echo -e "HTTP/1.1 200 OK\n\n $(cat index.html) <pre>$(date)</pre>" | nc -l -p 81 -q 1
done
' > server.sh && chmod +x server.sh
echo '<HTML><BODY><h1>lorem ipsum</h1><h2>lorem ipsum</h2></BODY></HTML>' > index.html
sudo ./server.sh