Shortnote

The secure remove tool srm can be used, as explained on the UNIX FUSS page, in order to substitute the default rm tool and hence make all deletions more secure.

There are several algorithms available, but none of them compare in speed to the plain rm tool. Even the simple deletion method (overwriting with one pass of 0xFF before unlinking the file), is slow. Nevertheless, it is the fastest option available for srm.

The following patch, changes the 0xFF overwrite the deleted file with a random hex-number every time. In doing so, the overall security (if any) is increased because on a system where many remove operations occur, this method will ensure that every single deletion is performed with one different random pass of characters every time.

In doing so, we preserve the original speed of the simple deletion method, and yet gain some security by changing the overwrite bytes every single time srm is called.

Code

This patch can be applied against srm at version 1.2.11. Aside from the enhanced simplistic overwrite algorithm, the patch additionally suppresses some error output for backward compatibility with rm.

srm.was.patch
--- main.c.old	2010-06-06 17:41:01.000000000 +0000
+++ main.c	2013-08-31 18:12:58.000000000 +0000
@@ -71,6 +71,7 @@
 	case 'P': options |= SRM_MODE_OPENBSD; break;
 	case 'D': options |= SRM_MODE_DOD; break;
 	case 'E': options |= SRM_MODE_DOE; break;
+	case 'F': options |= SRM_MODE_FULL; break;
 	case 'V': show_version=1; break;
 	case 'v':
 	  if((options & SRM_OPT_V) < SRM_OPT_V)
@@ -96,6 +97,7 @@
            "  -P, --openbsd         overwrite with three passes like OpenBSD rm\n"
            "  -D, --dod             overwrite with 7 US DoD compliant passes\n"
            "  -E, --doe             overwrite with 3 US DoE compliant passes\n"
+           "  _F, --full            overwrite with 32 passes\n"
 	   "  -r, -R, --recursive   remove the contents of directories\n"
 	   "  -v, --verbose         explain what is being done\n"
 	   "  -h, --help            display this help and exit\n"
--- srm.h.old	2010-06-06 17:08:05.000000000 +0000
+++ srm.h	2013-08-31 18:16:07.000000000 +0000
@@ -22,6 +22,8 @@
 #define SRM_MODE_DOD (1 << 18)
 /** US DoE overwrite mode */
 #define SRM_MODE_DOE (1 << 19)
+/** Full overwrite mode */ 
+#define SRM_MODE_FULL (1 << 20)
 
 #ifdef __cplusplus
 extern "C" {
--- sunlink.c.old	2010-11-25 22:42:06.000000000 +0000
+++ sunlink.c	2013-08-31 18:15:19.000000000 +0000
@@ -331,7 +331,7 @@
 	printf("Simple mode\n");
       if(overwrite_byte(srm, 1, 0x00) < 0) return -1;
     }
-  else
+  else if(srm->options & SRM_MODE_FULL)
     {
       if((srm->options&SRM_OPT_V) == SRM_OPT_V)
 	printf("Full mode\n");
@@ -367,6 +367,12 @@
       /* if you want to backup your partition or shrink your vmware image having the file zero-ed gives best compression results. */
       if(overwrite_byte(srm, 36, 0x00) < 0) return -1;
     }
+  else {
+    if((srm->options&SRM_OPT_V) == SRM_OPT_V)
+      printf("[WaS] mode\n");
+    srandom(time(NULL));
+    if(overwrite_byte(srm, 1, (int)(random() % 255)) < 0) return -1;
+  }
 
   if((srm->options & SRM_OPT_V) > 1)
     printf("\n");
--- tree_walker.c.old	2010-06-06 17:42:20.000000000 +0000
+++ tree_walker.c	2013-08-31 18:43:02.000000000 +0000
@@ -215,11 +215,13 @@
   case FTS_SLNONE:
 #endif
     if ( prompt_file(path, options) && (sunlink(path, options) < 0) ) {
-      if (errno == EMLINK) 
-	error("%s has multiple links, this one has been removed but not "
-	      "overwritten", path);
-      else
-	errorp("unable to remove %s", path);
+      if (options & SRM_OPT_V) {
+        if (errno == EMLINK) 
+	  error("%s has multiple links, this one has been removed but not "
+	        "overwritten", path);
+        else
+	  errorp("unable to remove %s", path);
+      }
     }
     break;

unix/system-wide_secure_remove.txt ยท Last modified: 2022/04/19 08:28 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.