Homework assignment for ScamLab exercise 5 - automatic reply to scam (ITC8210 Human Aspects of Cyber Security, TalTech).
The entire program consists of 2 main parts - Text Analysis, and Sending and receiving e-mails.
We are given an arbitrary string and need to extract the keywords. For that Microsoft Azure Cognitive Services Text Analytics API is used. They offer 5,000 free analytics per month, which is more than enough for the purposes of this assignment. This service takes English text of 1,000 symbols or less and provides it's keywords. One of the keywords will be used to form a question in the reply email (example: "I was wondering if you could elaborate on ABC", where "ABC" was taken from the initial email).
This part consists of 2 clients - IMAP, and SMTP. IMAP client is used to receive emails and SMTP is used to send the replies. The clients need to be set up from appsettings.json
file (example below).
Basic algorithm flowchart:
- Sleep for 5 minutes.
- Check if new emails arrived within those last 5 minutes.
- If new e-mail(s) arrived:
- Run keyword text analysis on the received e-mail(s).
- Pick a random selection of predetermined template messages (greeting, question, signature).
- Schedule a response e-mail to be sent in the next 5 minutes to 2 hours (instantaneous replies appear suspicious).
- Repeat from (1).
Rest of the code is used to sanitize and cleanup dirty email code, such as
characters.
[Required] .Net Core 3.1 Runtime
Download latest release from releases tab.
Edit appsettings.json
:
{
"CognitiveServices": {
"APIKey": "", // From Azure Cognitive services resource
"Endpoint": "" // From Azure Cognitive services resource
},
"EmailOptions": {
"Email": "", // Email address to use for the IMTP/SMTP clients
"Name": "", // Name to send emails as (usually your full name)
"Password": "", // Password to use for the IMTP/CMTP clients
"Host": "imap.gmail.com", // Host. Change if not using gmail.
"ImapPort": "993", // IMAP port. Default should work in most cases.
"SmtpPort": "465" // SMTP port. Default should work in most cases.
}
}
On Windows: Run Autoreply.exe
.
On Limux/MacOS: Run CLI dotnet Autoreply.dll
.