aee0d490bd96c46f89cc70ec5a48035c31b3a51a
[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 """
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 explore' to find a time at which to glitch.
31
32 Then on a chip to be extracted,
33 3) Run 'goodfet $chip exploit' to exploit a chip and recover its firmware."""
34     sys.exit();
35
36
37 if(sys.argv[2]=="graphx11"):
38     glitcher.graphx11();
39     exit();
40 if(sys.argv[2]=="graph"):
41     glitcher.graph();
42     exit();
43
44 glitcher.setup(sys.argv[1]);
45
46 if(sys.argv[2]=="learn"):
47     glitcher.learn();
48 if(sys.argv[2]=="explore"):
49     glitcher.explore();
50 if(sys.argv[2]=="exploit"):
51     print "Coming soon.";
52