AutoSpamEmailScan

4.4.2

AutoSpamEmailScan.ps1 is used to monitor a specific mailbox that in enterprise users can forward suspicious spam emails to a specific mailbox.
This PowerShell script can monitor the mailbox for any unread emails, grab the URLs and attachments from the emails and submit to virustotal.com, urlscan.io, Google safe browsing and OPSWAT. Script also can extract URLs from a
AutoSpamEmailScan.ps1 is used to monitor a specific mailbox that in enterprise users can forward suspicious spam emails to a specific mailbox.
This PowerShell script can monitor the mailbox for any unread emails, grab the URLs and attachments from the emails and submit to virustotal.com, urlscan.io, Google safe browsing and OPSWAT. Script also can extract URLs from a pdf file.
After the scan finished, script can generate HTML format scan report and auto reply to the senders.
Script can be run once or loop interval, if  in the init.conf is 0 means script will only run one time else the number is the loop interval seconds.
Visit https://github.com/banhao/AutoSpamEmailScan to get the init.conf and Bytescout.PDF2HTML.dll, this dll file is used to convert PDF to HTML.
Please check the License before you download this script, if you don't agree with the License please don't download and use this script. https://github.com/banhao/AutoSpamEmailScan/blob/master/LICENSE
The Password is base64 encoded and saved in init.conf, following is the example about how to genertae the encoded password:
"JkPgsiG9Zh0XCvk" is the password.
"yp9P7" is the salt. make sure salt is the unique string that can't have the same pattern in the password.
Insert the salt into password where ever you want:
yp9P7JkPgsiG9Zh0XCvk, JkPgsiG9Zh0XCvkyp9P7, JkPgyp9P7siG9Zh0XCvk, JkPgsiG9Zh0XCyp9P7vk, ...... all these are legitimate.
Generate the base64 encoded string:
[Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes("yp9P7JkPgsiG9Zh0XCvk"))
eQBwADkAUAA3AEoAawBQAGcAcwBpAEcAOQBaAGgAMABYAEMAdgBrAA==
[Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes("JkPgsiG9Zh0XCvkyp9P7"))
SgBrAFAAZwBzAGkARwA5AFoAaAAwAFgAQwB2AGsAeQBwADkAUAA3AA==
[Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes("JkPgyp9P7siG9Zh0XCvk"))
SgBrAFAAZwB5AHAAOQBQADcAcwBpAEcAOQBaAGgAMABYAEMAdgBrAA==
[Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes("JkPgsiG9Zh0XCyp9P7vk"))
SgBrAFAAZwBzAGkARwA5AFoAaAAwAFgAQwB5AHAAOQBQADcAdgBrAA==
Save the encoded string in the init.conf file.
Decode the encoded string:
[System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String("eQBwADkAUAA3AEoAawBQAGcAcwBpAEcAOQBaAGgAMABYAEMAdgBrAA=="))
yp9P7JkPgsiG9Zh0XCvk
[System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String("SgBrAFAAZwBzAGkARwA5AFoAaAAwAFgAQwB2AGsAeQBwADkAUAA3AA=="))
JkPgsiG9Zh0XCvkyp9P7
[System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String("SgBrAFAAZwB5AHAAOQBQADcAcwBpAEcAOQBaAGgAMABYAEMAdgBrAA=="))
JkPgyp9P7siG9Zh0XCvk
[System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String("SgBrAFAAZwBzAGkARwA5AFoAaAAwAFgAQwB5AHAAOQBQADcAdgBrAA=="))
JkPgsiG9Zh0XCyp9P7vk
Even someone can get the encoded string from the init.conf and use base64 to decode it, but they don't know the salt, so they still can't get the password directly.
This PowerShell passed the test in PowerShell version 5.1.16299.1146. Can not run on Powershell version 4 and below.
PS H:\>host
Check the PowerShell version.
Show more

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Script -Name AutoSpamEmailScan -RequiredVersion 4.4.2

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Package Details

Author(s)

  • HAO BAN/banhao@gmail.com

Functions

Submit-CHECKPHISH Google-Safe-Browsing Submit-URLSCAN Submit-URL-Virustotal Submit-FILE-Virustotal Submit-FILE-OPSWAT FromEmailAttachment ESASpamQuarantine ConvertLogToHTML ExtractURLFromPDFHTML CheckRedirectedURL MAIN

Dependencies

This script has no dependencies.

Release Notes

Creation Date:  <04/05/2021>
Purpose/Change: Optimize function CheckRedirectedURL{}
Creation Date:  <03/25/2021>
Purpose/Change: Update function CheckRedirectedURL{}
Creation Date:  <03/19/2021>
Purpose/Change: Add a new module for Cisco Email Security Appliance Spam Quarantine Blacklist.
Creation Date:  <11/10/2020>
Purpose/Change: Move emails to sub-folder when after the checking.
Creation Date:  <04/3/2020>
Purpose/Change: Optimize the parameters setting.
Creation Date:  <04/2/2020>
Purpose/Change: Add new feature to let the use input the credential just chose "N" when prompt "salt is empty". Add SystemException, fix the broken of the system error.
Creation Date:  <03/10/2020>
Purpose/Change: Add a new Function CheckRedirectedURL, this feature is used to detect URLs that try to escape the scan.
Change "function Submit-URL-Virustotal" to use the VirusTotal API V3
Creation Date:  <02/11/2020>
Purpose/Change: Add checkphish.ai API limit error
Creation Date:  <01/22/2020>
Purpose/Change: Add a new Function checkphish.ai
Creation Date:  <10/21/2019>
Purpose/Change: One funcation name was changed but calls the old name in the program. Update the Bytescout.PDF2HTML.dll to version 10.6.0.3667. It's still a trial version and will expire after 90 days. If you see this error:
--------------------------------------------------------------------------------------
"new-object : Exception calling ".ctor" with "0" argument(s): "Trial period expired."
+         $extractor = new-object Bytescout.PDF2HTML.HTMLExtractor
--------------------------------------------------------------------------------------
That means the DLL file has been expired.

FileList

Version History

Version Downloads Last updated
5.2.0 104 11/8/2022
5.1.6 104 9/21/2022
5.1.5 113 9/8/2022
5.1.4 134 8/17/2022
5.1.3 176 6/10/2022
5.1.2 172 5/31/2022
5.1.1 172 5/30/2022
5.1.0 173 5/26/2022
5.0.1 187 5/3/2022
5.0.0 187 4/29/2022
4.6.1 221 9/20/2021
4.6.0 205 7/9/2021
4.5.1 211 5/26/2021
4.5.0 201 5/19/2021
4.4.2 (current version) 209 4/5/2021
4.4.1 205 3/26/2021
4.4.0 203 3/22/2021
4.3.0 216 11/13/2020
4.2.2 236 4/3/2020
4.2.1 210 4/3/2020
4.2.0 216 3/10/2020
4.1.2 207 2/11/2020
4.1.1 206 2/11/2020
4.1.0 211 1/22/2020
4.0.2 217 10/21/2019
4.0.1 204 10/18/2019
4.0 206 10/8/2019
3.62 207 10/3/2019
3.61 220 9/26/2019
3.6 208 9/17/2019
3.5 211 9/5/2019
3.4 209 8/23/2019
3.3 214 8/20/2019
Show less