Exemple #1
0
 def build_arp_packet(self, opcode, hwdst, protodst):
     arppkt = arp.arp()
     arppkt.protosrc = self.myip.copy()
     arppkt.protodst = protodst.copy()
     arppkt.hwsrc = self.mymac.copy()
     arppkt.opcode = opcode
     return arppkt
Exemple #2
0
 def build_arp_packet(self, opcode, hwdst, protodst):
     arppkt = arp.arp()
     arppkt.protosrc = self.myip.copy()
     arppkt.protodst = protodst.copy()
     arppkt.hwsrc = self.mymac.copy()
     arppkt.opcode = opcode
     return arppkt
Exemple #3
0
def create_arp_request(srcMAC, srcIP, dstIP):
    arpRequest = arp()
    arpRequest.hwdst = ETHER_ANY
#    arpRequest.hwdst = ETHER_BROADCAST
    arpRequest.protodst = dstIP
    arpRequest.hwsrc = srcMAC
    arpRequest.protosrc = srcIP
    arpRequest.hwtype = arpRequest.HW_TYPE_ETHERNET
    arpRequest.hwlen = 6
    arpRequest.protolen = 4
    arpRequest.opcode = arpRequest.REQUEST

    ethRequest = ethernet()
    ethRequest.dst = ETHER_BROADCAST
    ethRequest.src = srcMAC
    ethRequest.type = ethernet.ARP_TYPE
    ethRequest.set_payload(arpRequest)

    return ethRequest.tostring()
Exemple #4
0
def create_arp_request(srcMAC, srcIP, dstIP):
    arpRequest = arp()
    arpRequest.hwdst = ETHER_ANY
    #    arpRequest.hwdst = ETHER_BROADCAST
    arpRequest.protodst = dstIP
    arpRequest.hwsrc = srcMAC
    arpRequest.protosrc = srcIP
    arpRequest.hwtype = arpRequest.HW_TYPE_ETHERNET
    arpRequest.hwlen = 6
    arpRequest.protolen = 4
    arpRequest.opcode = arpRequest.REQUEST

    ethRequest = ethernet()
    ethRequest.dst = ETHER_BROADCAST
    ethRequest.src = srcMAC
    ethRequest.type = ethernet.ARP_TYPE
    ethRequest.set_payload(arpRequest)

    return ethRequest.tostring()
Exemple #5
0
def create_virtual_arp_response(packet, srcMAC, srcIP):
    arpReqHeader = packet.find('arp')

    arpResponse = arp()
    arpResponse.hwdst = arpReqHeader.hwsrc
    arpResponse.protodst = arpReqHeader.protosrc
    arpResponse.hwsrc = srcMAC
    arpResponse.protosrc = srcIP
    arpResponse.hwtype = arpReqHeader.HW_TYPE_ETHERNET
    arpResponse.hwlen = 6
    arpResponse.prototype = arpResponse.PROTO_TYPE_IP
    arpResponse.protolen = 4
    arpResponse.opcode = arpResponse.REPLY

    ethResponse = ethernet()
    ethResponse.dst = packet.src
    ethResponse.src = srcMAC
    ethResponse.type = ethernet.ARP_TYPE
    ethResponse.set_payload(arpResponse)

    return ethResponse.tostring()
Exemple #6
0
def create_virtual_arp_response(packet, srcMAC, srcIP):
    arpReqHeader = packet.find('arp')

    arpResponse = arp()
    arpResponse.hwdst = arpReqHeader.hwsrc
    arpResponse.protodst = arpReqHeader.protosrc
    arpResponse.hwsrc = srcMAC
    arpResponse.protosrc = srcIP
    arpResponse.hwtype = arpReqHeader.HW_TYPE_ETHERNET
    arpResponse.hwlen = 6
    arpResponse.prototype = arpResponse.PROTO_TYPE_IP
    arpResponse.protolen = 4
    arpResponse.opcode = arpResponse.REPLY

    ethResponse = ethernet()
    ethResponse.dst = packet.src
    ethResponse.src = srcMAC
    ethResponse.type = ethernet.ARP_TYPE
    ethResponse.set_payload(arpResponse)

    return ethResponse.tostring()