All Projects → roccomuso → nc

roccomuso / nc

Licence: MIT license
Porting Netcat in Node.js. CLI util. 💻

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to nc

Netcat
💻 Netcat client and server modules written in pure Javascript for Node.js.
Stars: ✭ 315 (+1752.94%)
Mutual labels:  tcp, udp, net
hev-socks5-tproxy
A simple, lightweight socks5 transparent proxy for Linux. (IPv4/IPv6/TCP/UDP over TCP)
Stars: ✭ 209 (+1129.41%)
Mutual labels:  tcp, udp
KingNetwork
KingNetwork is an open source library to facilitate the creation and communication of clients and servers via TCP, UDP, WebSocket and RUDP sockets.
Stars: ✭ 78 (+358.82%)
Mutual labels:  tcp, udp
Socket
The Hoa\Socket library.
Stars: ✭ 61 (+258.82%)
Mutual labels:  tcp, udp
ctsTraffic
ctsTraffic is a highly scalable client/server networking tool giving detailed performance and reliability analytics
Stars: ✭ 125 (+635.29%)
Mutual labels:  tcp, udp
node-dns
🌐 DNS Server and Client Implementation in Pure JavaScript with no dependencies.
Stars: ✭ 390 (+2194.12%)
Mutual labels:  tcp, udp
voice
Implementation of the Discord Voice API for discord.js and other JS/TS libraries
Stars: ✭ 310 (+1723.53%)
Mutual labels:  tcp, udp
masscanned
Let's be scanned. A low-interaction honeypot focused on network scanners and bots. It integrates very well with IVRE to build a self-hosted alternative to GreyNoise.
Stars: ✭ 50 (+194.12%)
Mutual labels:  tcp, udp
net-protocol
golang模拟内核协议栈 实现链路层、网络层、传输层、应用层 用户态协议栈 ,基于虚拟网卡TUN/TAP
Stars: ✭ 129 (+658.82%)
Mutual labels:  tcp, udp
network
exomia/network is a wrapper library around System.Socket for easy and fast TCP/UDP client & server communication.
Stars: ✭ 18 (+5.88%)
Mutual labels:  tcp, udp
SACK
System Abstraction Component Kit
Stars: ✭ 18 (+5.88%)
Mutual labels:  tcp, udp
iit-kgp-network
Information repository and Solutions on IIT KGP Internet Problems.
Stars: ✭ 28 (+64.71%)
Mutual labels:  tcp, udp
ToxicEye
👽 Program for remote control of windows computers via telegram bot. Written in C#
Stars: ✭ 305 (+1694.12%)
Mutual labels:  backdoor, net
node-drivers
Industrial protocol drivers in node.js
Stars: ✭ 20 (+17.65%)
Mutual labels:  tcp, udp
RRQMSocket
TouchSocket是.Net(包括 C# 、VB.Net、F#)的一个整合性的、超轻量级的网络通信框架。包含了 tcp、udp、ssl、http、websocket、rpc、jsonrpc、webapi、xmlrpc等一系列的通信模块。一键式解决 TCP 黏分包问题,udp大数据包分片组合问题等。使用协议模板,可快速实现「固定包头」、「固定长度」、「区间字符」等一系列的数据报文解析。
Stars: ✭ 286 (+1582.35%)
Mutual labels:  tcp, udp
Backdoor
A backdoor that runs on Linux and Windows
Stars: ✭ 36 (+111.76%)
Mutual labels:  tcp, backdoor
socket
Dazzle Async Socket
Stars: ✭ 19 (+11.76%)
Mutual labels:  tcp, udp
ronin-support
A support library for Ronin. Like activesupport, but for hacking!
Stars: ✭ 23 (+35.29%)
Mutual labels:  tcp, udp
DDoS-Script
A script written in perl for ddos ​​with automatic detection of open and vulnerable port that gives up to 1.5 gb packages / s
Stars: ✭ 30 (+76.47%)
Mutual labels:  tcp, udp
reverse-tunnel
Reverse tunnel TCP and UDP
Stars: ✭ 100 (+488.24%)
Mutual labels:  tcp, udp

nc

NPM Version node Dependency Status JavaScript Style Guide Patreon donate button

Porting Netcat in Node.js. CLI util. 💻

To embed it in your Node.js app use the netcat package instead. This is meant to be used as a standalone tool, but it's not fully equal to the original implementation of netcat.

Linux Mac OS Windows

What you can do

  • TCP & UDP
  • Backdoor (Reverse Shell)
  • Honeypot
  • File transfer
  • Port forwarding
  • Proxy
  • Web Server & HTTP Client
  • Port scanning

Install

$ npm install -g nc

Usage

$ nc -l -p port [- options] [hostname] [port]

Available options:

-c shell commands    as `-e’; use /bin/sh to exec [dangerous!!]
-e filename          program to exec after connect [dangerous!!]
-b                   allow broadcasts
-h                   this cruft
-i secs              delay interval for lines sent, ports scanned
-k set               keepalive option on socket
-l                   listen mode, for inbound connects
-n                   numeric-only IP addresses, no DNS
-o file              hex dump of traffic
-p port              local port number
-r                   randomize local and remote ports
-s addr              local source address
-u                   UDP mode
-U                   Listen or connect to a UNIX domain socket
-v                   verbose
-w secs              timeout for connects and final net reads (client-side)
-z                   zero-I/O mode [used for scanning]

Server: Listen for inbound

$ nc -l -p 2389

Client mode

$ nc localhost 2389

Opening a raw connection to port 2389.

Transfer file

Server side Client side
nc -l 2389 > test cat testfile | nc localhost 2389

Timeout support

$ nc -w 10 localhost 2389

Connection above would be terminated after 10 seconds.

Force netcat server to stay up

$ nc -kl 2389

In this way the server remains up even if the client got disconnected.

Netcat execute

A far more exciting thing to do is to get a quick shell going on a remote machine by using the -l or listen option and the -e or execute option. When a connection is made, Netcat executes the program of your choice and connects the stdin and stdout of the program to the network connection.

$ nc -l -p 23 -e /bin/sh

Retrieve a website Homepage

Let's create a HTTP request file get.txt that contains the following line and then a blank line:

GET / HTTP/1.0

To use Netcat to retrieve the home page of a web site use:

$ nc -v www.website.com 80 < get.txt

You will see Netcat make a connection to port 80, send the text contained in the file get.txt, and then output the web server's response to stdout.

Configure netcat client to retry on disconnect

In a normal scenario, if the nc client disconnect, it will not retry the connection. With the --retry <secs> or -R <secs> param, it will retry the connection after tot seconds.

$ nc -R 5 localhost 2389

Unix socket file

If you have docker, let's try to list our containers' images connecting to the docker unix socket file:

$ echo -e "GET /images/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock

PS. for this example root permissions are required: sudo su.

Netcat as a Proxy

$ mkfifo /tmp/fifo
$ nc -l -k -p 8080 </tmp/fifo | nc website.com 80 >/tmp/fifo

Netcat as a simple port scanner

$ nc -z 192.168.1.100 1-255

Dump hex traffic

If you use the -o option you can dump all hex traffic.

$ nc 127.0.0.1 4445 -o /tmp/log.txt

UDP Protocol

By default all the sockets that nc utility creates are TCP protocols but this utility also works with UDP protocol. To enable UDP protocol the -u flag is used.

Server side Client side
nc -u -l -p 2389 nc -u localhost 2389

Send a UDP message

$ echo 'message' | nc -w 1 -u 192.168.1.111 514

Pipe via UDP (-u) with a wait time (-w) of 1 second to 192.168.1.111 on port 514.

DEBUG

Debug matches the verbose mode. You can enable it with the -v param or the env var DEBUG=nc. This module uses the node implementation of netcat under the hood, to debug both use: DEBUG=netcat:*,nc.

Author

Rocco Musolino (@roccomuso)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].