Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
Merge branch 'jinankjain-Bug116'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Claudius committed Aug 23, 2016
2 parents 7bd0f7e + c54dd9f commit caeb25a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/ssh_scan/target_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/ssh_scan/target_parser_rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit caeb25a

Please sign in to comment.