I have an USB drive that probably is infected. I have a PC where currently I have not any partition, just an "empty" PC and I have a CD with Ubuntu 22.04. I would like to copy USB data, format the USB and copy data back to USB.
To format the USB I will use dd:
sudo dd if=/dev/zero of=/dev/sdX bs=1k count=2048
I took this from here: https://askubuntu.com/a/185827
I was thinking of these ways to protect the formatted USB when I will insert it back to copy back the data:
First way: (Ubuntu Live and an empty partition)
- Launch Ubuntu 22.04 Live with the CD
- Create an empty partition on my PC just to put data
- Mount the partition
- Insert the USB and copy data to partition
- Format the USB
- Restart the Live
- Mount the partition where I copied data before
- Insert the USB and copy back data from the partition to the USB
I think that the problem of this way is that: The malware could to exploit an Ubuntu Live vulnerability and replicates itself from the USB to the partition, then when I will restart the live and mount the partition, it will replicate back from partition to the formatted USB. Also, I think that when you run Ubuntu Live, you don't have latest security update.
Second way: (Using installed Ubuntu)
- Install Ubuntu 22.04 on the PC and start it
- Insert the USB and copy data on the user Home
- Format the USB
- Restart the OS
- Insert the USB and copy back data from Ubuntu to the USB
In this way, I think that the problem is: The malware could to exploit an Ubuntu 22.04 vulnerability and replicates itself from the USB to the OS, then it will infect the OS and when I will insert the formatted USB back, it will replicate back from the OS to the formatted USB.
Third way: (Use installed Ubuntu and the live)
- Install Ubuntu 22.04 on the PC and start it
- Insert the USB and copy data on the user Home
- Shutdown the OS
- Start Ubuntu Live with the CD
- Insert the USB and format it without to mount the Ubuntu Partition
- Restart the Live
- Mount the Ubuntu Partition (the partition where Ubuntu is installed)
- Insert the USB and copy back data from the Ubuntu partition to the USB.
I think this is the longest but safest way, but I don't know.
Which is the safest way? Is there another way?
Yes, I know it's very paranoid question, but I want to try to make 99.9 % sure that the USB will not be reinfected back once I formatted it and copied back its data to it.
dddoes not touch firmware. So this is why I'm saying that you do not need to do any of this, if your drive's firmware is infected, then don't plug it into anything. – schroeder Dec 12 '22 at 20:51