コード例 #1
0
def handle_pkt(pkt):
    print "got a packet"
    pkt.show()
    hexdump(pkt)
    sys.stdout.flush()
    print "-------------------------"
    print(type(pkt[0][0]))
コード例 #2
0
def stormWithBeaconFrames():
    global interfaceName
    global monitorInterface
    log("Starting with storming on interface [{}]".format(interfaceName))
    
    netSSID = 'testSSID'       #Network name here
    iface = 'wlan0mon'         #Interface name here

    dot11 = Dot11(type=0, subtype=8, addr1='ff:ff:ff:ff:ff:ff', addr2=str(RandMAC()), addr3=str(RandMAC()))
    
    beacon = Dot11Beacon(cap='ESS+privacy')
    essid = Dot11Elt(ID='SSID',info=netSSID, len=len(netSSID))
    rsn = Dot11Elt(ID='RSNinfo', info=(
'\x01\x00'                 #RSN Version 1
'\x00\x0f\xac\x02'         #Group Cipher Suite : 00-0f-ac TKIP
'\x02\x00'                 #2 Pairwise Cipher Suites (next two lines)
'\x00\x0f\xac\x04'         #AES Cipher
'\x00\x0f\xac\x02'         #TKIP Cipher
'\x01\x00'                 #1 Authentication Key Managment Suite (line below)
'\x00\x0f\xac\x02'         #Pre-Shared Key
'\x00\x00'))               #RSN Capabilities (no extra capabilities)

    frame = RadioTap()/dot11/beacon/essid/rsn

    frame.show()
    print("\nHexdump of frame:")
    hexdump(frame)
    raw_input("\nPress enter to start\n")

    sendp(frame, iface=iface, inter=0.100, loop=1)
コード例 #3
0
    def decryptNotCompatibleData(self,apk,rules,comments):
        from scapy.all import hexdump
        #0000000: 3e34 c03b 010a 6147 6bec 9c52 3c13 4319  >4.;..aGk..R<.C.
        #0000010: 012d 9d2c 2a8a 49d9 6d67 e383 06ca 8a5e  .-.,*.I.mg.....^
        #0000020: 5651 cf74 41f5 c479 0b4b e887 382e 20da  VQ.tA..y.K..8. .
    
        #notcompatibleapp.eu|3na3budet9.ru|8014|8014
   
        #raw data file 
        #filename = "/path/to/notcompatible/res/raw/data"
        #size = os.path.getsize(filename)
        #f = open(filename, 'r')
        #data = bytearray(size)
        #f.readinto(data)


        #directly from the zip (relies upon working zip imlementation in python!)
        import zipfile
        file = zipfile.ZipFile(apk,"r")
        #for name in file.namelist():
        #   print name
        data = file.read("res/raw/data")
    
        hexdump(data)
    
        key = "ZTY4MGE5YQo"
        comments.append("key: %s" % key)
        plaintext = self.decrypt(key, data)
        comments.append("decrypted: %s" % plaintext)

        return plaintext
コード例 #4
0
ファイル: hexdump.py プロジェクト: roobixx/usbq
    def usbq_log_pkt(self, pkt):
        # Dump to console
        log.info(repr(pkt))

        if hasattr(pkt, 'content'):
            hexdump(pkt.content)
            print()
コード例 #5
0
def handle_pkt(pkt):
    #    if TCP in pkt and pkt[TCP].dport == 1234:
    if IP in pkt and pkt[IP].ttl == 63:
        print "got a packet"
        pkt.show2()
        hexdump(pkt)
        sys.stdout.flush()
コード例 #6
0
def handle_pkt(pkt):
    print(
        "############################## got a packet ##############################"
    )
    pkt.show()
    hexdump(pkt)
    sys.stdout.flush()
コード例 #7
0
ファイル: main.py プロジェクト: hopfenzapfen/wifi-forecast
def test():
    netSSID = 'testSSID' #Network name here
    iface = 'mon5'   #Interface name here

    dot11 = Dot11(type=0, subtype=8, addr1='ff:ff:ff:ff:ff:ff',
                  addr2='22:22:22:22:22:22', addr3='33:33:33:33:33:33')
    beacon = Dot11Beacon(cap='ESS+privacy')
    essid = Dot11Elt(ID='SSID',info=netSSID, len=len(netSSID))
    rsn = Dot11Elt(ID='RSNinfo', info=(
        '\x01\x00'              #RSN Version 1
        '\x00\x0f\xac\x02'      #Group Cipher Suite : 00-0f-ac TKIP
        '\x02\x00'              #2 Pairwise Cipher Suites (next two lines)
        '\x00\x0f\xac\x04'      #AES Cipher
        '\x00\x0f\xac\x02'      #TKIP Cipher
        '\x01\x00'              #1 Authentication Key Managment Suite (line below)
        '\x00\x0f\xac\x02'      #Pre-Shared Key
        '\x00\x00'))            #RSN Capabilities (no extra capabilities)

    frame = RadioTap()/dot11/beacon/essid/rsn
    frame.show()
    print("\nHexDump of frame:")
    hexdump(frame)
    raw_input("\nPress enter to start\n")

    sendp(frame, iface=iface, inter=0.100, loop=1)
コード例 #8
0
ファイル: send_ele_pkt.py プロジェクト: shouxi/p4exercise
def main():
    if len(sys.argv) < 3:
        print "Usage: send_ele_pkt.py [pkt_num] [tcp_sport] [tcp_dport] [nhop_1, nhop_2, ...]"
        #print "For example: send_ele_pkt.py  1 2"
        sys.exit(1)

    pkt_num   = int(sys.argv[1])
    tcp_sport = int(sys.argv[2])
    tcp_dport = int(sys.argv[3])
    if len(sys.argv) is 4:
        tcp_res = 0
    else:
        tcp_res = 4

    p = Ether(dst="00:00:00:00:00:02")/IP(dst="10.0.0.2")/TCP(reserved=tcp_res, sport=tcp_sport, dport=tcp_dport)

    if tcp_res == 4:
        p = p / BytePkt(val=len(sys.argv[4:]))
        for s in sys.argv[4:]:
            p = p / BytePkt(val=int(s))
            
    for i in range(pkt_num):
        pp = p #/ 'hello-{0}'.format(i)
        print pp.show()
        hexdump(pp)
        sendp(pp, iface = "eth0")
コード例 #9
0
def handle_pkt(pkt):
    #if UDP in pkt and pkt[UDP].dport == 2152:
    #if UDP in pkt:
    print "got a packet"
    pkt.show2()
    hexdump(pkt)
    main()
コード例 #10
0
ファイル: send.py プロジェクト: Fizzbb/ResearchPaper
def send_packet(pkt_ip, cnt=1, ipVer=8, iface=None):
    """send packet through eth0 or 1st available interfaces"""
    if iface is None:
        ifs = get_if_list()
        for i in ifs:
            if "eth0" in i:
                iface = i
                break
        if not iface:  # tmp test
            iface = 'lo'
    if ipVer == 8:
        pkt = Ether(src=get_if_hwaddr(iface),
                    dst='ff:ff:ff:ff:ff:ff',
                    type=0x888)
    elif ipVer == 6:
        pkt = Ether(src=get_if_hwaddr(iface),
                    dst='ff:ff:ff:ff:ff:ff',
                    type=0x86DD)
    else:
        print("IP version {} is not supported. Abort Early".format(inVer))
        exit(1)

    pkt = pkt / pkt_ip
    pkt.show()
    hexdump(pkt)

    t0 = time.time()
    sendp(pkt, iface=iface, count=cnt, inter=0.001, verbose=True)
    t_span = time.time() - t0
    print("send {} IPv{} packts use {} sec".format(cnt, ipVer, t_span))
    return iface
コード例 #11
0
 def get_Raw(self, packet, default=True):
     raw_layer = packet.getlayer(Raw)
     if raw_layer is None:
         return 'None'
     if default:
         hexdump(raw_layer.load)
     return ""
コード例 #12
0
def main():

    if len(sys.argv) < 6:
        print '[src] [dst] [interface] [spi] [si] [number of packets]'
        exit(1)


#src addr
    addr = socket.gethostbyname(sys.argv[1])
    addr1 = socket.gethostbyname(sys.argv[2])
    iface = sys.argv[3]
    spi = int(sys.argv[4])
    si = int(sys.argv[5])
    num_pkts = int(sys.argv[6])

    print(addr, addr1, iface, spi, si, num_pkts)

    out_ether = Ether(src='00:00:00:00:00:01',
                      dst='00:00:00:00:00:02',
                      type=0x894f)
    in_ether = Ether(src='00:00:00:00:00:01',
                     dst='00:00:00:00:00:02',
                     type=0x800)

    pkt1 = out_ether / NSH(SPI=spi, SI=si) / in_ether / IP(
        src=addr, dst=addr1) / TCP(dport=80, sport=20) / "hi"
    pkt1.show()
    hexdump(pkt1)

    for i in range(1, num_pkts + 1):
        sendp(pkt1, iface=iface, verbose=False)
        print "sending %s th SFC %s packets to interface %s " % (i, spi, iface)
コード例 #13
0
ファイル: send_dh_manual.py プロジェクト: hotephen/p4-dev
def main():

    if len(sys.argv) < 7:
        print(
            '[src] [dst] [interface] [vdp_id] [src_mac] [dst_mac] [src_port] [dst_port]'
        )
        exit(1)

    src_addr = socket.gethostbyname(sys.argv[1])
    dst_addr = socket.gethostbyname(sys.argv[2])
    iface = sys.argv[3]
    vdp_id = int(sys.argv[4])
    src_mac = sys.argv[5]
    dst_mac = sys.argv[6]
    src_port = int(sys.argv[7])
    dst_port = int(sys.argv[8])

    ether = Ether(src=src_mac, dst=dst_mac, type=0x800)
    pkt = DH(vdp_id=vdp_id) / ether / IP(src=src_addr, dst=dst_addr) / TCP(
        sport=src_port, dport=dst_port)

    pkt.show()
    hexdump(pkt)
    sendp(pkt, iface=iface, verbose=False)
    print("sending on interface %s to dmac=00:00:00:00:00:01" % (iface))
コード例 #14
0
def main():

    if len(sys.argv) < 3:
        print 'pass 1 arguments: <destination> '
        exit(1)


#src addr
    addr = socket.gethostbyname(sys.argv[1])

    #dst addr
    addr1 = socket.gethostbyname(sys.argv[2])

    iface = sys.argv[3]

    out_ether = Ether(src=get_if_hwaddr(iface),
                      dst='00:00:00:00:00:01',
                      type=0x894f)
    in_ether = Ether(src=get_if_hwaddr(iface),
                     dst='00:00:00:00:00:01',
                     type=0x800)

    pkt1 = out_ether / NSH() / in_ether / IP(src=addr, dst=addr1) / TCP(
        dport=80, sport=20) / "hi"
    pkt1.show()
    hexdump(pkt1)
    sendp(pkt1, iface=iface, verbose=False)
    print "sending on interface %s (Bmv2 port 0) to dmac=00:00:00:00:00:01" % (
        iface)
コード例 #15
0
ファイル: send.py プロジェクト: harshgondaliya/PSasCP
def main():
    iface = get_if()

    print "sending on interface %s" % (iface)
    pkt1 = ins_header(num_instructions=2, data_length=2) / Instruction(
        opcode=1, op1=20, op2=10,
        res=0) / Instruction(opcode=1, op1=20, op2=10, res=0) / Instruction(
            opcode=1, op1=20, op2=10, res=0
        ) / Instruction(opcode=1, op1=20, op2=10, res=0) / Instruction(
            opcode=1, op1=20, op2=10, res=0
        ) / Instruction(
            opcode=1, op1=20, op2=10, res=0
        ) / Instruction(
            op1_mode=1,
            op2_mode=1,
            opcode=1, res_mode=1,
            op1=0, op2=1, res=0) / Instruction(
                opcode=3,
                op1=1, op2=0, res=0) / OffsetData(data=20) / OffsetData(
                    data=10) / OffsetData() / OffsetData() / OffsetData(
                    ) / OffsetData() / OffsetData() / OffsetData() / StrData(
                        data="a") / StrData(data="a") / StrData(
                            data="a") / StrData(data="b")

    sendp(pkt1, iface=iface, verbose=False)
    pkt1.show2()
    hexdump(pkt1)
コード例 #16
0
ファイル: send3.py プロジェクト: hotephen/p4-dev
def main():

    if len(sys.argv) < 3:
        print 'pass 1 arguments: <destination> '
        exit(1)

#dst addr
    addr = socket.gethostbyname(sys.argv[1])
    #src addr
    addr1 = socket.gethostbyname(sys.argv[2])

    iface = "veth0"
    iface_1 = "veth2"
    iface_2 = "veth4"

    pkt = Ether(src=get_if_hwaddr(iface), dst='00:00:00:00:00:01')
    #    pkt = Ether(dst='00:00:00:00:00:02') / pkt / IP(src=addr1,dst=addr) / "hi"
    pkt1 = NSH() / pkt / IP(src=addr1, dst=addr) / "hi"
    # pkt = pkt /IP(src=addr1,dst=addr) / TCP(dport=1234, sport=random.randint(49152,65535)) / "hi"
    #    pkt.show2()
    pkt1.show()
    hexdump(pkt1)
    sendp(pkt1, iface=iface, verbose=False)
    print "sending on interface %s (Bmv2 port 0) to dmac=00:00:00:00:00:01" % (
        iface)
コード例 #17
0
def main():
    if len(sys.argv) < 3:
        print "Usage: send_ele_pkt.py [pkt_num] [tcp_sport] [tcp_dport] [nhop_1, nhop_2, ...]"
        #print "For example: send_ele_pkt.py  1 2"
        sys.exit(1)

    pkt_num = int(sys.argv[1])
    tcp_sport = int(sys.argv[2])
    tcp_dport = int(sys.argv[3])
    if len(sys.argv) is 4:
        tcp_res = 0
    else:
        tcp_res = 4

    p = Ether(dst="00:00:00:00:00:02") / IP(dst="10.0.0.2") / TCP(
        reserved=tcp_res, sport=tcp_sport, dport=tcp_dport)

    if tcp_res == 4:
        p = p / BytePkt(val=len(sys.argv[4:]))
        for s in sys.argv[4:]:
            p = p / BytePkt(val=int(s))

    for i in range(pkt_num):
        pp = p  #/ 'hello-{0}'.format(i)
        print pp.show()
        hexdump(pp)
        sendp(pp, iface="eth0")
コード例 #18
0
def handle_pkt(pkt):
    if TCP in pkt and pkt[TCP].dport == 1234:
        print "got a packet"
        hexdump(pkt)
        pkt.show()
        print(pkt.summary())
        sys.stdout.flush()
コード例 #19
0
    def decryptNotCompatibleData(self, apk, rules, comments):
        from scapy.all import hexdump
        #0000000: 3e34 c03b 010a 6147 6bec 9c52 3c13 4319  >4.;..aGk..R<.C.
        #0000010: 012d 9d2c 2a8a 49d9 6d67 e383 06ca 8a5e  .-.,*.I.mg.....^
        #0000020: 5651 cf74 41f5 c479 0b4b e887 382e 20da  VQ.tA..y.K..8. .

        #notcompatibleapp.eu|3na3budet9.ru|8014|8014

        #raw data file
        #filename = "/path/to/notcompatible/res/raw/data"
        #size = os.path.getsize(filename)
        #f = open(filename, 'r')
        #data = bytearray(size)
        #f.readinto(data)

        #directly from the zip (relies upon working zip imlementation in python!)
        import zipfile
        file = zipfile.ZipFile(apk, "r")
        #for name in file.namelist():
        #   print name
        data = file.read("res/raw/data")

        hexdump(data)

        key = "ZTY4MGE5YQo"
        comments.append("key: %s" % key)
        plaintext = self.decrypt(key, data)
        comments.append("decrypted: %s" % plaintext)

        return plaintext
コード例 #20
0
ファイル: writers.py プロジェクト: cj-dev/kafka-pcaps
 def write(self, packet):
     print "Timestamp {time}, {summary}".format(
             time=packet.time, summary=packet.summary())
     print "Src IP: {src}, Dst IP: {dst}".format(
             src=packet['IP'].src, dst=packet['IP'].dst)
     if self.verbosity >= 1:
         hexdump(packet)
         print base64.encodestring(str(packet))
コード例 #21
0
def main():

    iface = "veth1"

    pkt = Ether(src='00:00:00:00:00:00', dst='00:00:00:00:00:01', type=0x800)
    pkt.show()
    hexdump(pkt)  # show hexadecimal expression of packet
    sendp(pkt, iface=iface, verbose=False)
    print "sending on interface %s to dmac=00:00:00:00:00:01" % (iface)
コード例 #22
0
def process_cmd(ns):
    eth = Ether()
    arp = ARP(
        op="is-at",
        hwsrc="12:34:56:78:9A:BC",
        psrc="192.168.12.34",
    )
    print((eth / arp).show())
    hexdump(eth / arp)
    sendp(eth / arp, inter=2, loop=1)
コード例 #23
0
ファイル: cli.py プロジェクト: DrWrong/SnifferLite
def sniffer_mainprocess():
    queue = Queue.Queue()
    processlist = sniffer_prepare(Opt)

    sp = SnifferProcess(queue, Opt.filter, Opt.interface, Opt.outfile)
    sp.start()
    sys.stdout = stdout
    print('stratring sniffer')
    packet_list = []
    while True:

        option = raw_input(
            'plese choose displaymethod press "?" or "h" for help:')
        # print(option)
        m = re.match(r'(filter|f)\s(?P<filterstring>[\w\s]+)', option)
        if m:
            filterstring = m.groupdict()['filterstring']
            sp.changefilter(filterstring)
            continue
        if option == 'show' or option == 's':
            while True:
                try:
                    packet = queue.get()
                    num = len(packet_list)
                    print "%d:   %s" % (num, packet.summary())
                    packet_list.append(packet)
                except KeyboardInterrupt:
                    break
            continue

        m = re.match(r'(display|d)\s(?P<id>\d+)', option)
        if m:
            id = m.groupdict()['id']
            try:
                packet = packet_list[int(id)]
            except IndexError:
                print('choose a valiuable index')
            else:
                packet.show()
                hexdump(packet)
            continue
        if option == 'q':
            for process in processlist:
                process.terminate()
            sp.terminate()
            break
            # continue


        if option in ['?', 'h', 'help']:
            print('''
                s(show)   show the summary of captcure packet
                d(display) num    show the specific of the captcure packet
                f(filter)  change the filter options''')
コード例 #24
0
def main():
    values = [
        88, 188, 288, 388, 488, 588, 688, 788, 888, 988, 1088, 1188, 1288,
        1388, 1434
    ]
    for v in values:
        p = gen_packet(v - 88)
        p.show2()
        scapy.hexdump(p)
        str_v = v
        str_s = 'bench_' + str(str_v) + '.pcap'
        write(str_s, p)
コード例 #25
0
def test_decode_ant(msg, device_type):
    pkt = ANTMessage(msg, device_type=device_type)

    print()
    hexdump(pkt)
    print(repr(pkt))
    pkt.show()

    # assert pkt[CS] is not None
    assert pkt.checksum is not None
    assert bytes(pkt) == msg
    assert pkt._calc_checksum() == pkt.checksum
コード例 #26
0
 def to_stdout(self, capture):
     """Prints PCAP data to console"""
     try:
         for cap in capture:
             print_str = self.echo(cap)
             if not print_str:
                 continue
             print(print_str)
             if self._hex:
                 hexdump(cap)
                 print("\n")
     except KeyboardInterrupt:
         print("\n[ %sATTENTION%s ] SIGINT INVOKED: TERMINATING PROGRAM" %
               (fg(202), attr(0)))
コード例 #27
0
def handle_pkt2(pkt3):

    print "got a packet (ORIGINAL)"
    pkt3.show2()
    hexdump(pkt2)

    pkt4 = pkt3[UDP]
    pkt5 = pkt4[IPv6]

    print "packet clean (PKT SENT)"
    pkt5.show()
    hexdump(pkt5)
    sendp(pkt5, iface="eth2", verbose=False)
    main()
コード例 #28
0
    def geracao_pacotes(self):

        netSSID = 'testSSID'
        iface = 'wlp3s0mon'  #Nome da Interface Wireless

        mac_forjado_pr = self.criacao_mac_ponto_referencia()
        numero_pacotes = int(self.numero_pacotes.get())
        intervalo_envio = float(self.intervalo.get())

        ## addr1 = MAC de destino (MAC da placa wireless)
        ## addr2 = Endereco MAC de origem do remetente. (MAC forjado)
        ## addr3 = Endereco MAC do ponto de acesso.

        dot11 = Dot11(type=0,
                      subtype=8,
                      addr1='E4:18:6B:4B:94:00',
                      addr2=mac_forjado_pr,
                      addr3='33:33:33:33:33:33')

        beacon = Dot11Beacon(
            cap='ESS+privacy')  ## indica a capacidade do ponto de acesso

        essid = Dot11Elt(ID='SSID', info=netSSID, len=len(netSSID))

        rsn = Dot11Elt(ID='RSNinfo',
                       info=('\x01\x00'
                             '\x00\x0f\xac\x02'
                             '\x02\x00'
                             '\x00\x0f\xac\x04'
                             '\x00\x0f\xac\x02'
                             '\x01\x00'
                             '\x00\x0f\xac\x02'
                             '\x00\x00'))

        frame = RadioTap() / dot11 / beacon / essid / rsn

        frame.show()
        print("HexDump of frame")

        hexdump(frame)

        a = sendp(frame / "RURALRURALRURAL",
                  iface=iface,
                  inter=intervalo_envio,
                  loop=0,
                  count=numero_pacotes
                  )  # inter = intervalo entre o envio dos pacotes
        print(a)

        self.atualizar_tela()
コード例 #29
0
def delayReqPkt():
    global iface, addr
    DPSync = DPSyncTag(
        etherType = 0x9487,
        opCode = 0b0011,
        reserved = 0,
        originalPort = 0
    )

    pkt = Ether(src=get_if_hwaddr(iface), type=0x9487, dst='ff:ff:ff:ff:ff:ff')
    pkt =pkt / IP(dst=addr) / DPSync / TS
    pkt.show()
    hexdump(pkt)
    sendp(pkt, iface=iface, verbose=False)
コード例 #30
0
def sendDelayReqPkt(pkt):
    global iface
    DPSync = DPSyncTag(etherType=0x9487,
                       opCode=0b0010,
                       reserved=0,
                       originalPort=0)
    pkt2 = Ether(src=get_if_hwaddr(iface),
                 type=0x9487,
                 dst='ff:ff:ff:ff:ff:ff')
    pkt2 = pkt2 / IP(dst=pkt[IP].src, src=pkt[IP].dst) / DPSync / TS
    print("send the delay-req packet!!\n")
    pkt2.show()
    hexdump(pkt2)
    sendp(pkt2, iface=iface, verbose=False)
コード例 #31
0
ファイル: send_dh_arp.py プロジェクト: hotephen/p4-dev
def main():

    src_mac = sys.argv[1]
    src_addr = socket.gethostbyname(sys.argv[2])
    dst_addr = socket.gethostbyname(sys.argv[3])
    iface = sys.argv[4]
    vdp_id = int(sys.argv[5])

    ether = Ether(src=src_mac, dst="FF:FF:FF:FF:FF:FF", type=0x0806)
    pkt = DH(vdp_id=vdp_id) / ether / ARP(
        op=1, hwsrc=src_mac, psrc=src_addr, pdst=dst_addr)
    pkt.show()
    hexdump(pkt)
    sendp(pkt, iface=iface, verbose=False)
    print("sending on interface %s to dmac=00:00:00:00:00:01" % (iface))
コード例 #32
0
ファイル: receive.py プロジェクト: Fizzbb/ResearchPaper
def handle_pkt(pkt):
    global cnt, t1
    cnt += 1

    if cnt == 1:
        t1 = time.time()
    if cnt%1000 < 10:
        pkt.show()
        hexdump(pkt)
    if cnt%1000==0:
        print("takes {} sec to receive {} pkt".format(time.time()-t1, cnt))
        #pickle.dump(latency_list, open('/tmp/latency.pkl','wb'))

 
    sys.stdout.flush()
コード例 #33
0
ファイル: control_plane.py プロジェクト: hotephen/p4-dev
def handle_pkt(pkt):
    pkt.show()
    hexdump(pkt)
    # print ("############################## got a packet ##############################")
    try:
        if pkt[IP].dst == '10.10.0.1':  ##
            # if pkt[frame_type].frame_type == 3: # if timer packet
            print("got a packet")
            pkt.show()
            # sleep(1)
            sendp(pkt, iface=a.i, verbose=False)

    except IndexError:
        # print('IndexError')
        pass
コード例 #34
0
ファイル: http_gzip.py プロジェクト: TheProjecter/netwho
  def _smart_decompress(self, data, is_chunked, length=None):
    """Decompress gzipped data, taking length into account.

    Args:
      data: a string of data to decompress
      length: the expected length of the data
    """
    extracted = None
    if is_chunked:
      print "WE ARE CHUNKED: %s bytes" % len(data)
      extracted_chunks = []  
      # TODO(tstromberg): Measure the size of each chunk
      if data[-2:] == '\r\n':
        chunks = data.split('\r\n[0-9a-f]+\r\n')
        for chunk in chunks:
          print "processing chunk size: %s" % len(chunk)
          match = self.CHUNK_SIZE_RE.search(chunk)
          if match:
            size = int(match.group(1), 16)
            print "found chunk size: %s" % size
            content_location = chunk.find('\r\n') + 2
            chunk_content = chunk[content_location:content_location+size]
            extracted = self._decompress(chunk_content)
            if extracted:
              extracted_chunks.append(extracted)
            else:
              print "unable to extract chunk of %s bytes" % len(chunk_content)
              print hexdump(chunk_content)
        if extracted_chunks:
          print "%s chunks of %s chunks extracted." % (len(extracted_chunks), len(chunks))
          return ''.join(extracted_chunks)
      else:
        print "chunk end not found, waiting: %s bytes" % len(data)
      
    if length and len(data) > length:
      try_data = data[:length]
      extracted = self._decompress(try_data)

    if not extracted:
      extracted = self._decompress(data)
    
    return extracted
コード例 #35
0
ファイル: parser.py プロジェクト: 0x0d/wallofshame
        def process(self, pkt):

                self.data = pkt.data
                self.src = pkt.src[0]
                self.sport = pkt.src[1]
                self.dst = pkt.dst[0]
                self.dport = pkt.dst[1]


                if not len(self.data):
                        return

                # TCP
                if self.dport in self.tcpHandlers.keys():
                        try:
                                self.tcpHandlers[self.dport]()
                        except Exception, e:
                                self.logger.warn("Fail to parse stream with dport: %d cause of exception: %s" % (self.dport, str(e)))
                                traceback.print_exc()
                                self.logger.warn("Packet from %s:%s to %s:%s" % (self.src,self.sport,self.dst, self.dport))
                                scapy.hexdump(self.data)
コード例 #36
0
ファイル: packet.py プロジェクト: hydratk/hydratk-lib-network
def dump(packet, raw=False):
    """Method print packet dump

    Args:            
       packet (obj): packet, partial of composed
       raw (bool): print raw hexdump

    Returns:
       void

    """

    try:

        if (not raw):
            packet.show()
        else:
            from scapy.all import hexdump
            hexdump(packet)

    except Scapy_Exception as ex:
        mh.demsg('htk_on_error', ex, mh.fromhere())
        return None
コード例 #37
0
ファイル: Stream.py プロジェクト: Margaruga/rtmpSnoop
 def dump(self):
     self._mergeData()
     hexdump(self.stream[self.offset:])
コード例 #38
0
ファイル: flowsynth.py プロジェクト: Neo23x0/flowsynth
def hex_output():
    """ produce a hexdump of the compiler output """
    global COMPILER_OUTPUT
    for pkt in COMPILER_OUTPUT:
        hexdump(pkt)
コード例 #39
0
ファイル: Stream.py プロジェクト: Seven-zhang/rtmpSnoop
 def dump(self):
     hexdump(self.stream[self.offset:])
コード例 #40
0
ファイル: default.py プロジェクト: JavierOlmedo/WiFi-Pumpkin
 def hexdumpPackets(self,pkt):
     ''' show packets hexdump '''
     return hexdump(pkt)