WSL icon indicating copy to clipboard operation
WSL copied to clipboard

nmap not working

Open yasharne opened this issue 10 years ago • 94 comments

yashar@DESKTOP-MHBRT96:~$ sudo nmap -sP 192.168.1.0/24 Starting Nmap 6.40 ( http://nmap.org ) at 2016-11-11 23:37 STD route_dst_netlink: cannot bind AF_NETLINK socket: Invalid argument

yasharne avatar Nov 11 '16 20:11 yasharne

When opening issues please fill out the provided template. Which windows build are you running?

benhillis avatar Nov 14 '16 16:11 benhillis

  1. Title

nmap fails to open socket.

  1. Brief description

cannot bind AF_NETLINK socket when running nmap

  1. Windows version / build number

Microsoft Windows [Version 10.0.14393]

  1. Steps required to reproduce

apt-get install nmap nmap -sn 192.168.0.*

  1. Copy of the terminal output

root@DESKTOP-5UFF8C5:~# nmap -sn 192.168.0.*

Starting Nmap 6.40 ( http://nmap.org ) at 2016-11-19 10:42 DST route_dst_netlink: cannot bind AF_NETLINK socket: Invalid argument

  1. Expected Behavior

Should perform scan of local network.

  1. Strace of the failing command

https://gist.github.com/rtfmoz/bb41c6e0148d223a3e3bc310217e05ba

rtfmoz avatar Nov 18 '16 23:11 rtfmoz

@JasonLinMS as FYI @rtfmoz - Thanks for the trace. From the trace it looks like it relies on the NETLINK_ROUTE\RTM_GETROUTE message with the given , which we haven't yet implemented. I have opened a bug to track this internally.

sunilmut avatar Nov 19 '16 00:11 sunilmut

I have just installed the latest preview build of Windows 10.0.14971 which has Ubuntu 16.04 Xenial. It appears nmap on this is version 7.01 and suffers similar issues.

  1. Title

nmap fails to open socket.

  1. Brief description

AF_NETLINK operation not supported: route_dst_netlink

  1. Windows version / build number

Microsoft Windows [Version 10.0.14971]

  1. Steps required to reproduce

apt-get install nmap nmap -sn 192.168.0.*

  1. Copy of the terminal output

root@DESKTOP-5UFF8C5:~# nmap -sn 192.168.0.*

Starting Nmap 7.01 ( https://nmap.org ) at 2016-11-22 20:57 DST route_dst_netlink: cannot sendmsg: Operation not supported

  1. Expected Behavior

Should perform scan of local network.

  1. Strace of the failing command

https://gist.github.com/anonymous/9445b29cfce828a2eed7df96f2d970fb

rtfmoz avatar Nov 22 '16 09:11 rtfmoz

For tcpdump/wireshark/some nmap functions, upvote https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/17817685-support-af-packet-address-family-tcpdump-wireshar

gpotter2 avatar Jan 23 '17 18:01 gpotter2

i just installed creators update and did a clean install to WSL and nmap is still not working

~$ sudo nmap -sP 192.168.1.0/24

Starting Nmap 7.01 ( https://nmap.org ) at 2017-04-12 15:33 STD
dnet: Failed to open device wifi0
QUITTING!

lab1005 avatar Apr 12 '17 13:04 lab1005

@lab1005 That's partially because AF_PACKET family is not supported yet. You may upvote this to speed up the process...

Edited: official Uservoice issue https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/17817685-support-af-packet-address-family-tcpdump-wireshar

gpotter2 avatar Apr 12 '17 15:04 gpotter2

Any news about the nmap feature ?

mothinx avatar Aug 15 '17 23:08 mothinx

There are no interesting updates at this moment. As mentioned previously, this requires support for AF_PACKET on Windows. Some dependencies that are outside of WSL. We are working with the right set of teams to track these dependencies. But, this is not planned yet. Although, we understand the interest here and appreciate the feedback (which helps us make a case for this).

sunilmut avatar Oct 26 '17 18:10 sunilmut

You may upvote this to speed up the process...

@gpotter2 The 'this' link just goes to a Forbidden page?

OvermindDL1 avatar Oct 26 '17 19:10 OvermindDL1

One would think that Wireshark, Tshark and Nmap could be considered default requirements in an enterprise environment?

LFBernardo avatar Oct 30 '17 05:10 LFBernardo

nmap, wireshark and many other tools that use AF_PACKET are very used. The lack of this feature is really blocking.

shura35 avatar Nov 23 '17 12:11 shura35

An acceptable workaround is just to put the Windows version of nmap in your path somewhere.

jdgregson avatar Nov 30 '17 04:11 jdgregson

This is already what I do for nmap, but many other tools and business or personal developments are not available in Windows version. The lack of this feature is really blocking.

shura35 avatar Nov 30 '17 11:11 shura35

What is your development use case and we can try to help you with a work-around while you wait for AF_PACKET support. "Blocking" is a term that means there is none (for example say lack of inotify support back in the day).

If you explain a novel scenario that may (no guarantees) help MSFT to prioritise when they review their backlog. The User Voice has six pages of pointless +1s (why folks do that on a page with a vote button I will never understand) but is absent a single: "In my development workflow I do <insert your scenario>, but I am unable to to <thing> because there is no AF_PACKET support in WSL". In this context <thing> is a development goal you are trying to achieve, not "run native Linux wireshark" (which is a means not a goal). If you have a widespread compelling use-case that kind of stuff does end up getting attention, measured against many other competing scenarios that also need attention.

therealkenc avatar Nov 30 '17 16:11 therealkenc

Well I can answer that one easily, I use tcpdump, tshark nmap in my day to day tasks. Having this on one machine instead of having a separate machine will save me a ton of time as well as having to lug more than one machine around. I will try what was stated above to install windows binaries and stick it in the path. Not sure if it will work or not.

LFBernardo avatar Nov 30 '17 16:11 LFBernardo

You can try the Windows binaries; I have had a fairly good experience with tshark on Windows. But worst case here don't go lugging around another physical machine unless you have unrelated reasons to do so. Wireshark in VirtualBox (which supports bridged promiscuous mode) works surprisingly well. For the time being, WSL's focus is on development related scenarios, not enterprise scenarios (for some definition of either category). A VM might be a better fit for you for now, and there's nothing wrong with that. Bonne chance.

therealkenc avatar Nov 30 '17 16:11 therealkenc

I have come to realise this. But in the bigger picture of things it's just simpler to wipe my windows and install Kali with windows running as a vm. Just thought it would have made life simpler with default OS and bash implemented. Oh well, Cest la vie.

LFBernardo avatar Nov 30 '17 18:11 LFBernardo

@therealkenc ty for the interesting remark: "WSL's focus is on development related scenarios, not enterprise scenarios (for some definition of either category)." TL;DR: Is there a blog post that describes this distinction in more detail, perhaps with more compelling use cases than https://msdn.microsoft.com/en-us/commandline/wsl/faq ?

Detailed comments, questions; I've been really excited by WSL and am trying to figure out for myself how /when I can use it. (I have a windows machine I love, but my current shop is mac based. ) I already think Powershell's Bash sugar support is terrific.

Perhaps this is really a marketing / product placement question that apparently many of us share. If so , maybe you all can clarify and show us the win(s).

The idea of WSL focusing on dev not enterprise scenarios confuses me.

  • For pure 'development,' ie writing code, I can do that almost anywhere with a text editor nowadays.
  • For certain coding, like simple bash scripts, windows powershell already provides some interop with linux - no WSL required, right? (or maybe it is/was?)
  • The FAQ for WSL, above, references MS's desire to support dev on ruby stacks that use long filepaths and such. Are those scenarios satisfactorily solved without networking, ie this ticket #1349 , fully supported? [1]
  • The WSL FAQ states an intent not to support server tasks and references other tools like Docker, but aren't alot of the complex ruby programs related to server usage? In fact, isn't it exactly Linux's 'free enterprise services' such as nmap, tcpdump, etc that got it into the market(s) (of RubyRails hosting for ex.)? As one anonymous poster wrote on the UserVoice, above, November 24, 2017 17:43 "we use linux because we are nerds; dev nerds, infra nerds, network nerds, or all of the above. " That rings true to me, and I'm wondering what dev projects I should/not think of with WSL.

Your complaint is well taken that Uservoice is lacking and ' absent a single: "In my development workflow I do , but I am unable to to because there is no AF_PACKET support in WSL". In this context is a development goal you are trying to achieve, not "run native Linux wireshark" (which is a means not a goal). '

I checked and found the most substantial comments were:

  • James commented July 30, 2017 22:54 Pls support, don't want to have to run a VM to get these tools to work, kinda meant to be able to replace the need to have a VM to get a real Linux CLI... => this is the same concern as on this issue ticket, ie we thought WSL would replace needing also to have a VM. But here James doesn't say why he wants to use it.
  • Anonymous March 19, 2017 12:12 Yes, +1. Every few months I try out the latest Linux subsystem on my wifes laptop to see if it can replace my MacBook for mobile development. As of now, it can't. I develop apps that use libpcap and/or netmap on Linux. The great thing is, they compile and I can read from pcap files files. Its just when I want to do a "live " test it fails.

Some thoughts as an observer about the use case are above, but also once there are daemons [2], how about this scenario;

  • I start my dev ruby rails server on my linux box, it runs in background after I hide wsl
  • now periodically I want to check its network performance.
  • would I not need nmap etc on WSL to do so?
  • Similarly, or for the same scenario, if the website/process is a dockerized container , wouldn't I need these tools?

Since the FAQ seems to say I should never do this, I want the FAQ to specify more of the advantages of MS's proposed division of labor.

thank you for the project! I am definitely speaking as an amateur / explorer here so all/any resources appreciated. Anne

Notes [1] NB: Right now 2017-12-06 those scenarios might have some trouble as well , iff the files-intermittently-missing is not fixed completely by the latest update. I am not sure if it is - maybe no per #2712 but maybe yes per #2448 .

[2] Server work likely wouldn't make sense before getting background processes going, https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13653522-consider-enabling-cron-jobs-daemons-and-backgroun

//edit; add TLDR , reorg

AnneTheAgile avatar Dec 06 '17 12:12 AnneTheAgile

To second what @AnneTheAgile said, most developers are developing for the purposes of an enterprise solution or at least something that can be easily made to suit an enterprise environment as a company gets larger. There are some 'enterprise' specific scenarios that don't involve development but all development scenarios revolve around enterprise solutions and services (for those who have an enterprise environment of course). A proper project creating or modifying something involves not just the planning and development but also the testing of the feature just as MS is doing with the Insider Preview builds. There is no difference between what MS does and what other companies do (that follow industry standards/best practices anyways). Part of testing is obviously security testing and that means needing to check networking components of a software that utilizes network connections and/or possibly makes a change to the OS. Use of NMAP, Wireshark, etc. would then be required for use and is often needed by Linux developers/testers. The whole purpose of WSL is to bring Linux and Windows developers together to harness the technologies and abilities of both to work smarter not harder. Therefore the support of AF_Packet is absolutely essential if MS wants to attract more Linux developers/testers over to Windows.

WSLUser avatar Dec 06 '17 14:12 WSLUser