4월, 2022의 게시물 표시

Dynamically assigned TCP port scanning

이미지
 This time, we will create an echo server that can dynamically open a TCP port to check a connection. As with the previous UDP port detection, we will use epoll.  TCP works a little differently than UDP. In TCP, the client tries to connect to the bound socket. And the server socket creates a new socket through the accept function and then communicates with this socket. <tcp/ip socket  communication process> Multiple port tests To test ports in a specific band, all ports in the corresponding area should be opened and bind operation should be performed. If there is a port where the bind operation failed, take action after confirming that this port is already in use by another process. The TCP example is a little more complicated than the UDP example because it creates a new socket and communicates through the processes of listen and accept. #!/usr/bin/env python import socket import time import select import logging import argparse logger = logging . getLog

Dynamically assigned UDP port scanning

이미지
 Occasionally, there is a situation where data transmission and reception is impossible due to a firewall in server-to-server communication. This is a simple Python program that can test whether UDP communication is possible. I work for a VoIP product development company. The SIP protocol mainly used in VoIP (Voice Over IP) mainly uses UDP. In particular, RTP (RealTime Protocol) used to transmit and receive voice data requires many UDP ports. One or two UDP ports are used for one voice channel. Therefore, if the VoIP solution supports 1000 voice channels at the same time, 1000 ~ 2000 UDP ports can be used at the same time. Therefore, it is very important to determine whether the UDP port is serviceable. In general, nmap is often used to check whether a port is open. However, nmap is not appropriate in this case. The reason is that in VoIP, a UDP port for voice transmission/reception is randomly selected from a specific range and used. For example, if there is a VoIP product set to use