Nordic RF client library, test script.
[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 glitcher=GoodFETGlitch();
15
16 if(len(sys.argv)==1):
17     print "Usage: %s chip verb [objects]\n" % sys.argv[0];
18     print "%s avr learn" % sys.argv[0];
19     print "%s avr explore" % sys.argv[0];
20     print "%s avr graph" % sys.argv[0];
21     print "%s avr graphx11" % sys.argv[0];
22     print "%s avr points" % sys.argv[0];
23     print "%s avr npoints" % sys.argv[0];
24     print """
25 This populates a database, glitch.db, with a record of all attempted
26 glitches.  Graphs can then be generated from the results, allowing
27 results to be replicated on different hardware and models.  The general
28 sequence for a new chip is as follows.
29
30 On a sample chip for the same model as the target,
31 1) Run 'goodfet $chip learn' in order to learn the glitching voltages.
32 2) Run 'goodfet $chip crunch' in order to precompute glitching ranges.
33 3) Run 'goodfet $chip explore' to find a time at which to glitch.
34
35 Then on a chip to be extracted,
36 3) Run 'goodfet $chip exploit' to exploit a chip and recover its firmware."""
37     sys.exit();
38
39
40 if(sys.argv[2]=="graphx11"):
41     glitcher.graphx11();
42     exit();
43 if(sys.argv[2]=="graph"):
44     glitcher.graph();
45     exit();
46 if(sys.argv[2]=="points"):
47     glitcher.points();
48     exit();
49 if(sys.argv[2]=="npoints"):
50     glitcher.npoints();
51     exit();
52
53 if(sys.argv[2]=="crunch"):
54     glitcher.crunch();
55     exit();
56
57 glitcher.setup(sys.argv[1]);
58
59 if(sys.argv[2]=="learn"):
60     glitcher.learn();
61 if(sys.argv[2]=="explore"):
62     glitcher.explore();
63 if(sys.argv[2]=="exploit"):
64     print "Coming soon.";
65