简体   繁体   English

从Winsock数据中检测用户?

[英]Detecting user from winsock data?

For example i create socket using winsock under account named Admin. 例如,我使用Winsock在名为Admin的帐户下创建套接字。 Is there any possibility to detect which user created that socket? 是否有可能检测哪个用户创建了该套接字? I would like to write in my program: This socket was created by "Admin". 我想在我的程序中写:这个套接字是由“ Admin”创建的。 i am using c++ 我正在使用c ++

Sockets are not securable objects (see here ) and so cannot have a security descriptor associated with them and so there's no way you can know the user account that 'created the socket'. 套接字不是安全对象(请参阅此处 ),因此不能与它们关联安全描述符,因此无法知道“创建套接字”的用户帐户。

You could use GetExtendedTcpTable to get information about connections and then locate the PID of the process that created the socket; 您可以使用GetExtendedTcpTable获取有关连接的信息,然后找到创建套接字的进程的PID。 you could then decide to use something based on the process... 然后您可以根据流程决定使用某些东西...

Why do you want to do this anyway? 您为什么仍要这样做?

netstat -o should give you process IDs which created the socket; netstat -o应该为您提供创建套接字的进程ID; from there, you can find the process owner. 从那里,您可以找到流程所有者。 If everything else fails, you could spawn netstat in a new process and parse the output. 如果其他所有操作均失败,则可以在新进程中生成netstat并解析输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM