예제 #1
0
    def __init__(self, api):
        try:
            app = cwc.makeApplication(doDeleteLater=False)
        except RuntimeError as e:
            if 'QApplication instance already exists' in str(e):
                pass
            else:
                raise

        # Create and show the GUI
        self.gui = cwc.CWCaptureGUI(api)
        self.gui.show()

        self.gui.execute = ExecWithParentAsSelf(parent=self.gui)
        # This is what the API will execute
        self.api.openProject("projects/tut_descpa.cwp")
        self.initPreprocessing()

        # Setup the analysis, widgets, and do the attack
        self.initAnalysis()
        self.initReporting()
        self.attack.processTraces()

        # Delete all pending scripts executions (that are observing the api be available again),
        # otherwise the current setup would be overridden
        self.api.executingScripts.disconnectAll()


if __name__ == '__main__':
    from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI
    import chipwhisperer.capture.ui.CWCaptureGUI as cwc
    import chipwhisperer.analyzer.ui.CWAnalyzerGUI as cwa
    from chipwhisperer.common.utils.parameter import Parameter
    app = cwc.makeApplication(doDeleteLater=False)
    Parameter.usePyQtGraph = True
    api = CWCoreAPI()  # Instantiate the API

    gui = cwc.CWCaptureGUI(api)  # Instantiate the Capture GUI
    api.runScriptClass(Capture)
    gui.deleteLater()
    gui.reset()

    gui = cwa.CWAnalyzerGUI(api)  # Instantiate the Analyzer GUI
    api.runScriptClass(Attack)  # Run the script (default is the "run" method)
    app.exec_()
예제 #3
0
 def capture(self):
     self.app = cwc.makeApplication("Capture")
     self.window = cwc.CWCaptureGUI(self.api)
     self.window.show()
     # Run the main Qt loop
     self.app.exec_()
예제 #4
0
        
        # Download all hardware setup parameters
        for cmd in lstexample: self.api.setParameter(cmd)
        
        # Let's only do a few traces
        self.api.setParameter(['Simple Serial', 'Key Length (Bytes)', 8])
        self.api.setParameter(['Simple Serial', 'Input Length (Bytes)', 8])
        self.api.setParameter(['Simple Serial', 'Output Length (Bytes)', 8])
        self.api.setParameter(['Generic Settings', 'Basic', 'Key', 'Fixed'])
        self.api.setParameter(['Generic Settings', 'Basic', 'Fixed Encryption Key', u'2B 7E 15 16 28 AE D2 A6'])
        self.api.setParameter(['Generic Settings', 'Acquisition Settings', 'Number of Traces', 50])
                      
        # Throw away first few
        self.api.capture1()
        self.api.capture1()

        # Capture a set of traces and save the project
        # self.api.captureM()
        # self.api.saveProject("../../../projects/test.cwp")


if __name__ == '__main__':
    import chipwhisperer.capture.ui.CWCaptureGUI as cwc         # Import the ChipWhispererCapture GUI
    from chipwhisperer.common.utils.parameter import Parameter  # Comment this line if you don't want to use the GUI
    Parameter.usePyQtGraph = True                               # Comment this line if you don't want to use the GUI
    api = CWCoreAPI()                                           # Instantiate the API
    app = cwc.makeApplication("Capture")                        # Change the name if you want a different settings scope
    gui = cwc.CWCaptureGUI(api)                                 # Comment this line if you don't want to use the GUI
    api.runScriptClass(UserScript)                              # Run the User Script (executes "run()" by default)
    app.exec_()                                                 # Comment this line if you don't want to use the GUI
            ['CW Extra Settings', 'HS-Glitch Out Enable (High Power)', True],
            ['Glitch Module', 'Clock Source', 'CLKGEN'],
            ['Glitch Module', 'Single-Shot Arm', 'Before Scope Arm'],
            ['Glitch Module', 'Glitch Trigger', 'Ext Trigger:Single-Shot'],
            ['Glitch Module', 'Output Mode', 'Glitch Only'],

            ['Glitch Module', 'Glitch Width (as % of period)', 44.4],
            ['Glitch Module', 'Glitch Offset (as % of period)', 5.3],
            ['Glitch Module', 'Repeat', 2],
            ['Glitch Module', 'Ext Trigger Offset', 7218],

            # Fixme: these are specific to the target device I'm experimenting on
            ['Glitch Explorer', 'Normal Response', u's.find("rcode 5 total 34") >= 0'],
            ['Glitch Explorer', 'Successful Response', u"(lambda n: n.isdigit() and int(n))((s+' x').split('total ')[-1].split()[0]) > 34"],
            ]:
            self.api.setParameter(cmd)

        self.api.capture1()
        self.api.capture1()


if __name__ == '__main__':
    import chipwhisperer.capture.ui.CWCaptureGUI as cwc
    from chipwhisperer.common.utils.parameter import Parameter
    Parameter.usePyQtGraph = True
    api = CWCoreAPI()
    app = cwc.makeApplication("Capture")
    gui = cwc.CWCaptureGUI(api)
    api.runScriptClass(UserScript)
    app.exec_()