Last active
December 18, 2015 00:49
-
-
Save mckeed/5699686 to your computer and use it in GitHub Desktop.
Script that uses nmap to look for local devices that respond to broadcast ping and have open telnet ports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Looks for local devices that respond to broadcast ping and have open telnet ports | |
`ifconfig`.scan(/broadcast ([\d.]+)/) do |b,| | |
next unless b[/^(192|10)\./] | |
puts "Scanning #{b.gsub(/255/, '*')}" | |
`ping -c2 #{b}`.scan(/from ([\d.]+)/).uniq.sort_by {|a,| | |
a.split('.').map {|p| p.to_i } | |
}.each do |a,| | |
if `nmap -Pn -sT -p 23 #{a}`.include? "open telnet" | |
arp = `arp #{a}` | |
puts arp[/at/] ? arp : a | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment