This will not prevent any hardware attacks, like a USB-killer, but this should stop (almost?) all software attacks, except for the very most advanced versions where a malicious program is somehow hidden somewhere in the motherboard or something similar.
You need:
- A computer you can disassemble (must have a DVD reader, preferably NOT a combined reader & writher)
- A one time burnable DVD (not a flash drive, those can be written too later)
- A DVD burner (preferably on another computer)
What to do:
Follow these instructions to make a bootable Ubuntu (Linux) DVD:
https://tutorials.ubuntu.com/tutorial/tutorial-burn-a-dvd-on-windows#0
When you have a bootable DVD (& have tested that it works), also preferably make sure that the BIOS tries to boot from the DVD reader on the computer that you will disassemble.
then (unplug the power and) open the computer that you choose to disassemble & remove the hard-drive & any (wireless) network cards from the computer.
Now insert the bootable DVD into the disassembled computer & start it up.
Linux have an amazing OS that can run from the DVD, so now you should be able to insert the USB into a port on the disassembled computer.
Assuming that the USB is infected with all kinds of malicious software, now the malwares should not be able to store themselves anywhere, because the only places to potentially be stored at is:
the RAM memories (looses all data as soon as the power is turned off).
maybe some kind off boot-memory on the motherboard (requires a VERY advanced virus. probably specifically designed for EXACTLY that motherboard, since most motherboard types have slightly different programming).
some registers inside the CPU (can only hold a few bytes at a time, and probably(?) forgets everything when the power turns off).
BE CAREFUL with keyboards, mouses & screens that are connected to this computer because they might have some kind of memory inside them, so just assume that they are infected & don't use them anywhere else, I think it's a good idea to also use the oldest keyboard, mouse & screen you have, because I think it's less likely that they have a built in memory (unlike the latest Razor mouses & similar things).
When you are done, just unplug the computer & all memories should be cleared (the motherboard might have a "button cell battery" that keeps the clock ticking even when the computer is underpowered, this battery might also power some memories, so it could be a good idea to remove that battery too for a while (I don't know if this will clear any important "motherboard-booting-memories" or something, does anyone else know?))
Good luck!