PHP code example of palepurple / nmap

1. Go to this page and download the library: Download palepurple/nmap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

palepurple / nmap example snippets


$hosts = Nmap::create()->scan([ 'example.com' ]);

$ports = $hosts[0]->getOpenPorts();

$parser = new XmlOutputParser($xmlFile);
$parser->validate();
 php
$nmap = new Nmap();

$nmap->scan([ 'example.com' ], [ 21, 22, 80 ]);
 php
$nmap
    ->enableVerbose()
    ->scan([ 'example.com' ]);
 php
$nmap
    ->disablePortScan()
    ->scan([ 'example.com' ]);
 php
$nmap
    ->disableReverseDNS()
    ->scan([ 'example.com' ]);
 php
$nmap
    ->setTimeout(120)
    ->scan([ 'example.com' ]);
 php
$hosts = $nmap
    ->setTimeout(120)
    ->scan([ 'example.com' ], [ 443 ]);
    
$hosts[0]->setScripts(['ssl-heartbleed']);
$ports = $hosts[0]->getOpenPorts();

$ports[0]->getScripts();
 php
Nmap::parseOutput($xmlFile);
 php
$parser = new XmlOutputParser($xmlFile);
$parser->parse();