-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow scanning specified IPs #3
Comments
Good point and a useful feature. Not yet sure how that would fit into the ui. Maybe a search option in the toolbar, where you could enter the IP? |
Yes I think that is a good method I'd like to request CIDR in the search bar, so you can say scan a specific IP: here's some javascript that does it I found posted so you don't have to redo the math function getIpRangeFromAddressAndNetmask(str) {
var part = str.split("/"); // part[0] = base address, part[1] = netmask
var ipaddress = part[0].split('.');
var netmaskblocks = ["0","0","0","0"];
if(!/\d+\.\d+\.\d+\.\d+/.test(part[1])) {
// part[1] has to be between 0 and 32
netmaskblocks = ("1".repeat(parseInt(part[1], 10)) + "0".repeat(32-parseInt(part[1], 10))).match(/.{1,8}/g);
netmaskblocks = netmaskblocks.map(function(el) { return parseInt(el, 2); });
} else {
// xxx.xxx.xxx.xxx
netmaskblocks = part[1].split('.').map(function(el) { return parseInt(el, 10) });
}
var invertedNetmaskblocks = netmaskblocks.map(function(el) { return el ^ 255; });
var baseAddress = ipaddress.map(function(block, idx) { return block & netmaskblocks[idx]; });
var broadcastaddress = ipaddress.map(function(block, idx) { return block | invertedNetmaskblocks[idx]; });
return [baseAddress.join('.'), broadcastaddress.join('.')];
}
alert(getIpRangeFromAddressAndNetmask("192.168.138.0/23"));
alert(getIpRangeFromAddressAndNetmask("192.168.138.0/255.255.254.0")); I've tested
and some various others it seems to also take incorrectly formatted subnet masks as input too (as their example shows)
|
Thanks for the js snippet. I'll look into it |
It would be nice if Ning supported port scanning a specified IP without having to scan the whole subnet first — it would also allow for port scanning IPs outside the LAN.
The text was updated successfully, but these errors were encountered: