Ejemplo n.º 1
0
    def __init__(self,
                 size,
                 burst,
                 pattern,
                 mask,
                 addpattern,
                 suppress_packet_callback=None):
        """ Creates a new PhyWhisperer capture backend.

        Args:
            size: number of USB events to capture
            burst: read from capture FIFO in a single burst
            pattern: pattern match bytes
            mask: mask for pattern match bytes
            addpattern: the pattern match aren't captured; use this option to artificially
                insert them into the capture data
            suppress_packet_callback -- A callback function that determines
                which packets should be dropped before being submitted to the
                analysis queue.
        """

        # Create a new PhyWhisperer device; but don't yet try to connect to it.
        self.pw_device = pw.Usb(viewsb=True)

        # And create the packet sink we'll use to get data from the PW device.
        self.packet_sink = ViewSBEventSink(self, suppress_packet_callback)
        self.pw_device.register_sink(self.packet_sink)
        self.pw_device.addpattern = addpattern
        self.size = size
        self.burst = burst
        self.pattern = pattern
        self.mask = mask
Ejemplo n.º 2
0
    def __init__(self,
                 size,
                 burst,
                 pattern,
                 mask,
                 addpattern,
                 timeout,
                 suppress_packet_callback=None):
        """ Creates a new PhyWhisperer capture backend.

        Args:
            size: number of USB events to capture
            burst: read from capture FIFO in a single burst
            pattern: pattern match bytes
            mask: mask for pattern match bytes
            addpattern: the pattern match bytes aren't captured; use this option to artificially
                insert them into the capture data
            timeout: capture timeout in seconds
            suppress_packet_callback -- A callback function that determines
                which packets should be dropped before being submitted to the
                analysis queue.
        """

        super().__init__()

        if burst and size not in range(1, self.MAX_CAPTURE_SIZE + 1):
            sys.stderr.write(
                "size must be between 1 and %d (inclusive) when using burst mode\n"
                % self.MAX_CAPTURE_SIZE)
            sys.exit(errno.EINVAL)

        if len(pattern) != len(mask):
            sys.stderr.write(
                "pattern and mask must have same number of elements\n")
            sys.exit(errno.EINVAL)

        if len(pattern) > self.MAX_PATTERN_SIZE:
            sys.stderr.write("pattern cannot have more than %s elements\n" %
                             self.MAX_PATTERN_SIZE)
            sys.exit(errno.EINVAL)

        from phywhisperer import usb as pw

        # Create a new PhyWhisperer device; but don't yet try to connect to it.
        self.pw_device = pw.Usb(viewsb=True)

        # And create the packet sink we'll use to get data from the PW device.
        self.packet_sink = ViewSBEventSink(self, suppress_packet_callback)
        self.pw_device.register_sink(self.packet_sink)
        self.pw_device.addpattern = addpattern
        self.size = size
        self.burst = burst
        self.pattern = pattern
        self.mask = mask
        self.timeout = timeout
Ejemplo n.º 3
0
import phywhisperer.usb as pw
import csv
import base64
import random
import pickle
import signal

f_csv = open("classifier.csv","w")
spamwriter = csv.writer(f_csv,delimiter=',',quotechar='\"')

import sys

refptn = [195, 63, 35, 35, 0, 2, 0, 0, 0, 27, 10, 25, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 72, 101, 108, 108, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 206, 206]

print("Configuring PhyWhispererUSB")
phy = pw.Usb()
# phy.set_usb_mode("LS")
phy.con(program_fpga = True)
phy.reset_fpga()
phy.addpattern = True
phy.set_power_source("off")
pattern = [ord(x) for x in "xyabc123"]
pattern_true = [ord(x) for x in "HelloHelloHelloHelloHello"]
print(pattern)
import time

print("Configuring ChipWhisperer")
import chipwhisperer as cw
scope = cw.scope()
target = cw.target(scope)