Wiping Files

If you haven't heard of wiping and think i am ttalking about using the kill command alone you may aswell leave.
There is a form of deleting called DoD
this is supposed to overwrite the file 3 times with data and then kill it.
if you delete a file normally it can sometimes be restored with a disk utility so if anyone knows this method or anything that would do the same please tell me for 70 points
LVL 1
adam8Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
mcriderConnect With a Mentor Commented:
Here you go... This subroutine will wipe the file using DOD standards. First it writes hex 0 to all of the bytes in the file, then it writes hex 255, then it writes hex 0.  

You can also kill (erase) the file afterwards...

Cheers!®©



THE CODE:


    Sub WipeFile(Source As String, Passes As Integer, Optional KillFile As Boolean)
        Dim iVal As Long
        Dim jVal As Long
        Dim fNum As Integer
        iVal = FileLen(Source)
        fNum = FreeFile
        On Error Resume Next
        Open Source For Binary Access Write As fNum
        If Not Err = 0 Then Exit Sub
        For iVal = 1 To iVal
            For jVal = 1 To Passes
                Put #fNum, iVal, Chr$(0)
                Put #fNum, iVal, Chr$(255)
                Put #fNum, iVal, Chr$(0)
            Next jVal
        Next iVal
        Close fNum
        If KillFile = True Then Kill Source
    End Sub
0
 
mcriderCommented:
By the way, you call it like this:

   WipeFile "C:\MyDocs\Doc1.Doc", 3 ,True


This will open C:\MyDocs\Doc1.Doc, perform the 0/255/0 file write 3 times, then erase the file from the disk.


Curious?  Why are you thinking about using this type of system... The highest possible gvt rating for a windows system is C2.  Object Reuse and Data Remnant procedures dont apply until B1 or higher assurance systems...


Cheers!®©

0
 
adam8Author Commented:
look good. I will try it out and rate it very fairly.
Thanks a lot for your help.
could i also change the 3 to 26 or any higher number if i wanted?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
adam8Author Commented:
didn't work.
I put it in a form and got a file and it didn't do anything to the file.
the file still worked fine.
0
 
mcriderCommented:
You can change the 3 up to 32767 if you wanted... Just remember, 3 does a pass of writing 0/255/0 3 times...

What about my question to you about using this??


Cheers!®©
0
 
adam8Author Commented:
i didn't understand your question.
sorry
0
 
VbmasterCommented:
If you are to use the DoD technique more than once you need to flush the I/O buffer, does anyone know how to do this? Mcrider, doesn't your code just rewrite the internal buffer used by the OS (3 times)?

3x sounds enough.. but it's possible to restore the data up to 8x (not using cheep solutions but it's possible).
0
 
mcriderCommented:
What do you mean you couldn't get it to work???? Are you sure you are passing the name of the file correctly??

It works perfectly here.  

Put a break point on the line:

   Open Source For Binary Access Write As fNum

and run the program.  and step to the next line.  If Err is not 0, then the subroutine will exit. This happens if you passed a pathname that doesn't exist or VB was unable to open the file.


My question was Why are you concerned with DOD file wiping? PCs are not rated high enough to hold sensitive information.  The highest accreditation level they can hold is C2.  This type of wiping is written up in the Object Reuse and Data Remnant procedures for B1 Level systems and higher.
   
0
 
mcriderCommented:
Vbmaster,

The example I gave will write 3 times however, you can do this:

   WipeFile "C:\MyDocs\Doc1.Doc", 32767 ,True

and each byte in the file will be written to with 0/255/0 32767 times.

Flushing the buffer... THATS WHY a PC running WIN95/98/NT *CAN NOT* obtain an "ORANGE BOOK" rating higher than C2.

Object Reuse and Data Remnant Procedures can not be assured on this operating system.
0
 
mcriderCommented:
By the way, I have taken several operating systems through NSA (National Security Agency) accreditation... And have served as VSA (Vendor Security Analyst) to HP and WANG.


Cheers!®©
0
 
adam8Author Commented:
It's just more secure than deleting a file.
thats the only reason i guess.
Some people might like the feature in my Blowfish Encryption program..
0
 
adam8Author Commented:
thanks for helping
ive just got one more question.
if is used this command on any file
WipeFile "C:\MyDocs\Doc1.Doc", 2767 ,True
would it be possible to restore
0
 
VbmasterCommented:
If the file is small enough I guess what you are doing is you save over the buffer 2767 times? (it only saves over the data once on the physical harddrive). The only secure way is to do this in DOS I guess...
0
 
adam8Author Commented:
how did i get 40 expert points and i dont know which question i answered.
heheh
thanks for all your help
0
 
mcriderCommented:
Change the WipeFile subroutine to this...  It will flush the buffers to the disk after writing each instanciation of 0/255/0...

By the way, the Reset function will close any other files you have open... so don't perform this with other files open...


Cheers!®©



    Sub WipeFile(Source As String, Passes As Integer, Optional KillFile As Boolean)
        Dim iVal As Long
        Dim jVal As Long
        Dim kVal As Long
        Dim fNum As Integer
        kVal = FileLen(Source)
        fNum = FreeFile
        On Error Resume Next
        For jVal = 1 To Passes
            Open Source For Binary Access Write As fNum
            If Not Err = 0 Then Exit Sub
            For iVal = 1 To kVal
                Put #fNum, iVal, Chr$(0)
            Next iVal
            Close fNum
            Reset
            Open Source For Binary Access Write As fNum
            For iVal = 1 To kVal
                Put #fNum, iVal, Chr$(255)
            Next iVal
            Close fNum
            Reset
            Open Source For Binary Access Write As fNum
            For iVal = 1 To kVal
                Put #fNum, iVal, Chr$(0)
            Next iVal
            Close fNum
            Reset
        Next jVal
        If KillFile = True Then Kill Source
    End Sub
0
 
mcriderCommented:
If you're really paranoid, then you would also want to write 0/255/0 to all of the free space on your hard drive....



Cheers!®©
0
 
adam8Author Commented:
thanks for helping out.
0
 
midknyteCommented:
Great answer, Thanks!  I will be using this as well.

Be sure to add a command to reset the attributes of the file prior to action though.

  SetAttr Source, 0
0
All Courses

From novice to tech pro — start learning today.