updated command line 802.15.4 checksum calculator and added serClose to GoodFET to...
[goodfet] / client / goodfet.glitch
1 #!/usr/bin/env python
2
3 import sys,binascii,time,random;
4
5 sys.path.append('../../../trunk/client/')
6
7 from GoodFETAVR import GoodFETAVR;
8 from GoodFETGlitch import *;
9 from intelhex import IntelHex16bit, IntelHex;
10
11 import sqlite3;
12
13
14 if(len(sys.argv)==1):
15     print "Usage: %s chip verb [objects]\n" % sys.argv[0];
16     print "%s avr learn" % sys.argv[0];
17     print "%s avr explore" % sys.argv[0];
18     print "%s avr graph" % sys.argv[0];
19     print "%s avr graphx11" % sys.argv[0];
20     print "%s avr points" % sys.argv[0];
21     print "%s avr npoints" % sys.argv[0];
22     print """
23 This populates a database, glitch.db, with a record of all attempted
24 glitches.  Graphs can then be generated from the results, allowing
25 results to be replicated on different hardware and models.  The general
26 sequence for a new chip is as follows.
27
28 On a sample chip for the same model as the target,
29 1) Run 'goodfet $chip learn' in order to learn the glitching voltages.
30 2) Run 'goodfet $chip crunch' in order to precompute glitching ranges.
31 3) Run 'goodfet $chip explore [tstart tstop]' to find a time at which to glitch.
32
33 Then on a chip to be extracted,
34 3) Run 'goodfet $chip exploit' to exploit a chip and recover its firmware."""
35     sys.exit();
36
37 glitcher=GoodFETGlitch();
38
39 if(sys.argv[2]=="graphx11"):
40     glitcher.graphx11();
41     exit();
42 if(sys.argv[2]=="graph"):
43     glitcher.graph();
44     exit();
45 if(sys.argv[2]=="points"):
46     glitcher.points();
47     exit();
48 if(sys.argv[2]=="rangepoints"):
49     glitcher.rpoints();
50     exit();
51
52 if(sys.argv[2]=="crunch"):
53     glitcher.crunch();
54     exit();
55
56 glitcher.setup(sys.argv[1]);
57
58 if(sys.argv[2]=="learn"):
59     glitcher.learn();
60 if(sys.argv[2]=="explore"):
61     times=None;
62     if(len(sys.argv)>=4):
63         times=range(int(sys.argv[3]),
64                     int(sys.argv[4]));
65     glitcher.explore(times);
66 if(sys.argv[2]=="exploit"):
67     print "Coming soon.";
68