Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional flags to nmap.py #5566

Merged
merged 14 commits into from
Nov 17, 2022
Merged
2 changes: 2 additions & 0 deletions changelogs/fragments/5566-additional-flags-nmap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes
dstuart marked this conversation as resolved.
Show resolved Hide resolved
- 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
dstuart marked this conversation as resolved.
Show resolved Hide resolved
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
dstuart marked this conversation as resolved.
Show resolved Hide resolved
version_added: 6.1.0
dns_resolve:
description: Whether to always (C(true)) or never (C(false)) do DNS resolution.
type: boolean
default: false
felixfontein marked this conversation as resolved.
Show resolved Hide resolved
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