feat(server): DNS Reverse Lookup for IP Address'

!13 closes #4
This commit is contained in:
2024-02-25 18:02:13 +09:30
parent 93d40b7432
commit f89212b1cb
4 changed files with 74 additions and 11 deletions

View File

@ -82,3 +82,4 @@
api_address: addresses
api_subnets: subnets
api_scanagents: tools/scanagents
api_nameservers: tools/nameservers

View File

@ -1,12 +1,5 @@
---
- name: Scan subnet - {{ subnet.address }}
ansible.builtin.command:
cmd: nmap -sn "{{ subnet.address }}" -oX -
become: true
register: nmap_scan
- name: Get subnets Address'
ansible.builtin.include_tasks:
file: tasks/api_call.yaml
@ -17,15 +10,72 @@
api_query_string: "filter_by=subnetId&filter_value={{ subnet.id }}"
- name: Load Subnet - {{ subnet.address }}
- name: Register Subnet API Call
ansible.builtin.set_fact:
cached_subnet: "{{ lookup('file', cache_filepath) }}"
cacheable: false
subnet_api_call: "{{ api_call }}"
subnet_cache_filepath: "{{ cache_filepath }}"
api_call: ''
- name: Get subnet Name Servers
ansible.builtin.include_tasks:
file: tasks/api_call.yaml
vars:
api_client_name: "{{ nofusscomputing_phpipam_scan_agent.client_name }}"
api_token: "{{ nofusscomputing_phpipam_scan_agent.client_token }}"
api_path: "{{ api_nameservers }}"
api_query_string: "filter_by=id&filter_value={{ subnet.nameserverId }}"
when: >
subnet.nameserverId is defined
and
subnet.resolveDNS | int == 1
- name: Load Nameservers - {{ subnet.address }}
ansible.builtin.set_fact:
subnet_name_servers: "{{ lookup('file', cache_filepath) }}"
cacheable: false
no_log: true
when: >
subnet.nameserverId is defined
and
subnet.resolveDNS | int == 1
and
api_call.status | default(0) | int != 404
- name: Scan subnet - {{ subnet.address }}
ansible.builtin.command:
cmd: >
nmap -sn "{{ subnet.address }}" {% if
subnet_name_servers is defined
and
subnet.resolveDNS | int == 1
-%}
--dns-servers {% for nameserver in subnet_name_servers -%}
{% for name_server in nameserver.namesrv1 | split(';') %}
{{ name_server }},
{%- endfor -%}
{%- endfor -%}
{%- elif subnet.resolveDNS | int == 1 -%}
--system-dns
{%- else -%}
-n
{%- endif %} -oX -
become: true
register: nmap_scan
- name: Load Subnet - {{ subnet.address }}
ansible.builtin.set_fact:
cached_subnet: "{{ lookup('file', subnet_cache_filepath) }}"
cacheable: false
no_log: true
when: >
subnet_api_call.status | default(0) | int != 404
- name: Process Scan Results - {{ subnet.address }}
ansible.builtin.set_fact:
subnet_scan_results: |-

View File

@ -23,7 +23,9 @@
ansible.builtin.set_fact:
nfc_c_scan_agent_subnets: "{{ nfc_c_scan_agent_subnets + [{
'id': network.id,
'address': network.subnet + '/' + network.mask
'address': network.subnet + '/' + network.mask,
'nameserverId': network.nameserverId,
'resolveDNS': network.resolveDNS
}] }}"
loop: "{{ lookup('file', cache_filepath) | default ([]) }}"
loop_control: