Esempio n. 1
0
 def RCVD_OFFER(self, pkt):
 
     # send request
     request = Ether()/IP()/UDP(sport=68, dport=67)/BOOTP(xid=self.xid)/DHCP()
     
     request[DHCP].options = []
     
     # request[Ether].src    = '00:00:00:00:00:01'
     request[Ether].dst    = 'ff:ff:ff:ff:ff:ff'
     request[IP].src       = '0.0.0.0'
     request[IP].dst       = '255.255.255.255'
     # request[BOOTP].op     = 2
     # request[BOOTP].chpad  = '\x00'*10
     # request[BOOTP].sname  = '\x00'*64
     # request[BOOTP].file   = '\x00'*128
     request[BOOTP].chaddr = self.mac
     request[BOOTP].flags  = self.broadcast
    
     self.msgtype   = MSGTYPE(code=53, len=1, type=3)
     self.rqstaddr    = RQSTADDR(requested_addr=self.your_client_ip)
     self.server_id = SERVID(server_id=self.server_id)
     
     request[DHCP].options = [self.msgtype, self.clientmac, self.server_id, 
                              self.rqstaddr, self.hostname]
     if self.vendcls_id is not None:
         request[DHCP].options.append(self.vendclsid)
         
     request[DHCP].options.append(self.end)
     log_scapy.info("Send the DHCP Request")
     # request.show()
     sendp(request,iface=self._iface )
         
     raise self.WAITING()   
Esempio n. 2
0
 def SEND_DISCOVER(self):
     # record retry times
     self._cur_retry += 1
     
     discover = Ether()/IP()/UDP(sport=68, dport=67)/BOOTP(xid=self.xid)/DHCP()
     
     # discover[DHCP].options = []
     
     # discover[Ether].src    = self.mac
     discover[Ether].dst    = 'ff:ff:ff:ff:ff:ff'
     discover[IP].src       = '0.0.0.0'
     discover[IP].dst       = '255.255.255.255'
     discover[BOOTP].chaddr = self.mac
     discover[BOOTP].flags  = self.broadcast
     
    
    
     self.msgtype    = MSGTYPE(code=53, len=1, type=1)
     self.autoconfig = AUTOCONFIG(autoconfig=1) 
     self.clientmac  = CLIENTID(clientmac=self.mac)
     self.rqstaddr   = RQSTADDR()
     self.hostname   = HOSTNAME(hostname=self.hostname)
     self.end        = END(code=255)
     
     default_options = [self.msgtype, self.clientmac, self.autoconfig, 
                               self.rqstaddr, self.hostname]        
                        
     append_options = []                            
     if self._dhcp_options:
     
         for option in self._dhcp_options:
             for i in range(len(default_options)):                    
                 if option.__class__.__name__ == default_options[i].__class__.__name__:
                     default_options[i] = option
                     
             else:
                 append_options.append(option)
                 
         
     
     
     discover[DHCP].options = default_options + append_options
     if self.vendcls_id is not None:
        self.vendclsid  = VENDCLSID(vendor_class_id=self.vendcls_id)
        discover[DHCP].options.append(self.vendclsid)
     discover[DHCP].options.append(self.end)
     
     log_scapy.info("Send the DHCP Discover.")
     sendp(discover,iface=self._iface )
         
     raise self.WAITING()
Esempio n. 3
0
 def BEGIN(self):
     
     log_scapy.info('This is the beginning of the automata.')  
     raise self.SEND_DISCOVER()
Esempio n. 4
0
 def RCVD_ACK(self):
     # raise self.WAITING()
     log_scapy.info('This is the END state of the automata.')
Esempio n. 5
0
 def ERROR(self):
     log_scapy.info("This is ERROR state:Time out.")