https://github.com/krishpranav/ruby-nmap
A nmap made in ruby
https://github.com/krishpranav/ruby-nmap
hacking information-extraction information-gathering information-gathering-tools nmap osint port-scanner port-scanner-in-ruby ruby ruby-scanner
Last synced: about 1 year ago
JSON representation
A nmap made in ruby
- Host: GitHub
- URL: https://github.com/krishpranav/ruby-nmap
- Owner: krishpranav
- Created: 2021-05-11T10:51:34.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-12-13T07:01:35.000Z (over 1 year ago)
- Last Synced: 2025-04-15T02:45:19.800Z (about 1 year ago)
- Topics: hacking, information-extraction, information-gathering, information-gathering-tools, nmap, osint, port-scanner, port-scanner-in-ruby, ruby, ruby-scanner
- Language: Ruby
- Homepage:
- Size: 56.6 KB
- Stars: 4
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ruby-nmap
A simple nmap made in ruby
[](https://forthebadge.com)
[](https://forthebadge.com)
# Installation
```
git clone https://github.com/krishpranav/ruby-nmap
cd ruby-nmap
gem install
gem install ruby-nmap
ruby-nmap
```
## Examples
Run Nmap from Ruby:
```ruby
require 'nmap/program'
Nmap::Program.scan do |nmap|
nmap.syn_scan = true
nmap.service_scan = true
nmap.os_fingerprint = true
nmap.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/program'
Nmap::Program.sudo_scan do |nmap|
nmap.syn_scan = true
# ...
end
```
Parse Nmap XML scan files:
```ruby
require 'nmap/xml'
Nmap::XML.new('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.new('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 |name,output|
puts " [#{name}]"
output.each_line { |line| puts "#{line}" }
end
end
end
end
```
## Requirements
* [ruby] >= 2.0.0
* [nmap] >= 5.00
* [nokogiri] ~> 1.3
* [rprogram] ~> 0.3