Solved

Wiping Files

Posted on 2000-03-17
18
244 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
  • 8
  • 7
  • 2
  • +1
18 Comments
 
LVL 14

Accepted Solution

by:
mcrider earned 70 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Link a textbox in excel to a cell with more than 255 characters. 5 67
Excel object stays open 19 71
SLMGR Switches Are Not Working On KMS Host 3 70
VB6 ListBox Question 4 34
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now