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

⭐️ nmap provider #4168

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

⭐️ nmap provider #4168

wants to merge 8 commits into from

Conversation

chris-rock
Copy link
Member

@chris-rock chris-rock commented Jun 2, 2024

nmap provider

Nmap, short for Network Mapper, is a powerful and versatile open-source tool used for network discovery and security auditing. This tool is widely utilized by network administrators, security professionals, and penetration testers to map out network structures, discover hosts, identify services, and detect vulnerabilities.

The nmap provider maps primary objects and attributes that nmap uses to store and manage information about scanned targets, discovered hosts, and their associated ports and services.

Pre-requisites

This provider requires the nmap tool to be installed on your system. You can download and install nmap from the official website.

Get Started

cnquery shell nmap

Example

Scan active IP address in network

nmap.target("192.168.178.0/24").hosts { name ports { * }  }
nmap.target.hosts: [
  0: {
    ports: [
      0: {
        service: "http"
        version: ""
        method: "probed"
        state: "open"
        protocol: "tcp"
        port: 443
        product: "FRITZ!Box http config"
      }
      1: {
        service: "sip"
        version: ""
        method: "probed"
        state: "open"
        protocol: "tcp"
        port: 5060
        product: "AVM FRITZ!OS SIP"
      }
    ]
    name: "192.168.178.1"
  }
  1: {
    ports: [
      0: {
        service: "rtsp"
        version: "770.8.1"
        method: "probed"
        state: "open"
        protocol: "tcp"
        port: 5000
        product: "AirTunes rtspd"
      }
      1: {
        service: "rtsp"
        version: "770.8.1"
        method: "probed"
        state: "open"
        protocol: "tcp"
        port: 7000
        product: "AirTunes rtspd"
      }
    ]
    name: "192.168.178.25"
  }
]

Host scan with specific ip

nmap.target(target: "192.168.178.25").hosts { ports }
nmap.target.hosts: [
  0: {
    ports: [
      0: nmap.port port=5000 service="rtsp"
      1: nmap.port port=7000 service="rtsp"
    ]
  }
]

Advanced Usage

Discover all exposed hosts on a network.

cnquery shell nmap --networks "192.168.0.0/20" --discover hosts

Connect to a specific IP address and display all open ports.

cnquery shell nmap host 8.8.8.8

TODO

  • implement nmap discovery
  • expose nmap version to the nmap resource
  • implement nmap host discovery
  • ensure discovery returns multiple nmap host

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Jun 2, 2024

Test Results

3 115 tests  +1   3 113 ✅ ±0   1m 36s ⏱️ +14s
  377 suites +6       1 💤 ±0 
   29 files   +1       1 ❌ +1 

For more details on these failures, see this check.

Results for commit 6b9b283. ± Comparison against base commit 5788fb4.

♻️ This comment has been updated with latest results.

Makefile Outdated Show resolved Hide resolved
providers/defaults.go Outdated Show resolved Hide resolved
providers/nmap/README.md Outdated Show resolved Hide resolved
providers/nmap/README.md Outdated Show resolved Hide resolved

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Oct 4, 2024

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

Unrecognized words (9)

kqueue
libdnet
liblua
libpcap
libpcre
libssh
libz
nsock
openssl

Previously acknowledged words that are now absent gibibytes SSPR 🫥
To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the git@github.com:mondoohq/cnquery.git repository
on the chris-rock/nmap branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/mondoohq/cnquery/actions/runs/11179647898/attempts/1'
Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary

This includes both expected items (108) from .github/actions/spelling/expect.txt and unrecognized words (9)

Dictionary Entries Covers Uniquely
cspell:node/dict/node.txt 891 3 2
cspell:public-licenses/src/generated/public-licenses.txt 181 1 1
cspell:fullstack/dict/fullstack.txt 419 1
cspell:php/dict/php.txt 1689 1
cspell:python/src/python/python-lib.txt 2417 1

Consider adding them (in .github/workflows/spell-check.yaml) for uses: check-spelling/check-spelling@v0.0.22 in its with:

      with:
        extra_dictionaries:
          cspell:node/dict/node.txt
          cspell:public-licenses/src/generated/public-licenses.txt
          cspell:fullstack/dict/fullstack.txt
          cspell:php/dict/php.txt
          cspell:python/src/python/python-lib.txt

To stop checking additional dictionaries, add (in .github/workflows/spell-check.yaml) for uses: check-spelling/check-spelling@v0.0.22 in its with:

check_extra_dictionaries: ''
If the flagged items are false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants