0
使用Python libnmap模块调用get_host_byid,我有这样的Python代码:从libnmap返回“无”,而不是一个宿主对象
def DiffScan(Old, New):
Added = Old.diff(New).added()
for i in Added:
anIP = i.split('::')[1]
print "IP for lookup is " + anIP + " of " + str(type(anIP))
anewhost = New.get_host_byid(anIP)
pprint.pprint(anewhost)
当我调用这个函数,我得到的输出:
IP for lookup is X.X.X.X of <type 'str'>
None
IP for lookup is Y.Y.Y.Y of <type 'str'>
None
我意料的是,而不是“无”,我会得到这样的:
IP for lookup is Z.Z.Z.Z of <type 'str'>
NmapHost: [Z.Z.Z.Z() - up]
我不确定为什么致电.get_host_byid()
正在返回None而不是NMapHost
对象。也许我的anIP
字符串有问题,但我找不到错误。
我已经做了使用.get_host_byid一些实验()关闭保存libnmap.objects.report对象。我正在调用带有我知道在报告中的文字IP地址的函数。有些时候我得到一个NmapHost对象,有时我会回到“无”。根据我使用的数据,我应该每次都得到一个NMapHost对象。报告所依据的扫描结果超过了20MB。可能会有一个变量太大的问题? – Rudi