
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 매개변수를 사용할 수 있습니다.