Skip to content
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

Open
Atrate opened this issue Aug 14, 2020 · 3 comments
Open

Allow scanning specified IPs #3

Atrate opened this issue Aug 14, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@Atrate
Copy link

Atrate commented Aug 14, 2020

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.

@csicar
Copy link
Owner

csicar commented Sep 18, 2020

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?

@G2G2G2G
Copy link

G2G2G2G commented Oct 27, 2021

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: 192.168.0.55 or you can do 192.168.0.5/24 <-- note this isn't the actual network address (which should then default to the correct network of "192.168.0.0/24" and then scan 192.168.0.1 - 192.168.0.254
(0 and 255 aren't addressable right?)

here's some javascript that does it I found posted so you don't have to redo the math
http://jsfiddle.net/kLjdLadv/

    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

alert(getIpRangeFromAddressAndNetmask("192.168.138.33/23"));
    alert(getIpRangeFromAddressAndNetmask("192.168.138.76/24"));

and some various others

it seems to also take incorrectly formatted subnet masks as input too (as their example shows)

alert(getIpRangeFromAddressAndNetmask("192.168.138.0/255.255.254.0"));

@csicar
Copy link
Owner

csicar commented Oct 28, 2021

Thanks for the js snippet. I'll look into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants