Scapy:AttributeError:“NoneType”对象没有属性“getlayer”

2024-04-26 20:55:51 发布

您现在位置:Python中文网/ 问答频道 /正文

所以,我写了一个portscanner,它工作得很好。它输出了我想要的一切。但在某些时候,我打破了它,我不知道我是怎么打破它的。在

我得到的错误是:

line 12, in portscan
    if(tcp_connect.getlayer(TCP).flags == SYNACK):
AttributeError: 'NoneType' object has no attribute 'getlayer'
[Finished in 4.4s with exit code 1]

脚本如下:

^{pr2}$

我不知道为了打破它我改变了什么。任何想法都将不胜感激!在


Tags: inifobjectconnect错误linetcpflags
1条回答
网友
1楼 · 发布于 2024-04-26 20:55:51

Carcigenicate指出:

If there is no response a None value will be assigned instead when the timeout is reached. None being returned means there was no response. You'll need to check for that . . .

解决方案:

if tcp_connect == None: 
     (Handle Failure)
else: 
     (Handle success)

相关问题 更多 >