I find myself often working from the command line in the terminal or console when conducting various security tests and wondering if my proxy or VPN is truly working correctly for my command line tools. It is easy enough to check from a standard browser but this requires me to leave the console and actually open a browser, which of courses I am too lazy to do. In my search to keep all things command line I found this gem of a script written in python that does exactly what I have been looking for - and I had to share it with you! It is called “whatsmyip.py”. I did not write this but it is a great piece of python code and works simple enough. If you place this script in your PATH variable you should be able to access it from anywhere when in the command line, allowing us to quickly check our external ip and confirm our HTTP proxy or VPN is properly working for our CLI tools. No more need to even leave the console! You can always use ipconfig/ifconfig to check your internal IP from the command line, now you can also check your external IP. It is as simple as saving the code provided below as “<insert-name>.py” on your system and then running as “name.py” OR “python name.py”. It will grab your external IP and return the result to the console screen. It is super easy and really helpful. It won’t do anything else, but it does what it is supposed to and makes another fine addition to any real pen-testers bag of tricks to use at their disposal. Hope you find this helpful in some way, and as always Enjoy!
PS - All credits for coding this script go to: s3my0n