Page 3 of 5
Re: Sdel secure speedy deletion utility
Posted: 21 Dec 2015 16:08
by Squashman
thefeduke wrote:Edit: Sorry, Squashman. While I broke for supper and poker, a page 2 happened while I replied with some points already made by you. I notice a new requirement, too.
John A.
But my posts were 4 days before yours so that was a really really long poker sessions you had.
Re: Sdel - speedy deletion utility
Posted: 21 Dec 2015 17:13
by batchcc
Sorry Squashman,
I was just wondering when to use "!" instead of "%", I thought you had changed that sorry.
Re: Sdel secure speedy deletion utility
Posted: 21 Dec 2015 19:14
by foxidrive
Squashman wrote:But my posts were 4 days before yours so that was a really really long poker sessions you had.
It's John's shout at the bar, he must be bloody rich after that run of wins!
Re: Sdel - speedy deletion utility
Posted: 21 Dec 2015 19:44
by Squashman
batchcc wrote:Sorry Squashman,
I was just wondering when to use "!" instead of "%", I thought you had changed that sorry.
Two people here told you that you needed to use delayed expansion and also in your question on StackOverflow.
Re: Sdel - speedy deletion utility
Posted: 21 Dec 2015 19:58
by foxidrive
batchcc wrote:Foxdrive what i want to do is allow the user to call the file like this
This is untested, and it will need a little study to figure out as it's an unusual way of arranging the code.
It may not work - so test it first - and see below for some comments regarding your deletion technique, which is why this is not exactly the same.
Code: Select all
@echo off
title SDEL - speedy deletion utility
:del-file
if /i "%~1"=="/f" if exist "%~2" (
if /i not "%~f0"=="%~f2" call ren "%~2" "%%random%%%%random%%%%random%%%%random%%%%random%%%%random%%%%random%%.sdel.sdel"
del "%~dp2\*.sdel.sdel" 2>nul
goto :x
) else (goto :missing)
:del-folder
if /i "%~1"=="/d" if exist "%~2\" (
for %%a in ("%~2\*.*") do if /i not "%~f0"=="%%~fa" call ren "%%a" "%%random%%%%random%%%%random%%%%random%%%%random%%%%random%%%%random%%.sdel.sdel"
del "%~2\*.sdel.sdel" 2>nul
goto :x
) else (goto :missing)
:again
cls
echo SDEL - File deletion program
echo. (it only scrambles the filename, the data will still exist on the drive)
echo.
echo F - Delete only one file
echo D - Delete all files in a directory/folder that you supply
echo E - Exit this batch file
echo.
set "o="
set /p "o=Please select an option: "
if /i "%o%"=="F" goto :file
if /i "%o%"=="D" goto :folder
if /i "%o%"=="E" goto :EOF
goto :again
rem Delete only one file
:file
set "f="
set /p "f=Enter path of file including extension: "
call :del-file /f "%f%"
goto :EOF
rem Delete all files in selected directory (folder)
:folder
set "d="
set /p "d=enter path of folder to delete: "
call :del-folder /d "%d%"
goto :EOF
:missing
echo "%~2" doesn't exist - try again
pause
goto :EOF
:x
echo Deletion complete...
pause
A point you need to research is to understand that deleting a file doesn't remove it from the hard drive, nor does it change the file contents in any way.
Your code scrambles the filename in the file tables - but the data is unchanged and the file can be undeleted.
Using
type>nul filename doesn't overwrite the file contents, it just sets the filesize to zero in the file tables, but the file still exists in the same place on the hard drive.
Re: Sdel - speedy deletion utility
Posted: 22 Dec 2015 02:29
by thefeduke
Nice collaboration, moderators! Foxidrive's repackaging addressed the bad CD exposure that concerned me.
Now that I have recovered from Monday night pool, I'll apologize for some "senior moments" over the weekend. This topic piqued my interest about last Friday and I got so consumed in forensics to understand what was happening using Wednesday's code to better explain things to batchcc, that I completely missed the progress on Saturday afternoon. My error, that I was suspended on the last post on page one, but I am content to accept your good-natured humor.
More about the security part. A judicious defragmentation regime improves the chances of really over-writing the data, but is not a guarantee. If I understand correctly, the mechanisms that erase data from removable flash media are more secure than the traditional hard-disk. I must stress that there is no substitute for absolute physical security of the hardware.
John A.
Re: Sdel - speedy deletion utility
Posted: 22 Dec 2015 04:34
by foxidrive
I was suspended on the last post on page one
Been there, done that.
Will do it again.
More about the security part. A judicious defragmentation regime improves the chances of really over-writing the data, but is not a guarantee. If I understand correctly, the mechanisms that erase data from removable flash media are more secure than the traditional hard-disk.
You may be right John, particularly with the more modern secure versions. Flash drive technology has overtaken me.
Defragmentation does shuffle bits around as you say, but if secure deletion is needed then Microsoft provide a tool from Sysinternals which is perfect for the job.
https://technet.microsoft.com/en-us/sys ... elete.aspxMilitary grade file deletion probably needs a different tool.
Re: Sdel - speedy deletion utility
Posted: 01 Jan 2016 10:57
by batchcc
I tried to add a /s function to sdel.bat but its not working can someone explain why?
sdel /s
Code: Select all
if /i "%~1"=="/s" (
goto sub
)
:sub
if "%~2"=="" (
set /p d=enter path of folder to delete:
) else (
set "d=%~2"
)
cd /d %d%
setlocal EnableDelayedExpansion
FORFILES /S /C "CMD /C ECHO @relpath">slist.txt
for /f "delims=" %%f in (slist.txt) do (
if not "%~nx0"=="%%a" ren "%%~a" "sdel!random!.sdel"
for %%a in (*.sdel) do type nul > %%a
del *.sdel
)
"%%f"
:x
Re: Sdel - speedy deletion utility
Posted: 01 Jan 2016 11:29
by Squashman
Your FOR variable is %%f but you are using %%a.
Re: Sdel - speedy deletion utility
Posted: 01 Jan 2016 14:13
by batchcc
This still doesn't seem to be working for me.
Code: Select all
if /i "%~1"=="/s" (
goto sub
)
:sub
if "%~2"=="" (
set /p d=enter path of folder to delete:
) else (
set "d=%~2"
)
cd /d %d%
setlocal EnableDelayedExpansion
FORFILES /S /C "CMD /C ECHO @relpath">slist.txt
for /f "delims=" %%f in (slist.txt) do (
if not "%~nx0"=="%%f" ren "%%~a" "sdel!random!.sdel"
for %%f in (*.sdel) do type nul > %%f
del *.sdel
)
"%%f"
:x
Re: Sdel - speedy deletion utility
Posted: 01 Jan 2016 17:08
by foxidrive
There may be other issues, but examine your for loop variables again.
I'm only pointing this out, rather than helping, because coding takes a really fine attention to detail - many problems are due to typos.
Re: Sdel - speedy deletion utility
Posted: 01 Jan 2016 17:38
by Squashman
Squashman wrote:Your FOR variable is %%f but you are using %%a.
You still did not fix this error.
Re: Sdel - speedy deletion utility
Posted: 01 Jan 2016 18:56
by batchcc
Oh I just replaced %%a with %%f but I also needed to change this
Code: Select all
if not "%~nx0"=="%%f" ren "%%~a" "sdel!random!.sdel"
To this
Code: Select all
if not "%~nx0"=="%%f" ren "%%~f" "sdel!random!.sdel"
I'm not sure if this is correct and I am unable to check to see if it works right now but I will see to tomorrow.
Re: Sdel - speedy deletion utility
Posted: 02 Jan 2016 06:13
by batchcc
this still doesn't work
Code: Select all
if /i "%~1"=="/s" (
goto sub
)
:sub
if "%~2"=="" (
set /p d=enter path of folder to delete:
) else (
set "d=%~2"
)
cd /d %d%
setlocal EnableDelayedExpansion
FORFILES /S /C "CMD /C ECHO @relpath">slist.txt
for /f "delims=" %%f in (slist.txt) do (
if not "%~nx0"=="%%f" ren "%%~f" "sdel!random!.sdel"
for %%f in (*.sdel) do type nul > %%f
del *.sdel
)
"%%f"
:x
Re: Sdel - speedy deletion utility
Posted: 02 Jan 2016 06:40
by Meerkat
batchcc wrote:this still doesn't work
Code: Select all
if /i "%~1"=="/s" (
goto sub
)
:sub
if "%~2"=="" (
set /p d=enter path of folder to delete:
) else (
set "d=%~2"
)
cd /d %d%
setlocal EnableDelayedExpansion
FORFILES /S /C "CMD /C ECHO @relpath">slist.txt
for /f "delims=" %%f in (slist.txt) do (
if not "%~nx0"=="%%f" ren "%%~f" "sdel!random!.sdel"
for %%f in (*.sdel) do type nul > %%f
del *.sdel
)
"%%f"
:x
Hmm... at this part
Code: Select all
for %%f in (*.sdel) do type nul > %%f
I am not sure, but just use another "letter" aside from
f because it "interferes" with the another %%f on this code:
Code: Select all
for /f "delims=" %%f in (slist.txt) do (
Another is the "%%f" near the last line. Since this is outside the FOR loop, it will not work. I do not know, but maybe you want to echo the files that will be deleted. If yes, then this would work:
Code: Select all
cd /d %d%
setlocal EnableDelayedExpansion
FORFILES /S /C "CMD /C ECHO @relpath">slist.txt
for /f "delims=" %%f in (slist.txt) do if not "%~nx0"=="%%f" ren "%%~f" "sdel!random!.sdel"
for %%a in (*.sdel) do (
type nul >"%%a"
echo "%%a"
del /f "%%a"
)
Meerkat