# 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_()
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
['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
self.attack.setTargetSubkeys([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) self.attack.setTraceSource(self.traces) self.attack.setPointRange((0,3000)) def initReporting(self): # Configures the attack observers (usually a set of GUI widgets) self.api.getResults("Attack Settings").setAnalysisSource(self.attack) self.api.getResults("Correlation vs Traces in Attack").setAnalysisSource(self.attack) self.api.getResults("Output vs Point Plot").setAnalysisSource(self.attack) self.api.getResults("PGE vs Trace Plot").setAnalysisSource(self.attack) self.api.getResults("Results Table").setAnalysisSource(self.attack) self.api.getResults("Save to Files").setAnalysisSource(self.attack) self.api.getResults("Trace Output Plot").setTraceSource(self.traces) self.api.getResults("Trace Recorder").setTraceSource(self.traces) def run(self): self.attack.processTraces() if __name__ == '__main__': import sys from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI import chipwhisperer.analyzer.ui.CWAnalyzerGUI as cwa from chipwhisperer.common.utils.parameter import Parameter app = cwa.makeApplication() # Comment if you don't need the GUI Parameter.usePyQtGraph = True # Comment if you don't need the GUI api = CWCoreAPI() # Instantiate the API gui = cwa.CWAnalyzerGUI(api) # Comment if you don't need the GUI api.runScriptClass(UserScript) # Run UserScript through the API sys.exit(app.exec_()) # Comment if you don't need the GUI
ted.displayPartitions(differences={"partclass":PartitionHWIntermediate, "diffs":partDiffs}) ted.poi.setDifferences(partDiffs) def TraceExplorerDialog_PartitionDisplay_findPOI(self): # Calculate the POIs self.cwagui = CWAnalyzerGUI.getInstance() ted = self.cwagui.attackScriptGen.utilList[0].exampleScripts[0] return ted.poi.calcPOI(numMax=3, pointRange=(0, 3000), minSpace=5)['poi'] def generateTemplates(self): # Generate the templates and save to the project self.TraceExplorerDialog_PartitionDisplay_displayPartitionStats() tRange = (0, 1499) poiList = self.TraceExplorerDialog_PartitionDisplay_findPOI() partMethod = PartitionHWIntermediate() templatedata = chipwhisperer.analyzer.attacks.profiling_algorithms.template.TemplateUsingMVS.generate(self.attack.getTraceSource(), tRange, poiList, partMethod) tfname = self.attack.attack.saveTemplatesToProject(tRange, templatedata) if __name__ == '__main__': import sys from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI import chipwhisperer.analyzer.ui.CWAnalyzerGUI as cwa from chipwhisperer.common.utils.parameter import Parameter app = cwa.makeApplication() Parameter.usePyQtGraph = True api = CWCoreAPI() # Instantiate the API api.runScriptClass(Capture) gui = cwa.CWAnalyzerGUI(api) # Instantiate the Analyzer GUI api.runScriptClass(Attack) # Run the script (default is the "run" method) sys.exit(app.exec_())
# 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_()
self.attack.setPointRange((0, 3000)) def initReporting(self): # Configures the attack observers (usually a set of GUI widgets) self.api.getResults("Attack Settings").setAnalysisSource(self.attack) self.api.getResults("Correlation vs Traces in Attack").setAnalysisSource(self.attack) self.api.getResults("Output vs Point Plot").setAnalysisSource(self.attack) self.api.getResults("PGE vs Trace Plot").setAnalysisSource(self.attack) self.api.getResults("Results Table").setAnalysisSource(self.attack) self.api.getResults("Save to Files").setAnalysisSource(self.attack) self.api.getResults("Trace Output Plot").setTraceSource(self.traces) self.api.getResults("Trace Recorder").setTraceSource(self.traces) def run(self): self.attack.processTraces() if __name__ == "__main__": import sys from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI import chipwhisperer.analyzer.ui.CWAnalyzerGUI as cwa from chipwhisperer.common.utils.parameter import Parameter app = cwa.makeApplication() # Comment if you don't need the GUI Parameter.usePyQtGraph = True # Comment if you don't need the GUI api = CWCoreAPI() # Instantiate the API gui = cwa.CWAnalyzerGUI(api) # Comment if you don't need the GUI api.runScriptClass(UserScript) # Run UserScript through the API sys.exit(app.exec_()) # Comment if you don't need the GUI
partDiffs = ted.generatePartitionDiffs(DifferenceModeSAD, statsInfo={"partclass":PartitionHWIntermediate, "stats":partStats}, saveFile=True, loadFile=False, progressBar=progressBar) ted.displayPartitions(differences={"partclass":PartitionHWIntermediate, "diffs":partDiffs}) ted.poi.setDifferences(partDiffs) def TraceExplorerDialog_PartitionDisplay_findPOI(self): self.cwagui = CWAnalyzerGUI.getInstance() ted = self.cwagui.attackScriptGen.utilList[0].exampleScripts[0] return ted.poi.calcPOI(numMax=3, pointRange=(0, 3000), minSpace=5)['poi'] def generateTemplates(self): self.TraceExplorerDialog_PartitionDisplay_displayPartitionStats() tRange = (0, 1499) poiList = self.TraceExplorerDialog_PartitionDisplay_findPOI() partMethod = PartitionHWIntermediate() templatedata = self.attack.attack.profiling.generate(tRange, poiList, partMethod) tfname = self.attack.attack.saveTemplatesToProject(tRange, templatedata) if __name__ == '__main__': import sys from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI import chipwhisperer.analyzer.ui.CWAnalyzerGUI as cwa from chipwhisperer.common.utils.parameter import Parameter app = cwa.makeApplication() # Comment if you don't need the GUI Parameter.usePyQtGraph = True # Comment if you don't need the GUI api = CWCoreAPI() # Instantiate the API api.runScriptClass(Capture) gui = cwa.CWAnalyzerGUI(api) # Comment if you don't need the GUI gui.show() # Comment if you don't need the GUI api.runScriptClass(Attack) sys.exit(app.exec_()) # Comment if you don't need 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_()