0

[Crossposting from SO]

I am trying to make a port scanner in Python and trying to list which all ports are accessible by anyone remotely.

Using the socket.connect_ex package, I was able to check which all ports are open for my local machine to use, but couldn't find a way on how to check what all ports anyone on the internet can access on my machine.

1 Answer 1

1

If you want to know what port is accessible from the internet you actually need to try to access the port from some place on the internet. There is no way to do this locally since it is unknown what firewalls, NAT etc might actually block the access.

You can be pretty sure that at most what is accessible from inside the local network is also accessible from the internet. But likely there is much less accessible since most machines are not connected directly to the wild internet but separated from the it using some NAT router or some firewall which implicitly or explicitly restrict what can be accessed.

3
  • Ohkayy, yeah that makes sense. So for example if I want to check if someone else on my wifi network has access or not, I'll have to try to access it from another machine on the same network, right?
    – Eagle
    Apr 9, 2021 at 17:05
  • @Eagle: exactly. Note that it still might be that there are firewall rules which allow or deny access only to specific IP addresses or only at specific times or similar, so the check is not 100% reliable. It will be reliable in most cases to find out misconfiguration which allow access you did not want to allow. But it will not detect some backdoor access which was explicitly designed to not be easily visible. Apr 9, 2021 at 17:19
  • Okay, thank you very much! I think I'll resort to a remote server then which will try to ping the ports to return the status; will keep in mind the points you mentioned :)
    – Eagle
    Apr 9, 2021 at 17:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .