
Whatportis : IANA के पोर्ट्स की सूची का अन्वेषण करें
.. image:: https://github.com/opencve/opencve/workflows/Tests/badge.svg :target: https://github.com/ncrocfer/whatportis/actions/workflows/tests.yml
.. image:: https://badge.fury.io/py/whatportis.svg :target: https://pypi.python.org/pypi/whatportis/
.. image:: https://img.shields.io/badge/python-3.6%2B-blue.svg :target: https://pypi.python.org/pypi/whatportis/
.. image:: https://img.shields.io/github/license/ncrocfer/whatportis.svg :target: https://github.com/ncrocfer/whatportis/blob/master/LICENSE.txt
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/python/black
किसी सेवा का डिफ़ॉल्ट पोर्ट नंबर खोजना एक सामान्य कार्य है। कुछ पोर्ट :code:/etc/services फ़ाइल में उपलब्ध हैं, लेकिन सूची पूर्ण नहीं है और यह समाधान पोर्टेबल नहीं है।
Whatportis एक सरल उपकरण है जो Iana.org <http://www.iana.org/assignments/port-numbers>_ डेटाबेस को डाउनलोड करता है और पोर्ट की आधिकारिक सूची का पता लगाने के लिए इसका उपयोग करता है।
Whatportis आपको यह पता लगाने की अनुमति देता है कि किसी सेवा के साथ कौन सा पोर्ट जुड़ा है:
.. code-block:: shell
$ whatportis redis
+-------+------+----------+---------------------------------------+
| Name | Port | Protocol | Description |
+-------+------+----------+---------------------------------------+
| redis | 6379 | tcp | An advanced key-value cache and store |
+-------+------+----------+---------------------------------------+
या, इसके विपरीत, किसी पोर्ट नंबर के साथ कौन सी सेवा जुड़ी है:
.. code-block:: shell
$ whatportis 5432
+------------+------+----------+---------------------+
| Name | Port | Protocol | Description |
+------------+------+----------+---------------------+
| postgresql | 5432 | tcp, udp | PostgreSQL Database |
+------------+------+----------+---------------------+
आप :code:--like विकल्प जोड़कर सटीक नाम जाने बिना भी पैटर्न खोज सकते हैं:
.. code-block:: shell
$ whatportis mysql --like
+----------------+-------+----------+-----------------------------------+
| Name | Port | Protocol | Description |
+----------------+-------+----------+-----------------------------------+
| mysql-cluster | 1186 | tcp, udp | MySQL Cluster Manager |
| mysql-cm-agent | 1862 | tcp, udp | MySQL Cluster Manager Agent |
| mysql-im | 2273 | tcp, udp | MySQL Instance Manager |
| mysql | 3306 | tcp, udp | MySQL |
| mysql-proxy | 6446 | tcp, udp | MySQL Proxy |
| mysqlx | 33060 | tcp | MySQL Database Extended Interface |
+----------------+-------+----------+-----------------------------------+
.. code-block:: shell
$ pip install whatportis
Whatportis पोर्ट की सूची का पता लगाने के लिए एक स्थानीय JSON फ़ाइल (:code:~/.whatportis_db.json) का उपयोग करता है। पहला उपयोग इसे आपके लिए बनाएगा, फिर आप इसे सिंक्रोनाइज़ करने के लिए :code:--update विकल्प का उपयोग कर सकते हैं:
.. code-block:: shell
$ whatportis --update
Previous database will be updated, do you want to continue? [y/N]: y
Downloading https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.csv...
Populating database...
14145 ports imported.
आप :code:--json विकल्प का उपयोग करके परिणामों को JSON के रूप में प्रदर्शित कर सकते हैं:
.. code-block:: shell
$ whatportis 5432 --json
[
{
"name": "postgresql",
"port": "5432",
"protocol": "tcp, udp",
"description": "PostgreSQL Database"
}
]
Whatportis को RESTful API सर्वर के रूप में भी शुरू किया जा सकता है। यह सुविधा डिफ़ॉल्ट रूप से सक्षम नहीं है, आपको एक अतिरिक्त पैकेज स्थापित करना होगा:
.. code-block:: shell
$ pip install whatportis[server]
$ whatportis --server localhost 8080
* Serving Flask app "whatportis.server" (lazy loading)
* Environment: prod
* Debug mode: off
* Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)
एंडपॉइंट :code:/ports पूरी सूची के लिए (लंबा हो सकता है) और :code:/ports/<search> किसी विशिष्ट पोर्ट को खोजने के लिए हैं:
.. code-block:: shell
$ curl http://127.0.0.1:8080/ports/3306
{"ports":[{"description":"MySQL","name":"mysql","port":"3306","protocol":"tcp, udp"}]}
$ curl http://localhost:8080/ports/redis
{"ports":[{"description":"An advanced key-value cache and store","name":"redis","port":"6379","protocol":"tcp"}]}
आप पैटर्न खोजने के लिए :code:?like पैरामीटर का उपयोग कर सकते हैं।