PHP code example of kazemisoroush / ntm

1. Go to this page and download the library: Download kazemisoroush/ntm 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/ */

    

kazemisoroush / ntm example snippets


'providers' => [
    ...
    Ntcm\Ntm\NtmServiceProvider::class
    ...
]

use Ntcm\Ntm\Ntm;

$targets = 'scanme.nmap.org';

Ntm::create()
   ->setTimeout(60) // in seconds...
   ->scan($targets)
   ->parseOutputFile();

$targets = ['scanme.nmap.org', '192.168.101.0/24'];

Ntm::create()
   ->setTimeout(60)
   ->scan($targets)
   ->parseOutputFile();

$targets = ['scanme.nmap.org', '192.168.101.0/24'];

Ntm::create()
   ->setTimeout(60)
   ->scan($targets)
   ->setTraceroute(true)
   ->setReverseDns(true)
   ->setPortScan(true)
   ->setOsDetection(true)
   ->setServiceInfo(true)
   ->setVerbose(false)
   ->setTreatHostsAsOnline(true)
   ->parseOutputFile();

$targets = ['scanme.nmap.org', '192.168.101.0/24'];

// call scan artisan command...
Artisan::call('scan', [
  'targets'     => $targets,
  '--os'        => true, // to enable operating system scan...
  '--ports'     => true, // to enable well-known TCP ports...
  '--scheduled' => '0 1,13 * * * *' // you can use this to schedule the scan...
]);


    /**
     * Define the application's command schedule.
     *
     * @param Schedule $schedule
     *
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        foreach(Target::scheduled()->get() as $target) {
            $schedule
                ->command('scan', [
                    'ranges'  => $target->range,
                    '--os'    => $target->ports,
                    '--ports' => $target->os,
                ])
                ->cron($target->scheduled);
        }
    }

$ php artisan vendor:publish

$ php artisan migrate