scapy.layers.inet
IPv4 (Internet Protocol v4).
- class scapy.layers.inet.DestIPField(name, default)[源代码]
- class scapy.layers.inet.ICMP(_pkt, /, *, type=8, code=0, chksum=None, id=0, seq=0, ts_ori=50496994, ts_rx=50496994, ts_tx=50496994, gw='0.0.0.0', ptr=0, reserved=0, length=0, addr_mask='0.0.0.0', nexthopmtu=0, unused=None)[源代码]
基类:
Packet
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TYPE | CODE | CHKSUM | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ID | SEQ | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TS ORI | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TS RX | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TS TX | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | GW | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PTR | RESERVED | LENGTH | ADDR MASK | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | NEXTHOPMTU | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |UNUSE| +-+-+-+-+-+-+-+-+ Fig. ICMP
ICMP fields type
8
code
MultiEnumField
(Depends on 8)0
chksum
None
id
XShortField
(Cond)0
seq
XShortField
(Cond)0
ts_ori
ICMPTimeStampField
(Cond)50496994
ts_rx
ICMPTimeStampField
(Cond)50496994
ts_tx
ICMPTimeStampField
(Cond)50496994
gw
IPField
(Cond)'0.0.0.0'
ptr
ByteField
(Cond)0
reserved
ByteField
(Cond)0
length
ByteField
(Cond)0
addr_mask
IPField
(Cond)'0.0.0.0'
nexthopmtu
ShortField
(Cond)0
unused
MultipleTypeField
(ShortField, IntField, StrFixedLenField)b''
- class scapy.layers.inet.ICMPEcho_am(self)[源代码]
-
Responds to ICMP Echo-Requests (ping)
- function_name = 'icmpechod'
- optam0: Dict[str, Any]
- optam1: Dict[str, Any]
- optam2: Dict[str, Any]
- optsend: Dict[str, Any]
- optsniff: Dict[str, Any]
- class scapy.layers.inet.ICMPTimeStampField(name: str, default: int | None)[源代码]
基类:
IntField
- re_hmsm = re.compile('([0-2]?[0-9])[Hh:](([0-5]?[0-9])([Mm:]([0-5]?[0-9])([sS:.]([0-9]{0,3}))?)?)?$')
- class scapy.layers.inet.ICMPerror(_pkt, /, *, type=8, code=0, chksum=None, id=0, seq=0, ts_ori=50496994, ts_rx=50496994, ts_tx=50496994, gw='0.0.0.0', ptr=0, reserved=0, length=0, addr_mask='0.0.0.0', nexthopmtu=0, unused=None)[源代码]
基类:
ICMP
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TYPE | CODE | CHKSUM | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ID | SEQ | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TS ORI | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TS RX | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TS TX | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | GW | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PTR | RESERVED | LENGTH | ADDR MASK | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | NEXTHOPMTU | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | |UNUSE| +-+-+-+-+-+-+-+-+ Fig. ICMPerror
ICMPerror fields type
8
code
MultiEnumField
(Depends on 8)0
chksum
None
id
XShortField
(Cond)0
seq
XShortField
(Cond)0
ts_ori
ICMPTimeStampField
(Cond)50496994
ts_rx
ICMPTimeStampField
(Cond)50496994
ts_tx
ICMPTimeStampField
(Cond)50496994
gw
IPField
(Cond)'0.0.0.0'
ptr
ByteField
(Cond)0
reserved
ByteField
(Cond)0
length
ByteField
(Cond)0
addr_mask
IPField
(Cond)'0.0.0.0'
nexthopmtu
ShortField
(Cond)0
unused
MultipleTypeField
(ShortField, IntField, StrFixedLenField)b''
- class scapy.layers.inet.IP(_pkt, /, *, version=4, ihl=None, tos=0, len=None, id=1, flags=<Flag 0 ()>, frag=0, ttl=64, proto=0, chksum=None, src=None, dst=None, options=[])[源代码]
-
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |VERSION| IHL | TOS | LEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ID |FLAGS| FRAG | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TTL | PROTO | CHKSUM | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SRC | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DST | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | OPTIONS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. IP
IP fields version
BitField
(4 bits)4
ihl
BitField
(4 bits)None
tos
0
len
None
id
1
flags
<Flag 0 ()>
frag
BitField
(13 bits)0
ttl
64
proto
0
chksum
None
src
None
dst
None
options
[]
- scapy.layers.inet.IPID_count(lst, funcID=<function <lambda>>, funcpres=<function <lambda>>)[源代码]
Identify IP id values classes in a list of packets
lst: a list of packets funcID: a function that returns IP id values funcpres: a function used to summarize packets
- class scapy.layers.inet.IPOption(_pkt, /, *, copy_flag=0, optclass=0, option=0, length=None, value=b'')[源代码]
基类:
Packet
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|OPT| OPTION | LENGTH | VALUE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. IPOption
IPOption fields copy_flag
BitField
(1 bit)0
optclass
0
option
0
length
None
value
b''
- registered_ip_options = {0: <class 'scapy.layers.inet.IPOption_EOL'>, 1: <class 'scapy.layers.inet.IPOption_NOP'>, 2: <class 'scapy.layers.inet.IPOption_Security'>, 3: <class 'scapy.layers.inet.IPOption_LSRR'>, 4: <class 'scapy.layers.inet.IPOption_Timestamp'>, 7: <class 'scapy.layers.inet.IPOption_RR'>, 8: <class 'scapy.layers.inet.IPOption_Stream_Id'>, 9: <class 'scapy.layers.inet.IPOption_SSRR'>, 11: <class 'scapy.layers.inet.IPOption_MTU_Probe'>, 12: <class 'scapy.layers.inet.IPOption_MTU_Reply'>, 18: <class 'scapy.layers.inet.IPOption_Traceroute'>, 19: <class 'scapy.layers.inet.IPOption_Address_Extension'>, 20: <class 'scapy.layers.inet.IPOption_Router_Alert'>, 21: <class 'scapy.layers.inet.IPOption_SDBM'>}
- class scapy.layers.inet.IPOption_Address_Extension(_pkt, /, *, copy_flag=1, optclass=0, option=19, length=10, src_ext='0.0.0.0', dst_ext='0.0.0.0')[源代码]
基类:
IPOption
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|OPT| OPTION | LENGTH | SRC EXT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | DST EXT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. IPOption_Address_Extension
IPOption_Address_Extension fields copy_flag
BitField
(1 bit)1
optclass
0
option
19
length
10
src_ext
'0.0.0.0'
dst_ext
'0.0.0.0'
- class scapy.layers.inet.IPOption_EOL(_pkt, /, *, copy_flag=0, optclass=0, option=0)[源代码]
基类:
IPOption
- aliastypes
- class scapy.layers.inet.IPOption_LSRR(_pkt, /, *, copy_flag=1, optclass=0, option=3, length=None, pointer=4, routers=[])[源代码]
基类:
IPOption_RR
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|OPT| OPTION | LENGTH | POINTER | ROUTERS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. IPOption_LSRR
IPOption_LSRR fields copy_flag
BitField
(1 bit)1
optclass
0
option
3
length
None
pointer
4
routers
[]
- class scapy.layers.inet.IPOption_MTU_Probe(_pkt, /, *, copy_flag=0, optclass=0, option=11, length=4, mtu=0)[源代码]
基类:
IPOption
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|OPT| OPTION | LENGTH | MTU | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. IPOption_MTU_Probe
IPOption_MTU_Probe fields copy_flag
BitField
(1 bit)0
optclass
0
option
11
length
4
mtu
0
- class scapy.layers.inet.IPOption_MTU_Reply(_pkt, /, *, copy_flag=0, optclass=0, option=12, length=4, mtu=0)[源代码]
-
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|OPT| OPTION | LENGTH | MTU | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. IPOption_MTU_Reply
IPOption_MTU_Reply fields copy_flag
BitField
(1 bit)0
optclass
0
option
12
length
4
mtu
0
- class scapy.layers.inet.IPOption_NOP(_pkt, /, *, copy_flag=0, optclass=0, option=1)[源代码]
基类:
IPOption
- aliastypes
- class scapy.layers.inet.IPOption_RR(_pkt, /, *, copy_flag=0, optclass=0, option=7, length=None, pointer=4, routers=[])[源代码]
基类:
IPOption
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|OPT| OPTION | LENGTH | POINTER | ROUTERS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. IPOption_RR
IPOption_RR fields copy_flag
BitField
(1 bit)0
optclass
0
option
7
length
None
pointer
4
routers
[]
- class scapy.layers.inet.IPOption_Router_Alert(_pkt, /, *, copy_flag=1, optclass=0, option=20, length=4, alert=0)[源代码]
基类:
IPOption
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|OPT| OPTION | LENGTH | ALERT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. IPOption_Router_Alert
IPOption_Router_Alert fields copy_flag
BitField
(1 bit)1
optclass
0
option
20
length
4
alert
0
- class scapy.layers.inet.IPOption_SDBM(_pkt, /, *, copy_flag=1, optclass=0, option=21, length=None, addresses=[])[源代码]
基类:
IPOption
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|OPT| OPTION | LENGTH | ADDRESSES | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. IPOption_SDBM
IPOption_SDBM fields copy_flag
BitField
(1 bit)1
optclass
0
option
21
length
None
addresses
[]
- class scapy.layers.inet.IPOption_SSRR(_pkt, /, *, copy_flag=1, optclass=0, option=9, length=None, pointer=4, routers=[])[源代码]
基类:
IPOption_RR
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|OPT| OPTION | LENGTH | POINTER | ROUTERS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. IPOption_SSRR
IPOption_SSRR fields copy_flag
BitField
(1 bit)1
optclass
0
option
9
length
None
pointer
4
routers
[]
- class scapy.layers.inet.IPOption_Security(_pkt, /, *, copy_flag=1, optclass=0, option=2, length=11, security=0, compartment=0, handling_restrictions=0, transmission_control_code=b'xxx')[源代码]
基类:
IPOption
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|OPT| OPTION | LENGTH | SECURITY | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | COMPARTMENT | HANDLING RESTRICTIONS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TRANSMISSION CONTROL CODE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. IPOption_Security
IPOption_Security fields copy_flag
BitField
(1 bit)1
optclass
0
option
2
length
11
security
0
compartment
0
handling_restrictions
0
transmission_control_code
b'xxx'
- class scapy.layers.inet.IPOption_Stream_Id(_pkt, /, *, copy_flag=1, optclass=0, option=8, length=4, security=0)[源代码]
基类:
IPOption
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|OPT| OPTION | LENGTH | SECURITY | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. IPOption_Stream_Id
IPOption_Stream_Id fields copy_flag
BitField
(1 bit)1
optclass
0
option
8
length
4
security
0
- class scapy.layers.inet.IPOption_Timestamp(_pkt, /, *, copy_flag=0, optclass=2, option=4, length=None, pointer=9, oflw=0, flg=1, internet_address='0.0.0.0', timestamp=0)[源代码]
基类:
IPOption
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|OPT| OPTION | LENGTH | POINTER | OFLW | FLG | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | INTERNET ADDRESS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TIMESTAMP | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. IPOption_Timestamp
IPOption_Timestamp fields copy_flag
BitField
(1 bit)0
optclass
2
option
4
length
None
pointer
9
oflw
BitField
(4 bits)0
flg
1
internet_address
IPField
(Cond)'0.0.0.0'
timestamp
0
- class scapy.layers.inet.IPOption_Traceroute(_pkt, /, *, copy_flag=0, optclass=0, option=18, length=12, id=0, outbound_hops=0, return_hops=0, originator_ip='0.0.0.0')[源代码]
基类:
IPOption
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C|OPT| OPTION | LENGTH | ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | OUTBOUND HOPS | RETURN HOPS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ORIGINATOR IP | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. IPOption_Traceroute
IPOption_Traceroute fields copy_flag
BitField
(1 bit)0
optclass
0
option
18
length
12
id
0
outbound_hops
0
return_hops
0
originator_ip
'0.0.0.0'
- class scapy.layers.inet.IPerror(_pkt, /, *, version=4, ihl=None, tos=0, len=None, id=1, flags=<Flag 0 ()>, frag=0, ttl=64, proto=0, chksum=None, src=None, dst=None, options=[])[源代码]
基类:
IP
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |VERSION| IHL | TOS | LEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ID |FLAGS| FRAG | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TTL | PROTO | CHKSUM | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SRC | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DST | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | OPTIONS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. IPerror
IPerror fields version
BitField
(4 bits)4
ihl
BitField
(4 bits)None
tos
0
len
None
id
1
flags
<Flag 0 ()>
frag
BitField
(13 bits)0
ttl
64
proto
0
chksum
None
src
None
dst
None
options
[]
- class scapy.layers.inet.TCP(_pkt, /, *, sport=20, dport=80, seq=0, ack=0, dataofs=None, reserved=0, flags=<Flag 2 (S)>, window=8192, chksum=None, urgptr=0, options=b'')[源代码]
基类:
Packet
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SPORT | DPORT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SEQ | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ACK | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |DATAOFS|RESER| FLAGS | WINDOW | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CHKSUM | URGPTR | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | OPTIONS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TCP
TCP fields sport
20
dport
80
seq
0
ack
0
dataofs
BitField
(4 bits)None
reserved
BitField
(3 bits)0
flags
<Flag 2 (S)>
window
8192
chksum
None
urgptr
0
options
b''
- payload_guess
Possible sublayers:
HSFZ
,DoIP
,SOMEIP
,BGP
,CRX1New
,DiamG
,ENIPTCP
,LDP
,ModbusADURequest
,ModbusADUResponse
,MQTT
,OpenFlow
,PostgresBackend
,PostgresFrontend
,RTR
,Skinny
,SOCKS
,STUN
,TacacsHeader
,DceRpc
,DNS
,HTTP
,UDP
,KerberosTCPHeader
,LDAP
,NBTSession
,PPTP
,Skinny
- class scapy.layers.inet.TCPAOValue(_pkt, /, *, keyid=None, rnextkeyid=None, mac=b'')[源代码]
基类:
Packet
Value of TCP-AO option
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | KEYID | RNEXTKEYID | MAC | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TCPAOValue
TCPAOValue fields keyid
None
rnextkeyid
None
mac
b''
- class scapy.layers.inet.TCPOptionsField(name: str, default: I | None, fmt: str = 'H', remain: int = 0)[源代码]
基类:
StrField
- islist = 1
- class scapy.layers.inet.TCP_client(self, ip, port, srcip=None, **kargs)[源代码]
基类:
Automaton
Creates a TCP Client Automaton. This automaton will handle TCP 3-way handshake.
- Usage: the easiest usage is to use it as a SuperSocket.
>>> a = TCP_client.tcplink(HTTP, "www.google.com", 80) >>> a.send(HTTPRequest()) >>> a.recv()
- 参数:
ip -- the ip to connect to
port --
src -- (optional) use another source IP
- CLOSED(*args: ATMT, **kargs: Any) NewStateRequested [源代码]
- ESTABLISHED(*args: ATMT, **kargs: Any) NewStateRequested [源代码]
- LAST_ACK(*args: ATMT, **kargs: Any) NewStateRequested [源代码]
- START(*args: ATMT, **kargs: Any) NewStateRequested [源代码]
- STOP(*args: ATMT, **kargs: Any) NewStateRequested [源代码]
- STOP_SENT_FIN_ACK(*args: ATMT, **kargs: Any) NewStateRequested [源代码]
- SYN_SENT(*args: ATMT, **kargs: Any) NewStateRequested [源代码]
- actions: Dict[str, List[_StateWrapper]] = {'ack_of_fin_received': [], 'connect': [<function TCP_client.send_syn>], 'fin_received': [<function TCP_client.send_finack>], 'incoming_data_received': [<function TCP_client.receive_data>], 'outgoing_data_received': [<function TCP_client.send_data>], 'reset_received': [], 'stop_ack_timeout': [], 'stop_fin_received': [<function TCP_client.stop_send_ack>], 'stop_requested': [<function TCP_client.stop_send_finack>], 'syn_ack_timeout': [], 'synack_received': [<function TCP_client.send_ack_of_synack>]}
- breakpoints: Set[_StateWrapper]
- conditions: Dict[str, List[_StateWrapper]] = {'CLOSED': [], 'ESTABLISHED': [], 'LAST_ACK': [], 'START': [<function TCP_client.connect>], 'STOP': [<function TCP_client.stop_requested>], 'STOP_SENT_FIN_ACK': [], 'SYN_SENT': []}
- initial_states: List[_StateWrapper] = [<function ATMT.state.<locals>.deco.<locals>._state_wrapper>]
- interception_points: Set[_StateWrapper]
- ioevents: Dict[str, List[_StateWrapper]] = {'CLOSED': [], 'ESTABLISHED': [<function TCP_client.outgoing_data_received>], 'LAST_ACK': [], 'START': [], 'STOP': [], 'STOP_SENT_FIN_ACK': [], 'SYN_SENT': []}
- ionames: List[str] = ['tcp']
- iosupersockets: List[SuperSocket] = [<function TCP_client.outgoing_data_received>]
- packets: PacketList
- recv_conditions: Dict[str, List[_StateWrapper]] = {'CLOSED': [], 'ESTABLISHED': [<function TCP_client.incoming_data_received>, <function TCP_client.reset_received>, <function TCP_client.fin_received>], 'LAST_ACK': [<function TCP_client.ack_of_fin_received>], 'START': [], 'STOP': [], 'STOP_SENT_FIN_ACK': [<function TCP_client.stop_fin_received>], 'SYN_SENT': [<function TCP_client.synack_received>]}
- states: Dict[str, _StateWrapper] = {'CLOSED': <function ATMT.state.<locals>.deco.<locals>._state_wrapper>, 'ESTABLISHED': <function ATMT.state.<locals>.deco.<locals>._state_wrapper>, 'LAST_ACK': <function ATMT.state.<locals>.deco.<locals>._state_wrapper>, 'START': <function ATMT.state.<locals>.deco.<locals>._state_wrapper>, 'STOP': <function ATMT.state.<locals>.deco.<locals>._state_wrapper>, 'STOP_SENT_FIN_ACK': <function ATMT.state.<locals>.deco.<locals>._state_wrapper>, 'SYN_SENT': <function ATMT.state.<locals>.deco.<locals>._state_wrapper>}
- stop_states: List[_StateWrapper] = [<function ATMT.state.<locals>.deco.<locals>._state_wrapper>]
- tcplink = <scapy.automaton._ATMT_to_supersocket object>
- threadid: int | None
- timeout: Dict[str, _TimerList] = {'CLOSED': [], 'ESTABLISHED': [], 'LAST_ACK': [], 'START': [], 'STOP': [], 'STOP_SENT_FIN_ACK': [<Timer 0.000000(1.000000)>], 'SYN_SENT': [<Timer 0.000000(1.000000)>]}
- class scapy.layers.inet.TCPerror(_pkt, /, *, sport=20, dport=80, seq=0, ack=0, dataofs=None, reserved=0, flags=<Flag 2 (S)>, window=8192, chksum=None, urgptr=0, options=b'')[源代码]
基类:
TCP
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SPORT | DPORT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SEQ | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ACK | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |DATAOFS|RESER| FLAGS | WINDOW | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CHKSUM | URGPTR | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | OPTIONS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. TCPerror
TCPerror fields sport
20
dport
80
seq
0
ack
0
dataofs
BitField
(4 bits)None
reserved
BitField
(3 bits)0
flags
<Flag 2 (S)>
window
8192
chksum
None
urgptr
0
options
b''
- class scapy.layers.inet.TracerouteResult(res=None, name='Traceroute', stats=None)[源代码]
基类:
SndRcvList
- graph(ASres=<scapy.as_resolvers.AS_resolver_multi object>, padding=0, **kargs)[源代码]
x.graph(ASres=conf.AS_resolver, other args): ASres=None : no AS resolver => no clustering ASres=AS_resolver() : default whois AS resolver (riswhois.ripe.net) ASres=AS_resolver_cymru(): use whois.cymru.com whois database ASres=AS_resolver(server="whois.ra.net") type: output type (svg, ps, gif, jpg, etc.), passed to dot's "-T" option # noqa: E501 target: filename or redirect. Defaults pipe to Imagemagick's display program # noqa: E501 prog: which graphviz program to use
- graphASres
- graphdef
- graphpadding
- hloc
- nloc
- padding
- class scapy.layers.inet.UDP(_pkt, /, *, sport=53, dport=53, len=None, chksum=None)[源代码]
基类:
Packet
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SPORT | DPORT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | LEN | CHKSUM | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. UDP
UDP fields sport
53
dport
53
len
None
chksum
None
- payload_guess
Possible sublayers:
PDUTransport
,DoIP
,SOMEIP
,BFD
,BIFT
,CoAP
,CRX1New
,GENEVE
,GTPHeader
,GTP_U_Header
,HICP
,IKEv2
,KNX
,LDP
,LTP
,MPLS
,MQTTSN
,PFCP
,ProfinetIO
,RIPng
,BTH
,SebekHead
,SOCKS5UDP
,STAMPSessionReflectorTestUnauthenticated
,STAMPSessionSenderTestUnauthenticated
,STUN
,VQP
,Wireguard
,BOOTP
,_dhcp6_dispatcher
,DNS
,HSRP
,ESP
,Kerberos
,L2TP
,CLDAP
,_LLMNR
,MGCP
,MobileIP
,NBNSHeader
,NBTDatagram
,NetflowHeader
,NTP
,Radius
,RIP
,SNMP
,TFTP
,VXLAN
,ZEP2
- class scapy.layers.inet.UDPerror(_pkt, /, *, sport=53, dport=53, len=None, chksum=None)[源代码]
基类:
UDP
- aliastypes
- fields_desc
Display RFC-like schema
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SPORT | DPORT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | LEN | CHKSUM | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. UDPerror
UDPerror fields sport
53
dport
53
len
None
chksum
None
- scapy.layers.inet.calc_tcp_md5_hash(tcp: TCP, key: bytes) bytes [源代码]
Calculate TCP-MD5 hash from packet and return a 16-byte string
- class scapy.layers.inet.connect_from_ip(host, port, srcip, poison=True, timeout=1)[源代码]
基类:
object
Open a TCP socket to a host:port while spoofing another IP.
- 参数:
host -- the host to connect to
port -- the port to connect to
srcip -- the IP to spoof. the cache of the gateway will be poisonned with this IP.
poison -- (optional, default True) ARP poison the gateway (or next hop), so that it answers us.
timeout -- (optional) the socket timeout.
Example - Connect to 192.168.0.1:80 spoofing 192.168.0.2:
from scapy.layers.http import HTTP, HTTPRequest client = connect_from_ip("192.168.0.1", 80, "192.168.0.2") sock = SSLStreamSocket(client.sock, HTTP) resp = sock.sr1(HTTP() / HTTPRequest(Path="/"))
Example - Connect to 192.168.0.1:443 with TLS wrapping spoofing 192.168.0.2:
import ssl from scapy.layers.http import HTTP, HTTPRequest context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) context.check_hostname = False context.verify_mode = ssl.CERT_NONE client = connect_from_ip("192.168.0.1", 443, "192.168.0.2") sock = context.wrap_socket(client.sock) sock = SSLStreamSocket(client.sock, HTTP) resp = sock.sr1(HTTP() / HTTPRequest(Path="/"))
- scapy.layers.inet.defrag(plist) ([not fragmented], [defragmented], [源代码]
[ [bad fragments], [bad fragments], ... ])
- scapy.layers.inet.get_tcpao(tcphdr: TCP) TCPAOValue | None [源代码]
Get the TCP-AO option from the header
- scapy.layers.inet.in4_chksum(proto: int, u: IP, p: bytes) int [源代码]
IPv4 Pseudo Header checksum as defined in RFC793
- 参数:
proto -- value of upper layer protocol
u -- upper layer instance
p -- the payload of the upper layer provided as a string
- scapy.layers.inet.in4_pseudoheader(proto: int, u: IP, plen: int) bytes [源代码]
IPv4 Pseudo Header as defined in RFC793 as bytes
- 参数:
proto -- value of upper layer protocol
u -- IP layer instance
plen -- the length of the upper layer and payload
- scapy.layers.inet.overlap_frag(p, overlap, fragsize=8, overlap_fragsize=None)[源代码]
Build overlapping fragments to bypass NIPS
p: the original packet overlap: the overlapping data fragsize: the fragment size of the packet overlap_fragsize: the fragment size of the overlapping packet
- scapy.layers.inet.report_ports(target, ports)[源代码]
portscan a target and output a LaTeX table report_ports(target, ports) -> string
- scapy.layers.inet.sign_tcp_md5(tcp: TCP, key: bytes) None [源代码]
Append TCP-MD5 signature to tcp packet
- scapy.layers.inet.tcp_pseudoheader(tcp: TCP) bytes [源代码]
Pseudoheader of a TCP packet as bytes
Requires underlayer to be either IP or IPv6
- scapy.layers.inet.traceroute(target, dport=80, minttl=1, maxttl=30, sport=<RandShort>, l4=None, filter=None, timeout=2, verbose=None, **kargs)[源代码]
Instant TCP traceroute
- 参数:
target -- hostnames or IP addresses
dport -- TCP destination port (default is 80)
minttl -- minimum TTL (default is 1)
maxttl -- maximum TTL (default is 30)
sport -- TCP source port (default is random)
l4 -- use a Scapy packet instead of TCP
filter -- BPF filter applied to received packets
timeout -- time to wait for answers (default is 2s)
verbose -- detailed output
- 返回:
an TracerouteResult, and a list of unanswered packets