droidstealth / droid-stealth

THIS PROJECT IS DEPRECATED
GNU General Public License v2.0
61 stars 22 forks source link

Little side project: data wiper #76

Closed OlivierHokke closed 10 years ago

OlivierHokke commented 10 years ago

I wrote this snippet that writes a file as big as your available space in order to completely fill your internal SD with random bytes so data can't be recovered. This snippet is made for the #66 branch. Eagerly waiting for a merge of that pull request.


        new Thread(new Runnable() {
            @Override
            public void run() {
                Random r = new Random();
                File cache = Utils.getRandomCacheFile("");
                Utils.debugToast("Cleaning free space");
                try {
                    BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(cache));
                    long available = cache.getUsableSpace();
                    int writeBytes = 10000;
                    byte[] bytes = new byte[writeBytes];
                    while (available / 2 > writeBytes) {
                        r.nextBytes(bytes);
                        bos.write(bytes);
                        bos.flush();
                        available = cache.getUsableSpace();
                        Utils.debugToast("Wrote a piece, space left: " + available/1024 + " KB");
                    }
                    bos.close();
                    Utils.debugToast("Done! Deleting file: " + cache.delete());
                } catch (IOException e) {
                    Log.e(Utils.tag(this), "SOM TIN WONG", e);
                }
            }
        }).start();
OlivierHokke commented 10 years ago

Create notification that shows progress perhaps too?

OlivierHokke commented 10 years ago

Related to #82

jzvandenoever commented 10 years ago

While an interesting start I recommend first reading literature on best practices with this sort of thing. And make sure to take note of the differences between flash and magnetic drives. Just to have some reasoning behind the method used if nothing else. Because I know just overwriting once isn't enough in a lot of cases. As well as putting a lot of stress on the storage medium. No need to reinvent the wheel either.

Secondly, it's a bit of sidetrack right now to what we want to deliver. So I'm making this a bit for now and we can revisit this later.

OlivierHokke commented 10 years ago

I agree, but I actually did research on this :) also, I use the same method as another app does, see #82, but paid. And since this feature is apparently so easily implemented, it might be cool to add if we end up having a bit of time for it. All we'd have to do is add a fragment with a button for it and let it update a notification showing the progress while it is running. Easy peasy.

AlexKolpa commented 10 years ago

"Eagerly waiting for a merge of that pull request."

Label: Do not merge.

Stop being so confusing!

Also, why would you want to remove the entire primary storage? Even if you were to overwrite just our own data (which seems to be your suggestion?), it seems a bit overkill, especially for this version.

OlivierHokke commented 10 years ago

oh I forgot about that label :P I walt added that (which was good). Will fix now.

Not sure what you mean with removing the entire primary storage?

What I am doing is filling the free space up with random bytes, as when you delete a file a file system usually picks another location for the next file to write on. Overwriting a file, does not mean you are literally overwriting the file on the physical location of the file. Therefore overwriting a file is not enough to fully delete it. It is still recoverable. Until you overwrite the entire free space with random bytes.