As part of my work on the IBM X-Force Application Security Team, a few months ago I wanted to see if I could reproduce a Rowhammer-exploit-type memory corruption via an externally-generated electromagnetic pulse (EMP). The idea here was to target primary memory (usually [S]DRAM) to perform a bit-flip via an electromagnetic pulse-induced glitch.
I have (thus far) failed miserably to build an actual exploit; more on why in a subsequent blog post.
In this post, I'd like to detail my IBM-sponsored single-pulse glitcher (EMP generator) build (yes, it involves Tupperware) and touch on some basics of the theory of operation of its various components.
DISCLAIMER 1: IF YOU DON'T KNOW EXACTLY WHAT YOU'RE DOING, DO NOT TRY REPRODUCE THIS BUILD OR PLAY AROUND WITH HIGH-VOLTAGE CAPACITORS. IT'S POTENTIALLY DANGEROUS (READ: DEADLY)!
DISCLAIMER 2: EVEN IF YOU KNOW EXACTLY WHAT YOU'RE DOING, DO NOT BUILD THIS! LEAVING IT AROUND COULD BE DANGEROUS TO SOMEONE WHO TOUCHES IT (LIKE YOUR KIDS)!
Disclaimer 3: My build's EMP range is in the order of millimeters to centimeters and the interference it causes is relatively weak. It's not a weapon and was built at my employer for security-research purposes only and used only within a private lab. Do not use this build for nefarious reasons!
OK, warnings aside, let's begin.
I'll start by detailing the most basic build which simply consists of a single capacitor, a switch and a coil of wire like so:
If the capacitor was charged, closing the circuit (by flipping the switch) would induce an extremely high current over the coil load (as there is very little resistance in the circuit). This is because capacitors store energy. The amount of energy stored by a capacitor is denoted by Farads, or the symbol
As the electrons flow from the negative pole to the positive pole of the capacitor, a magnetic field is formed as per Maxwell's correction to Ampère's Law. In our circuit above, these electrons flow through the coil - a solenoid - concentrating the magnetic field inside the coil. The strength of this field is proportional to the current flowing through the solenoid which, in turn, is proportional to the energy dissipated by the capacitor discharge.
It is this magnetic field that causes electronics to go crazy. This is due to the fact that the field can excite electrons (and hence current flow) within the target device (the exact reverse of what's happening on the EMP side). If one manages to excite the target enough, Bad Things May Happen.
It follows therefore that the more energy stored within the capacitor, the stronger the magnetic field will be.
The decision that we have to make at this point is which capacitor to chose. We need a capacitor capable of quickly discharging its stored energy and one with large enough capacity to induce a sufficiently-strong magnetic field within the solenoid. We don't wish for the field to be too strong as our range of operation for this project (glitching memory) is in the order of millimeters and the target devices operate at around 3.3 volt so the glitch amplitude shouldn't need to be that high to induce some undefined behaviour.
The easiest capacitor to go for, imho, is a
330V 80uF flash capacitor. You'll see this advised by a number of glitcher-building guides on the net. The reason is that it's easily available and comes with a charging circuit to match! Just find a disposable camera with a flash and gut it (actually getting more difficult to find these days; I think I found the last 3 in the country).
A word of caution when opening these cameras. Make sure the capacitor is discharged before touching any part of the circuitry inside. You can do this by firstly winding up the camera and charging the flash. Then activate the shutter to discharge the capacitor. Additionally it's a good idea to make sure it has fully discharged by shorting both ends of the capacitor with a rubber-handled screwdriver (it might make a spark - the energy dissipates as light and heat - but it's likely safe to do with a capacitance of this value).
In our first circuit above, we assumed that the capacitor was already charged. In our working circuit we will need to charge the capacitor.
In order to charge capacitors, one must apply a potential difference (voltage) over it's poles which is greater than its rated voltage for a set amount of time. The time that a capacitor takes to charge is specified by the RC time constant, tau
T, of the circuit such that the capacitor will be charged to
4T the capacitor will be charged to
98%. The charging time between
4T is called the transient period. After
4T the capacitor enters the steady-state period. At
5T the capacitor is considered to be fully charged.
In our circuit, we have selected a value of
R = 10k. Our capacitance is
C = 80uF.
T = RC = 10k x 80u = 800 milliseconds 5T = 4 seconds
So in order to charge our capacitor to capacity, we need to apply
330V over its poles for
The challenge now is to provide a
330V source with which to charge the capacitor. One can use a DC-DC step-up transformer, however luckily the disposable camera which we pillaged above has a nice little charging circuit which we can re-purpose for our needs.
The circuit in most disposable cameras has a feedback mechanism whereby closing the switch causes the charging process to commence and it automatically stops charging when the target voltage is reached (this is so that one doesn't need to hold down the flash button on the camera for the whole duration of the transient period). We'll consider it a black-box for our purposes and using this charger, we can update our circuit diagram as follows:
The push button switch in the diagram above commences the charging procedure. After the capacitor has reached capacity, closing the switch between the capacitor and the solenoid will create the EMP.
Even though we now have a full EMP circuit, I added a number of features to my design.
Firstly, I doubled the capacitance of the circuit in order to create a stronger pulse. I pillaged another
80uF capacitor from a disposable camera and added it in parallel to the first capacitor. This gives a total capacitance of
I then added a high impedance voltage-divider circuit which allows me to digitally measure the voltage of the circuit. This is connected in parallel over the capacitor. The reason for the high impedance is that I don't want the capacitor to discharge ('bleed') its energy though this path otherwise there won't be any energy to discharge through the coil!
The total impedance of the voltage divider is just over
2.2M. To understand the affect that this has on the circuit, we need to take a look at how the capacitor discharges.
As with the charging circuit above, the capacitor will discharge
63% of its energy in
1T and be fully discharged at
5T. The impedance of the voltage divider is approximated
T = RC = 2.2M * 160uF = 58.6 minutes
As one can see, the bleeding through the voltage divider is quite slow and doesn't have a major affect on the energy of the EMP if the EMP is triggered shortly after the capacitor is charged.
Interestingly this also provides a built-in safety feature. Forgetting to discharge the circuit could prove hazardous as capacitors will hold their charge for a long time. The voltage divider will cause the circuit to bleed the capacitors over time as even though the impedance is high, there is some current flowing through this path. The capacitors I'm using will generally be considered safe at around
42V. They will be discharged to this value at roughly
2.2T, so after about 2 hours and 10 minutes.
The aforementioned voltage divider is connected to a microcontroller (MCU). The one I'm using is the MicroPython board which is a pretty awesome bit of kit (highly recommended). I use this board connected over USB to a PC to control the glitcher (mostly). The voltmeter gives me an indication of the current level of charge of the capacitor. The MCU is also connected to two relays. The first relay is used to complete the charger circuit (in place of the disposable camera push button). The second relay connects a
3.3k resistor over the poles of the capacitor. I can use this to very quickly discharge (bleed) the circuit and even use it to select a particular voltage for the pulse (I can bleed the circuit for a very short time causing a controlled drop in capacitor charge; to half the voltage for example). This is a
35W rated part as it needs to be able to handle the amount of energy dissipated through it (high current). The interface is shown in the video of the capacitor charging below:
The final part of the build is the solenoid itself. I have experimented with a number of different coils; diameter, number of windings etc. The ideal coil depends on the application and isn't an exact science at all. For my needs I wanted a small, focused EMP with which I could target a RAM IC without glitching the surrounding electronics. My first attempt at a large coil tended to reset my computer! I then made a few smaller coils out of insulated copper wire wound around ferrite iron cores. Here are some pictures of my various coils:
So does the glitcher work? Well yes! I verified this experimentally. As mentioned, the large coil can reset my computer. I used the smaller coils to target RAM IC chips in a PC. I was able to cause some havoc with RAM contents but I'll leave that for another blog post.
As for how the glitch actually looks on the target; according to Wikipedia, what we should see is a damped sinewave pulse. This is due to coupling on the ground plane between the glitcher and the target. I won't go into this in detail but it's all on Wikipedia if you're interested. Throwing an EM pulse out at a scope probe shows exactly this affect so all seems to be working well:
That's all for now folks! Leaving you with a picture of the glitcher in all it's tupperwear-enclosed glory!