如何检测 LAN 上的主机?

发布于 2024-07-10 17:50:42 字数 149 浏览 7 评论 0原文

为了帮助用户,我希望我的代码能够发现 LAN 上的 Oracle 数据库。 我想通过首先检测所有主机,然后检查每个主机以查看它是否正在侦听 Oracle 的默认端口来实现此目的。

有什么想法如何解决这个问题吗? 最好使用 Java,但任何语言或算法都可以。

To help users, I would like my code to discover Oracle databases on the LAN. I thought to do this by first detecting all hosts, then checking each host to see if it is listening on Oracle's default port.

Any ideas how to go about this? Preferably in Java, but any language or algorithm would do.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

为你拒绝所有暧昧 2024-07-17 17:50:42

您使用 DHCP 吗? 如果是这样,您的 DHCP 服务器就有一份已过期的租约列表。 这应该可以为您提供 LAN 上的主机列表。 然后尝试在每台主机上打开与 Oracle 端口的连接,并查看它是否接受该连接。

作为一个只有六行左右的 shell 脚本来实现应该非常简单。 对于这样的事情,Java 似乎有点矫枉过正。 循环遍历租约文件,从每个租约中获取IP,并telnet到Oracle端口; 如果连接,则断开连接并将 IP 打印到标准输出。

Are you using DHCP? If so, your DHCP server has a list of the leases it has passed out. That should do you for a list of hosts on the LAN. Then try opening a connection to the Oracle port on each of those hosts and see if it accepts the connection.

It should be pretty simple to implement as a shell script with half a dozen lines or so. Java seems like overkill for something like this. Loop through the leases file, grab the IP from each lease, and telnet to the Oracle port; if it connects, disconnect and print the IP to standard out.

才能让你更想念 2024-07-17 17:50:42

如果您想保持平台独立性,并且除非您有权访问某种列出主机的数据库,否则获取列表的唯一方法是尝试本地网络中的每个 IP 地址 - 不妨尝试连接到它们各自上都有 Oracle 端口。

这种方法有很多问题:

  • 只会搜索本地网络,这可能只是 LAN 的一小部分(对于拥有大量子网的大公司)
  • 可能需要很长时间(您肯定希望减少连接尝试超时,但如果有人将其 LAN 配置为 A 类网络,则仍然需要永远)
  • 可以触发各种警报,例如桌面用户的个人防火墙和入侵检测系统 - 因为您正在做与尝试利用 Oracle 服务器中的安全漏洞的人所做的完全相同

If you want to stay platform-independant, and unless you have access to some kind of database that lists the hosts, the only way to get a list is to try each IP address in the local network - might as well try to connect to the Oracle port on each of them.

There are lots of problems with this approach:

  • Will only search through the local network, which may only be a small part of the LAN (in case of large companies with lots of subnets)
  • Can take a long time (you definitely want to reduce the timeout for the connection attempts, but if someone has configured his LAN as a class A network, it will still take forever)
  • Can trigger all kinds of alerts, such as desktop users' personal firewalls, and intrusion detection systems - because you're doing exactly the same thing someone trying to exploit a security hole in Oracle servers would do
柳若烟 2024-07-17 17:50:42

正如 brazzy 指出的那样,扫描主机可能会导致问题,尤其是当您的扫描仪存在错误时。

更好的方法可能是让数据库的所有者在某个地方注册它们,例如在本地 DNS 服务中(或者 Oracle 是否支持 Zeroconf?),或者只是在某些 Intranet 网页或 wiki 上。

As brazzy points out, scanning for hosts is likely to cause problems, especially if there is a bug in your scanner.

A better approach may be to get the owners of the databases to register them somewhere, for example in a local DNS service (or does Oracle have zeroconf support?), or simply on some intranet webpage or wiki.

嘦怹 2024-07-17 17:50:42

您最好将 SID 名称/地址注册到某个具有固定地址的服务器(可能使用简单的 Web 服务),然后从那里查询列表。 另一种方法是通过扫描一个或多个子网进行暴力破解(由@brazzy 解释),但这并不是一件好事。

You better register the SID names/addresses to some server with a fixed address(maybe with a simple web service), and then query the list from there. Another approach is the bruteforce one (explained by @brazzy) by scanning one or more subnets, but this isn't really a good thing to do.

会傲 2024-07-17 17:50:42

如果您正在寻找一个工具 Loo@Lan 可以为您做到这一点。 不幸的是没有可用的来源...

In case you are looking for a tool Loo@Lan can do this for you. Unfortunately there's no source available...

滴情不沾 2024-07-17 17:50:42

所有这些明智的答案都是许多公司不使用默认端口的原因。 您知道,为每个数据库使用不同的端口是完全可能的。

All of these smart answers are the reasons why many companies do not use the default port. Using a different port for each database is entirely possible, you know.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文