diff --git a/scapy/layers/dhcp.py b/scapy/layers/dhcp.py index 8572fe9c1be7691ca339a3b2d8bd5104335b35a4..3b4b55266b46fd463c1adce4c01152a8c2db4be4 100644 --- a/scapy/layers/dhcp.py +++ b/scapy/layers/dhcp.py @@ -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") diff --git a/scapy/layers/dot11.py b/scapy/layers/dot11.py index 1ddccfca661557f2dd0e06a127088eda157d2329..51471c9cd07401d91e824a5275763461ddf7f808 100644 --- a/scapy/layers/dot11.py +++ b/scapy/layers/dot11.py @@ -492,6 +492,7 @@ def get_toDS(): # os.system("iwconfig %s mode monitor" % iffrom) # +@conf.commands.register def airpwn(iffrom, ifto, replace, pattern="", ignorepattern=""): """Before using this, initialize "iffrom" and "ifto" interfaces: iwconfig iffrom mode monitor diff --git a/test/regression.uts b/test/regression.uts index 36d2fef2af0b996c88269c90e646e6f57f1cedf9..c41cc0de9f86ec31b712f4c9cbf71d04463974f8 100644 --- a/test/regression.uts +++ b/test/regression.uts @@ -7727,3 +7727,52 @@ assert [p[TCP].flags for p in plist] == range(512) plist = PacketList(list(IP()/TCP(flags=["S", "SA", "A"]))) assert [p[TCP].flags for p in plist] == [2, 18, 16] + + +############ +############ ++ SCTP + += SCTP - Chunk Init - build +s = str(IP()/SCTP()/SCTPChunkInit(params=[SCTPChunkParamIPv4Addr()])) +s == 'E\x00\x00<\x00\x01\x00\x00@\x84|;\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00@,\x0b_\x01\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x08\x7f\x00\x00\x01' + += SCTP - Chunk Init - dissection +p = IP(s) +SCTPChunkParamIPv4Addr in p and p[SCTP].chksum == 0x402c0b5f and p[SCTPChunkParamIPv4Addr].addr == "127.0.0.1" + += SCTP - SCTPChunkSACK - build +s = str(IP()/SCTP()/SCTPChunkSACK(gap_ack_list=["7:28"])) +s == 'E\x00\x004\x00\x01\x00\x00@\x84|C\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00;\x01\xd4\x04\x03\x00\x00\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x07\x00\x1c' + += SCTP - SCTPChunkSACK - dissection +p = IP(s) +SCTPChunkSACK in p and p[SCTP].chksum == 0x3b01d404 and p[SCTPChunkSACK].gap_ack_list[0] == "7:28" + += 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)