开发一个工具来知道谁连接到远程机器?

发布于 2024-09-11 17:12:25 字数 655 浏览 11 评论 0原文

场景:我们是一个由 22 名成员组成的团队,他们每天使用唯一的 ID 登录到本地计算机,然后使用一组登录名连接到远程计算机。

这里用于连接到远程计算机的登录名不是唯一的。我的意思是可以使用相同的用户名连接多于一台计算机。

在一行中,22 台远程计算机将只有 5-6 个登录名,由 22 台计算机使用成员..

问题: 由于远程计算机并非专用于每个员工..每天我们需要向所有组发送一封邮件,询问谁连接到特定的远程计算机..并且如果有人回答是..我们将要求他们断开连接..

我想使用java开发一个小工具,它在每台机器上运行并显示哪台机器使用哪台机器..

该站点中提到的代码是有用,但它没有指定谁使用了该登录?链接:http://lazynetworkadmin.com/content/view/34/6/

我希望我的观点清楚:)

请指导我如何继续?..你认为这可能吗?

注意:忘了提及操作系统,它是:Windows XP

Scenario: We are a team of 22 members who daily log on to their local machines with their unique IDs and then connect to remote machines with a set of Logins.

Here the logins used to connect to remote machines are not unique..I mean more than one machine can be connected with same user name..

In one line 22 remote machines will have only 5- 6 logins which are used by 22 members..

Problem: As the remote machines are not dedicated to each employee..Everyday we need to send a mail to all the group asking who is connected to specific remote machine..And if any one replies yes..we will ask them to disconnect..

I want to develop a small tool using java, which runs on every machine and displays which machine is used by which one..

The code which is mentioned in this site is useful but it does not specify as the who used that login? Link : http://lazynetworkadmin.com/content/view/34/6/

I hope i made my point clear :)

Please guide me as how i can proceed?..Do you think it is possible?

NOTE: Forgot about mentioning the operating system, it is: Windows XP

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

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

发布评论

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

评论(2

冷情 2024-09-18 17:12:25

在远程计算机上,您可以运行 netstat 程序,该程序会输出如下内容:

C:\> netstat -n | find ":80"
  TCP    192.168.1.33:1930      209.85.129.190:80      ESTABLISHED
  TCP    192.168.1.33:2749      74.125.39.139:80       ESTABLISHED
  TCP    192.168.1.33:2861      74.125.171.167:80      TIME_WAIT

从该输出中,您可以看到已建立的所有网络连接。在第三列中,您可以看到其他主机的 IP 地址和端口。 find 只保留包含“:80”的行(在我的例子中是我连接到的所有远程 HTTP 主机)。由于您知道远程主机将连接到的端口,因此您可以按该端口号进行过滤。第三列将包含连接到该主机的所有计算机的 IP 地址和端口。

从 IP 地址应该很容易找出这台计算机是谁的。

更新:

由于您想使用 Java,因此应该直接执行以下操作:

  1. 运行 netstat -n 命令。
  2. List 中捕获输出。
  3. 将每一行分成单词。
  4. 仅保留 word[0]TCPword[1]:3389 结尾且 <代码>words[3] 已已建立
  5. 在冒号处拆分这些行的 word[2]。第一个元素是 IP 地址。
  6. 将这些 IP 地址的列表报告给中央服务器。

在中央服务器上,有一个可通过 Web 服务器访问的小程序:

  1. 服务器保留活动连接的列表。每个都由远程主机、客户端主机和上次更新的时间戳组成。
  2. 接受来自远程计算机的传入连接。
  3. 从一个连接接收客户端 IP 地址列表。
  4. 从“活动列表”中删除已从该 IP 报告的所有客户端 IP 地址。
  5. 显示结果列表。

例如:

  • 最初,活动连接列表为空。
  • remote0 发送 192.168.0.33,192.168.0.35 作为其活动客户端。
  • 活动连接列表现在包含 remote0:192.168.0.33remote0:192.168.0.35
  • 一段时间后,remote0 发送``(空响应)作为其活动客户端。
  • 现在活动连接列表也为空。

因此,Web 服务器需要处理两个 URL:

  • /connections/list 用于列出所有活动连接
  • /connections/update 用于更新单个远程主机的连接

听起来像有点工作,但这肯定是可行的。当它完成后,我感觉非常有用。

On the remote machine you can run the netstat program, which outputs something like this:

C:\> netstat -n | find ":80"
  TCP    192.168.1.33:1930      209.85.129.190:80      ESTABLISHED
  TCP    192.168.1.33:2749      74.125.39.139:80       ESTABLISHED
  TCP    192.168.1.33:2861      74.125.171.167:80      TIME_WAIT

From this output you can see all network connections that are established. In the third column you see the IP address and port of the other host. The find only keeps the lines that contain ":80" (which in my case is all the remote HTTP hosts I'm connected to). Since you know the port that the remote hosts will connect to, you can filter by that port number. The third column will then contain the IP addresses and ports of all the computers that are connected to this host.

From the IP address it should be easy to find out whose computer it is.

Update:

As you want to use Java, it should be straight-forward what to do:

  1. Run the netstat -n command.
  2. Capture the output in a List<String>.
  3. Split each line into words.
  4. Keep only those lines whose word[0] is TCP, word[1] ends with :3389 and words[3] is ESTABLISHED.
  5. Split the word[2] of these lines at the colon. The first element is then the IP address.
  6. Report the list of these IP addresses to a central server.

On the central server, have a little program accessible via a web server:

  1. The server keeps a list of active connections. Each consists of the remote host, the client host and the timestamp it has been updated the last time.
  2. Accept incoming connections from the remote machines.
  3. Receive a list of client IP addresses from one connection.
  4. Remove from the "active list" all client IP addresses that have been reported from that IP.
  5. Display the resulting list.

For example:

  • Initially, the list of active connections is empty.
  • remote0 sends 192.168.0.33,192.168.0.35 as its active clients.
  • The list of active connections now contains remote0:192.168.0.33, remote0:192.168.0.35.
  • Some time later, remote0 sends `` (an empty response) as its active clients.
  • Now the list of active connections is empty, too.

The web server therefore needs to process two URLs:

  • /connections/list for listing all the active connections
  • /connections/update for updating the connections for a single remote host

Sounds like a bit of work, but this is certainly doable. And when it's finished it feels quite usable to me.

肤浅与狂妄 2024-09-18 17:12:25

通过本地代理。然后代理就知道哪些连接是活动的。

Go through a local proxy. Then the proxy knows which connections are active.

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