def __init__(self, oldprojectname, newprojectname):

        cwapi_new = CWCoreAPI()
        cwapi_old = CWCoreAPI()

        cwapi_old.openProject(oldprojectname)

        cwapi_new.newProject()
        cwapi_new.saveProject(newprojectname)

        tm = cwapi_old.project().traceManager()
        ntraces = tm.numTraces()

        segs = tm.getSegmentList()

        numtraces = 0

        for offset, seg_idx in enumerate(segs['offsetList']):
            seg_len = segs['lengthList'][seg_idx]

            seg = tm.getSegment(seg_idx)
            tc = TraceContainerNative()
            tc.clear()
            # Copy all aux data over
            # seg.config._configfile
            tc.config.config = seg.config.config
            prefix = tc.config.config['Trace Config']['prefix']
            tc.config.setConfigFilename(cwapi_new.project().datadirectory +
                                        "traces/config_" + prefix + ".cfg")

            tc.setDirty(True)
            tc.config.syncFile()

            for tnum in range(offset, seg_len + offset):
                trace = tm.getTrace(tnum)
                textin = tm.getTextin(tnum)
                textout = tm.getTextout(tnum)
                key = tm.getKnownKey(tnum)

                try:
                    textin, textout, trace, key = self.trace_callback(
                        textin, textout, trace, key)
                except StopIteration:
                    continue

                numtraces += 1
                tc.addTrace(trace, textin, textout, key)
            tc.closeAll()
            cwapi_new.project().traceManager().appendSegment(tc)

        cwapi_new.saveProject()
示例#2
0
#    chipwhisperer is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Lesser General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with chipwhisperer.  If not, see <http://www.gnu.org/licenses/>.
#=================================================

from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI
from matplotlib.pylab import *
import numpy as np

cwapi = CWCoreAPI()
#You may need to specify the full path for this to work
cwapi.openProject(r'rsa_test_2bytes.cwp')

tm = cwapi.project().traceManager()
ntraces = tm.numTraces()

#Reference trace
trace_ref = tm.getTrace(0)

#plot(trace_ref)

#The target trace we will attack
#If following tutorial:
#0/1 = 80 00
#2/3 = 81 40
#4/5 = AB E2
#6/7 = AB E3 (this won't work as we don't detect the last 1)
示例#3
0
import chipwhisperer
from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI
from matplotlib.pylab import *

cwapi = CWCoreAPI()

#cwapi.openProject(r'c:\users\colin\chipwhisperer_projects\tmp\mpc5748g_password_group0_100k.cwp')
#knownkey = "0000000000000000FFFFFFFFFFFFFFFF00000000FFFFFFFF0000000000000000"

cwapi.openProject(
    r'c:\users\colin\chipwhisperer_projects\tmp\mpc5748g_password_group3_100k.cwp'
)
knownkey = "5c3c3dc267b1d8f792f633c51389356c104100f0b52f1aa7f85c2c786d376cf8"
#knownkey = "6d376cf8f85c2c78b52f1aa7104100f01389356c92f633c567b1d8f75c3c3dc2"

knownkey = [int(knownkey[i:(i + 2)], 16) for i in range(0, 64, 2)]

#HD Tests
knownkey[4:] = [knownkey[i + 0] ^ knownkey[i + 4] for i in range(0, 32 - 4)]

tm = cwapi.project().traceManager()

#ppMod0 = chipwhisperer.analyzer.preprocessing.resync_sad.ResyncSAD(cwapi.project().traceManager(), connectTracePlot=False)
#ppMod0.setEnabled(True)
##ppMod0.setReference(rtraceno=0, refpoints=(12,211), inputwindow=(0,487))
#ppMod0.setReference(rtraceno=0, refpoints=(513,657), inputwindow=(326,713))
#ppMod0.init()
#
#ppMod4 = chipwhisperer.analyzer.preprocessing.cache_traces.CacheTraces(ppMod0)
#ppMod4.setEnabled(False)
#ppMod4.init()
import chipwhisperer
from chipwhisperer.common.api.CWCoreAPI import CWCoreAPI
from matplotlib.pylab import *

cwapi = CWCoreAPI()

#cwapi.openProject(r'c:\users\colin\chipwhisperer_projects\tmp\mpc5748g_password_group0_100k.cwp')
#knownkey = "0000000000000000FFFFFFFFFFFFFFFF00000000FFFFFFFF0000000000000000"

#cwapi.openProject(r'c:\users\colin\chipwhisperer_projects\tmp\mpc5748g_password_group3_100k.cwp')
cwapi.openProject(r'e:\mpcfiles\mpc5748g_pw_1core_200k_randtext_group3.cwp')
#Knownkey for group 3 as sent
knownkey = "5c3c3dc267b1d8f792f633c51389356c104100f0b52f1aa7f85c2c786d376cf8"
#Knownkey for group 3 as written in FLASH (which is bakcwards to how comparison actually ahppens)
#knownkey = "6d376cf8f85c2c78b52f1aa7104100f01389356c92f633c567b1d8f75c3c3dc2"

knownkey = [int(knownkey[i:(i + 2)], 16) for i in range(0, 64, 2)]

#HD Tests
knownkey[4:] = [knownkey[i - 4] ^ knownkey[i] for i in range(0, 32 - 4)]

tm = cwapi.project().traceManager()

#ppMod0 = chipwhisperer.analyzer.preprocessing.resync_sad.ResyncSAD(cwapi.project().traceManager(), connectTracePlot=False)
#ppMod0.setEnabled(True)
##ppMod0.setReference(rtraceno=0, refpoints=(12,211), inputwindow=(0,487))
#ppMod0.setReference(rtraceno=0, refpoints=(513,657), inputwindow=(326,713))
#ppMod0.init()

#ppMod4 = chipwhisperer.analyzer.preprocessing.cache_traces.CacheTraces(ppMod0)
#pMod4.setEnabled(True)