Solved

Wiping Files

Posted on 2000-03-17
18
243 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 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

13 Experts available now in Live!

Get 1:1 Help Now