免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
1234下一页
最近访问板块 发新帖
查看: 19536 | 回复: 32
打印 上一主题 下一主题

如何探测目标主机的udp端口是否在监听? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-01-26 17:24 |只看该作者 |倒序浏览
我们项目中,有这样一个事务:
主机B向主机A发出音频请求(请求参数中包含本机在监听的一个udp端口值),
然后主机A 源源不断的向主机B的这个监听端口发送udp音频流数据...
(这里不考虑网段的问题, 主机A和B处在可以彼此主动连接的网络中)

问题是当我主机B掉电或断网或其它某种原因这个端口它不再监听了,我主机A如何知道?
有什么好办法吗?

主机B的程序不方便修改,所以没法添加一种心跳包的机制;
通过抓包工具显示,当主机B不再监听这个端口后,收到无效的udp音频流也不会回应icmp包.


愁...

[ 本帖最后由 yulc 于 2007-1-26 17:25 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2007-01-29 15:54 |只看该作者
三天过去了, 我的贴子无人问津...

论坛徽章:
0
3 [报告]
发表于 2007-01-29 17:01 |只看该作者
方法太多了,举个简单的吧

在Host A装一个Agent程序,定时向Host B返回Host A的端口情况,Host B不就知道了

论坛徽章:
0
4 [报告]
发表于 2007-01-29 17:02 |只看该作者
B受到数据后连个回应也不给吗?

如果一定要探测的话好象似乎也是可以的
但是在下不确定啊
nmap扫描器应该可以扫描出哪些UDP端口是打开的吧

论坛徽章:
0
5 [报告]
发表于 2007-01-29 17:05 |只看该作者
--

可以给数据包加个头部,头部里用标志位。类似 ICMP,ICMP echo 类型消息就是用来检测对方主机是否存活的。

方法应该有很多。

--

论坛徽章:
0
6 [报告]
发表于 2007-01-29 17:05 |只看该作者
你可以下载nmap软件,nmap -sU xxx.xxx.xxx.xxx 可以进行UDP port scan,
具体原理我不清楚,可以看看它的源码,也许可以借鉴

论坛徽章:
0
7 [报告]
发表于 2007-01-29 17:17 |只看该作者
我觉得要想准确判断,不太容易。
UDP Scanning

Port scanning usually means scanning for TCP ports, which are connection-oriented and therefore give good feedback to the attacker. UDP responds in a different manner. In order to find UDP ports, the attacker generally sends empty UDP datagrams. If the port is listening, the service should send back an error message or ignore the incoming datagram. If the port is closed, then most operating systems send back an "ICMP Port Unreachable" message. Thus, you can find out if a port is NOT open, and by exclusion determine which ports are open. Neither UDP packets, nor the ICMP errors are guaranteed to arrive, so UDP scanners of this sort must also implement retransmission of packets that appear to be lost (or you will get a bunch of false positives). Also, this scanning technique is slow because of compensation for machines that implement the suggestions of RFC 1812 and limit ICMP error message rate. For example, a kernal may limit destination unreachable message generation to 80 per 4 seconds, with a 1/4 second penalty if that is exceeded.

Some people think UDP scanning is pointless - not so.  Sometimes for example, Rpcbind can be found hiding on an undocumented UDP port somewhere above 32770. So it doesn't matter that port 111 is blocked by the firewall. But can you find which of the more than 30,000 high ports it is listening on? With a UDP scanner you can.

论坛徽章:
0
8 [报告]
发表于 2007-01-29 18:04 |只看该作者
先谢谢各位的点子...


使用agent或nmap 等软件来做,我这项目不可取.

如langue所说,在我的包中加上一个头部,可否说具体一点?
另外, 我加上头部,估计接收端的代码也要修改,至少需要懂得响应我的这个头吧.

论坛徽章:
0
9 [报告]
发表于 2007-01-29 18:05 |只看该作者
原帖由 bleem1998 于 2007-1-29 17:02 发表
B受到数据后连个回应也不给吗?

如果一定要探测的话好象似乎也是可以的
但是在下不确定啊
nmap扫描器应该可以扫描出哪些UDP端口是打开的吧



B收到数据后,确实连个回应也没有..
不过, 回答你贴子的同时, 我突然想:
"妈的, 我(主机A)辛辛苦苦发包给你(主机B),你收了这么多从不理我,你哪天死了,那我为什么要理你...."

论坛徽章:
0
10 [报告]
发表于 2007-01-29 18:09 |只看该作者
原帖由 yulc 于 2007-1-29 18:04 发表
先谢谢各位的点子...


使用agent或nmap 等软件来做,我这项目不可取.

如langue所说,在我的包中加上一个头部,可否说具体一点?
另外, 我加上头部,估计接收端的代码也要修改,至少需要懂得响应我的这个头吧.


是这样的。头部加上标志位,用来识别数据包的类型。如果类型为 “普通音频流数据”,那么按照原定的操作进行即可。如果是 “echo request” 类型的,就用 “echo reply” 来返回。

确实,服务端和客户端都要支持。

--
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP