goodfet.glitch crunch
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Sat, 20 Mar 2010 00:32:20 +0000 (00:32 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Sat, 20 Mar 2010 00:32:20 +0000 (00:32 +0000)
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@427 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

client/GoodFETGlitch.py
client/goodfet.glitch

index 7e997cb..2e0b2b4 100644 (file)
@@ -75,15 +75,21 @@ class GoodFETGlitch(GoodFET):
             return range(min,max,1);
         #If we get here, there are no points.  Return empty set.
         return [];
-    def buildglitchvoltages(self):
+    def crunch(self):
         """This builds tables for glitching voltage ranges from the training set."""
-        print "Precomputing glitching ranges.  This might take a while.";
+        print "Precomputing glitching ranges.  This might take a long while.";
+        print "Times...";
         sys.stdout.flush();
-        self.db.execute("create temporary table glitchrange(time integer primary key asc,max,min);");
+        self.db.execute("drop table if exists glitchrange;");
+        self.db.execute("create table glitchrange(time integer primary key asc,max,min);");
         self.db.execute("insert into glitchrange(time,max,min) select distinct time, 0, 0 from glitches;");
+        print "Maximums...";
+        sys.stdout.flush();
         self.db.execute("update glitchrange set max=(select max(vcc) from glitches where glitches.time=glitchrange.time and count=0);");
+        print "Minimums...";
+        sys.stdout.flush();
         self.db.execute("update glitchrange set min=(select min(vcc) from glitches where glitches.time=glitchrange.time and count>0);");
-        
+        print "Ranges calculated.";
     def graphx11(self):
         try:
             import Gnuplot, Gnuplot.PlotItems, Gnuplot.funcutils
@@ -126,9 +132,9 @@ class GoodFETGlitch(GoodFET):
             tstop=self.client.glitchstarttime();
         times=range(tstart,tstop);
         random.shuffle(times);
-        self.buildglitchvoltages();
+        #self.crunch();
         count=0.0;
-        total=1.0*len(t);
+        total=1.0*len(times);
         for t in times:
             voltages=self.glitchvoltages(t);
             count=count+1.0;
index aee0d49..823b8de 100755 (executable)
@@ -27,7 +27,8 @@ sequence for a new chip is as follows.
 
 On a sample chip for the same model as the target,
 1) Run 'goodfet $chip learn' in order to learn the glitching voltages.
-2) Run 'goodfet $chip explore' to find a time at which to glitch.
+2) Run 'goodfet $chip crunch' in order to precompute glitching ranges.
+3) Run 'goodfet $chip explore' to find a time at which to glitch.
 
 Then on a chip to be extracted,
 3) Run 'goodfet $chip exploit' to exploit a chip and recover its firmware."""
@@ -41,6 +42,10 @@ if(sys.argv[2]=="graph"):
     glitcher.graph();
     exit();
 
+if(sys.argv[2]=="crunch"):
+    glitcher.crunch();
+    exit();
+
 glitcher.setup(sys.argv[1]);
 
 if(sys.argv[2]=="learn"):