aaronjwood / PortAuthority

A handy systems and security-focused tool, Port Authority is a very fast Android port scanner. Port Authority also allows you to quickly discover hosts on your network and will display useful network information about your device and other hosts.
https://play.google.com/store/apps/details?id=com.aaronjwood.portauthority.free
GNU General Public License v3.0
350 stars 67 forks source link

Hostname support #8

Closed Septolum closed 8 years ago

Septolum commented 9 years ago

Is it possible to add hostname support? It would be really useful, eg finding a specific computer that has a variable IP address

aaronjwood commented 9 years ago

Hostnames are fetched now during a host scan, are you talking about something different from that? Do you mean that you'd like a feature where you can enter in a hostname and it'll give you back an IP?

Septolum commented 9 years ago

Oh, are they? I can't see any when I do a scan, and I believe I'm using the latest version

Septolum commented 9 years ago

Although I can imagine that feature may be useful to people :)

aaronjwood commented 9 years ago

Hmm, that's strange. If you look at the third screenshot here you can see examples of hostnames that should come up https://play.google.com/store/apps/details?id=com.aaronjwood.portauthority.free&hl=en

You can see that I'm getting the hostname here https://github.com/aaronjwood/PortAuthority/blob/master/app/src/main/java/com/aaronjwood/portauthority/async/GetHostnameAsyncTask.java#L35

It's possible that your environment might be setup incorrectly or in such a way that it won't be possible to resolve names. I've heard that name resolution can also fail in a few other cases like when CNAMEs are in use but you're trying to resolve an IP to a name (which is what I'm doing), not the other way around. Multihomed hosts can also present an issue I think.

Would you be able to confirm if you can resolve hostnames from IP addresses in your environment using other tools? I haven't seen this fail for anyone else yet so I'm not sure what it could be...

Septolum commented 9 years ago

Yes, I can confirm there are hostnames for some of the ip's it has found using an ip scanner on my computer and another one on my phone. Where the hostname should be in port authority is just the ip address, same as the one directly below it

aaronjwood commented 9 years ago

Okay, thanks for verifying that. I'll look into this more.

aaronjwood commented 9 years ago

Would you mind attaching a screenshot? Also could you let me know what version of Android you're running, what your phone is, etc.?

Septolum commented 9 years ago

Not at all

Septolum commented 9 years ago

img_20150305_185108 My apologies, it didn't seem to work with an email attachment

aaronjwood commented 9 years ago

No worries, thanks for the screenshot! Can you tell me your OS version, phone model, etc?

Septolum commented 9 years ago

4.4.2, Cubot S208 (obscure chinese cheap decent spec(processor equiv samsung s3)), Stock rom, running dalvik, Wpa/Wpa2 psk access point

aaronjwood commented 9 years ago

Thanks! I'll follow up with you once I get some time to dig into this.

Septolum commented 9 years ago

Thanks, no rush! :)

aaronjwood commented 9 years ago

I haven't been able to reproduce this. Would it be possible for you to try the application on a different device within the same network that you initially scanned on? Another thing would be to try the host scan on a different network than the one you initially scanned.

Also, could you tell me what your phone is using for DNS servers? You can use the first four options of this to see what they are https://support.opendns.com/entries/42848890-Android-Configuration-instructions-for-OpenDNS

Septolum commented 9 years ago

Dns 1: 192.168.1.254 Dns 2: 8.8.4.4 (grayed out) Happens on all networks I try I can't test it on another device at the moment, my only other android is a HTC wildfire, and it won't install due to the api requirements, I'll let you know if I get a chance to test it on another device

aaronjwood commented 9 years ago

Thanks. Is 192.168.1.254 your gateway? Looks a little suspicious since most non-customized setups have 192.168.1.1 as the default gateway. I'll continue to look into this.

Septolum commented 9 years ago

It's a bt home hub 3.0 if that's any help

aaronjwood commented 9 years ago

Hmm, were all the networks you tried this on using that same device? I found some interesting info on the BT HH V3: https://community.bt.com/t5/Other-Broadband-Queries/BT-Home-Hub-V3-DNS-problem/td-p/666644 https://community.bt.com/t5/Other-Broadband-Queries/Home-Hub-3-Firmware-update-stops-DNS-queries-and-management-web/td-p/1208659

Not to say that's the underlying problem but there seems to be a decent amount of talk about DNS issues with that device. Is there anyway you can do a scan on a network that's not using this device?

Septolum commented 9 years ago

No, just my home one. The college network I scanned on uses an aerohive setup and the hostnames didn't show then. Weird thing is that every other port scan I've done using my computer or a different app on my phone came up with hostnames

aaronjwood commented 9 years ago

Okay, definitely an issue with something I'm doing in the code then. Thanks for running through all that with me.

Septolum commented 9 years ago

No problem, happy to help :)

Septolum commented 9 years ago

Just tested it on another device, still no hostnames on my network

aaronjwood commented 9 years ago

Gah, this issue is going to be a pain :) Thanks for testing it on something else. When you click on a host after the host scan finishes and it brings you to the screen where you can scan ports, are you able to see the hostname there?

Septolum commented 9 years ago

No, just lists the ip where the hostname should be

aaronjwood commented 9 years ago

Interesting. It sounds like reverse DNS lookups aren't working at all for you. I actually don't know of another way to do the reverse lookup in Java without trying to go to a lower level with JNI or something. Is your other device running the same Android version by chance?

Septolum commented 9 years ago

I believe it is, yes The odd thing is that hostnames are visible when I scan on my phone using fing http://goo.gl/GiFVE

aaronjwood commented 9 years ago

I just deployed a new version to Google Play. Should be available in a few hours. When you get the update could you let me know if the issue got fixed? I'm making calls to getCanonicalHostName() now instead of getHostName() which I probably should have done in the first place.

Septolum commented 9 years ago

I might be a bit slow getting it as I'm an f droid user, but I'll let you know when I do (or when I get bored of waiting and compile it myself)

Septolum commented 9 years ago

Just updated, no luck unfortunately, still no hostnames :/

aaronjwood commented 9 years ago

Okay, sorry about that. Let me look into this for a bit and see what I can do.

Septolum commented 9 years ago

Don't worry about it, thanks :)

aaronjwood commented 8 years ago

What I think will solve this issue is implementing NetBIOS/WINS resolution in addition to DNS resolution. I'm working on implementing this for the next major version (along with a bunch of other things). It should at least help for environments where DNS is not configured or provided by the router. Look for NetBIOS/WINS support in 1.6

aaronjwood commented 8 years ago

Just rolled out 1.6. Let me know how it works out for you.

Septolum commented 8 years ago

Apologies for the late reply, but it now works! Hostnames are visible for those devices that have them and are displayed in the correct place Thanks for your continued work :)

aaronjwood commented 8 years ago

No worries, very glad to hear that it works now! :)