PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → securely delete files
securely delete files
Débuté par Mark Nelson, 29 sep. 2014 16:35 - 19 réponses
Posté le 29 septembre 2014 - 16:35
Does anyone have a Example of how to "securely delete files" in windev ?

ResSize is int = fSize("e:\ emp\myfile.iso") FileID is int = fOpen("e:\ emp\myfile.iso", foReadWrite) IF FileID <> -1 THEN FOR Subscript = 1 TO ResSize ResWrite is int = fWrite(FileID,"X",Subscript) IF ResWrite <> -1 THEN END END END
Posté le 29 septembre 2014 - 16:51
Hi Mark

it depends on what you call "securely delete files" as there are many standards. Generating a random string or the appropriate size and writing it on top, doing that 20 times, alternating with zeros, and so on, and so forth...

Best regards
Posté le 29 septembre 2014 - 16:54
I am just looking to write X for ever byte the delete the file. I am thinking buffer the write the buffer.
Posté le 29 septembre 2014 - 17:25
This seems to work BUT SLOW~~:confused:

ResSize is int = fSize("e:\ emp\LinuxRescue2.iso") FileID is int = fOpen("e:\ emp\LinuxRescue2.iso", foReadWrite) IF FileID <> -1 THEN // Write into this file FOR Subscript = 1 TO ResSize ResPosition is int = fSeek(FileID, Subscript,fpBeginning) ResWrite is int = fWrite(FileID,"X",ResPosition) Trace(ResPosition) IF ResWrite <> -1 THEN END END END
Posté le 29 septembre 2014 - 17:58
Mark,

You know the size of the file and thus the number of "X"s you need to write. You should write them all in a single write operation and not one "X" at a time. Look at replacing your loop for ResSize with a single write operation using the RepeatString() function.

= RepeatString( Initial String , Number of Repetitions )
Posté le 29 septembre 2014 - 18:02
JP,

How about if the file is 2gb , That will kill the MEMORY Load right?

What of I did 1024 blocks?
Posté le 29 septembre 2014 - 18:08
Hi Mark,

Perhaps:
sFile is string="e:\ emp\myfile.iso" ResSize is int = fSize(sFile) sContent is string=RepeatString(Charact(0),ResSize) fSaveText(sFile,sContent) fDelete(sFile) It's probably fast, but I don't know if the OS will save the file in exactly the same disk space.

Regards,
Piet
Posté le 29 septembre 2014 - 18:16
Thinking that's the Ticket

sFile is string="e:\ emp\LinuxRescue2.iso"
ResSize is int = fSize(sFile)
sContent is string=RepeatString(Charact(0),ResSize)
fSaveText(sFile,sContent)
sContent=RepeatString("x",ResSize)
fSaveText(sFile,sContent)
sContent=RepeatString("O",ResSize)
fSaveText(sFile,sContent)
sContent=RepeatString(Charact(0),ResSize)
fSaveText(sFile,sContent)
fDelete(sFile)
Posté le 29 septembre 2014 - 18:45
Mark,

Well there will be a trade-off between memory consumption and the number of writes into the file. And that in turn will largely depend on the machine specs itself. Also, I guess it depends on the way WD does the StringRepeat() function. But to be safe I would safe limit the StringRepeat() to 1Mb length and repeat the loop. Writing every 1 byte is far too onerous.

On the other-hand it depends on the sensisitivy of the file being deleted. If it is very sensitive then what you are doing is not secure enough. But i it is just to stop the average user from retrieving the file then perhaps a single write of 1Mb of garbage and then delete the file. The user would need to know how to first undelete the file and then would find out that it has been corrupted.

Or a combination perhaps of writing 1Mb chunks in random place, say every 10th Mb in the actual 2Gb file. Lots of options I guess which largely depend on what is being protected and from who...
Posté le 29 septembre 2014 - 22:35
Yes , I need something that will do 8GB or more.. When testing with a 2gb file it fails
Posté le 29 septembre 2014 - 22:51
Mark,

How sensitive is the data? The reason to ask is because writing some characters into the file does not actually guarantee that the original data is overwritten since you do not know if the new character data is being written to the same disk sectors/locations as where the original data is. Therefore the original data might still be retrievable given the requisite expertise to do so.

If this is not a concern then overwriting with garbage data has no real value and niether would repeat writes serve any purpose. In this case you could perhaps just copy a 1Mb file over the original file and then delete the file. This operation could be done in a background thread to allow your app to continue servicing the user. A user who undeletes the file would only undelete the 1Mb garbage file and that would be unusable.

If you need the most secure deletion, and assuming the user has the expertise to look at the disk sectors, then the idea of overwriting the file with characters is not secure enough. I would suggest looking into getting a secure file delete activex or similar professional tool which actually destroys the original data in the actual disk sectors where it resides.
Posté le 01 octobre 2014 - 15:56
JP,

So the files I need to wack are LOW sensitive data.. So what do you think I should run with?
Posté le 01 octobre 2014 - 16:37
Mark,

For low sensitive data I would feel that destroying the initial part of the file (by writing for example 1Mb or 0.5Mb of garbage characters into it) and then deleting it is sufficient protection because even if the user uses a file-undelete program he would get back only the destroyed file (the garbage) and not the original file contents. In order to get the original file contents the user would need to do a disk sector analysis + retrieval and that requires much more skill and time which a low senstive file would not warrant.
Posté le 01 octobre 2014 - 17:09
Yes , I need something that will do 8GB or more.. When testing with a 2gb file it fails.

//ResSize is int = fSize("e:\ emp\LinuxRescue2.iso")
//FileID is int = fOpen("e:\ emp\LinuxRescue2.iso", foReadWrite)
//
//IF FileID <> -1 THEN
// // Write into this file
// FOR Subscript = 1 TO ResSize
// ResPosition is int = fSeek(FileID, Subscript,fpBeginning)
// ResWrite is int = fWrite(FileID,"X",ResPosition)
// Trace(ResPosition)
// IF ResWrite <> -1 THEN
//
// END
//
// END
//
//END
//Info("ENDOF FILE")
//ThreadEnd()
Posté le 02 octobre 2014 - 15:08
I know it is not a pure WD solution, but you can use a third-party and free utility like Eraser, which can be found at eraser.heidi.ie

The Eraser Launcher, eraserl.exe, can be called from WD using ExeRun.

Eraser can manage large files.

Christopher
Posté le 02 octobre 2014 - 15:46
Thank you , I thinking I have to go back to POWERBASIC to write a DLL.

<img src="/NG2013_WEB/ui/smiley/2.gif" align=absmiddle border=0 alt=":(">
Posté le 02 octobre 2014 - 16:49
If you are going to use some external tool sdelete from microsoft sysinternals can help you.
<a class="ExternalLink" rel="nofollow" target="_blank" href="http://technet.microsoft.com/en-us/sysinternals/bb897443">http://technet.microsoft.com/en-us/sysinternals/bb897443</a>
Posté le 02 octobre 2014 - 16:53
I am ok using a external tool but would like to us a DLL format with a callback
Posté le 03 octobre 2014 - 15:03
A native Windev command for this can be one of the new 2020 New Features of V.20.
Posté le 03 octobre 2014 - 16:06
Do you know this ?