Solved

Wiping Files

Posted on 2000-03-17
18
248 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 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

734 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