예제 #1
0
 def testTCP(self):
     eth = ethernet()
     eth.dst  = '\xca\xfe\xde\xad\xbe\xef'
     eth.src  = '\xca\xfe\xde\xad\xd0\xd0'
     eth.type = ethernet.IP_TYPE 
     ipstr = '\x45\x00\x00\x34\x1c\x1b\x40\x00\x40\x06\x34\xdf\xab\x40\x4a\x31\xac\x18\x48\x40'
     iparr = array('B',ipstr)
     tcpstr = '\x03\x20\x08\x01\xd2\x9d\x61\x67\x57\x37\xc3\x0f\x80\x10\x7e\x82\xf2\x6e\x00\x00\x01\x01\x08\x0a\xf3\xb5\x9c\x36\x18\xa2\x1a\x06'
     tcparr = array('B',tcpstr)
     tcph = ethernet(array('B', eth.tostring()) + iparr + tcparr).find('tcp')
     assert(tcph)
     assert(tcph.parsed)
     assert(tcph.srcport == 800)
     assert(tcph.dstport == 2049)
     assert(tcph.seq     == 0xd29d6167)
     assert(tcph.ack     == 0x5737c30f)
     assert(tcph.off     == 8)
     assert(tcph.res     == 0)
     assert(not tcph.flags & tcp.CWR)
     assert(not tcph.flags & tcp.ECN)
     assert(not tcph.flags & tcp.URG)
     assert(tcph.flags & tcp.ACK)
     assert(not tcph.flags & tcp.PUSH)
     assert(not tcph.flags & tcp.RST)
     assert(not tcph.flags & tcp.SYN)
     assert(not tcph.flags & tcp.FIN)
     assert(tcph.win == 32386)
     assert(tcph.csum == 0xf26e)
     assert(tcph.checksum() == tcph.csum)
     assert(len(tcph.options) == 3)                            
     assert(tcph.options[0].type == tcp_opt.NOP)
     assert(tcph.options[1].type == tcp_opt.NOP)
     assert(tcph.options[2].type == tcp_opt.TSOPT)
     assert(tcph.options[2].val[0] == 4088765494)
예제 #2
0
 def testTCP(self):
     eth = ethernet()
     eth.dst = '\xca\xfe\xde\xad\xbe\xef'
     eth.src = '\xca\xfe\xde\xad\xd0\xd0'
     eth.type = ethernet.IP_TYPE
     ipstr = '\x45\x00\x00\x34\x1c\x1b\x40\x00\x40\x06\x34\xdf\xab\x40\x4a\x31\xac\x18\x48\x40'
     iparr = array('B', ipstr)
     tcpstr = '\x03\x20\x08\x01\xd2\x9d\x61\x67\x57\x37\xc3\x0f\x80\x10\x7e\x82\xf2\x6e\x00\x00\x01\x01\x08\x0a\xf3\xb5\x9c\x36\x18\xa2\x1a\x06'
     tcparr = array('B', tcpstr)
     tcph = ethernet(array('B', eth.tostring()) + iparr +
                     tcparr).find('tcp')
     assert (tcph)
     assert (tcph.parsed)
     assert (tcph.srcport == 800)
     assert (tcph.dstport == 2049)
     assert (tcph.seq == 0xd29d6167)
     assert (tcph.ack == 0x5737c30f)
     assert (tcph.off == 8)
     assert (tcph.res == 0)
     assert (not tcph.flags & tcp.CWR)
     assert (not tcph.flags & tcp.ECN)
     assert (not tcph.flags & tcp.URG)
     assert (tcph.flags & tcp.ACK)
     assert (not tcph.flags & tcp.PUSH)
     assert (not tcph.flags & tcp.RST)
     assert (not tcph.flags & tcp.SYN)
     assert (not tcph.flags & tcp.FIN)
     assert (tcph.win == 32386)
     assert (tcph.csum == 0xf26e)
     assert (tcph.checksum() == tcph.csum)
     assert (len(tcph.options) == 3)
     assert (tcph.options[0].type == tcp_opt.NOP)
     assert (tcph.options[1].type == tcp_opt.NOP)
     assert (tcph.options[2].type == tcp_opt.TSOPT)
     assert (tcph.options[2].val[0] == 4088765494)
예제 #3
0
    def testIPv4Edge(self):
        eth = ethernet()
        eth.dst = '\xca\xfe\xde\xad\xbe\xef'
        eth.src = '\xca\xfe\xde\xad\xd0\xd0'
        eth.type = ethernet.IP_TYPE

        ipstr = '\x46\x00\x00\x34\x1c\x1b\x40\x00\x40\x06\x34\xdf\xab\x40\x4a\x31\xac\x18\x48\x40'
        iparr = array('B', ipstr)
        iph = ethernet(array('B', eth.tostring()) + iparr).find('ipv4')
        assert (not iph)

        ipstr = '\x45\x00\x00\x34\x1c\x1b\x40\x00\x40\x06\x34\xdf\xab\x40\x4a\x310'
        iparr = array('B', ipstr)
        iph = ethernet(array('B', eth.tostring()) + iparr).find('ipv4')
        assert (not iph)
    def testIPv4Edge(self):
        eth = ethernet()
        eth.dst  = '\xca\xfe\xde\xad\xbe\xef'
        eth.src  = '\xca\xfe\xde\xad\xd0\xd0'
        eth.type = ethernet.IP_TYPE 

        ipstr = '\x46\x00\x00\x34\x1c\x1b\x40\x00\x40\x06\x34\xdf\xab\x40\x4a\x31\xac\x18\x48\x40'
        iparr = array('B',ipstr)
        iph = ethernet(array('B', eth.tostring()) + iparr).find('ipv4')
        assert(not iph)

        ipstr = '\x45\x00\x00\x34\x1c\x1b\x40\x00\x40\x06\x34\xdf\xab\x40\x4a\x310'
        iparr = array('B',ipstr)
        iph = ethernet(array('B', eth.tostring()) + iparr).find('ipv4')
        assert(not iph)
예제 #5
0
 def testVlanRemove(self):
     eth = ethernet(vlan_str)
     vlanh = eth.find('vlan') 
     eth.type = vlanh.eth_type
     eth.set_payload(vlanh.next)
     self.failUnless(len(eth.tostring()) == (len(vlan_str) - 4))
     self.failUnless(eth.tostring() == no_vlan_str)
예제 #6
0
    def fullUDPPacket(self):    
        eth = ethernet(array('B',large_udp))   
        udph = eth.find('udp')
        iph  = eth.find('ipv4')
        assert(udph)
        assert(iph)
        assert(udph.srcport == 68)
        assert(udph.dstport == 67)
        assert(udph.len     == 556)
        assert(udph.csum    == 0x5ee2)
        assert(udph.checksum() == udph.csum)
        assert(len(udph.payload) == udph.len - 8)
        assert(udph.tostring() == large_udp[34:] )
        dhcph = eth.find('dhcp')

        assert(dhcph)
        assert(dhcph.op    == 1)
        assert(dhcph.htype == 1)
        assert(dhcph.hlen  == 6)
        assert(dhcph.hops  == 0)
        assert(dhcph.xid   == 0x9514f72d)
        assert(dhcph.secs  == 0)
        assert(dhcph.flags == 0)
        assert(dhcph.ciaddr == 0)
        assert(dhcph.yiaddr == 0)
        assert(dhcph.siaddr == 0)
        assert(dhcph.giaddr == 0)
        assert(array_to_octstr(dhcph.chaddr[:6]) == '00:1d:09:21:7f:14')
        assert(len(dhcph.parsedOptions.keys()) == 4)
def testVlanRemove():
    eth = ethernet(vlan_str)
    vlanh = eth.find('vlan') 
    eth.type = vlanh.eth_type
    eth.set_payload(vlanh.next)
    nox_test_assert(len(eth.tostring()) == (len(vlan_str) - 4))
    nox_test_assert(eth.tostring() == no_vlan_str)
예제 #8
0
def testVlanRemove():
    eth = ethernet(vlan_str)
    vlanh = eth.find('vlan')
    eth.type = vlanh.eth_type
    eth.set_payload(vlanh.next)
    nox_test_assert(len(eth.tostring()) == (len(vlan_str) - 4))
    nox_test_assert(eth.tostring() == no_vlan_str)
예제 #9
0
def fullUDPPacket():
    eth = ethernet(array("B", large_udp))
    udph = eth.find("udp")
    iph = eth.find("ipv4")
    nox_test_assert(udph, "udp parse")
    nox_test_assert(iph)
    nox_test_assert(udph.srcport == 68)
    nox_test_assert(udph.dstport == 67)
    nox_test_assert(udph.len == 556)
    nox_test_assert(udph.csum == 0x5EE2)
    nox_test_assert(udph.checksum() == udph.csum)
    nox_test_assert(len(udph.payload) == udph.len - 8)
    nox_test_assert(udph.tostring() == large_udp[34:])
    dhcph = eth.find("dhcp")

    nox_test_assert(dhcph)
    nox_test_assert(dhcph.op == 1)
    nox_test_assert(dhcph.htype == 1)
    nox_test_assert(dhcph.hlen == 6)
    nox_test_assert(dhcph.hops == 0)
    nox_test_assert(dhcph.xid == 0x9514F72D)
    nox_test_assert(dhcph.secs == 0)
    nox_test_assert(dhcph.flags == 0)
    nox_test_assert(dhcph.ciaddr == 0)
    nox_test_assert(dhcph.yiaddr == 0)
    nox_test_assert(dhcph.siaddr == 0)
    nox_test_assert(dhcph.giaddr == 0)
    nox_test_assert(array_to_octstr(dhcph.chaddr[:6]) == "00:1d:09:21:7f:14")
    nox_test_assert(len(dhcph.parsedOptions.keys()) == 4)
예제 #10
0
 def testVlanRemove(self):
     eth = ethernet(vlan_str)
     vlanh = eth.find('vlan')
     eth.type = vlanh.eth_type
     eth.set_payload(vlanh.next)
     self.failUnless(len(eth.tostring()) == (len(vlan_str) - 4))
     self.failUnless(eth.tostring() == no_vlan_str)
예제 #11
0
 def testLLDP(self):
     eth = ethernet(lldp_str)
     lldph = eth.find('lldp')
     assert(lldph)
     assert(len(lldph.tlvs) == 17) 
     assert(array_to_octstr(lldph.tlvs[0].id) == "00:01:30:f9:ad:a0")
     assert(lldph.tlvs[1].id.tostring() == '1/1')
     assert(lldph.tlvs[2].ttl == 120)
 def testLLDP(self):
     eth = ethernet(lldp_str)
     lldph = eth.find('lldp')
     assert(lldph)
     assert(len(lldph.tlvs) == 17) 
     assert(array_to_octstr(lldph.tlvs[0].id) == "00:01:30:f9:ad:a0")
     assert(lldph.tlvs[1].id.tostring() == '1/1')
     assert(lldph.tlvs[2].ttl == 120)
def testVlan():
    eth = ethernet(vlan_str)
    vlanh = eth.find('vlan') 
    nox_test_assert(vlanh, 'vlan parse')
    nox_test_assert(eth.type       == ethernet.VLAN_TYPE)
    nox_test_assert(vlanh.eth_type == ethernet.ARP_TYPE)
    nox_test_assert(vlanh.pcp      == 6)
    nox_test_assert(vlanh.cfi      == 0)
    nox_test_assert(vlanh.id       == 570)
예제 #14
0
 def testVlan(self):
     eth = ethernet(vlan_str)
     vlanh = eth.find('vlan') 
     self.failUnless(vlanh)
     self.failUnless(eth.type       == ethernet.VLAN_TYPE)
     self.failUnless(vlanh.eth_type == ethernet.ARP_TYPE)
     self.failUnless(vlanh.pcp      == 6)
     self.failUnless(vlanh.cfi      == 0)
     self.failUnless(vlanh.id       == 570)
예제 #15
0
def testVlan():
    eth = ethernet(vlan_str)
    vlanh = eth.find('vlan')
    nox_test_assert(vlanh, 'vlan parse')
    nox_test_assert(eth.type == ethernet.VLAN_TYPE)
    nox_test_assert(vlanh.eth_type == ethernet.ARP_TYPE)
    nox_test_assert(vlanh.pcp == 6)
    nox_test_assert(vlanh.cfi == 0)
    nox_test_assert(vlanh.id == 570)
예제 #16
0
 def testVlan(self):
     eth = ethernet(vlan_str)
     vlanh = eth.find('vlan')
     self.failUnless(vlanh)
     self.failUnless(eth.type == ethernet.VLAN_TYPE)
     self.failUnless(vlanh.eth_type == ethernet.ARP_TYPE)
     self.failUnless(vlanh.pcp == 6)
     self.failUnless(vlanh.cfi == 0)
     self.failUnless(vlanh.id == 570)
def testICMPEcho():
    eth = ethernet(icmp_echo_str)
    icmph = eth.find('icmp')
    nox_test_assert(icmph, 'icmp parse')
    nox_test_assert(icmph.type == 8)
    nox_test_assert(icmph.csum == 0x2bde)
    echoh = eth.find('echo')
    nox_test_assert(echoh)
    nox_test_assert(echoh.id  == 0x6d73)
    nox_test_assert(echoh.seq == 1)
예제 #18
0
def testICMPEcho():
    eth = ethernet(icmp_echo_str)
    icmph = eth.find('icmp')
    nox_test_assert(icmph, 'icmp parse')
    nox_test_assert(icmph.type == 8)
    nox_test_assert(icmph.csum == 0x2bde)
    echoh = eth.find('echo')
    nox_test_assert(echoh)
    nox_test_assert(echoh.id == 0x6d73)
    nox_test_assert(echoh.seq == 1)
예제 #19
0
 def testICMPEcho(self):
     eth = ethernet(icmp_echo_str)
     icmph = eth.find('icmp')
     assert (icmph)
     assert (icmph.type == 8)
     assert (icmph.csum == 0x2bde)
     echoh = eth.find('echo')
     assert (echoh)
     assert (echoh.id == 0x6d73)
     assert (echoh.seq == 1)
 def testICMPEcho(self):
     eth = ethernet(icmp_echo_str)
     icmph = eth.find('icmp')
     assert(icmph)
     assert(icmph.type == 8)
     assert(icmph.csum == 0x2bde)
     echoh = eth.find('echo')
     assert(echoh)
     assert(echoh.id  == 0x6d73)
     assert(echoh.seq == 1)
    def testEthernetConstruct(self):
        eth = ethernet(ether_str)
        assert(eth)
        assert(array_to_octstr(eth.dst) == '00:00:0c:07:ac:4a')
        assert(array_to_octstr(eth.src) == '00:07:e9:4c:a9:eb')
        assert(eth.type == ethernet.IP_TYPE)
        assert(eth.find('ipv4'))
        assert(eth.tostring() == ether_str)

        eth = ethernet()
        eth.dst = octstr_to_array('00:00:0c:07:ac:4a')
        eth.src = octstr_to_array('00:07:e9:4c:a9:eb')
        eth.type = ethernet.IP_TYPE
        eth.set_payload(ip_str)
        assert(eth.tostring() == ether_str)

        iph = ipv4(arr=ip_str)
        eth.set_payload(iph)
        assert(eth.next.tostring() == iph.tostring())
        assert(eth.tostring() == ether_str)
예제 #22
0
    def testEthernetConstruct(self):
        eth = ethernet(ether_str)
        assert (eth)
        assert (array_to_octstr(eth.dst) == '00:00:0c:07:ac:4a')
        assert (array_to_octstr(eth.src) == '00:07:e9:4c:a9:eb')
        assert (eth.type == ethernet.IP_TYPE)
        assert (eth.find('ipv4'))
        assert (eth.tostring() == ether_str)

        eth = ethernet()
        eth.dst = octstr_to_array('00:00:0c:07:ac:4a')
        eth.src = octstr_to_array('00:07:e9:4c:a9:eb')
        eth.type = ethernet.IP_TYPE
        eth.set_payload(ip_str)
        assert (eth.tostring() == ether_str)

        iph = ipv4(arr=ip_str)
        eth.set_payload(iph)
        assert (eth.next.tostring() == iph.tostring())
        assert (eth.tostring() == ether_str)
예제 #23
0
    def testEthernetConstruct(self):
        eth = ethernet(ether_str)
        assert eth
        assert array_to_octstr(eth.dst) == "00:00:0c:07:ac:4a"
        assert array_to_octstr(eth.src) == "00:07:e9:4c:a9:eb"
        assert eth.type == ethernet.IP_TYPE
        assert eth.find("ipv4")
        assert eth.tostring() == ether_str

        eth = ethernet()
        eth.dst = octstr_to_array("00:00:0c:07:ac:4a")
        eth.src = octstr_to_array("00:07:e9:4c:a9:eb")
        eth.type = ethernet.IP_TYPE
        eth.set_payload(ip_str)
        assert eth.tostring() == ether_str

        iph = ipv4(arr=ip_str)
        eth.set_payload(iph)
        assert eth.next.tostring() == iph.tostring()
        assert eth.tostring() == ether_str
 def testEthernet(self):
     eth = ethernet(array('B','\x00'))
     assert(not eth.parsed)
     pstr = '\xca\xfe\xde\xad\xbe\xef\xca\xfe\xde\xad\xd0\xd0\xff\xff'
     parr = array('B', pstr)
     eth = ethernet(parr)
     assert(eth.parsed)
     assert(eth.tostring() == pstr)
     parr = array('B', pstr + '\x00')
     eth = ethernet(parr)
     assert(eth.parsed)
     for i in xrange(0,255):
         nstr = '%s%c' % (pstr,i)
         parr = array('B',nstr)
         eth = ethernet(parr)
         assert(eth.parse)
     eth = ethernet()
     eth.dst  = '\xca\xfe\xde\xad\xbe\xef'
     eth.src  = '\xca\xfe\xde\xad\xd0\xd0'
     eth.type = 0xffff 
     assert(eth.tostring() == pstr)
예제 #25
0
 def testEthernet(self):
     eth = ethernet(array('B', '\x00'))
     assert (not eth.parsed)
     pstr = '\xca\xfe\xde\xad\xbe\xef\xca\xfe\xde\xad\xd0\xd0\xff\xff'
     parr = array('B', pstr)
     eth = ethernet(parr)
     assert (eth.parsed)
     assert (eth.tostring() == pstr)
     parr = array('B', pstr + '\x00')
     eth = ethernet(parr)
     assert (eth.parsed)
     for i in xrange(0, 255):
         nstr = '%s%c' % (pstr, i)
         parr = array('B', nstr)
         eth = ethernet(parr)
         assert (eth.parse)
     eth = ethernet()
     eth.dst = '\xca\xfe\xde\xad\xbe\xef'
     eth.src = '\xca\xfe\xde\xad\xd0\xd0'
     eth.type = 0xffff
     assert (eth.tostring() == pstr)
예제 #26
0
 def testEthernet(self):
     eth = ethernet(array("B", "\x00"))
     assert not eth.parsed
     pstr = "\xca\xfe\xde\xad\xbe\xef\xca\xfe\xde\xad\xd0\xd0\xff\xff"
     parr = array("B", pstr)
     eth = ethernet(parr)
     assert eth.parsed
     assert eth.tostring() == pstr
     parr = array("B", pstr + "\x00")
     eth = ethernet(parr)
     assert eth.parsed
     for i in xrange(0, 255):
         nstr = "%s%c" % (pstr, i)
         parr = array("B", nstr)
         eth = ethernet(parr)
         assert eth.parse
     eth = ethernet()
     eth.dst = "\xca\xfe\xde\xad\xbe\xef"
     eth.src = "\xca\xfe\xde\xad\xd0\xd0"
     eth.type = 0xFFFF
     assert eth.tostring() == pstr
def testVlanAdd():
    eth = ethernet(vlan_str)
    vlanh = eth.find('vlan') 
    arph  = eth.find('arp') 
    nox_test_assert(arph)
    eth.type = vlanh.eth_type
    eth.set_payload(vlanh.next)
    nox_test_assert(len(eth.tostring()) == (len(vlan_str) - 4))
    nox_test_assert(eth.tostring() == no_vlan_str)
    vlanh = vlan(vlan_hdr)
    vlanh.set_payload(arph)
    eth.set_payload(vlanh)
    eth.type = ethernet.VLAN_TYPE
    nox_test_assert(eth.tostring() == vlan_str)
예제 #28
0
 def testVlanAdd(self):
     eth = ethernet(vlan_str)
     vlanh = eth.find('vlan') 
     arph  = eth.find('arp') 
     self.failUnless(arph)
     eth.type = vlanh.eth_type
     eth.set_payload(vlanh.next)
     self.failUnless(len(eth.tostring()) == (len(vlan_str) - 4))
     self.failUnless(eth.tostring() == no_vlan_str)
     vlanh = vlan(vlan_hdr)
     vlanh.set_payload(arph)
     eth.set_payload(vlanh)
     eth.type = ethernet.VLAN_TYPE
     self.failUnless(eth.tostring() == vlan_str)
예제 #29
0
 def testVlanAdd(self):
     eth = ethernet(vlan_str)
     vlanh = eth.find('vlan')
     arph = eth.find('arp')
     self.failUnless(arph)
     eth.type = vlanh.eth_type
     eth.set_payload(vlanh.next)
     self.failUnless(len(eth.tostring()) == (len(vlan_str) - 4))
     self.failUnless(eth.tostring() == no_vlan_str)
     vlanh = vlan(vlan_hdr)
     vlanh.set_payload(arph)
     eth.set_payload(vlanh)
     eth.type = ethernet.VLAN_TYPE
     self.failUnless(eth.tostring() == vlan_str)
예제 #30
0
def testVlanAdd():
    eth = ethernet(vlan_str)
    vlanh = eth.find('vlan')
    arph = eth.find('arp')
    nox_test_assert(arph)
    eth.type = vlanh.eth_type
    eth.set_payload(vlanh.next)
    nox_test_assert(len(eth.tostring()) == (len(vlan_str) - 4))
    nox_test_assert(eth.tostring() == no_vlan_str)
    vlanh = vlan(vlan_hdr)
    vlanh.set_payload(arph)
    eth.set_payload(vlanh)
    eth.type = ethernet.VLAN_TYPE
    nox_test_assert(eth.tostring() == vlan_str)
예제 #31
0
 def testIPv4(self):
     eth = ethernet()
     eth.dst = '\xca\xfe\xde\xad\xbe\xef'
     eth.src = '\xca\xfe\xde\xad\xd0\xd0'
     eth.type = ethernet.IP_TYPE
     ipstr = '\x45\x00\x00\x34\x1c\x1b\x40\x00\x40\x06\x34\xdf\xab\x40\x4a\x31\xac\x18\x48\x40'
     iparr = array('B', ipstr)
     iph = ethernet(array('B', eth.tostring()) + iparr).find('ipv4')
     assert (iph)
     assert (iph.parsed)
     assert (iph.v == 4)
     assert (iph.hl == 5)
     assert (iph.tos == 0)
     assert (iph.iplen == 52)
     assert (iph.id == 0x1c1b)
     assert (iph.flags == 0x02)
     assert (iph.flags == ipv4.DF_FLAG)
     assert (iph.frag == 0)
     assert (iph.ttl == 64)
     assert (iph.protocol == 0x06)
     assert (iph.csum == 0x34df)
     assert (iph.checksum() == iph.csum)
     assert (ip_to_str(iph.srcip) == "171.64.74.49")
     assert (ip_to_str(iph.dstip) == "172.24.72.64")
 def testIPv4(self):
     eth = ethernet()
     eth.dst  = '\xca\xfe\xde\xad\xbe\xef'
     eth.src  = '\xca\xfe\xde\xad\xd0\xd0'
     eth.type = ethernet.IP_TYPE 
     ipstr = '\x45\x00\x00\x34\x1c\x1b\x40\x00\x40\x06\x34\xdf\xab\x40\x4a\x31\xac\x18\x48\x40'
     iparr = array('B',ipstr)
     iph = ethernet(array('B', eth.tostring()) + iparr).find('ipv4')
     assert(iph)
     assert(iph.parsed  )
     assert(iph.v     == 4)
     assert(iph.hl    == 5)
     assert(iph.tos   == 0)
     assert(iph.iplen == 52)
     assert(iph.id    == 0x1c1b)
     assert(iph.flags == 0x02)
     assert(iph.flags == ipv4.DF_FLAG)
     assert(iph.frag  == 0)
     assert(iph.ttl   == 64)
     assert(iph.protocol == 0x06)
     assert(iph.csum  == 0x34df)
     assert(iph.checksum()  == iph.csum)
     assert(ip_to_str(iph.srcip) == "171.64.74.49")
     assert(ip_to_str(iph.dstip) == "172.24.72.64")
예제 #33
0
def testVlanARP():
    eth = ethernet(vlan_str)
    vlanh = eth.find('vlan')
    arph = eth.find('arp')
    nox_test_assert(vlanh)
    nox_test_assert(arph)
    nox_test_assert(arph.hwtype == arp.HW_TYPE_ETHERNET)
    nox_test_assert(arph.prototype == arp.PROTO_TYPE_IP)
    nox_test_assert(arph.hwlen == 6)
    nox_test_assert(arph.protolen == 4)
    nox_test_assert(array_to_octstr(arph.hwsrc) == "00:19:e1:e2:03:53")
    nox_test_assert(array_to_octstr(arph.hwdst) == "00:19:e1:e2:03:53")
    nox_test_assert(arph.opcode == 1)
    nox_test_assert(ip_to_str(arph.protosrc) == "172.28.64.126")
    nox_test_assert(ip_to_str(arph.protodst) == "172.28.64.1")
def testVlanARP():
    eth = ethernet(vlan_str)
    vlanh = eth.find('vlan') 
    arph  = eth.find('arp') 
    nox_test_assert(vlanh)
    nox_test_assert(arph)
    nox_test_assert(arph.hwtype    == arp.HW_TYPE_ETHERNET)
    nox_test_assert(arph.prototype == arp.PROTO_TYPE_IP)
    nox_test_assert(arph.hwlen     == 6)
    nox_test_assert(arph.protolen  == 4)
    nox_test_assert(array_to_octstr(arph.hwsrc) == "00:19:e1:e2:03:53")
    nox_test_assert(array_to_octstr(arph.hwdst) == "00:19:e1:e2:03:53")
    nox_test_assert(arph.opcode == 1)
    nox_test_assert(ip_to_str(arph.protosrc) == "172.28.64.126")
    nox_test_assert(ip_to_str(arph.protodst) == "172.28.64.1")
예제 #35
0
 def testVlanARP(self):
     eth = ethernet(vlan_str)
     vlanh = eth.find('vlan') 
     arph  = eth.find('arp') 
     self.failUnless(vlanh)
     self.failUnless(arph)
     self.failUnless(arph.hwtype    == arp.HW_TYPE_ETHERNET)
     self.failUnless(arph.prototype == arp.PROTO_TYPE_IP)
     self.failUnless(arph.hwlen     == 6)
     self.failUnless(arph.protolen  == 4)
     self.failUnless(array_to_octstr(arph.hwsrc) == "00:19:e1:e2:03:53")
     self.failUnless(array_to_octstr(arph.hwdst) == "00:19:e1:e2:03:53")
     self.failUnless(arph.opcode == 1)
     self.failUnless(ip_to_str(arph.protosrc) == "172.28.64.126")
     self.failUnless(ip_to_str(arph.protodst) == "172.28.64.1")
예제 #36
0
 def testVlanARP(self):
     eth = ethernet(vlan_str)
     vlanh = eth.find('vlan')
     arph = eth.find('arp')
     self.failUnless(vlanh)
     self.failUnless(arph)
     self.failUnless(arph.hwtype == arp.HW_TYPE_ETHERNET)
     self.failUnless(arph.prototype == arp.PROTO_TYPE_IP)
     self.failUnless(arph.hwlen == 6)
     self.failUnless(arph.protolen == 4)
     self.failUnless(array_to_octstr(arph.hwsrc) == "00:19:e1:e2:03:53")
     self.failUnless(array_to_octstr(arph.hwdst) == "00:19:e1:e2:03:53")
     self.failUnless(arph.opcode == 1)
     self.failUnless(ip_to_str(arph.protosrc) == "172.28.64.126")
     self.failUnless(ip_to_str(arph.protodst) == "172.28.64.1")
예제 #37
0
    def testICMPUnreach(self):
        eth = ethernet(icmp_unreach_str)
        icmph = eth.find('icmp')
        assert (icmph)
        unreach = eth.find('unreach')
        assert (unreach)
        iph = unreach.find('ipv4')
        assert (iph)
        udph = unreach.find('udp')
        assert (udph)

        assert (icmph.type == 3)
        assert (icmph.code == 3)
        assert (icmph.csum == 0x8081)

        assert (ip_to_str(iph.srcip) == "192.168.1.12")
        assert (ip_to_str(iph.dstip) == "192.168.1.14")

        assert (udph.srcport == 2006)
        assert (udph.dstport == 5322)
예제 #38
0
def test_fullDHCPPacket():    
    eth = ethernet(array('B',large_dhcp))   
    udph = eth.find('udp')
    iph  = eth.find('ipv4')
    dhcph = eth.find('dhcp')

    nox_test_assert(dhcph, 'dhcp')
    nox_test_assert(dhcph.op    == 1, 'dhcp')
    nox_test_assert(dhcph.htype == 1, 'dhcp')
    nox_test_assert(dhcph.hlen  == 6, 'dhcp')
    nox_test_assert(dhcph.hops  == 0, 'dhcp')
    nox_test_assert(dhcph.xid   == 0x9514f72d, 'dhcp')
    nox_test_assert(dhcph.secs  == 0, 'dhcp')
    nox_test_assert(dhcph.flags == 0, 'dhcp')
    nox_test_assert(dhcph.ciaddr == 0, 'dhcp')
    nox_test_assert(dhcph.yiaddr == 0, 'dhcp')
    nox_test_assert(dhcph.siaddr == 0, 'dhcp')
    nox_test_assert(dhcph.giaddr == 0, 'dhcp')
    nox_test_assert(array_to_octstr(dhcph.chaddr[:6]) == '00:1d:09:21:7f:14', 'dhcp')
    nox_test_assert(len(dhcph.parsedOptions.keys()) == 4, 'dhcp')
    def testICMPUnreach(self):
        eth = ethernet(icmp_unreach_str)
        icmph = eth.find('icmp')
        assert(icmph)
        unreach = eth.find('unreach')
        assert(unreach)
        iph = unreach.find('ipv4')
        assert(iph)
        udph = unreach.find('udp')
        assert(udph)

        assert(icmph.type == 3)
        assert(icmph.code == 3)
        assert(icmph.csum == 0x8081)

        assert(ip_to_str(iph.srcip) == "192.168.1.12")
        assert(ip_to_str(iph.dstip) == "192.168.1.14")

        assert(udph.srcport == 2006)
        assert(udph.dstport == 5322)
예제 #40
0
    def fullTCPPacket(self):
        eth = ethernet(array('B', large_tcp))
        tcph = eth.find('tcp')
        iph = eth.find('ipv4')
        assert (tcph)
        assert (iph)
        self.checkFullTcpHeader(tcph)
        tcp2 = tcp(arr=tcph.tostring(), prev=None)
        assert (tcph.checksum() == tcph.csum)
        self.checkFullTcpHeader(tcp2)

        # check out some edge conditions
        tcp2 = tcp(arr=tcph.tostring()[:12])
        assert (not tcp2.parsed)
        tcph.off = 0
        tcp2 = tcp(arr=tcph.tostring())
        assert (not tcp2.parsed)
        tcph.off = 0xff
        tcp2 = tcp(arr=tcph.tostring())
        tcp2 = tcp(arr=tcph.tostring()[:21])
        assert (not tcp2.parsed)
        tcph.off = 0x06
        tcp2 = tcp(arr=tcph.tostring()[:25])
        assert (not tcp2.parsed)
예제 #41
0
    def fullTCPPacket(self):
        eth = ethernet(array('B',large_tcp))   
        tcph = eth.find('tcp')
        iph  = eth.find('ipv4')
        assert(tcph)
        assert(iph)
        self.checkFullTcpHeader(tcph)
        tcp2 = tcp(arr=tcph.tostring(),prev=None)
        assert(tcph.checksum() == tcph.csum)
        self.checkFullTcpHeader(tcp2)

        # check out some edge conditions
        tcp2 = tcp(arr=tcph.tostring()[:12])
        assert(not tcp2.parsed)
        tcph.off = 0
        tcp2 = tcp(arr=tcph.tostring())
        assert(not tcp2.parsed)
        tcph.off = 0xff 
        tcp2 = tcp(arr=tcph.tostring())
        tcp2 = tcp(arr=tcph.tostring()[:21])
        assert(not tcp2.parsed)
        tcph.off = 0x06 
        tcp2 = tcp(arr=tcph.tostring()[:25])
        assert(not tcp2.parsed)
def testEAPOL():
    eth = ethernet(ether_eapol)
    nox_test_assert(eth.tostring() == ether_eapol, "eapol")
 def testEAPOL(self):
     eth = ethernet(ether_eapol)
     assert(eth.tostring() == ether_eapol)
예제 #44
0
 def testLLDPConstruct2(self):
     eth = ethernet(lldp_str_2)
     lldph = eth.find('lldp')
     assert(len(eth.tostring()) == len(lldp_str_2))
     assert(eth.tostring() == lldp_str_2)
 def testICMPUnreachConstruct(self):
     eth = ethernet(icmp_unreach_str)
     assert(eth.tostring() == icmp_unreach_str)
 def testICMPEchoConstruct(self):
     eth = ethernet(icmp_echo_str)
     assert(eth.tostring() == icmp_echo_str)
예제 #47
0
def testEAPOL():
    eth = ethernet(ether_eapol)
    nox_test_assert(eth.tostring() == ether_eapol, "eapol")
def testLLDPConstruct():
    eth = ethernet(lldp_str)
    lldph = eth.find('lldp')
    nox_test_assert(len(eth.tostring()) == len(lldp_str))
    nox_test_assert(eth.tostring() == lldp_str)
예제 #49
0
def testICMPEchoConstruct():
    eth = ethernet(icmp_echo_str)
    nox_test_assert(eth.tostring() == icmp_echo_str)
예제 #50
0
 def testICMPEchoConstruct(self):
     eth = ethernet(icmp_echo_str)
     assert (eth.tostring() == icmp_echo_str)
예제 #51
0
 def testICMPUnreachConstruct(self):
     eth = ethernet(icmp_unreach_str)
     assert (eth.tostring() == icmp_unreach_str)
 def testLLDPConstruct2(self):
     eth = ethernet(lldp_str_2)
     lldph = eth.find('lldp')
     assert(len(eth.tostring()) == len(lldp_str_2))
     assert(eth.tostring() == lldp_str_2)
예제 #53
0
def testICMPUnreachConstruct():
    eth = ethernet(icmp_unreach_str)
    nox_test_assert(eth.tostring() == icmp_unreach_str)
def testICMPUnreachConstruct():
    eth = ethernet(icmp_unreach_str)
    nox_test_assert(eth.tostring() == icmp_unreach_str)
예제 #55
0
 def testEAPOL(self):
     eth = ethernet(ether_eapol)
     assert (eth.tostring() == ether_eapol)
예제 #56
0
def testLLDPConstruct():
    eth = ethernet(lldp_str)
    lldph = eth.find('lldp')
    nox_test_assert(len(eth.tostring()) == len(lldp_str))
    nox_test_assert(eth.tostring() == lldp_str)