netcat (nc) - wAlber47/Tech-Journal GitHub Wiki

  • netcat - integrated wireless connection that almost every Linux version has. Windows does not have this integrated.
  • Hosting a Server:
    • nc -l -p PORT where -l is listening and -p is the port that it is opening for connections.
  • Connecting to a Server as a Client:
    • nc IP-ADDRESS PORT
  • Pull down an HTTP: Should show you the HTTP file of a website in the command line, can also use > to push it to a new file.
    • nc www.google.com 80
    • GET /HTTP /1.1
    • HOST:www.google.com
    • 'Enter' x2
  • Pushing Files:
    • As a client, you can use < this to send files, as long as it is followed by the file name.
    • As a server, you can use > to receive a file containing whatever is passed through the server.
    • A good rule of thumb, is that the arrow should point towards what the file is being sent to.
  • Executing Commands through Netcat (Windows Server):
    • Hosting: nc -l -p PORT -e cmd.exe
    • Connection: Follow Normal Command
  • Executing commands through Netcat (Linux Server):
    • This is a little confusing as their is some commands that I don't know completely how they work.
    • You must create a 'fifo' using command mkfifo /tmp/fifo
    • Once created you must run this command cat /tmp/fifo | /bin/sh -i 2>&1 | nc -l