[英]Detect if a remote computer is Windows or Linux OS
我有远程计算机的IP地址和服务器名称。 如果计算机运行Windows,我可以查询WMI
以获取OS version
,但是如果计算机未运行Windows( Linux
, Solaris
),是否可以查询远程计算机并获取OS version
?
我想Active Directory
会给我我所需要的。 这是我到目前为止所拥有的。 看起来很有希望。
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);
}
}
}
}
有很多方法可以检测到远程计算机正在使用Windows OS或Linux。 信息收集包括正在渗透测试中的那部分。 基本上,在扫描远程计算机上的端口数量以及这些端口上正在运行的服务之后,我们可以确定远程计算机上安装了什么操作系统。 还有另一种检查方法,您可以为此目的使用SNMP协议 。
user@host $ snmpget -v2c -c <community string> <computer> <mib / oid >
eq。
user@host $ snmpget -v2c -c public x.x.x.x sysDescr.0
将为您提供与远程计算机有关的信息。 默认情况下, <community string>是public 。
从Windows PC知道远程PC的Windows版本是什么,可以运行Windows命令“ systeminfo / s [PCname]”,也可以使用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.