Hack Forums
[Shell] Word Gatherer - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Shell] Word Gatherer (/showthread.php?tid=4407399)



Word Gatherer - mickro - Aug 21, 2014

Not long ago i was working on this script, for those who usually lurk this sub you should know that the help thread i made is related to this project.

The word gatherer works like the name says, it gathers every string of text in every text file located in the same folder as the batch or its subfolder. Then it puts it on a list, this list can later be used to crack encryptions through dictionary attack (for example).

Currentlly it works, but sometimes it crashes and i don't even know why. It also doesn't know where to end, repeating the process on the last sentence over and over again.
Feel Free to check it out and help me fix it if you want.
Code
@echo off
Setlocal EnableDelayedExpansion

set /a n=0
Findstr /I /S /P /R [a-z] *.txt>Grab.dic
:reset
set /a i=1

:Begin
if %n% GTR 0 (
  set SKIP=skip=%n%
) else (
  set SKIP=
)
for /f "%SKIP% tokens=2* delims=:" %%A in (Grab.dic) do (
set Line=%%A& goto Form1
)

:Form1
set /a n=%n%+1

IF Not defined Line goto Begin
call :getNumTokens "%Line%"

:Form2
For /f "tokens=%i% delims=*-()<>/=,.?:_ " %%B in ("%Line%") do (
echo %%B>>List.dic
)
@echo off
If %numTokens%==%i% goto reset
set /a i=%i%+1
goto Form2

:getNumTokens
    set numTokens=0
    set "textRemaining=%~1"
    :again
    for /f "tokens=1*" %%a in ("%textRemaining%") do (set /a numTokens+=1&& set "textRemaining=%%b")
    if "%textRemaining%" == "" goto :eof
    goto :again