Changeset 1210
- Timestamp:
- 9/29/2009 10:39:00 AM (4 years ago)
- Location:
- trunk/eraser6/Eraser.DefaultPlugins
- Files:
-
- 4 added
- 2 edited
- 13 moved
-
Eraser.DefaultPlugins.csproj (modified) (2 diffs)
-
ErasureMethods (added)
-
ErasureMethods/Custom.cs (moved) (moved from trunk/eraser6/Eraser.DefaultPlugins/EraseCustom.cs)
-
ErasureMethods/DoD.cs (moved) (moved from trunk/eraser6/Eraser.DefaultPlugins/EraseDoD.cs)
-
ErasureMethods/FirstLast16KB.cs (moved) (moved from trunk/eraser6/Eraser.DefaultPlugins/EraseFirstLast16KB.cs)
-
ErasureMethods/GOSTP50739.cs (moved) (moved from trunk/eraser6/Eraser.DefaultPlugins/EraseGOSTP50739.cs)
-
ErasureMethods/Gutmann.cs (moved) (moved from trunk/eraser6/Eraser.DefaultPlugins/EraseGutmann.cs)
-
ErasureMethods/HMGIS5.cs (moved) (moved from trunk/eraser6/Eraser.DefaultPlugins/EraseHMGIS5.cs)
-
ErasureMethods/RCMP_TSSIT_OPS_II.cs (moved) (moved from trunk/eraser6/Eraser.DefaultPlugins/EraseRCMP_TSSIT_OPS_II.cs)
-
ErasureMethods/Random.cs (moved) (moved from trunk/eraser6/Eraser.DefaultPlugins/EraseRandom.cs)
-
ErasureMethods/Schneier.cs (moved) (moved from trunk/eraser6/Eraser.DefaultPlugins/EraseSchneier.cs)
-
ErasureMethods/USAF5020.cs (moved) (moved from trunk/eraser6/Eraser.DefaultPlugins/EraseUSAF5020.cs)
-
ErasureMethods/USArmyAR380_19.cs (moved) (moved from trunk/eraser6/Eraser.DefaultPlugins/EraseUSArmyAR380_19.cs)
-
ErasureMethods/VSITR.cs (moved) (moved from trunk/eraser6/Eraser.DefaultPlugins/EraseVSITR.cs)
-
FileSystems (added)
-
FileSystems/Fat.cs (added)
-
FileSystems/Ntfs.cs (added)
-
FileSystems/Windows.cs (moved) (moved from trunk/eraser6/Eraser.DefaultPlugins/FileSystemWindows.cs) (1 diff)
-
Plugin.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser6/Eraser.DefaultPlugins/Eraser.DefaultPlugins.csproj
r1209 r1210 57 57 <DependentUpon>CustomMethodPassEditor.cs</DependentUpon> 58 58 </Compile> 59 <Compile Include="EraseCustom.cs" /> 60 <Compile Include="EraseDoD.cs" /> 61 <Compile Include="EraseRandom.cs" /> 62 <Compile Include="EraseGutmann.cs" /> 63 <Compile Include="EraseFirstLast16KB.cs" /> 64 <Compile Include="EraseHMGIS5.cs" /> 65 <Compile Include="EraseGOSTP50739.cs" /> 66 <Compile Include="EraseUSAF5020.cs" /> 67 <Compile Include="EraseVSITR.cs" /> 68 <Compile Include="EraseRCMP_TSSIT_OPS_II.cs" /> 69 <Compile Include="FileSystemWindows.cs" /> 59 <Compile Include="ErasureMethods\Custom.cs" /> 60 <Compile Include="ErasureMethods\DoD.cs" /> 61 <Compile Include="ErasureMethods\Random.cs" /> 62 <Compile Include="ErasureMethods\Gutmann.cs" /> 63 <Compile Include="ErasureMethods\FirstLast16KB.cs" /> 64 <Compile Include="ErasureMethods\HMGIS5.cs" /> 65 <Compile Include="ErasureMethods\GOSTP50739.cs" /> 66 <Compile Include="ErasureMethods\USAF5020.cs" /> 67 <Compile Include="ErasureMethods\VSITR.cs" /> 68 <Compile Include="ErasureMethods\RCMP_TSSIT_OPS_II.cs" /> 69 <Compile Include="FileSystems\Fat.cs" /> 70 <Compile Include="FileSystems\Ntfs.cs" /> 71 <Compile Include="FileSystems\Windows.cs" /> 70 72 <Compile Include="Plugin.cs" /> 71 73 <Compile Include="Properties\AssemblyInfo.cs" /> 72 74 <Compile Include="RNGCrypto.cs" /> 73 <Compile Include="Eras eSchneier.cs" />75 <Compile Include="ErasureMethods\Schneier.cs" /> 74 76 <Compile Include="SettingsForm.cs"> 75 77 <SubType>Form</SubType> … … 78 80 <DependentUpon>SettingsForm.cs</DependentUpon> 79 81 </Compile> 80 <Compile Include="Eras eUSArmyAR380_19.cs" />82 <Compile Include="ErasureMethods\USArmyAR380_19.cs" /> 81 83 </ItemGroup> 82 84 <ItemGroup> -
trunk/eraser6/Eraser.DefaultPlugins/FileSystems/Windows.cs
r1209 r1210 310 310 protected abstract DateTime MinTimestamp { get; } 311 311 } 312 313 /// <summary>314 /// Provides functions to handle erasures specific to NTFS volumes.315 /// </summary>316 public class NtfsFileSystem : WindowsFileSystem317 {318 public override bool Supports(string fileSystemName)319 {320 if (fileSystemName == "NTFS")321 return true;322 return false;323 }324 325 public override void EraseOldFileSystemResidentFiles(VolumeInfo volume,326 DirectoryInfo tempDirectory, ErasureMethod method,327 FileSystemEntriesEraseProgress callback)328 {329 try330 {331 //Squeeze one-byte files until the volume or the MFT is full.332 long oldMFTSize = NtfsApi.GetMftValidSize(volume);333 334 for (; ; )335 {336 //Open this stream337 using (FileStream strm = new FileStream(338 GenerateRandomFileName(tempDirectory, 18), FileMode.CreateNew,339 FileAccess.Write, FileShare.None, 8, FileOptions.WriteThrough))340 {341 long streamSize = 0;342 try343 {344 while (true)345 {346 //Stretch the file size to use up some of the resident space.347 strm.SetLength(++streamSize);348 349 //Then run the erase task350 method.Erase(strm, long.MaxValue,351 PrngManager.GetInstance(ManagerLibrary.Settings.ActivePrng),352 null);353 }354 }355 catch (IOException)356 {357 if (streamSize == 1)358 return;359 }360 }361 362 //We can stop when the MFT has grown.363 if (NtfsApi.GetMftValidSize(volume) > oldMFTSize)364 break;365 }366 }367 catch (IOException)368 {369 //OK, enough squeezing.370 }371 }372 373 public override void EraseDirectoryStructures(VolumeInfo info,374 FileSystemEntriesEraseProgress callback)375 {376 //Create a directory to hold all the temporary files377 DirectoryInfo tempDir = new DirectoryInfo(FileSystem.GenerateRandomFileName(378 new DirectoryInfo(info.MountPoints[0]), 32));379 tempDir.Create();380 381 try382 {383 //Get the size of the MFT384 long mftSize = NtfsApi.GetMftValidSize(info);385 long mftRecordSegmentSize = NtfsApi.GetMftRecordSegmentSize(info);386 int pollingInterval = (int)Math.Max(1, (mftSize / info.ClusterSize / 20));387 int totalFiles = (int)Math.Max(1L, mftSize / mftRecordSegmentSize) *388 (FileNameErasePasses + 1);389 int filesCreated = 0;390 391 while (true)392 {393 ++filesCreated;394 using (FileStream strm = new FileStream(FileSystem.GenerateRandomFileName(395 tempDir, 220), FileMode.CreateNew, FileAccess.Write))396 {397 }398 399 if (filesCreated % pollingInterval == 0)400 {401 if (callback != null)402 callback(filesCreated, totalFiles);403 404 //Check if the MFT has grown.405 if (mftSize < NtfsApi.GetMftValidSize(info))406 break;407 }408 }409 }410 catch (IOException)411 {412 }413 finally414 {415 //Clear up all the temporary files416 FileInfo[] files = tempDir.GetFiles("*", SearchOption.AllDirectories);417 int totalFiles = files.Length * (FileNameErasePasses + 1);418 for (int i = 0; i < files.Length; ++i)419 {420 if (callback != null && i % 50 == 0)421 callback(files.Length + i * FileNameErasePasses, totalFiles);422 DeleteFile(files[i]);423 }424 425 DeleteFolder(tempDir);426 }427 }428 429 public override void EraseFileSystemObject(StreamInfo info, ErasureMethod method,430 ErasureMethodProgressFunction callback)431 {432 //Check if the file fits in one MFT record433 long mftRecordSize = NtfsApi.GetMftRecordSegmentSize(VolumeInfo.FromMountpoint(info.DirectoryName));434 while (info.Length < mftRecordSize)435 {436 //Yes it does, erase exactly to the file length437 using (FileStream strm = info.Open(FileMode.Open, FileAccess.Write,438 FileShare.None))439 {440 strm.SetLength(strm.Length + 1);441 method.Erase(strm, long.MaxValue,442 PrngManager.GetInstance(ManagerLibrary.Settings.ActivePrng), null);443 }444 }445 446 //Create the file stream, and call the erasure method to write to447 //the stream.448 long fileArea = GetFileArea(info.FullName);449 450 //If the stream is empty, there's nothing to overwrite. Continue451 //to the next entry452 if (fileArea == 0)453 return;454 455 using (FileStream strm = info.Open(FileMode.Open, FileAccess.Write,456 FileShare.None, FileOptions.WriteThrough))457 {458 //Set the end of the stream after the wrap-round the cluster size459 strm.SetLength(fileArea);460 461 //Then erase the file.462 method.Erase(strm, long.MaxValue,463 PrngManager.GetInstance(ManagerLibrary.Settings.ActivePrng),464 callback465 );466 467 //Set the length of the file to 0.468 strm.Seek(0, SeekOrigin.Begin);469 strm.SetLength(0);470 }471 }472 473 protected override DateTime MinTimestamp474 {475 get476 {477 return new DateTime(1601, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);478 }479 }480 }481 482 /// <summary>483 /// Provides functions to handle erasures specific to FAT volumes.484 /// </summary>485 public class FatFileSystem : WindowsFileSystem486 {487 public override bool Supports(string fileSystemName)488 {489 if (fileSystemName == "FAT" || fileSystemName == "FAT32")490 return true;491 return false;492 }493 494 public override void EraseOldFileSystemResidentFiles(VolumeInfo volume,495 DirectoryInfo tempDirectory, ErasureMethod method,496 FileSystemEntriesEraseProgress callback)497 {498 //Nothing to be done here. FAT doesn't store files in its FAT.499 }500 501 public override void EraseDirectoryStructures(VolumeInfo info,502 FileSystemEntriesEraseProgress callback)503 {504 Fat32Api api = new Fat32Api(info);505 }506 507 public override void EraseFileSystemObject(StreamInfo info, ErasureMethod method,508 ErasureMethodProgressFunction callback)509 {510 //Create the file stream, and call the erasure method to write to511 //the stream.512 long fileArea = GetFileArea(info.FullName);513 using (FileStream strm = info.Open(FileMode.Open, FileAccess.Write,514 FileShare.None, FileOptions.WriteThrough))515 {516 //Set the end of the stream after the wrap-round the cluster size517 strm.SetLength(fileArea);518 519 //If the stream is empty, there's nothing to overwrite. Continue520 //to the next entry521 if (strm.Length != 0)522 {523 //Then erase the file.524 method.Erase(strm, long.MaxValue,525 PrngManager.GetInstance(ManagerLibrary.Settings.ActivePrng),526 callback527 );528 }529 530 //Set the length of the file to 0.531 strm.Seek(0, SeekOrigin.Begin);532 strm.SetLength(0);533 }534 }535 536 protected override DateTime MinTimestamp537 {538 get539 {540 return new DateTime(1980, 1, 1, 0, 0, 0);541 }542 }543 }544 312 } -
trunk/eraser6/Eraser.DefaultPlugins/Plugin.cs
r1209 r1210 56 56 PrngManager.Register(new RngCrypto()); 57 57 58 FileSystemManager.Register(new Fat FileSystem());58 FileSystemManager.Register(new Fat32FileSystem()); 59 59 FileSystemManager.Register(new NtfsFileSystem()); 60 60 }
Note: See TracChangeset
for help on using the changeset viewer.
