[英]Detect if a remote computer is Windows or Linux OS
I have IP Address and Server name of a remote computer. 我有远程计算机的IP地址和服务器名称。 I am able to query WMI
to get the OS version
if the computer is running Windows but is there a way i can query the remote computer and get the OS version
if the computer is not running Windows ( Linux
, Solaris
)? 如果计算机运行Windows,我可以查询WMI
以获取OS version
,但是如果计算机未运行Windows( Linux
, Solaris
),是否可以查询远程计算机并获取OS version
?
I guess Active Directory
is going to give me what i need. 我想Active Directory
会给我我所需要的。 This is what i have so far. 这是我到目前为止所拥有的。 Looks promising. 看起来很有希望。
using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain))
{
ComputerPrincipal computer = ComputerPrincipal.FindByIdentity(ctx, "mylinuxservername");
if (computer != null)
{
var unObject = computer.GetUnderlyingObject() as System.DirectoryServices.DirectoryEntry;
if(null != unObject)
{
var osProperty = unObject.Properties.Cast<System.DirectoryServices.PropertyValueCollection>().Where(p => p.PropertyName == "operatingSystem");
if(null != osProperty.FirstOrDefault())
{
Console.WriteLine(osProperty.FirstOrDefault().Value);
}
}
}
}
There are many ways to detect that the remote computer is using Windows OS or Linux . 有很多方法可以检测到远程计算机正在使用Windows OS或Linux。 Information gathering consist that part under penetration testing . 信息收集包括正在渗透测试中的那部分。 Basically after scanning number of ports on the remote computer and the running services on these ports , we can decide that what OS is installed on the remote computer. 基本上,在扫描远程计算机上的端口数量以及这些端口上正在运行的服务之后,我们可以确定远程计算机上安装了什么操作系统。 There are one more way to check it , you can use SNMP Protocol for that purpose. 还有另一种检查方法,您可以为此目的使用SNMP协议 。
user@host $ snmpget -v2c -c <community string> <computer> <mib / oid >
eq. eq。
user@host $ snmpget -v2c -c public x.x.x.x sysDescr.0
will gives you the information related to the remote computer . 将为您提供与远程计算机有关的信息。 By default <community string> is public . 默认情况下, <community string>是public 。
从Windows PC知道远程PC的Windows版本是什么,可以运行Windows命令“ systeminfo / s [PCname]”,也可以使用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.