naabu 用 go 编写的快速端口扫描器

Naabu 是一款用 Go 编写的端口扫描工具,可让您快速可靠地枚举主机的有效端口。这是一个非常简单的工具,可对主机/主机列表进行快速 SYN/CONNECT/UDP 扫描,并列出返回回复的所有端口。

特征

纳布

  • 快速而简单的基于SYN/CONNECT/UDP探测的扫描
  • 针对易用性和轻量级资源进行了优化
  • DNS端口扫描
  • DNS 端口扫描的自动 IP 重复数据删除
  • IPv4/IPv6端口扫描(实验
  • 使用 Shodan Internetdb进行被动端口枚举
  • 主机发现扫描(实验性
  • NMAP集成用于服务发现
  • 多输入支持-STDIN/HOST/IP/CIDR/ASN
  • 支持多种输出格式 – JSON/TXT/STDOUT

用法

naabu -h

这将显示该工具的帮助。以下是它支持的所有开关。

Usage:
  ./naabu [flags]

INPUT:
   -host string[]              hosts to scan ports for (comma-separated)
   -list, -l string            list of hosts to scan ports (file)
   -exclude-hosts, -eh string  hosts to exclude from the scan (comma-separated)
   -exclude-file, -ef string   list of hosts to exclude from scan (file)

PORT:
   -port, -p string            ports to scan (80,443, 100-200)
   -top-ports, -tp string      top ports to scan (default 100) [full,100,1000]
   -exclude-ports, -ep string  ports to exclude from scan (comma-separated)
   -ports-file, -pf string     list of ports to scan (file)
   -port-threshold, -pts int   port threshold to skip port scan for the host
   -exclude-cdn, -ec           skip full port scans for CDN/WAF (only scan for port 80,443)
   -display-cdn, -cdn          display cdn in use

RATE-LIMIT:
   -c int     general internal worker threads (default 25)
   -rate int  packets to send per second (default 1000)

UPDATE:
   -up, -update                 update naabu to latest version
   -duc, -disable-update-check  disable automatic naabu update check

OUTPUT:
   -o, -output string  file to write output to (optional)
   -j, -json           write output in JSON lines format
   -csv                write output in csv format

CONFIGURATION:
   -config string                   path to the naabu configuration file (default $HOME/.config/naabu/config.yaml)
   -scan-all-ips, -sa               scan all the IP's associated with DNS record
   -ip-version, -iv string[]        ip version to scan of hostname (4,6) - (default 4) (default ["4"])
   -scan-type, -s string            type of port scan (SYN/CONNECT) (default "s")
   -source-ip string                source ip and port (x.x.x.x:yyy)
   -interface-list, -il             list available interfaces and public ip
   -interface, -i string            network Interface to use for port scan
   -nmap                            invoke nmap scan on targets (nmap must be installed) - Deprecated
   -nmap-cli string                 nmap command to run on found results (example: -nmap-cli 'nmap -sV')
   -r string                        list of custom resolver dns resolution (comma separated or from file)
   -proxy string                    socks5 proxy (ip[:port] / fqdn[:port]
   -proxy-auth string               socks5 proxy authentication (username:password)
   -resume                          resume scan using resume.cfg
   -stream                          stream mode (disables resume, nmap, verify, retries, shuffling, etc)
   -passive                         display passive open ports using shodan internetdb api
   -irt, -input-read-timeout value  timeout on input read (default 3m0s)
   -no-stdin                        Disable Stdin processing

HOST-DISCOVERY:
   -sn, -host-discovery           Perform Only Host Discovery
   -Pn, -skip-host-discovery      Skip Host discovery
   -ps, -probe-tcp-syn string[]   TCP SYN Ping (host discovery needs to be enabled)
   -pa, -probe-tcp-ack string[]   TCP ACK Ping (host discovery needs to be enabled)
   -pe, -probe-icmp-echo          ICMP echo request Ping (host discovery needs to be enabled)
   -pp, -probe-icmp-timestamp     ICMP timestamp request Ping (host discovery needs to be enabled)
   -pm, -probe-icmp-address-mask  ICMP address mask request Ping (host discovery needs to be enabled)
   -arp, -arp-ping                ARP ping (host discovery needs to be enabled)
   -nd, -nd-ping                  IPv6 Neighbor Discovery (host discovery needs to be enabled)
   -rev-ptr                       Reverse PTR lookup for input ips

OPTIMIZATION:
   -retries int       number of retries for the port scan (default 3)
   -timeout int       millisecond to wait before timing out (default 1000)
   -warm-up-time int  time in seconds between scan phases (default 2)
   -ping              ping probes for verification of host
   -verify            validate the ports again with TCP verification

DEBUG:
   -health-check, -hc        run diagnostic check up
   -debug                    display debugging information
   -verbose, -v              display verbose output
   -no-color, -nc            disable colors in CLI output
   -silent                   display only results in output
   -version                  display version of naabu
   -stats                    display stats of the running scan (deprecated)
   -si, -stats-interval int  number of seconds to wait between showing a statistics update (deprecated) (default 5)
   -mp, -metrics-port int    port to expose naabu metrics on (default 63636)

安装说明

下载可运行的二进制文件docker或者使用 GO 安装

先决条件

注意:在安装naabu之前,请确保安装了libpcap用于数据包捕获的库。

在Linux上安装 libcap :,sudo apt install -y libpcap-devMac上安装:brew install libpcap

安装 Naabu

go install -v github.com/projectdiscovery/naabu/v2/cmd/naabu@latest

运行Naabu

要在目标上运行该工具,只需使用以下命令。

naabu -host hackerone.com

这将针对 hackerone.com 运行该工具。您可以使用此命令传递许多配置选项。详细开关-v可用于显示详细信息。

naabu -host hackerone.com

                  __
  ___  ___  ___ _/ /  __ __
 / _ \/ _ \/ _ \/ _ \/ // /
/_//_/\_,_/\_,_/_.__/\_,_/ v2.0.3

    projectdiscovery.io

[WRN] Use with caution. You are responsible for your actions
[WRN] Developers assume no liability and are not responsible for any misuse or damage.
[INF] Running SYN scan with root privileges
[INF] Found 4 ports on host hackerone.com (104.16.100.52)

hackerone.com:80
hackerone.com:443
hackerone.com:8443
hackerone.com:8080

可以通过参数指定主机上要扫描的端口-p(udp 端口​​必须表示为u:port)。它采用 nmap 格式的端口并对其进行枚举。

naabu -p 80,443,21-23,u:53 -host hackerone.com

默认情况下,Naabu 会检查 nmap 的Top 100端口。它支持以下内置端口列表 –

旗帜描述
-top-ports 100扫描 nmap 前100 个端口
-top-ports 1000扫描 nmap 前1000 个端口
-p -扫描1-65535的完整端口

您还可以指定要从扫描中排除的特定端口。

naabu -p - -exclude-ports 80,443

要在主机列表上运行 naabu,-list可以使用选项。

naabu -list hosts.txt

要在 ASN 上运行 naabu,可以使用 AS 输入。它获取给定 ASN 可用的 IP 地址并对其运行枚举。

echo AS14421 | naabu -p 80,443

216.101.17.249:80
216.101.17.249:443
216.101.17.248:443
216.101.17.252:443
216.101.17.251:80
216.101.17.251:443
216.101.17.250:443
216.101.17.250:80

您还可以使用开关获取 JSON 格式的输出-json。此开关以 JSON 行格式保存输出。

naabu -host 104.16.99.52 -json

{"ip":"104.16.99.52","port":443}
{"ip":"104.16.99.52","port":80}

发现的端口也可以通过管道传输到其他工具。例如,你可以将 naabu 发现的端口通过管道传输到httpx,然后 httpx 会找到主机上运行的 http 服务器。

echo hackerone.com | naabu -silent | httpx -silent

http://hackerone.com:8443
http://hackerone.com:443
http://hackerone.com:8080
http://hackerone.com:80

可以通过更改表示每秒数据包数量的标志值来控制速度rate。在处理主机时增加它可能会导致误报率增加。因此建议将其保持在合理的范围内。

IPv4 和 IPv6

Naabu 支持 IPv4 和 IPv6。两个范围可以作为输入一起传输。如果使用 IPv6,则必须正确配置连接,并且网络接口必须分配有 IPv6 地址 ( inet6) 和默认网关。

echo hackerone.com | dnsx -resp-only -a -aaaa -silent | naabu -p 80 -silent

104.16.99.52:80
104.16.100.52:80
2606:4700::6810:6434:80
2606:4700::6810:6334:80

该选项-ip-version 6使该工具在解析域名时使用 IPv6 地址。

echo hackerone.com | ./naabu -p 80 -ip-version 6

                  __
  ___  ___  ___ _/ /  __ __
 / _ \/ _ \/ _ \/ _ \/ // /
/_//_/\_,_/\_,_/_.__/\_,_/ v2.0.8

      projectdiscovery.io

Use with caution. You are responsible for your actions
Developers assume no liability and are not responsible for any misuse or damage.
[INF] Running CONNECT scan with non root privileges
[INF] Found 1 ports on host hackerone.com (2606:4700::6810:6334)
hackerone.com:80

要扫描两个版本的所有 IP,可以与标志ip-version 4,6一起使用。-scan-all-ips

echo hackerone.com | ./naabu -iv 4,6 -sa -p 80 -silent

[INF] Found 1 ports on host hackerone.com (104.16.100.52)
hackerone.com:80
[INF] Found 1 ports on host hackerone.com (104.16.99.52)
hackerone.com:80
[INF] Found 1 ports on host hackerone.com (2606:4700::6810:6334)
hackerone.com:80
[INF] Found 1 ports on host hackerone.com (2606:4700::6810:6434)
hackerone.com:80

主机发现

Naabu 可选地支持多种选项来执行主机发现,如下所述。如果进程具有足够的权限,则在开始连接/同步扫描之前会自动完成主机发现。-sn标志指示 toll 仅执行主机发现。-Pn标志跳过主机发现阶段。主机发现使用多种内部方法完成;可以通过设置可用选项来指定执行主机发现所需的方法。

执行主机发现的可用选项:

  • ARP ping(-arp
  • TCP SYN ping ( -ps 80)
  • TCP确认ping ( -pa 443)
  • ICMP回显ping ( -pe)
  • ICMP时间戳ping ( -pp)
  • ICMP地址掩码ping ( -pm)
  • IPv6邻居发现-nd)

配置文件

Naabu 支持默认位于的配置文件$HOME/.config/naabu/config.yaml,它允许您在配置文件中定义任何标志并设置要包含所有扫描的默认值。

Nmap 集成

我们已经集成了 nmap 对服务发现的支持,或者对 Naabu 发现的结果进行 nmap 支持的任何其他扫描,请确保您已nmap安装以使用此功能。

要使用,nmap-cli可以在 nmap 命令后使用标志,例如:-

echo hackerone.com | naabu -nmap-cli 'nmap -sV -oX nmap-output'
                  __       
  ___  ___  ___ _/ /  __ __
 / _ \/ _ \/ _ \/ _ \/ // /
/_//_/\_,_/\_,_/_.__/\_,_/ v2.0.0        

    projectdiscovery.io

[WRN] Use with caution. You are responsible for your actions
[WRN] Developers assume no liability and are not responsible for any misuse or damage.
[INF] Running TCP/ICMP/SYN scan with root privileges
[INF] Found 4 ports on host hackerone.com (104.16.99.52)

hackerone.com:443
hackerone.com:80
hackerone.com:8443
hackerone.com:8080

[INF] Running nmap command: nmap -sV -p 80,8443,8080,443 104.16.99.52

Starting Nmap 7.01 ( https://nmap.org ) at 2020-09-23 05:02 UTC
Nmap scan report for 104.16.99.52
Host is up (0.0021s latency).
PORT     STATE SERVICE       VERSION
80/tcp   open  http          cloudflare
443/tcp  open  ssl/https     cloudflare
8080/tcp open  http-proxy    cloudflare
8443/tcp open  ssl/https-alt cloudflare

CDN/WAF 排除

Naabu 还支持排除要进行端口扫描的 CDN/WAF IP。如果使用,80则仅443扫描这些 IP 的端口。可以使用exclude-cdn标志启用此功能。

目前支持、和 IPcloudflareakamai排除incapsulasucuri

扫描状态

Naabu 在绑定到 localhost 的本地端口上公开 json 扫描信息http://localhost:63636/metrics(可以通过标志更改端口-metrics-port

使用naabu作为库

以下示例程序扫描80的端口scanme.sh。结果通过OnResult回调返回:

package main

import (
	"log"

	"github.com/projectdiscovery/goflags"
	"github.com/projectdiscovery/naabu/v2/pkg/result"
	"github.com/projectdiscovery/naabu/v2/pkg/runner"
)

func main() {
	options := runner.Options{
		Host:      goflags.StringSlice{"scanme.sh"},
		ScanType: "s",
		OnResult: func(hr *result.HostResult) {
			log.Println(hr.Host, hr.Ports)
		},
		Ports: "80",
	}

	naabuRunner, err := runner.NewRunner(&options)
	if err != nil {
		log.Fatal(err)
	}
	defer naabuRunner.Close()

	naabuRunner.RunEnumeration()
}

笔记

  • Naabu 允许任意二进制执行作为支持nmap 集成的功能。
  • Naabu 旨在扫描多个主机上的端口/批量端口扫描。
  • 默认情况下,naabu 配置为假设您从 VPS 运行它。
  • 如果从本地系统运行 naabu,我们建议调整标志/速率。
  • 为了获得最佳效果,请以root用户身份运行 naabu。

国内下载链接

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享