This project is maintained fork of the original project: https://github.com/willdurand/nmap
Nmap is a PHP wrapper for Nmap, a free security scanner for network exploration.
$hosts = Nmap::create()->scan([ 'example.com' ]);
$ports = $hosts[0]->getOpenPorts();
You can specify the ports you want to scan:
$nmap = new Nmap();
$nmap->scan([ 'example.com' ], [ 21, 22, 80 ]);
OS detection and Service Info are disabled by default, if you want to
enable them, use the enableOsDetection()
and/or enableServiceInfo()
methods:
$nmap
->enableOsDetection()
->scan([ 'example.com' ]);
$nmap
->enableServiceInfo()
->scan([ 'example.com' ]);
// Fluent interface!
$nmap
->enableOsDetection()
->enableServiceInfo()
->scan([ 'example.com' ]);
Turn the verbose mode by using the enableVerbose()
method:
$nmap
->enableVerbose()
->scan([ 'example.com' ]);
For some reasons, you might want to disable port scan, that is why nmap
provides a disablePortScan()
method:
$nmap
->disablePortScan()
->scan([ 'example.com' ]);
You can also disable the reverse DNS resolution with disableReverseDNS()
:
$nmap
->disableReverseDNS()
->scan([ 'example.com' ]);
You can define the process timeout (default to 60 seconds) with setTimeout()
:
$nmap
->setTimeout(120)
->scan([ 'example.com' ]);
Nmap::parseOutput($xmlFile);
The recommended way to install nmap is through Composer:
{
"require": {
"palepurple/nmap": "^2.0"
}
}
nmap is released under the MIT License. See the bundled LICENSE file for details.