WOrking on MSP430 client mode.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Sun, 7 Mar 2010 23:56:31 +0000 (23:56 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Sun, 7 Mar 2010 23:56:31 +0000 (23:56 +0000)
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@396 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

client/GoodFET.py
client/GoodFETGlitch.py
client/goodfet.glitch

index d024638..5c38ca9 100755 (executable)
@@ -14,7 +14,7 @@ def getClient(name="GoodFET"):
     elif name=="cc" or name=="chipcon": return GoodFETCC.GoodFETCC();
     elif name=="avr": return GoodFETAVR.GoodFETAVR();
     elif name=="spi": return GoodFETSPI.GoodFETSPI();
-    elif name=="msp430": return GoodFETSPI.GoodFETMSP430();
+    elif name=="msp430": return GoodFETMSP430.GoodFETMSP430();
     
     print "Unsupported target: %s" % name;
     sys.exit(0);
index 2790367..d87b9ab 100644 (file)
@@ -10,6 +10,18 @@ import sqlite3;
 
 from GoodFET import *;
 
+script_timevcc="""
+plot "< sqlite3 glitch.db 'select time,vcc,glitchcount from glitches where count=0;'" \
+with dots \
+title "Scanned", \
+"< sqlite3 glitch.db 'select time,vcc,count from glitches where count>0;'" \
+with dots \
+title "Success", \
+"< sqlite3 glitch.db 'select time,vcc,count from glitches where count>0 and lock>0;'" \
+with dots \
+title "Exploited"
+""";
+
 class GoodFETGlitch(GoodFET):
     
     def __init__(self, *args, **kargs):
@@ -20,17 +32,38 @@ class GoodFETGlitch(GoodFET):
         self.client=0;
     def setup(self,arch="avr"):
         self.client=getClient(arch);
+    def graph(self):
+        try:
+            import Gnuplot, Gnuplot.PlotItems, Gnuplot.funcutils
+        except ImportError:
+            print "gnuplot-py is missing.  Can't graph."
+            return;
+        g = Gnuplot.Gnuplot(debug=1);
+        g.clear();
+        
+        g.title('Glitch Training Set');
+        g.xlabel('Time (16MHz)');
+        g.ylabel('VCC (DAC12)');
+        
+        g('set datafile separator "|"');
+        
+        g(script_timevcc);
+        while 1==1:
+            time.sleep(30);
+            g('replot');
+        
     def learn(self):
         #Learning phase
         trials=1;
         lock=0;  #1 locks, 0 unlocked
         vstart=0;
-        vstop=0xFFF;  #Smaller range sometimes helps.
+        vstop=1024;  #Could be as high as 0xFFF
         vstep=1;
         tstart=0;
         tstop=-1; #<0 defaults to full range
         tstep=0x1; #Must be 1
         self.scan(lock,trials,vstart,vstop,tstart,tstop);
+
     def scan(self,lock,trials=1,vstart=0,vstop=0xfff,tstart=0,tstop=-1):
         client=self.client;
         self.lock=lock;
@@ -62,7 +95,7 @@ class GoodFETGlitch(GoodFET):
         gnd=0;     #TODO, glitch GND.
         vcc=0xfff;
         random.shuffle(voltages);
-        random.shuffle(times);
+        #random.shuffle(times);
         
         count=0; #Commit counter.
         for vcc in voltages:
@@ -70,9 +103,10 @@ class GoodFETGlitch(GoodFET):
                 self.scanat(trials,vcc,gnd,time)
                 sys.stdout.flush()
                 count+=trials;
-                if count>1000:
+                if count>100:
                     count=0;
                     self.db.commit();
+                        
 
     def scanat(self,trials,vcc,gnd,time):
         client=self.client;
@@ -81,7 +115,7 @@ class GoodFETGlitch(GoodFET):
         client.glitchVoltages(gnd, vcc);  #drop voltage target
         gcount=0;
         scount=0;
-        print "-- (%i,%i)" % (time,vcc);
+        print "-- (%5i,%5i)" % (time,vcc);
         sys.stdout.flush();
         for i in range(0,trials):
             client.glitchstart();
@@ -99,8 +133,8 @@ class GoodFETGlitch(GoodFET):
                     gcount+=1;
                 if(a==self.secret):
                     scount+=1;
-        print "values (%i,%i,%i,%i,%i);" % (
-            time,vcc,gnd,gcount,scount);
+        #print "values (%i,%i,%i,%i,%i);" % (
+        #    time,vcc,gnd,gcount,scount);
         self.db.execute("insert into glitches(time,vcc,gnd,trials,glitchcount,count,lock)"
                    "values (%i,%i,%i,%i,%i,%i,%i);" % (
                 time,vcc,gnd,trials,gcount,scount,self.lock));
index edce100..7e20263 100755 (executable)
@@ -16,6 +16,7 @@ glitcher=GoodFETGlitch();
 if(len(sys.argv)==1):
     print "Usage: %s chip verb [objects]\n" % sys.argv[0];
     print "%s avr learn" % sys.argv[0];
+    print "%s avr graph" % sys.argv[0];
     print """
 This populates a database, glitch.db, with a record of all attempted
 glitches.  Graphs can then be generated from the results, allowing
@@ -29,3 +30,5 @@ glitcher.setup(sys.argv[1]);
 
 if(sys.argv[2]=="learn"):
     glitcher.learn();
+if(sys.argv[2]=="graph"):
+    glitcher.graph();