The stun (also known as taser) can paralyze the attacker with paralyzing electric shock. Brief contact with the stun gun output voltage he gets an electric shock that temporarily paralyzes him to deter further attacks. Prolonged contact with the stun gun output voltage (more than 1s) leads to muscle spasm, the attacker falls to the ground. Up to several minutes he is unable to coordinated movement.
Stun gun works as a two-stage voltage converter. The first stage with the high frequency switching transformer increases the voltage of the battery to a higher voltage of a few hundred volts to several kV. This voltage is charging a capacitor. After being charged the capacitor is discharged into the second (pulse) transformer to increase the voltage to approximately 10 - 50kV. (Numbers on the Stun gun as 100 000 V or even 2000 000 V are fictitious, voltage 2 000 000 V would create discharges of more than 2m long - manufacturers are just competing in the silly numbers of volts the general public does not understand.) Repetition rate is about 5 - 40Hz.
There are 3 basic types: Thyristor (SCR) ones, spark gap ones and multiplier ones. spark gap stun guns are just the cheapest types are very unreliable and ineffective. Thyristor is replaced by a spark gap. Battery voltage is boosted using transistor converter. For the ignition of the spark gap, a higher voltage (at least 1kV) is needed and is therefore sometimes an auxiliary multiplier is attached to the secondary of the first voltage transformer. After charging the capacitor to a voltage sufficient to ignite the spark gap it discharges into the capacitor in the pulse transformer. The principle is similar to the Tesla coil. Thyristor stun guns are more reliable and more efficient - the spark gap is replaced by thyristor (SCR). Capacitor voltage is not so high, just about 250 - 500V. Thyristor is driven by a diac, neon lamp or resistive divider (for thyristor control with sensitive electrode). multiplier stun guns have only one transformer with a higher output voltage, followed by a high-voltage multiplier cascade of diodes and capacitors. Their output is a DC voltage. Thanks to the capacitors in multipliers the sparks are very loud. In direct contact with the skin, however, capacitors are not discharged in pulses, but continuous current flows, which can significantly reduce the effect. It is therefore necessary to only get the electrodes close to the attacker body, but not touch him directly.
I chose thyristor (SCR) version. I made a voltage converter with a MOSFET, because "children's" push-pull converters with bipolar transistors used in commercial stun guns have an efficiency of around 20%. The effectiveness of my converter is about 75%. Working frequency is about 80 - 120kHz. As a second stage switch I used a thyristor with a gate driven by 4 glow neon lamps in the series (their ignition voltage is about 95V, a total of 380V). Pulse repetition rate is about 30 - 50Hz. Inverter transformer is on ferrite EE core with cross-section of the the middle column 20 to 25 mm2. The air gap is in the middle column of the core and is about 0.5 mm thick. Primary has 2x 12 turns of wire diameter of 0.4 mm, a secondary is 700 turns of wire 0.1 mm. Secondary is is wound in several layers, which are isolated from each other - otherwise the wire enamel can break down under such voltage. Secondary polarity must be observed! HV pulse transformer with voltage of many kV can be hard to make. You can use the high voltage transformer for Xenon strobe lamps ingition. I used 2 such transformers with primaries in parallel and secondaries in series. The stun gun has two electrodes: one called test, which are closer to each other. Among them he discharge forms during no-load operation. Discharge limits the maximum voltage and also serves to deter an attacker. Second, the main electrodes facing forward. The distance between them is considerably larger than the distance between the test ones. From those electrodes the current flows into the body of attacking people :). Stun gun can be powered by 6 cells 1.5 V or 6 to 7 cells 1.2 V (NiCd or NiMH). Very suitable are 2 cells of Li-ion or Li-pol connected in series (2x 3.6 - 3.7 V). The stun gun draws a high current around 1.5 A from the battery, so ordinary 9V battery can not be used.