nmap 是一个用于网络探测的免费安全扫描器 Nmap 的 PHP 封装。这是(主要是)willdurand/nmap 的分支,增加了 PHP 7 和 vimeo/psalm 静态分析的改进。

维护者

详细信息

github.com/DavidGoodwin/nmap

来源

安装1,223

依赖项: 0

建议者: 0

安全性: 0

星标: 12

关注者: 2

分支: 54

3.0.2 2023-12-04 15:02 UTC

This package is auto-updated.

Last update: 2024-09-04 16:26:39 UTC


README

本项目是原始项目的维护分支:[https://github.com/willdurand/nmap](https://github.com/willdurand/nmap)

Nmap

Nmap 是一个用于网络探测的免费安全扫描器 Nmap 的 PHP 封装。

PHP Build

开始扫描

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

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

您可以指定要扫描的端口

$nmap = new Nmap();

$nmap->scan([ 'example.com' ], [ 21, 22, 80 ]);

操作系统检测服务信息 默认禁用,如果需要启用,请使用 enableOsDetection() 和/或 enableServiceInfo() 方法

$nmap
    ->enableOsDetection()
    ->scan([ 'example.com' ]);

$nmap
    ->enableServiceInfo()
    ->scan([ 'example.com' ]);

// Fluent interface!
$nmap
    ->enableOsDetection()
    ->enableServiceInfo()
    ->scan([ 'example.com' ]);

使用 enableVerbose() 方法开启 详细模式

$nmap
    ->enableVerbose()
    ->scan([ 'example.com' ]);

由于某些原因,您可能想要禁用端口扫描,这就是为什么 nmap 提供了 disablePortScan() 方法

$nmap
    ->disablePortScan()
    ->scan([ 'example.com' ]);

您还可以通过 disableReverseDNS() 禁用反向 DNS 解析

$nmap
    ->disableReverseDNS()
    ->scan([ 'example.com' ]);

您可以使用 setTimeout() 定义进程超时时间(默认为 60 秒)

$nmap
    ->setTimeout(120)
    ->scan([ 'example.com' ]);

您可以使用 setScripts() 运行特定脚本,并通过 getScripts() 获取结果

$hosts = $nmap
    ->setTimeout(120)
    ->scan([ 'example.com' ], [ 443 ]);
    
$hosts[0]->setScripts(['ssl-heartbleed']);
$ports = $hosts[0]->getOpenPorts();

$ports[0]->getScripts();

Nmap XML 输出

解析现有输出

Nmap::parseOutput($xmlFile);

$parser = new XmlOutputParser($xmlFile);
$parser->parse();

使用 Nmap DTD 验证输出文件。可以将自定义 DTD 路径传递给 validate 函数。

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

安装

推荐通过 Composer 安装 nmap

对于 PHP 8.0 及以上版本

{
    "require": {
        "palepurple/nmap": "^3.0"
    }
}

对于旧版本的 PHP,尝试 ^2.0;请参阅 https://github.com/DavidGoodwin/nmap/releases/tag/2.0.1

许可证

nmap 在 MIT 许可证下发布。有关详细信息,请参阅捆绑的 LICENSE 文件。