远程检查IP端口状态

时间:2020-03-06 14:38:06  来源:igfitidea点击:

我找到了有关在计算机上获得活动的tcp / udp连接的文章。

http://www.codeproject.com/KB/IP/iphlpapi.aspx

但是,我的问题是,我需要能够远程确定活动连接,以查看特定端口是否在运行或者监听,而无需篡改机器。

这可能吗?

看起来不是本机的,否则可能会带来安全问题。替代方法是查询远程服务,然后可以在本地计算机上进行必要的调用。

有什么想法吗?

解决方案

没有远程计算机知道,就无法知道哪些端口是打开的。但是我们可以在不知道端口上运行的程序的情况下确定信息(即不干扰程序)。

使用SYN扫描:

为了建立连接,TCP使用三向握手。可以利用此漏洞在程序不知道的情况下找出端口是否打开。

握手的工作方式如下:

  • 客户端通过向服务器发送SYN来执行主动打开。
  • 服务器回复一个SYN-ACK。
  • 通常,客户端将ACK发送回服务器。但是,此步骤被跳过。
SYN scan is the most popular form of
  TCP scanning. Rather than use the
  operating system's network functions,
  the port scanner generates raw IP
  packets itself, and monitors for
  responses. This scan type is also
  known as "half-open scanning", because
  it never actually opens a full TCP
  connection. The port scanner generates
  a SYN packet. If the target port is
  open, it will respond with a SYN-ACK
  packet. The scanner host responds with
  a RST packet, closing the connection
  before the handshake is completed.
  
  The use of raw networking has several
  advantages, giving the scanner full
  control of the packets sent and the
  timeout for responses, and allowing
  detailed reporting of the responses.
  There is debate over which scan is
  less intrusive on the target host. SYN
  scan has the advantage that the
  individual services never actually
  receive a connection while some
  services can be crashed with a connect
  scan. However, the RST during the
  handshake can cause problems for some
  network stacks, particularly simple
  devices like printers. There are no
  conclusive arguments either way.

来源维基百科

如下所述,我认为nmap可以进行SYN扫描。

使用套接字进行TCP端口扫描:

确定打开哪个端口的一种方法是打开该端口的套接字。或者连接到另一个端口,以查找我们提到的信息。

例如从命令提示符或者终端:

telnet google.com 80

UDP端口扫描:

如果UDP数据包发送到未打开的端口,则系统将以ICMP端口不可达消息进行响应。我们可以使用此方法确定端口是打开还是关闭。但是接收程序会知道的。

Nmap是我们要寻找的。

neouser99(et al)建议使用NMAP。如果我们要做的就是检测远程计算机上打开的端口,则NMAP非常好。

但是从问题听起来,我们实际上是在尝试确定远程计算机上同时打开和连接了哪些端口。如果我们要使用通用监控解决方案(包括连接的端口),则可以在远程计算机上安装snmp服务器。有两个可用于检查端口状态的MIB:TCP-MIB :: tcpConnectionTable和UDP-MIB :: udpEndpointTable。

net-snmp中提供的守护程序(服务器)很可能已获得了这些mib的支持。