FindYhoo.bat:
@echo ***This batch file will log into a SmarterMail server and dump all the possible @echo ***ways that mail is being forwarded (user forwards and aliases) to Yahoo. @echo *** @echo *** Syntax: FINDYHOO host user pass @echo *** Where : host is the base URL of the server (ex: http://mail.josh.com) @echo *** user is the system admin username @echo *** pass is the system admin password Echo * First clear out the file that will hold the results... del results.txt Echo * Get a list of all domains on the server. We'll use this for a few things... TsmaDump /ODomains.txt DOMAIN %1 %2 %3 if not errorlevel 1 goto error :FORWARDS Echo * Next iterate though the domains grabbing forwards... for /f "tokens=1" %%i in (Domains.txt) do ( Echo * Get a list of all the users in domain [%%i]... TSMADump /oUsers.txt USER %1 %2 %3 %%i if not errorlevel 1 goto error Echo * Then iterate though all the users looking for forwards... for /f "tokens=1" %%j in (users.txt) do ( Echo * Check forwarding for user [%%j]... TSMADump /oForward.txt USERFORWARD %1 %2 %3 %%j if not errorlevel 1 goto error Echo * First field in file forward.txt is username Echo * Second field in file forward.txt is the forwarding address for /f "tokens=1,2,4" %%k in (Forward.txt) do ( Echo * Forward enabled is [%%l] if "%%l"=="True" ( Echo * add this username and forward address to the results... echo %%k %%m >>results.txt ) ) ) ) :ALIASES Echo * Next iterate though the domains grabbing aliases... for /f "tokens=1" %%i in (Domains.txt) do ( Echo * Get a list of all the aliases in domain [%%i]... TSMADump /OAliases.txt ALIAS %1 %2 %3 %%i if not errorlevel 1 goto error Echo * Then iterate though all forward addresses for each alias... for /f "tokens=1" %%j in (aliases.txt) do ( Echo * Check forwarding for alias [%%j]... TSMADump /oForward.txt ALIASADDRESS %1 %2 %3 %%i %%j if not errorlevel 1 goto error Echo * First field in file forward.txt is alias address Echo * Second field in file forward.txt is the forwarding address for /f "tokens=1,2" %%k in (Forward.txt) do ( Echo * add this alias and forward address to the results... echo %%k@%%i %%l >>results.txt ) ) ) :PROCESS Echo * Process out just the destination addresses... del processed.txt for /f "tokens=2" %%i in (results.txt) do ( echo %%i, >>processed.txt ) :YAHOO Echo * Filter out only destinations going to Yahoo del yahoo.txt find /I "@yahoo.com" processed.txt >yahoo.txt notepad yahoo.txt goto done :error Echo !!!! There was an error !!!! :done |