🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Rooster's Revised Batch Decryption Method

#255894
From: Rooster
Date: Mon, 09 Apr 2012 00:49
340 lines
17557 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In light of the fact that there was a reasonable request made by a user here, who expressed concern that
the existing gpg signature verification report provided by my batch decryption method could get
overlooked or lost among the other standard output during the batch process, I have decided to revise my
script to improve the method of reporting presented in Rooster's Method.  I completed this enhancement
and will now present the revised script here. I have also changed some of the coding for greater
efficiency in general.

My verification summary is created now during the decryption process as a succinct report made
separately from the messages themselves.  At the end of the batch processing, a file named "status.log"
will be present in the same folder as the batch script itself. There are four parts on the report: It
includes the date and time of processing, the list of any files deciphered successfully, any signature
verifications that would normally be reported by the gpg program and sent to standard output for each of
those deciphered files, and the names of all the validly named files that were in the batch for your
reference. It is neatly laid out and easily read. If you have any questions about it, feel free to ask.
I welcome any positive criticism or reasonable recommendations.

My report is created plainly and separately like this because I still adamantly reject the notions
thrown around by some close-minded pundits suggesting it would be good to have the verification report
data mixed in with the messages themselves or in their headers. These messages are gpg encrypted, and in
order to preserve their integrity, it is important that we keep to standard usage in accordance with gpg
best-practices. Therefore, mixing these data with message content is a bad, bad idea. Anyone trying to
spin a story for you to the contrary is simply hoping to justify his convenient abberations from secure
and proven standards. The folks at gpg would not sanction that, and I am not going to do that either.

My newly revised script follows below. Using it is simply a matter of putting the batch script into an
otherwise empty folder in your directory. For maximum security you could use a truecrypt container or
USB drive, but that is certainly not required for it and the choice is, obviously, yours as to how you
should put confidential information into your Windows directories. Another good choice would be to use
Sandboxie, which, when properly configured, securely deletes the contents of sandboxed data. Sandboxie
can be gotten freely, but again this program is not necessary for the script to function properly.

 All you need for the batch script is the standard Windows OS and the gpg program installed, nothing
more. Put the script into an empty folder and give it a name like "Rooster1.bat". Put a text file into
this same folder and name it "password-file", without any suffix extension, and put your passwords
inside it, each on a separate line. The name of the password file must be named exactly as I just stated
because it will be identified in the script with that name too. Then copy the downloaded "a.a.m."
messages into the folder as individual text files. You can put as many as you like in batch process and
they can be downloaded however you want.  No special program is needed for them.  These message files
can have any valid Windows filenames and they must have a ".txt" suffix.  So, they might be like this:
message1.txt, message2.txt, message3.txt, etc.  Normally these files would be named with their message
subjects as their names, which in the case of nym servers would be comprised of 48 hexadecimal
characters, and quite often these subjects also represent hsub encoding.  If you want to use that same
convention, it would be fine to do so, but bear in mind that these special subject names are quite
irrelevant insofar as the method of processing is concerned. "My method of deciphering messages in this
batch procedure does not need any special name for a subject other than a valid Windows filename." Once
you have these three components in the folder, you are good to go: the batch file, the password file,
the group of messages individually saved as text files with ".txt" extensions.

When the batch procedure begins it will ask you a couple of simple questions about what sort of messages
your want it to search through. You have three choices: to search through only symmetrically encrypted
messages, only asymmetically encrypted messages, or both kinds of message. Searching for symmetric only
is by far the fastest procedure because for each message there is only one key possible as an option,
namely, the unique symmetric password. Then again, almost every symmetrically encrypted message that
gets deciphered would also have an inner layer of asymmetic encryption, which would require a second
pass before revealing the core message.  On the other hand, messages with only asymmetric encryption,
although requiring only one layer of decryption, do require that each of the secret keys on your keyring
be tried in succession until the correct one is found to match up with one of the passwords. The reason
all the keys have to be tried is that the messages encrypted only asymmetrically are for the most part
made with a gpg command option of "throw-keyids" for security reasons; and, therefore, gpg cannot
determine right away exactly which key ID to use for decryption and must try each of them one by one
until it comes across a valid one, if at all.  Of course, the whole procedure is automated in the
script; and, moreover, one good way to minimize the delay would be to use a separate keyring with only
the reduced set of keys needed for your messages instead of one with all of your valid keys. It isn't
difficult to maintain a second keyring to be used temporarily with only a few of all the keys from your
main keyring where everything can still be kept if you want.

When the procedure has finished, it will clean up after itself and delete all the message files except
any of those which have resulted in a deciphered message. It will delete your password file too.  It
will delete any temporary file or folder it created during the procedure.  It will leave a folder called
"badnames", in which any message file will have been put if its filename contain unusual characters that
could interfere with the script routines during processing (for example like these: &, ^, etc.), and any
message file with a filename that contains spaces in it.  If you think that one of these could be yours,
you could rename it to any valid name without spaces or one of these characters, and rerun it through
the script. Otherwise, you should simply delete the folder and these inconsequential files. Also left
will be the processing report, i.e., the "status.log", which includes the signature validations, etc.,
as described above. Finally, the batch script itself will be left over for your re-use.

Finally, if your passwords themselves contain unusual characters, then I strongly recommend that you
look at the brief notes included inside the batch file before running it. There are four characters
which would have to be escaped within the password file prior to processing.  Here are these notes again
for your reference, along with the batch script ready for copying and saving. Feel free to ask me any
questions you may have. Contrary to the disinformation and hype you may have read here from any of my
detractors, I am quite approachable by anyone with a reasonable and friendly inquiry.  I am as willing
to help anyone asking for it as I would expect from others when I do the asking of them.  :)


	----------------- ROOSTER 1.2 BATCH DECRYPTION METHOD ---------------------

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 preparing messages for gpg processing...)
REN *.txt *.asc
IF NOT errorlevel 0 GOTO EOF
ECHO.
IF not exist password-file ((Echo    There is no "password-file") & GOTO EOF )
(ECHO    Moving files with problematic names into 'badnames' folder...)
ECHO.

MD badnames
DIR *.asc /A:-d /b >filenames
FOR %%G in (^& ^< ^> ^| ^^ "=" ^( ^)) do @echo:%%~G>>badstuff
FOR /f "tokens=*" %%H in ('FINDSTR /g:badstuff filenames') do (
Move /y "%%H" .\badnames\"%%H" >nul 2>&1)
ERASE badstuff

FOR /f "tokens=* usebackq" %%I in (`DIR *.asc /A:-d /b ^|FIND " "`) do (
move /y "%%I" .\badnames\"%%I" >nul 2>&1)

ERASE /f/q filenames
FOR /f "tokens=*" %%J in ('dir *.asc /a:-d /b') do @echo:%%~nJ>>filenames
FOR /f "tokens=* usebackq" %%K in (`findstr /v /x "[0-9a-f]*" filenames`) do (
(If not exist %%K.asc echo %%K.asc) & Move /y "%%K.asc" .\badnames\"%%K.asc"
)

ERASE /f/q filenames
FOR /f %%L in ('dir *.asc /b') do @echo:%%~nL>>filenames
FINDSTR /x "[0-9a-f]*" filenames >goodnames
MOVE /y goodnames 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 (
ECHO %date%  %time%>record
ECHO Attempting decryption of both symmetric and asymmetric messages>>record
ECHO.>>record
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 %%M in (*.asc) do (
gpg --list-only --status-fd 1 %%M | Find /i "enc_to" && Erase /f/q %%M
)
ECHO.
ECHO.
ECHO    Deleting messages not having an outer layer of symmetric encryption...
ECHO %date%  %time%>record
ECHO Removing messages with asymmetric encryption>>record
ECHO.>>record
rem: end routine for removing messages without outer symmetric encryption
GOTO core

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 asymmetric 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 %%N in (*.asc) do (
gpg --list-only --status-fd 1 %%N | FIND /i "enc_to" && DIR /b %%N>>asymfiles)
IF NOT EXIST asymfiles (
(ECHO There are no messages that indicate having asymmetric encryption on its outer layer!) & (
GOTO endprocess)
)
ECHO.
ECHO.
ECHO    Removing messages with symmetric encryption...
FOR %%P in (*.asc) do @Findstr /c:%%P asymfiles || Erase /f /q %%P
ECHO %date%  %time%>record
ECHO Removing messages with symmetric encryption>>record
ECHO.>>record

:core
md temp1
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 %%R in (*.asc) do (
IF NOT EXIST %%~nR (
Echo:%pword%|gpg --batch --passphrase-fd 0 --status-file %%R.log %%R
IF EXIST %%~nR (Dir %%R /b >>record & Move /y %%R .\temp1\%%R >nul)
))
FOR /F "skip=1" %%S in (password-file) do @echo %%S>>password-file2
IF NOT EXIST password-file2 (ECHO.>>record & GOTO endprocess)
ATTRIB -R password-file
MOVE /y password-file2 password-file
GOTO variable

:endprocess
IF EXIST asymfiles Erase /f/q asymfiles
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
COPY record status.log
ECHO ^"If any files were sucessfully deciphered, their names>>status.log
ECHO would appear above this line, and the status of any signa->>status.log
ECHO tures would appear just below this line in the same order.^">>status.log
ECHO.>>status.log

FOR /f %%T in (record) do (
IF EXIST %%~nT (
ECHO GPG validation result for "%%~nT":>>status.log
Type %%T.log>>status.log 2>&1
ECHO.>>status.log
))

ECHO.>>status.log
ECHO:The following filenames were processed effectively:>>status.log
ECHO.>>status.log
TYPE filenames >>status.log
MOVE /y status.log .\temp1
TYPE nul>record
FOR %%V in (*.) do (
IF NOT EXIST %%V.asc.log Erase /f %%V)
ERASE /f *.log
MOVE /y .\temp1\*.* >nul
RD /q temp1

:EOF
ECHO.
ECHO The batch has finished processing.
ENDLOCAL

	----------------- ROOSTER 1.2 BATCH DECRYPTION METHOD ----------------------

-----BEGIN PGP SIGNATURE-----
Version: N/A

iQGVAwUBT4IxKeWcBAJ+953TAQI8ZQv+Kp3HhPkwFCe4xSiYlNp4WgWGP5ssIKot
lFwAQAq7li/66PiyGkDxbyKDAEyV4u6HpBK0Sb3erT+KaNNq48fMaeLIN5LGVZ55
akj56z7kA+2ZdwRqXlN4HMLvlyesAsBxFmIIv14P1SM4WC7xJVTRGi82AVmPhDpC
TlEjUVsnwM6cQMv7F4IqWOOfWT0WdchpCquWt1LJW/6KEPgc3fFEMVUAwDVL8h6n
Ui85NHpjShBnURyeRbG/DLhxsYC48OC1Axg96OFs8iE2TPdi7gBLhUTuRRvyVPvF
ud47YEnwG89y+KnXQoUTJtMes+MRg25aeuZkG1qu3tMcJCAJaroIFk7g9TAZ54Ty
jxBErk7g/IrnFXrd4rEKj05CfC1Z6AQ+cmeSZndYFkKwm2K0g5R/yjDnIosjaJga
1E9CDXPzLNz3I8s3uZQL8/cdJClyA966q2s22/4utrw4rBsZV9GwqM1HqZRWWWvC
kmZvqTcVMMPx5YLxLEQRf68IwM3PF6XJ
=EuyT
-----END PGP SIGNATURE-----

-- 
"Our experience of life assaults and offends our psyche with its apparent indifference to
the meaning we desperately seek in it."	- Rooster -

rooster@thechickencoop.net
gallus gallus domesticus
A Happy Member of Kingdom Animalia

Technical Details
Message-ID: <ZFMTHGJA41008.3680439815@reece.net.au>
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!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!border1.hitnews.com!eweka.nl!hq-usenetpeers.eweka.nl!188.40.76.149.MISMATCH!mail2news.mixmin.net!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <ZFMTHGJA41008.3680439815@reece.net.au>
Subject: Rooster's Revised Batch Decryption Method
Date: Mon, 09 Apr 2012 00:49:59 +0000
From: Rooster <remailer@reece.net.au>
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!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!border1.hitnews.com!eweka.nl!hq-usenetpeers.eweka.nl!188.40.76.149.MISMATCH!mail2news.mixmin.net!not-for-mail
X-Remailer-Contact: abuse@reece.net.au (English Only Please)
Newsgroups: alt.privacy.anon-server
Lines: 341
Injection-Info: mail2news.mixmin.net; mail-complaints-to=abuse@mixmin.net
X-Original-Bytes: 17204