コード例 #1
0
    def processTraces(self):
        # print "Running attack: %s" % self._name

        self.sigAnalysisStarted.emit()

        progressBar = ProgressBar("Analysis in Progress",
                                  "Attacking with %s:" % self._name)
        with progressBar:
            self.attack.setTargetBytes(self.targetBytes())
            self.attack.setReportingInterval(self.getReportingInterval())
            self.attack.getStatistics().clear()
            self.attack.setStatsReadyCallback(self.sigAnalysisUpdated.emit)

            self.sigAnalysisStarted.emit()

            #--- call the algorithm module

            startingTrace = self.getTraceStart()
            endingTrace = startingTrace + self.getTracesPerAttack() - 1

            self.attack.addTraces(self.getTraceSource(),
                                  (startingTrace, endingTrace),
                                  progressBar,
                                  pointRange=self.getPointRange(),
                                  attack=self)

        self.sigAnalysisDone.emit()
コード例 #2
0
ファイル: _base.py プロジェクト: wuyasec/chipwhisperer
    def processTraces(self):
        progressBar = ProgressBar("Analysis in Progress",
                                  "Attacking with " + self.getName())
        with progressBar:
            self.attack.setModel(self.attackModel)
            self.attack.getStatistics().clear()
            self.attack.setReportingInterval(self.getReportingInterval())
            self.attack.setTargetSubkeys(self.getTargetSubkeys())
            self.attack.setStatsReadyCallback(self.sigAnalysisUpdated.emit)
            self.sigAnalysisStarted.emit()

            for itNum in range(self.getIterations()):
                startingTrace = self.getTracesPerAttack(
                ) * itNum + self.getTraceStart()
                endingTrace = startingTrace + self.getTracesPerAttack() - 1

                # TODO:support start/end point different per byte
                self.attack.addTraces(self.getTraceSource(),
                                      (startingTrace, endingTrace),
                                      progressBar,
                                      pointRange=self.getPointRange(None))

                if progressBar and progressBar.wasAborted():
                    return

        self.sigAnalysisDone.emit()
コード例 #3
0
    def redrawPlot(self):
        """Redraw the plot, loading data from attack"""
        if not self._analysisSource:
            return

        progress = ProgressBar("Redrawing " + CorrelationVsTrace._name, "Status:")

        with progress:
            data = self._analysisSource.getStatistics().maxes_list

            enabledlist = []
            for bnum in range(0, len(self.enabledbytes)):
                if self.enabledbytes[bnum]:
                    enabledlist.append(bnum)

            xrangelist = [0] * self._numKeys()
            newdata = [0] * self._numKeys()
            for bnum in enabledlist:
                maxdata = data[bnum]
                tlist = []
                for m in maxdata:
                    tlist.append(m['trace'])

                maxlist = np.zeros((self._numPerms(bnum), len(tlist)))
                for i, m in enumerate(maxdata):
                    for j in range(0, self._numPerms(bnum)):
                        maxlist[m['maxes'][j][0], i] = m['maxes'][j][2]

                newdata[bnum] = maxlist
                xrangelist[bnum] = tlist

            self.drawData(progress, xrangelist, newdata, enabledlist)
            self.pw.setYRange(0, 1, update=True)
コード例 #4
0
    def __init__(self, parent):
        AutoScript.__init__(self)
        self.enabled = False
        self.autoScriptInit()

        # Add example scripts to this list
        self.exampleScripts = [PartitionDisplay(self), TextDisplay(self)]

        # Add Scripts
        self.setupCommonScripts()

        self.progressBar = ProgressBar(show=False)
コード例 #5
0
    def processTraces(self):
        progressBar = ProgressBar("Analysis in Progress",
                                  "Attaking with Profiling:")
        with progressBar:
            self.attack.setReportingInterval(self.getReportingInterval())

            #TODO: support start/end point different per byte
            (startingPoint, endingPoint) = self.getPointRange(None)

            self.attack.getStatistics().clear()

            self.sigAnalysisStarted.emit()
            for itNum in range(1, self.getIterations() + 1):
                startingTrace = self.getTracesPerAttack() * (
                    itNum - 1) + self.getTraceStart()
                endingTrace = self.getTracesPerAttack(
                ) * itNum + self.getTraceStart()

                data = []
                textins = []
                textouts = []

                for i in range(startingTrace, endingTrace):
                    d = self.getTraceSource().getTrace(i)

                    if d is None:
                        continue

                    d = d[startingPoint:endingPoint]

                    data.append(d)
                    textins.append(self.getTraceSource().getTextin(i))
                    textouts.append(self.getTraceSource().getTextout(i))

                #self.attack.clearStats()
                self.attack.setByteList(self.targetBytes())
                self.attack.setStatsReadyCallback(self.sigAnalysisUpdated.emit)

                #TODO:  pointRange=self.TraceRangeList[1:17]
                self.attack.addTraces(data,
                                      textins,
                                      textouts,
                                      knownkeys=None,
                                      progressBar=progressBar)

        self.sigAnalysisDone.emit()
コード例 #6
0
    def processTraces(self):
        progressBar = ProgressBar("Analysis in Progress", "Attaking with CPA:")
        with progressBar:
            self.attack.setTargetBytes(self.targetBytes())
            self.attack.setReportingInterval(self.getReportingInterval())
            self.attack.getStatistics().clear()
            self.attack.setStatsReadyCallback(self.sigAnalysisUpdated.emit)

            self.sigAnalysisStarted.emit()
            for itNum in range(1, self.getIterations()+1):
                startingTrace = self.getTracesPerAttack() * (itNum - 1) + self.getTraceStart()
                endingTrace = startingTrace + self.getTracesPerAttack() - 1
                #TODO:  pointRange=self.TraceRangeList[1:17]
                self.attack.addTraces(self.getTraceSource(), (startingTrace, endingTrace), progressBar, pointRange=self.getPointRange())
                if progressBar and progressBar.wasAborted():
                    return

        self.sigAnalysisDone.emit()
コード例 #7
0
    def redrawPlot(self):
        progress = ProgressBar("Redrawing " + OutputVsTime._name, "Status:")

        with progress:
            data = self._analysisSource.getStatistics().diffs

            enabledlist = []
            for bnum in range(0, len(self.enabledbytes)):
                if self.enabledbytes[bnum]:
                    enabledlist.append(bnum)

            xrangelist = [0] * self._numKeys()
            for bnum in enabledlist:
                diffs = data[bnum]

                if diffs is not None:
                    if not hasattr(diffs[0], '__iter__'):
                        diffs = [[t] for t in diffs]

                    prange = self.getPrange(bnum, diffs)
                    xrangelist[bnum] = prange

            self.drawData(progress, xrangelist, data, enabledlist)