mirror of https://github.com/secdev/scapy.git
DHCP tests
This commit is contained in:
parent
ee950aaa2a
commit
e4ed84e06e
|
@ -4,7 +4,7 @@
|
|||
## This program is published under a GPLv2 license
|
||||
|
||||
"""
|
||||
DHCP (Dynamic Host Configuration Protocol) d BOOTP
|
||||
DHCP (Dynamic Host Configuration Protocol) and BOOTP
|
||||
"""
|
||||
|
||||
from collections import Iterable
|
||||
|
@ -286,6 +286,7 @@ bind_layers( UDP, BOOTP, dport=68, sport=67)
|
|||
bind_bottom_up( UDP, BOOTP, dport=67, sport=67)
|
||||
bind_layers( BOOTP, DHCP, options='c\x82Sc')
|
||||
|
||||
@conf.commands.register
|
||||
def dhcp_request(iface=None,**kargs):
|
||||
if conf.checkIPaddr != 0:
|
||||
warning("conf.checkIPaddr is not 0, I may not be able to match the answer")
|
||||
|
|
|
@ -7620,3 +7620,28 @@ SCTPChunkSACK in p and p[SCTP].chksum == 0x3b01d404 and p[SCTPChunkSACK].gap_ack
|
|||
|
||||
= SCTP - answers
|
||||
(IP()/SCTP()).answers(IP()/SCTP()) == True
|
||||
|
||||
############
|
||||
############
|
||||
+ DHCP
|
||||
|
||||
= BOOTP - misc
|
||||
BOOTP().answers(BOOTP()) == True
|
||||
|
||||
import random
|
||||
random.seed(0x2807)
|
||||
str(RandDHCPOptions()) == "[('WWW_server', '90.219.239.175')]"
|
||||
|
||||
value = ("hostname", "scapy")
|
||||
dof = DHCPOptionsField("options", value)
|
||||
dof.i2repr("", value) == '[hostname scapy]'
|
||||
dof.i2m("", value) == '\x0cscapy'
|
||||
|
||||
|
||||
= DHCP - build
|
||||
s = str(IP()/UDP()/BOOTP(chaddr="00:01:02:03:04:05")/DHCP(options=[("message-type","discover"),"end"]))
|
||||
s == 'E\x00\x01\x10\x00\x01\x00\x00@\x11{\xda\x7f\x00\x00\x01\x7f\x00\x00\x01\x00C\x00D\x00\xfcf\xea\x01\x01\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0000:01:02:03:04:0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00c\x82Sc5\x01\x01\xff'
|
||||
|
||||
= DHCP - dissection
|
||||
p = IP(s)
|
||||
DHCP in p and p[DHCP].options[0] == ('message-type', 1)
|
||||
|
|
Loading…
Reference in New Issue