🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.privacy.anon-server
Article #254741

rooster1.bat with word-wrap removed

#254741
From: rooster
Date: Fri, 02 Mar 2012 07:19
193 lines
7733 bytes
There was a little bit of word-wrap in the previous post, and I want to fix that problem right 
now so that the script can be copied exactly right and so that there is no cause for confusion. I 
have removed the word-wrap from this message, and the script should post correctly here.  Sorry 
for the inconvenience.  :)

------------ rooster1.bat -------------------

SETLOCAL
CLS
@ECHO off
ECHO : The folder where you execute this batch file
ECHO : should have ONLY this batch file, the
ECHO : password-file, and the messages for decrypting.
ECHO.
ECHO Beginning Rooster's Method for batch decryption:
ECHO.
ECHO.
(@ECHO    Now renaming *.txt to *.asc for gpg processing...)
REN *.txt *.asc
IF NOT errorlevel 0 GOTO EOF

ECHO.
(ECHO    Moving files with problematic names into 'badnames' folder...)
DIR/b |findstr /i "[!\&^]">>badnames1
MD badnames
FOR /f "tokens=* eol=\" %%G in (badnames1) do (
MOVE "%%G" .\badnames\"%%G")
IF EXIST badnames1 ERASE /f/q badnames1

rem: This block routine removes spaces from erratic filenames
SET "filename="
FOR %%F in (*.asc) do SET filename=%%F & CALL:sub1 %%F
GOTO :jump

:sub1
SET nospace=%filename: =%
RENAME "%*" %nospace%
GOTO :eof
:jump
rem: end routine to remove spaces from filenames

SET counter=0
:startnow
IF %counter%==2 GOTO core
SET /a counter+=1
IF %counter%==2 ECHO    This block allows the user to choose whether to attempt deciphering
IF %counter%==2 ECHO    on both symmetric and asymmetric encrypted messages, or to attempt
IF %counter%==2 ECHO    on only one of these two types of encrytion. Unless you choose either
IF %counter%==2 ECHO    "Y" or "N", both types of message will be attempted.
IF %counter%==2 ECHO    You get one more try to answer correctly.
SET "choice="
ECHO.
ECHO    Do you want to search both types of message?
ECHO    You must type Y or N and hit enter.
SET /p choice=   Please make your choice now:  ^(Y or ^N)?
@ECHO.
IF NOT DEFINED choice GOTO startnow
IF /i %choice%==Y GOTO core
IF /i NOT %choice%==N GOTO startnow

rem: This block routine allows you to remove all
rem: messages not having outer symmetric encryption
CLS
SET counter=0
:option1
IF %counter%==2 GOTO EOF
IF %counter%==1 (
(ECHO    You will get only 2 tries to answer correctly.))
IF %counter%==1 (
(ECHO    Unless you choose "Y" or "N", batch processing will cease.))
SET /a counter+=1
SET "decision="
ECHO.
ECHO    You have chosen "not" to do both types of message.
ECHO    Do you want to search only files with an outer layer
ECHO    of symmetric encryption^? If you know that all of your
ECHO    messages have an outer layer of symmetric encryption,
ECHO    then you should select "yes." If you do select "yes,"
ECHO    then all files having only asymmetric encryption
ECHO    will be deleted first, before decryption begins.
ECHO    This can save a lot of time.
ECHO    You must type Y or N and hit enter.
ECHO.
ECHO    This is try # %counter%.
ECHO.
SET /p decision=  Please make your decision now:  ^(Y or ^N)?
ECHO.
IF NOT DEFINED decision GOTO option1
IF /i %decision%==N GOTO option2
IF /i NOT %decision%==Y GOTO option1
FOR %%G in (*.asc) do (
gpg --list-only --status-fd 1 %%G | find /i "enc_to" && del %%G
)
ECHO.
ECHO    Deleting messages not having an outer layer of symmetric encryption...
GOTO core
rem: end routine for removing messages without outer symmetric encryption

rem: this block routine allows you to remove all
rem: messages with outer layer of symmetric encryption
CLS
:option2
SET "decision2="
ECHO.
ECHO    You have chosen to attempt deciphering of messages
ECHO    with no outer layer of symmetric encryption. Only
ECHO    those with asymmetric (public key) encryption will be
ECHO    searched. This means that for any of the messages with
ECHO    hidden-recipients, all of the secret keys on your key-
ECHO    ring will be tried until a match is made, if any.
ECHO.
ECHO    If you want to search only these messages, you should
ECHO    answer "yes" below.  If you prefer to abort the decryption
ECHO    process, you should answer "no" below. If you do answer
ECHO    "no", the messages will "not" be deleted and the batch
ECHO    processing will end.
ECHO.
SET counter=0
:lasttry
IF %counter%==2 (
(ECHO    You have not chosen to search any messages) & GOTO EOF)
SET /a counter+=1
ECHO.
ECHO	   Do you want to search only messages with asmmetric encryption?
SET /p decision2=   Please make your decision now:  ^(Y or ^N)?
ECHO.
IF NOT DEFINED decision2 (
(ECHO   You have answered incorrectly.) & GOTO lasttry)
IF /i %decision2%==N GOTO EOF
IF /i NOT %decision2%==Y (
(ECHO   You have answered incorrectly.) & GOTO EOF)
FOR %%K in (*.asc) do (
gpg --list-only --status-fd 1 %%K | FIND /i "enc_to" && DIR /b %%K>>filelist)
IF NOT EXIST filelist (
(ECHO There are no messages that indicate having asymmetric encryption on its outer layer!) & (
GOTO endprocess)
)
ECHO.
ECHO    Removing messages with symmetric encryption...
FOR %%A in (*.asc) do @FINDSTR /c:%%A filelist || ERASE /f /q %%A


:core
SET "pword="
:variable
SET /p pword=<password-file
rem: IMPORTANT NOTE: If your password contains any of these command characters
rem: (between the quotation marks) "& < > |", which take precedence over ECHO,
rem: then you should precede the character with this symbol "^" in the password
rem: file, not only once but THREE TIMES, like this for example: ^^^& ; for
rem: each time one of those command characters appears in your password.
IF NOT DEFINED pword GOTO endprocess ELSE GOTO decipher
:decipher
ECHO    Beginning the decryption process....
ECHO.
ECHO    You may see error messages during the decryption process
ECHO    related to those messages with IDEA cipher unless you
ECHO    have the IDEA extension capability. This is normal, and
ECHO    has no effect on your valid messages.
ECHO.
FOR %%G IN (*.asc) DO (
(echo %pword%|gpg --batch --passphrase-fd 0 --decrypt-files %%G))
FOR /F "skip=1" %%A IN (password-file) DO @echo %%A>>password-file2
IF NOT EXIST password-file2 GOTO endprocess
ATTRIB -R password-file
MOVE /y password-file2 password-file
GOTO variable

:endprocess
IF EXIST filelist ERASE /f filelist
TYPE nul>password-file
ERASE /f password-file
ECHO There are no more passwords in the password-file.
SET "pword="
ECHO Your messages, if any, have been deciphered.
ECHO Removing undeciphered messages...
ERASE /f *.asc
:EOF
ECHO The batch has finished processing.
ENDLOCAL

------------------------------------------------


-- 
  Enjoy the ride!

 rooster@thechickencoop.net
 gallus gallus domesticus
 "A happy member of Kingdom Animalia"
~~
Technical Details
Message-ID: <20120302072121.f0GxMLW9Dega@mail2news.mixmin.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.privacy.anon-server.20141023.mbox.gz!border1.nntp.ams3.giganews.com!border2.nntp.ams3.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!feeder.erje.net!lightspeed.eweka.nl!81.171.88.16.MISMATCH!eweka.nl!hq-usenetpeers.eweka.nl!188.40.76.149.MISMATCH!mail2news.mixmin.net!not-for-mail
References: <RW1MZF0040970.5818055556@reece.net.au> <20120302070150.ECq3i3DlJ9c5@mail2news.mixmin.net>

Show Full Headers
Complete Article Headers
Message-ID: <20120302072121.f0GxMLW9Dega@mail2news.mixmin.net>
Subject: rooster1.bat with word-wrap removed
Date: Fri, 2 Mar 2012 01:19:23 -0600
From: rooster@thechickencoop.net
References: <RW1MZF0040970.5818055556@reece.net.au> <20120302070150.ECq3i3DlJ9c5@mail2news.mixmin.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.privacy.anon-server.20141023.mbox.gz!border1.nntp.ams3.giganews.com!border2.nntp.ams3.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!feeder.erje.net!lightspeed.eweka.nl!81.171.88.16.MISMATCH!eweka.nl!hq-usenetpeers.eweka.nl!188.40.76.149.MISMATCH!mail2news.mixmin.net!not-for-mail
Newsgroups: alt.privacy.anon-server
Lines: 194
Injection-Info: mail2news.mixmin.net; mail-complaints-to=abuse@mixmin.net
X-Original-Bytes: 7463