Ejemplo n.º 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_()
                      ['OpenADC', 'Gain Setting', 'Setting', 45],
                      ['OpenADC', 'Trigger Setup', 'Mode', 'rising edge'],
                      #Final step: make DCMs relock in case they are lost
                      ['OpenADC', 'Clock Setup', 'ADC Clock', 'Reset ADC DCM', None],
                      ]
        
        #Download all hardware setup parameters
        for cmd in lstexample: self.api.setParameter(cmd)
        
        #Let's only do a few traces
        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__':
    app = cwc.makeApplication()                     # 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.setApplicationName("Capture Scripted")    # If you DO NOT want to overwrite settings from the GUI
    gui = cwc.CWCaptureGUI(api)                     # Comment this line if you don't want to use the GUI
    gui.show()                                      # Comment this line if you don't want to use the GUI
    api.runScriptClass(UserScript)                  # Run the User Script

    sys.exit(app.exec_())                           # Comment this line if you don't want to use the GUI
Ejemplo n.º 4
0
        for i in range(5):
            for c in trylist:
                # Get a power trace using our next attempt
                nextPass = password + '{}'.format(c)
                self.api.setParameter(['Simple Serial', 'Go Command', '{}\n'.format(nextPass)])
                self.api.capture1()
                
                # Grab the trace
                nextTrace = self.api.getScope().datapoints
                
                # Check location 153, 225, etc. If it's too low, we've failed
                if nextTrace[153 + 72*i] < -0.2:
                    continue
                    
                # If we got here, we've found the right letter
                password += c
                print '{} characters: {}'.format(i+1, password)
                break


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
    gui.show()                                                  # 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
Ejemplo n.º 5
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_()
Ejemplo n.º 6
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
            ['Glitch Explorer', 'Tuning Parameter 1', 'Step', 0.5],
            ['Glitch Explorer', 'Tuning Parameter 1', 'Repeat', 1],
            ['Glitch Explorer', 'Tuning Parameter 0', 'Range', (-8, 3)],
            ['Glitch Explorer', 'Tuning Parameter 0', 'Value', -8],
            ['Glitch Module', 'Repeat', 1],
            ['Generic Settings', 'Acquisition Settings', 'Number of Traces', 345],
        ]
        for cmd in lstexample: self.api.setParameter(cmd)
        self.api.captureM()

        print "Using the Glitch Explorer - Fine-tune those values"
        self.api.setParameter(['Glitch Module', 'Glitch Offset (as % of period)',-3.5])
        self.api.setParameter(['Glitch Module', 'Glitch Width (as % of period)',7.5])
        self.api.capture1()
        self.api.capture1()
        self.api.capture1()
        self.api.setParameter(['Glitch Module', 'Glitch Offset (fine adjust)', 44])
        self.api.capture1()
        self.api.capture1()
        self.api.capture1()

if __name__ == '__main__':
    app = cwc.makeApplication()                     # 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
    gui = cwc.CWCaptureGUI(api)                     # Comment this line if you don't want to use the GUI
    gui.glitchMonitor.show()
    gui.serialTerminal.show()
    api.runScriptClass(UserScript)                  # Run the User Script

    app.exec_()
Ejemplo n.º 8
0
    ])

    # Record traces
    api.newProject()
    api.saveProject(cwp_fname)
    api.captureM()
    api.saveProject(cwp_fname)


if __name__ == "__main__":
    # Record timestamp for labelling output
    run_timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")

    # Get ChipWhisperer API ready
    import chipwhisperer.capture.ui.CWCaptureGUI as cwc
    app = cwc.makeApplication("Capture")
    api = CWCoreAPI()

    # Set up the ChipWhisperer
    setup_chipwhisperer(api)

    for i in range(len(fw_fnames)):
        fw_fname = fw_fnames[i]
        proj_title = proj_titles[i]

        print "Testing firmware file %s..." % fw_fname

        # Run capture script
        print "Capturing power traces..."
        base_fname = "%s-%s" % (run_timestamp, fw_fname)
        fw_fname_full = os.path.join(fw_path, fw_fname)
Ejemplo n.º 9
0
    def run(self):
        # 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_()
Ejemplo n.º 10
0
        # Fix the traces
        self.initPreprocessing2()

        # 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()
    Parameter.usePyQtGraph = True
    api = CWCoreAPI()               # Instantiate the API
    gui = cwc.CWCaptureGUI(api)     # Instantiate the Capture GUI
    gui.show()
    api.runScriptClass(Capture)
    gui.reset()

    gui = cwa.CWAnalyzerGUI(api)    # Instantiate the Analyzer GUI
    gui.show()
    api.runScriptClass(Attack)      # Run the script (default is the "run" method)

    app.exec_()
Ejemplo n.º 11
0
            ['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_()
Ejemplo n.º 12
0
        self.api.setParameter(['Generic Settings', 'Auxiliary Module', 'Record Length of Trigger/Trace'])

        ##### Check encryption length
        self.api.capture1()
        self.api.capture1()
        time.sleep(0.05)
        trig_len = self.api.getParameter(['OpenADC', 'Trigger Setup', 'Trigger Active Count'])

        if trig_len < 1000:
            raise IOError("ERROR: Trigger appears to have failed (len = %d)"%trig_len)

        self.api.setParameter(['OpenADC', 'Trigger Setup', 'Total Samples', trig_len])
        print trig_len

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

        #sys.exit()


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