Пример #1
0
        def test_IP(self):
            #pcap = dpkt.pcap.PcapDumper('/tmp/foo.pcap', linktype=14)
            s = 'E\x00\x00"\x00\x00\x00\x00@\x11r\xc0\x01\x02\x03\x04\x01\x02\x03\x04\x00o\x00\xde\x00\x0e\xbf5foobar'
            ip = IP(id=0, src='\x01\x02\x03\x04', dst='\x01\x02\x03\x04', p=17)
            u = udp.UDP(sport=111, dport=222)
            u.data = 'foobar'
            u.ulen += len(u.data)
            ip.data = u
            ip.len += len(u)
            self.failUnless(str(ip) == s)
            #pcap.append(s)

            ip = IP(s)
            self.failUnless(str(ip) == s)
            self.failUnless(ip.udp.sport == 111)
            self.failUnless(ip.udp.data == 'foobar')
Пример #2
0
def test_ip():
    import udp

    s = 'E\x00\x00"\x00\x00\x00\x00@\x11r\xc0\x01\x02\x03\x04\x01\x02\x03\x04\x00o\x00\xde\x00\x0e\xbf5foobar'
    ip = IP(id=0, src='\x01\x02\x03\x04', dst='\x01\x02\x03\x04', p=17)
    u = udp.UDP(sport=111, dport=222)
    u.data = 'foobar'
    u.ulen += len(u.data)
    ip.data = u
    ip.len += len(u)
    assert (str(ip) == s)

    ip = IP(s)
    assert (str(ip) == s)
    assert (ip.udp.sport == 111)
    assert (ip.udp.data == 'foobar')
Пример #3
0
 def __init__(self, queue):
     Thread.__init__(self)
     self.event = None
     self.users_ip = conf.IPTABLE
     self.UDP = udp.UDP(30)
     self.queue = queue
Пример #4
0
    motor_node = nengo.Node(bot_motor, size_in=4)
    nengo.Connection(motor.output, motor_node, synapse=synapse)

    def sensors(t):
        #left = (bot.lego_sensors[0] + bot.lego_sensors[1]) * 0.5
        #right = (bot.lego_sensors[2] + bot.lego_sensors[3]) * 0.5
        #joystick.output.joystick.set_vibration(left, right)

        if use_bot:
            return bot.lego_sensors
        else:
            return [0, 0, 0, 0]
    sensor_node = nengo.Node(sensors, size_out=4)


    udp_node = nengo.Node(udp.UDP(size_in=4, size_out=4, address='localhost',
                                  in_port=8889, out_port=8888),
                          size_in=4, size_out=4)

    nengo.Connection(sensor_node, udp_node, synapse=None)
    nengo.Connection(udp_node, control.input, synapse=synapse)

    '''
    avoid_inhibit = nengo.Ensemble(n_neurons=50, dimensions=1,
                                   intercepts=Uniform(0.2, 0.9))
    nengo.Connection(joystick[5], avoid_inhibit, synapse=None)
    nengo.Connection(avoid_inhibit, sensors_ir.neurons, transform=[[-1]]*200,
                     synapse=0.1)
    nengo.Connection(avoid_inhibit, sensors_us.neurons, transform=[[-1]]*200,
                     synapse=0.1)
    '''
Пример #5
0
 def __init__(self):
     Thread.__init__(self)
     self.proposer_ip = ''
     self.record = {}
     self.readlog()
     self.UDP = udp.UDP()
Пример #6
0
def main():
	op = input('¿Iniciar ciclo de captura? (S/N)')
	
	if (op == 'S'):
		conn = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.ntohs(3))

		while (op == 'S'):
			rawData, addr = conn.recvfrom(65535)
			eth = ethernet.Ethernet(rawData)
			print ('Ethernet Frame:')	
			print(eth.getInfo())

			if (getattr(eth, 'type') == 8):
				'Is IPv4'
				ipv4Packet = ipv4.IPv4( getattr(eth, 'ethPayload') )
				print ('IPv4 Datagram:')
				print (ipv4Packet.getInfo())

				if (getattr(ipv4Packet, 'protocol') == 1):
					'Is ICMPv4'
					icmpv4Packet = icmpv4.ICMPv4( getattr(ipv4Packet, 'ipv4Payload') )
					print('ICMPv4 Packet:')
					print(icmpv4Packet.getInfo())

				elif (getattr(ipv4Packet, 'protocol') == 6):
					'Is TCP'
					tcpSegment = tcp.TCP( getattr(ipv4Packet, 'ipv4Payload') )
					print ('TCP Segment:')
					print (tcpSegment.getInfo())

				elif (getattr(ipv4Packet, 'protocol') == 17):
					'Is UDP'
					udpSegment = udp.UDP( getattr(ipv4Packet, 'ipv4Payload') )
					print ('UDP Segment:')
					print (udpSegment.getInfo())

			elif (getattr(eth, 'type') == 1544):
				'Is ARP'
				arpPacket = arp.ARP( getattr(eth, 'ethPayload') )
				print ('ARP Message:')
				print (arpPacket.getInfo())

			elif (getattr(eth, 'type') == 56710):
				'Is IPv6'
				ipv6Packet = ipv6.IPv6( getattr(eth, 'ethPayload') )
				print('IPv6 Packet:')
				print(ipv6Packet.getInfo())

				if (getattr(ipv6Packet, 'nextHeader') == 58):
					'Is ICMPv6'
					icmpv6Packet = icmpv6.ICMPv6( getattr(ipv6Packet, 'ipv6Payload') )
					print('ICMPv6 Packet:')
					print(icmpv6Packet.getInfo())

				elif (getattr(ipv6Packet, 'nextHeader') == 6):
					'Is TCP'
					tcpSegment = tcp.TCP( getattr(ipv6Packet, 'ipv6Payload') )
					print ('TCP Segment:')
					print (tcpSegment.getInfo())

				elif (getattr(ipv6Packet, 'nextHeader') == 17):
					'Is UDP'
					udpSegment = udp.UDP( getattr(ipv6Packet, 'ipv6Payload') )
					print ('UDP Segment:')
					print (udpSegment.getInfo())