2

How to enable the equivalent of -PN (or -P0) command line option for nmap when using the python-nmap?

>>> import nmap
>>> nm = nmap.PortScanner()
>>> nm.scan('127.0.0.1', '22-443')
>>> nm.command_line()
'nmap -oX - -p 22-443 -sV 127.0.0.1'

The goals is the have -PN (or -P0) in the above... how can I obtain this?

Zabuzzman
  • 194
  • 1
  • 9
  • Please note that `-P0` has not been the preferred name for this option since 2007 (version 4.22SOC8). Please use `-Pn`, as this reduces confusion with `-PO` (IP Protocol host discovery). – bonsaiviking Dec 24 '14 at 13:18
  • OK, you're right and I've modified the question as such. I'm a legacy user I guess ;-) – Zabuzzman Dec 24 '14 at 14:36
  • No problem. We don't have any reason to stop supporting `-P0` as an alias, so it's not really critical, but there is nice symmetry between `-Pn`, `-sn`, and `-n` now. (`-PN` is also a deprecated form, and `-sn` used to be `-sP`). – bonsaiviking Dec 24 '14 at 18:49

1 Answers1

2

Explicitly pass the option using arguments argument:

>>> import nmap
>>> nm = nmap.PortScanner()
>>> nm.scan('127.0.0.1', '22-443', arguments='-P0')  # <----
{'nmap': ...}
>>> nm.command_line()
u'nmap -oX - -p 22-443 -P0 127.0.0.1'
falsetru
  • 357,413
  • 63
  • 732
  • 636