From c54dd9f207940f8b100be788a49c0e28bc469ce9 Mon Sep 17 00:00:00 2001 From: Jinank Jain Date: Mon, 22 Aug 2016 18:06:05 -0400 Subject: [PATCH] Fixed #116 --- lib/ssh_scan/target_parser.rb | 8 +++++++- spec/ssh_scan/target_parser_rspec.rb | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/ssh_scan/target_parser.rb b/lib/ssh_scan/target_parser.rb index 73762be3..62064e36 100644 --- a/lib/ssh_scan/target_parser.rb +++ b/lib/ssh_scan/target_parser.rb @@ -14,8 +14,14 @@ def enumerateIPRange(ip) upper = NetAddr::CIDR.create(octets.join('.') + "." + range[1]) ip_array = NetAddr.range(lower, upper,:Inclusive => true) return ip_array + elsif ip.include? "/" + cidr = NetAddr::CIDR.create(ip) + ip_array = cidr.enumerate + ip_array.delete(cidr.network) + ip_array.delete(cidr.last) + return ip_array else - return NetAddr::CIDR.create(ip).enumerate + return [ip] end end end diff --git a/spec/ssh_scan/target_parser_rspec.rb b/spec/ssh_scan/target_parser_rspec.rb index 8f5c8863..b2147c8f 100644 --- a/spec/ssh_scan/target_parser_rspec.rb +++ b/spec/ssh_scan/target_parser_rspec.rb @@ -26,7 +26,7 @@ context "IPv4 with subnet mask specified" do it "should return an array containing all the IPv4 in that range" do target_parser = SSHScan::TargetParser.new() - expect(target_parser.enumerateIPRange("192.168.1.0/30")).to eq(["192.168.1.0", "192.168.1.1", "192.168.1.2", "192.168.1.3"]) + expect(target_parser.enumerateIPRange("192.168.1.0/30")).to eq(["192.168.1.1", "192.168.1.2"]) end end end