How to Easily Find What Port a Service Runs On and Vice-Versa

May 29, 2015 12:04 AM
May 30, 2015 03:34 PM
635684277127616525.jpg

I wrote a python script that allows you to easily ask what service runs on a specific port and vice-versa. Now, I am sure that such a program already exists on our lovely linux OS's, but... I didn't think of that before I started, and haven't found it yet. So if you haven't found it yet either, maybe you'll find this of some use.

635684276564805858.jpg

It's just called getport. If I have a port number, and want to know what services run on that port, I do:

getport 1234 (or whatever number)

635684277127616525.jpg

and if I have the name of a service, or a keyword (sql, oracle, ssh etc.) I can do:

getport mysql

OR

getport ssh etc..

If there is no match for your search, the script simply does nothing..

635684277519178902.jpg
635684277863242735.jpg
635684277519178902.jpg
635684277863242735.jpg

Get the script:

You can get it here:

http://pastebin.com/q5Ae0gRj

When you get it you'll need to make it executable like this:

go to the directory it's in

cd ~/directory/of/script (wherever it is)

make it executable

sudo chmod +x getport

And preferably put it somewhere on your system PATH so you can call it from anywhere.

And ready to go. Thanks for reading!

Extra stuff - What it's doing:

It's basically just looking for your port/service/keyword, in the file /etc/unicornscan/ports.txt which is on my kali linux by default, and I assume is also on yours.. thus I have hardcoded that path into the script. If you don't have it though, or if you want this to work on other linux OS's, there is a file: /etc/services which looks very similar to the unicorn one, except seemlingly far more established on linux systems, seeing as it has it's own manpage(you want man services...). However, I preferred the layout of the ports.txt for this, but the script could easily be changed to use /etc/services instead.

Just updated your iPhone? You'll find new Apple Intelligence capabilities, sudoku puzzles, Camera Control enhancements, volume control limits, layered Voice Memo recordings, and other useful features. Find out what's new and changed on your iPhone with the iOS 18.2 update.

Comments

No Comments Exist

Be the first, drop a comment!