• Arnaud's links
  • Home
  • RSS Feed
  • Tag cloud
  • Login
all links
  • Few Useful Netcat Tricks | Terminally Incoherent

    [Summary, full note in Shaarli]
    Few useful netcat tricks (Luke Maciak, 2007): a ~60 KB tool that reads and writes data over network sockets.

    • Port scan: nc -v -w 1 localhost -z 1-3000
    • File transfer: on B: nc -lp 1337 > file.zip ; on A: nc -w 1 10.48.2.40 1337 < file.zip
    • One-to-one chat: nc -lp 1337 on one side, nc 10.48.2.40 1337 on the other
    • Shell server: nc -lp 1337 -e /bin/bash (Windows: -e cmd.exe); gives the shell with the permissions of the user running nc
    • Hand-written HTTP request with spoofed headers: nc google.com 80, then type "GET / HTTP/1.1", "Host: google.com", "User-Agent: ...", "Referrer: ..." and a blank line; also a good way to read response headers
    • One-page emergency web server: while true; do nc -l -p 80 -q 1 < error.html; done
    • Clone a partition over the network (both unmounted, e.g. from a live distro; works for NTFS too): dd if=/dev/sda | nc 192.168.0.1 9000 ; receiver: nc -l -p 9000 | dd of=/dev/sda

    Netcat follows the Unix philosophy: one thing done well. socat is a more powerful fork with a different syntax.

    February 21, 2013 - permalink - http://www.terminally-incoherent.com/blog/2007/08/07/few-useful-netcat-tricks/
    nc netcat