百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

ruby-nmap

> 编程语言
开源

一个用于 nmap 的 Ruby 接口, nmap 是一个探索工具和安全/端口扫描器。可自动执行 nmap 并解析 nmap XML 文件。

297 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

一个用于 nmap 的 Ruby 接口, nmap 是一个探索工具和安全/端口扫描器。可自动执行 nmap 并解析 nmap XML 文件。

ruby-nmap

  • Source
  • Issues
  • Documentation

Description

A Ruby API to nmap, the exploration tool and security / port scanner. Allows automating nmap and parsing nmap XML files.

Features

  • Provides a Ruby API for automating nmap.
  • Provides a Parser for enumerating nmap XML scan files.
  • Supports the full Nmap XML DTD.

Examples

Run Nmap from Ruby:

ruby
require 'nmap/command'

Nmap::Command.run do |nmap|
  nmap.connect_scan   = true
  nmap.service_scan   = true
  nmap.output_xml     = 'scan.xml'
  nmap.verbose        = true

  nmap.ports   = [20, 21, 22, 23, 25, 80, 110, 443, 512, 522, 8080, 1080]
  nmap.targets = '192.168.1.*'
end

Run sudo nmap from Ruby:

ruby
require 'nmap/command'

Nmap::Command.sudo do |nmap|
  nmap.syn_scan       = true
  nmap.os_fingerprint = true
  nmap.service_scan   = true
  nmap.output_xml     = 'scan.xml'
  nmap.verbose        = true

  nmap.ports   = [20, 21, 22, 23, 25, 80, 110, 443, 512, 522, 8080, 1080]
  nmap.targets = '192.168.1.*'
end

Parse Nmap XML scan files:

ruby
require 'nmap/xml'

Nmap::XML.open('scan.xml') do |xml|
  xml.each_host do |host|
    puts "[#{host.ip}]"

    host.each_port do |port|
      puts "  #{port.number}/#{port.protocol}\t#{port.state}\t#{port.service}"
    end
  end
end

Print NSE script output from an XML scan file:

ruby
require 'nmap/xml'

Nmap::XML.open('nse.xml') do |xml|
  xml.each_host do |host|
    puts "[#{host.ip}]"

    host.scripts.each do |name,output|
      output.each_line { |line| puts "  #{line}" }
    end

    host.each_port do |port|
      puts "  [#{port.number}/#{port.protocol}]"

      port.scripts.each do |id,script|
        puts "    [#{id}]"

        script.output.each_line { |line| puts "      #{line}" }
      end
    end
  end
end

Requirements

  • ruby >= 2.0.0
  • nmap >= 5.00
  • nokogiri ~> 1.3
  • command_mapper ~> 0.3

Install

  • Debian / Ubuntu:
bash
$ sudo apt install nmap
  • Fedora / RedHat:
bash
$ sudo dnf install nmap
  • Homebrew:
bash
$ brew install nmap
bash
$ gem install ruby-nmap

License

See {file:LICENSE.txt} for license information.

Issues· 9 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubyautomationnmaprubyruby-nmap

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言