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.
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)
and if I have the name of a service, or a keyword (sql, oracle, ssh etc.) I can do:
getport ssh etc..
If there is no match for your search, the script simply does nothing..
Get the script:
You can get it here:
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.
Learn How To Code with Null Byte's Beginner's Python Course.