Python 3.x python中的远程操作系统检测
我想使用类似于nmap的python实现操作系统检测,我找到了库,但它没有提供操作系统响应! 我如何改变它来实现我的目标 编辑: 在样本中: 它可以找到操作系统,但当我运行自己的操作系统时,它没有显示任何操作系统。 是否有查找远程操作系统的功能?请尝试使用-O选项Python 3.x python中的远程操作系统检测,python-3.x,nmap,os-detection,Python 3.x,Nmap,Os Detection,我想使用类似于nmap的python实现操作系统检测,我找到了库,但它没有提供操作系统响应! 我如何改变它来实现我的目标 编辑: 在样本中: 它可以找到操作系统,但当我运行自己的操作系统时,它没有显示任何操作系统。 是否有查找远程操作系统的功能?请尝试使用-O选项 nm.scan('scanme.nmap.org', arguments='-O') 问题是,如果您这样做,信息将不会出现 print(nm.csv()) 所以你必须做一个循环 nm.scan("127.0.0.1", argum
nm.scan('scanme.nmap.org', arguments='-O')
问题是,如果您这样做,信息将不会出现
print(nm.csv())
所以你必须做一个循环
nm.scan("127.0.0.1", arguments="-O")
if 'osclass' in nm['127.0.0.1']:
for osclass in nm['127.0.0.1']['osclass']:
print('OsClass.type : {0}'.format(osclass['type']))
print('OsClass.vendor : {0}'.format(osclass['vendor']))
print('OsClass.osfamily : {0}'.format(osclass['osfamily']))
print('OsClass.osgen : {0}'.format(osclass['osgen']))
print('OsClass.accuracy : {0}'.format(osclass['accuracy']))
print('')
更多信息
PS:您需要Python3.x,我认为它不适合Python2.x
编辑
当然,您可以通过以下方式直接访问
print nm['127.0.0.1']['osclass']
或
尝试使用-O选项
nm.scan('scanme.nmap.org', arguments='-O')
问题是,如果您这样做,信息将不会出现
print(nm.csv())
所以你必须做一个循环
nm.scan("127.0.0.1", arguments="-O")
if 'osclass' in nm['127.0.0.1']:
for osclass in nm['127.0.0.1']['osclass']:
print('OsClass.type : {0}'.format(osclass['type']))
print('OsClass.vendor : {0}'.format(osclass['vendor']))
print('OsClass.osfamily : {0}'.format(osclass['osfamily']))
print('OsClass.osgen : {0}'.format(osclass['osgen']))
print('OsClass.accuracy : {0}'.format(osclass['accuracy']))
print('')
更多信息
PS:您需要Python3.x,我认为它不适合Python2.x
编辑
当然,您可以通过以下方式直接访问
print nm['127.0.0.1']['osclass']
或
如果您只需要操作系统名称,则可以执行以下操作:
import nmap
nm = nmap.PortScanner()
machine = nm.scan('<hostIP>', arguments='-O')
print(machine['scan']['<hostIP>']['osmatch'][0]['osclass'][0]['osfamily'])
这将提供操作系统名称[Ex:'Linux']如果您只需要操作系统名称,则可以执行以下操作:
import nmap
nm = nmap.PortScanner()
machine = nm.scan('<hostIP>', arguments='-O')
print(machine['scan']['<hostIP>']['osmatch'][0]['osclass'][0]['osfamily'])
这将提供操作系统名称[Ex:'Linux']分享您的研究成果对每个人都有帮助。告诉我们您尝试了什么,以及为什么它不能满足您的需求。这表明你花了时间来帮助自己,它使我们避免重复显而易见的答案,最重要的是,它帮助你得到一个更具体和相关的答案!另外,分享你的研究成果对每个人都有帮助。告诉我们您尝试了什么,以及为什么它不能满足您的需求。这表明你花了时间来帮助自己,它使我们避免重复显而易见的答案,最重要的是,它帮助你得到一个更具体和相关的答案!也看到