harryhorton / node-nmap

NPM package for interfacing with local NMAP installation
MIT License
67 stars 26 forks source link

Service version #25

Closed bheru27 closed 7 years ago

bheru27 commented 7 years ago

Hi, I was wondering if you could include the option to get the version of the services running, I dont know if it would be much trouble, but this is what the library needs, would be really awesome to include that since im working in a big project where we are using it.

Or if it is already there and im not seeing it, please guide me, thanks.

harryhorton commented 7 years ago

There isn't a way in the current version to get the version of NMAP.

To add this as a feature, I would need to add a new function that runs nmap -v and uses regex to grab the version and return it as a string. Would that work for you?

bheru27 commented 7 years ago

no no, i mean, when yo do an nmap scan, you get somethng like PORT STATE SERVICE VERSION 25/tcp filtered smtp 80/tcp open http nginx 1.6.2 110/tcp open pop3 Dovecot pop3d 143/tcp open imap Dovecot imapd 443/tcp open ssl/http nginx 465/tcp open ssl/smtp Postfix smtpd 587/tcp open smtp Postfix smtpd 993/tcp open ssl/imap Dovecot imapd 995/tcp open ssl/pop3 Dovecot pop3d

but the library only shows 'http', 'pop3'... would we cool if we could get also the "dovecot", "nginx" ... part :)

Thanks for the quick reply!

harryhorton commented 7 years ago

If the information is output by NMAP, then I should be able to grab it an include it in the output. I'll try to find some time to look into this within the next week.

harryhorton commented 7 years ago

Just to give you an update, I'm working on this. However, I'm doing a full Typescript to ES6 conversion first since my old code for this module isn't very maintainable.

cojack commented 7 years ago

@Johnhhorton any news?

harryhorton commented 7 years ago

@cojack Finished converting to ES6 from TypeScript on a separate branch tonight. I still need to add this requested feature and update the documentation.

@bheru27 Checking out the JSON I'm getting from NMAP with OsAndPortScan, I get this kind of data:

 "$": {
        "protocol": "tcp",
        "portid": "10001"
    },
    "state": [
        {
            "$": {
                "state": "open",
                "reason": "syn-ack",
                "reason_ttl": "64"
            }
        }
    ],
    "service": [
        {
            "$": {
                "name": "scp-config",
                "method": "table",
                "conf": "3"
            }
        }
    ]
}

What NMAP flags are you using for your scans in NMAP to get the additional output? I need to be able to reproduce your scan to get the desired keys to make available in the final output. If I can reproduce the data, I can have the new version out that night.

There will be breaking changes in this at the require level. I was using pretty poor practices before, so you'll just need to change how you're requiring it (I'll include the changes in the documentation). The code base still isn't great, but it's much more manageable for adding new features.

Thanks for being patient guys, work and home live have been busy this past month.

harryhorton commented 7 years ago

Got it: -sV I'll have the new version up soon.

harryhorton commented 7 years ago

Since -sV will probe for ports and attempt to gather additional information. use

const nmap = require('./index');

let scan = new nmap.NmapScan("google.com", "-sV");

node-nmap will attempt to gather additional options returned from the port/service if they exist.

                "port": 443,
                "protocol": "tcp",
                "service": "http",
                "tunnel": "ssl",
                "method": "probed",
                "product": "ssl"
            }

the key product will contain the information you're looking for. Note: if a value isn't returned, the key will not be set.

New version has been published. @cojack @bheru27

cojack commented 7 years ago

@Johnhhorton thanks :)