开发一个工具来知道谁连接到远程机器?
场景:我们是一个由 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在远程计算机上,您可以运行
netstat
程序,该程序会输出如下内容:从该输出中,您可以看到已建立的所有网络连接。在第三列中,您可以看到其他主机的 IP 地址和端口。
find
只保留包含“:80”的行(在我的例子中是我连接到的所有远程 HTTP 主机)。由于您知道远程主机将连接到的端口,因此您可以按该端口号进行过滤。第三列将包含连接到该主机的所有计算机的 IP 地址和端口。从 IP 地址应该很容易找出这台计算机是谁的。
更新:
由于您想使用 Java,因此应该直接执行以下操作:
netstat -n
命令。List
中捕获输出。word[0]
为TCP
、word[1]
以:3389
结尾且 <代码>words[3] 已已建立
。word[2]
。第一个元素是 IP 地址。在中央服务器上,有一个可通过 Web 服务器访问的小程序:
例如:
remote0
发送192.168.0.33,192.168.0.35
作为其活动客户端。remote0:192.168.0.33
、remote0: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: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:
netstat -n
command.List<String>
.word[0]
isTCP
,word[1]
ends with:3389
andwords[3]
isESTABLISHED
.word[2]
of these lines at the colon. The first element is then the IP address.On the central server, have a little program accessible via a web server:
For example:
remote0
sends192.168.0.33,192.168.0.35
as its active clients.remote0:192.168.0.33
,remote0:192.168.0.35
.remote0
sends `` (an empty response) as its active clients.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 hostSounds like a bit of work, but this is certainly doable. And when it's finished it feels quite usable to me.
通过本地代理。然后代理就知道哪些连接是活动的。
Go through a local proxy. Then the proxy knows which connections are active.