Source: Starfinder Core Rulebook p.120
As a reaction when you take damage from an attack by a technological weapon or source within medium range that specifically targets you, you can expend an unused spell slot to disrupt the attack. With a spell slot of 1st to 5th level, you can counter an attack from a technological weapon whose item level is equal to or less than the level of the expended spell slot x 3, to a maximum of your caster level. 6th-level spell slots can counter any weapon with a level equal to or less than your caster level. For example, at 2nd level, you could expend a 1st-level spell slot to counter an attack from a 1st- or 2nd-level weapon. To successfully counter the attack, you must roll a countertech check (1d20 + your caster level) with a DC equal to 11 + the weapon's level. If the countertech check succeeds, the attack deals half damage. If the countertech check fails, the attack deals normal damage. This magic hack only affects attacks that target you directly; you cannot use countertech against attacks that target an area or that target another person.