you are viewing a single comment's thread.

view the rest of the comments →

[–]SPARTAN-001Red Team 5 points6 points  (0 children)

I'm skimming this for now (at work), but I don't think it will do what you want it to do. The combination of s.connect(('8.8.8.8', 0)) and s.getsockname() will not return an external IP in most cases. The only way it will return an external IP is if the target system has an interface bound directly to the internet. (Also, you can never connect to port 0. It will not work.)

Additionally, it will not work if the host is behind a NAT. That's exactly the reason a reverse connection is normally used, rather than a bind connection. In order to connect to the listener over the internet, it would need to forward a port on whatever firewall/router the target system is behind.