?
Solved

Wiping Files

Posted on 2000-03-17
18
Medium Priority
?
250 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:adam8
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
  • 2
  • +1
18 Comments
 
LVL 14

Accepted Solution

by:
mcrider earned 280 total points
ID: 2629805
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
 
LVL 14

Expert Comment

by:mcrider
ID: 2629821
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
 
LVL 1

Author Comment

by:adam8
ID: 2629862
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:adam8
ID: 2629902
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
 
LVL 14

Expert Comment

by:mcrider
ID: 2629906
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
 
LVL 1

Author Comment

by:adam8
ID: 2629923
i didn't understand your question.
sorry
0
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2629974
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
 
LVL 14

Expert Comment

by:mcrider
ID: 2629992
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
 
LVL 14

Expert Comment

by:mcrider
ID: 2630010
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
 
LVL 14

Expert Comment

by:mcrider
ID: 2630025
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
 
LVL 1

Author Comment

by:adam8
ID: 2630935
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
 
LVL 1

Author Comment

by:adam8
ID: 2630937
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
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2630961
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
 
LVL 1

Author Comment

by:adam8
ID: 2631015
how did i get 40 expert points and i dont know which question i answered.
heheh
thanks for all your help
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2631242
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
 
LVL 14

Expert Comment

by:mcrider
ID: 2631246
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
 
LVL 1

Author Comment

by:adam8
ID: 2632046
thanks for helping out.
0
 

Expert Comment

by:midknyte
ID: 9914520
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

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question