Skip to content

Commit

Permalink
Add additional flags to nmap.py (#5566) (#5576)
Browse files Browse the repository at this point in the history
* Adding extra flag options for NMAP scaning udp_scan, icmp_timestamp and dns_resolve

* Update nmap.py

* Update plugins/inventory/nmap.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Updates as per felixfontein  suggestions

* Updates as per felixfontein  suggestions

* Update plugins/inventory/nmap.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/inventory/nmap.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update nmap.py

* Update changelogs/fragments/5566-additional-flags-nmap.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update changelogs/fragments/5566-additional-flags-nmap.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update 5566-additional-flags-nmap.yml

* Update nmap.py

Co-authored-by: Axis12 <3225945+axistwelve@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 52c2849)

Co-authored-by: David Stuart <dave@axistwelve.com>
  • Loading branch information
patchback[bot] and dstuart authored Nov 23, 2022
1 parent 17447d2 commit 5ebd980
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/5566-additional-flags-nmap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
minor_changes:
- nmap inventory plugin - add new options ``udp_scan``, ``icmp_timestamp``, and ``dns_resolve`` for different types of scans (https://github.com/ansible-collections/community.general/pull/5566).

28 changes: 28 additions & 0 deletions plugins/inventory/nmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@
description: use IPv6 type addresses
type: boolean
default: true
udp_scan:
description:
- Scan via UDP.
- Depending on your system you might need I(sudo=true) for this to work.
type: boolean
default: false
version_added: 6.1.0
icmp_timestamp:
description:
- Scan via ICMP Timestamp (C(-PP)).
- Depending on your system you might need I(sudo=true) for this to work.
type: boolean
default: false
version_added: 6.1.0
dns_resolve:
description: Whether to always (C(true)) or never (C(false)) do DNS resolution.
type: boolean
default: false
version_added: 6.1.0
notes:
- At least one of ipv4 or ipv6 is required to be True, both can be True, but they cannot both be False.
- 'TODO: add OS fingerprinting'
Expand Down Expand Up @@ -166,6 +185,15 @@ def parse(self, inventory, loader, path, cache=True):
cmd.append('--exclude')
cmd.append(','.join(self._options['exclude']))

if self._options['dns_resolve']:
cmd.append('-n')

if self._options['udp_scan']:
cmd.append('-sU')

if self._options['icmp_timestamp']:
cmd.append('-PP')

cmd.append(self._options['address'])
try:
# execute
Expand Down

0 comments on commit 5ebd980

Please sign in to comment.