Группа :: Система/Основа
Пакет: secure_delete
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: secure_delete-3.1-configure-rand-file.patch
Скачать
Скачать
diff --git a/README b/README
index b96b4a0..8394aab 100644
--- a/README
+++ b/README
@@ -7,6 +7,7 @@
(c) 1997-2003 by van Hauser / THC <vh@thc.org>
http://www.thc.org
+ (C) 2018 by Maxim Nikolaev
@@ -122,10 +123,10 @@
Here are the command line options:
- srm [-d] [-f] [-l] [-l] [-v] [-z] file [file] [another file] [etc.]
- sfill [-i] [-I] [-f] [-l] [-l] [-v] [-z] target-directory
- sswap [-f] [-l] [-l] [-v] [-z] /dev/of_swap_filesystem
- smem [-f] [-l] [-l] [-v]
+ srm [-d] [-f] [-l] [-l] [-p] [-v] [-z] file [file] [another file] [etc.]
+ sfill [-i] [-I] [-f] [-l] [-l] [-p] [-v] [-z] target-directory
+ sswap [-f] [-l] [-l] [-p] [-v] [-z] /dev/of_swap_filesystem
+ smem [-f] [-l] [-l] [-p] [-v]
The -s options are deprecated now, and will be ignored.
@@ -141,6 +142,7 @@
written.
-l a seconds time as parameter switches into the most insecure mode,
it overwrites the file only once with 0xff.
+ -p use file with pattern instead /dev/urandom
-v turn verbose mode on.
-z last wipe mode writes zeros instead of random data
file file to delete. Wildcards are of course allowed.
diff --git a/sdel-lib.c b/sdel-lib.c
index 3898742..7069deb 100644
--- a/sdel-lib.c
+++ b/sdel-lib.c
@@ -1,7 +1,9 @@
/* Secure Delete Library - by van Hauser / [THC], vh@thc.org
+ * (C) 2018, Evgeny Proshkin
*
* Secure Delete Library provides the following public functions:
*
+ *
* void sdel_init(int secure_random)
* Initializiation function for sdel_overwrite. It needs to be called
* once at program start, not for each file to be overwritten.
@@ -82,8 +84,23 @@ void __sdel_random_buf(unsigned long bufsize, char *buf) {
if (devrandom == NULL)
for (loop = 0; loop < bufsize; loop++)
*buf++ = (unsigned char) (256.0*rand()/(RAND_MAX+1.0));
- else
- fread(buf, bufsize, 1, devrandom);
+ else {
+ ssize_t num, cnt;
+
+ num = 0;
+ do {
+ cnt = fread (buf + num, 1, bufsize - num, devrandom);
+ if (cnt < 0) {
+ fprintf(stderr, "read error in %s\n", random_dev);
+ break;
+ }
+ num += cnt;
+ if (num < bufsize)
+ fseek (devrandom, 0, SEEK_SET);
+ } while (num < bufsize);
+
+ //fread(buf, bufsize, 1, devrandom);
+ }
}
void __sdel_random_filename(char *filename) {
@@ -109,9 +126,9 @@ void sdel_init(int secure_random) {
devrandom = NULL;
#ifdef RANDOM_DEVICE
if (secure_random) {
- if ((devrandom = fopen(RANDOM_DEVICE, "r")) != NULL)
+ if ((devrandom = fopen(random_dev, "r")) != NULL)
if (verbose)
- printf("Using %s for random input.\n", RANDOM_DEVICE);
+ printf("Using %s for random input.\n", random_dev);
}
#endif
diff --git a/sdel-lib.h b/sdel-lib.h
index 757795e..f9fc660 100644
--- a/sdel-lib.h
+++ b/sdel-lib.h
@@ -32,6 +32,7 @@ unsigned char write_modes[27][3] = {
unsigned char std_array_ff[3] = "\xff\xff\xff";
unsigned char std_array_00[3] = "\x00\x00\x00";
+char *random_dev = RANDOM_DEVICE;
FILE *devrandom = NULL;
int verbose = 0;
int __internal_sdel_init = 0;
diff --git a/sdel.h b/sdel.h
index acbab02..99270d2 100644
--- a/sdel.h
+++ b/sdel.h
@@ -21,6 +21,7 @@
char *prg;
+extern char *random_dev;
extern int verbose;
extern void sdel_init(int secure_random);
diff --git a/sfill.c b/sfill.c
index c67a6a8..a775abb 100644
--- a/sfill.c
+++ b/sfill.c
@@ -1,4 +1,5 @@
/* Secure FILL - by van Hauser / [THC], vh@thc.org
+ * (C) 2018, Evgeny Proshkin
*
* Secure FILL overwrites all available free diskspace by creating a file,
* wiping all free diskspace it gets and finally deleting the file.
@@ -49,13 +50,14 @@ char *filename = NULL;
FILE *f;
void help() {
- printf("sfill %s (c) 1997-2003 by %s <%s>\n\n", VERSION, AUTHOR, EMAIL);
+ printf("sfill %s (c) 1997-2003,2018 by %s <%s>\n\n", VERSION, AUTHOR, EMAIL);
printf("Syntax: %s [-fiIlvz] directory\n\n", prg);
printf("Options:\n");
printf("\t-f fast (and insecure mode): no /dev/urandom, no synchronize mode.\n");
printf("\t-i wipe only inodes in the directory specified\n");
printf("\t-I just wipe space, not inodes\n");
printf("\t-l lessens the security (use twice for total insecure mode).\n");
+ printf("\t-p use pattern file instead /dev/urandom.\n");
printf("\t-v is verbose mode.\n");
printf("\t-z last wipe writes zeros, not random data.\n");
printf("\nsfill does a secure overwrite of the free space on the partition the specified\ndirectory resides and all free inodes of the directory specified.\n");
@@ -101,7 +103,7 @@ int main (int argc, char *argv[]) {
help();
while (1) {
- result = getopt(argc, argv, "fFiIlLsSvVzZ");
+ result = getopt(argc, argv, "fFiIlLP:p:sSvVzZ");
if (result < 0)
break;
switch (result) {
@@ -115,6 +117,9 @@ int main (int argc, char *argv[]) {
case 'l' :
case 'L' : if (secure) secure--;
break;
+ case 'P' :
+ case 'p' : random_dev = optarg;
+ break;
case 's' :
case 'S' : secure++;
break;
diff --git a/smem.c b/smem.c
index 7a272b8..40934d3 100644
--- a/smem.c
+++ b/smem.c
@@ -1,4 +1,5 @@
/* Secure MEMORY cleaner - by van Hauser / [THC], vh@thc.org
+ * (C) 2018, Evgeny Proshkin
*
* Note that this program is beta. It was tested with linux, solaris and
* openbsd but I can't tell for other platforms.
@@ -41,11 +42,12 @@ int slow = 1;
extern FILE *devrandom;
void help() {
- printf("smem %s (c) 1997-2003 by %s <%s>\n\n", VERSION, AUTHOR, EMAIL);
+ printf("smem %s (c) 1997-2003,2018 by %s <%s>\n\n", VERSION, AUTHOR, EMAIL);
printf("Syntax: %s [-flv]\n\n", prg);
printf("Options:\n");
printf("\t-f fast (and insecure mode): no /dev/urandom.\n");
printf("\t-l lessens the security (use twice for total insecure mode).\n");
+ printf("\t-p use pattern file instead /dev/urandom.\n");
printf("\t-v is verbose mode.\n");
printf("\nsmem does a secure overwrite of the memory (RAM), because memory contents can\n");
printf("be recovered even after a shutdown! Default is secure mode (38 writes).\n");
@@ -170,7 +172,7 @@ int main (int argc, char *argv[]) {
help();
while (1) {
- result = getopt(argc, argv, "FfLlSsVvZz");
+ result = getopt(argc, argv, "FfLlP:p:SsVvZz");
if (result<0) break;
switch (result) {
case 'F' :
@@ -179,6 +181,9 @@ int main (int argc, char *argv[]) {
case 'L' :
case 'l' : if (secure) secure--;
break;
+ case 'P' :
+ case 'p' : random_dev = optarg;
+ break;
case 'S' :
case 's' : secure++;
break;
diff --git a/srm.c b/srm.c
index eddfcc8..c7ab04c 100644
--- a/srm.c
+++ b/srm.c
@@ -1,4 +1,5 @@
/* Secure RM - by van Hauser / [THC], vh@thc.org
+ * (C) 2018, Evgeny Proshkin
*
* Secure ReMove first overwrites then renames and finally deletes the target
* file(s) specified via parameters.
@@ -41,12 +42,13 @@ unsigned long bufsize = BLOCKSIZE;
int fd;
void help () {
- printf("srm %s (c) 1997-2003 by %s <%s>\n\n", VERSION, AUTHOR, EMAIL);
+ printf("srm %s (c) 1997-2003,2018 by %s <%s>\n\n", VERSION, AUTHOR, EMAIL);
printf("Syntax: %s [-dflrvz] file1 file2 etc.\n\n", prg);
printf("Options:\n");
printf("\t-d ignore the two dot special files \".\" and \"..\".\n");
printf("\t-f fast (and insecure mode): no /dev/urandom, no synchronize mode.\n");
printf("\t-l lessens the security (use twice for total insecure mode).\n");
+ printf("\t-p use pattern file instead /dev/urandom.\n");
printf("\t-r recursive mode, deletes all subdirectories.\n");
printf("\t-v is verbose mode.\n");
printf("\t-z last wipe writes zeros instead of random data.\n");
@@ -210,7 +212,7 @@ int main (int argc, char *argv[]) {
help();
while (1) {
- result = getopt(argc, argv, "DdFfLlRrSsVvZz");
+ result = getopt(argc, argv, "DdFfLlP:p:RrSsVvZz");
if (result < 0) break;
switch (result) {
case 'd' :
@@ -222,6 +224,9 @@ int main (int argc, char *argv[]) {
case 'L' :
case 'l' : if (secure) secure--;
break;
+ case 'P' :
+ case 'p' : random_dev = optarg;
+ break;
case 'R' :
case 'r' : recursive++;
break;
diff --git a/sswap.c b/sswap.c
index 7ae2f13..42903cf 100644
--- a/sswap.c
+++ b/sswap.c
@@ -1,4 +1,5 @@
/* Secure SWAP cleaner - by van Hauser / [THC], vh@thc.org
+ * (C) 2018, Evgeny Proshkin
*
* Note that this program is beta. It was tested with linux, but I can't
* tell for other platforms. Read the statement at #define SWAP_PAGESIZE
@@ -48,12 +49,13 @@ int slow = O_SYNC;
int zero = 0;
void help() {
- printf("sswap %s (c) 1997-2003 by %s <%s>\n\n", VERSION, AUTHOR, EMAIL);
+ printf("sswap %s (c) 1997-2003,2018 by %s <%s>\n\n", VERSION, AUTHOR, EMAIL);
printf("Syntax: %s [-flvz] [-j start] /dev/of_swap_device\n\n", prg);
printf("Options:\n");
printf("\t-f fast (and insecure mode): no /dev/urandom, no synchronize mode.\n");
printf("\t-j jump over the first number of bytes when wiping. (default: %d)\n", SWAP_PAGESIZE);
printf("\t-l lessens the security (use twice for total insecure mode).\n");
+ printf("\t-p use pattern file instead /dev/urandom.\n");
printf("\t-v is verbose mode.\n");
printf("\t-z last wipe writes zeros instead of random data.\n");
printf("\nsswap does a secure overwrite of the swap space.\n");
@@ -83,7 +85,7 @@ int main (int argc, char *argv[]) {
help();
while (1) {
- result = getopt(argc, argv, "FfJ:j:LlSsVvZz");
+ result = getopt(argc, argv, "FfJ:j:LlP:p:SsVvZz");
if (result<0) break;
switch (result) {
case 'F' :
@@ -99,6 +101,9 @@ int main (int argc, char *argv[]) {
case 'L' :
case 'l' : if (secure) secure--;
break;
+ case 'P' :
+ case 'p' : random_dev = optarg;
+ break;
case 'S' :
case 's' : secure++;
break;