You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PhishingAwarenessSimulation/Assets/Editor/PhishingEmailAssetGenerator.cs

75 lines
3.7 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using UnityEngine;
using UnityEditor;
using System.IO;
public class PhishingEmailAssetGenerator
{
[MenuItem("Tools/Generate Phishing EmailData Assets")]
public static void GeneratePhishingEmails()
{
string folderPath = "Assets/ScriptableObjects/PhishingEmails";
if (!AssetDatabase.IsValidFolder("Assets/ScriptableObjects"))
{
AssetDatabase.CreateFolder("Assets", "ScriptableObjects");
}
if (!AssetDatabase.IsValidFolder(folderPath))
{
AssetDatabase.CreateFolder("Assets/ScriptableObjects", "PhishingEmails");
}
CreateEmail("Accure Bank", "support@accure-bank-ank.com",
"ob1ink a update now Avoid Suspension",
InjectLink(
"Dear Customer,\n\nOur system has detected unusual activity in your account. You must ob1ink a update immediately to prevent restriction. If no action is taken within 2 hours, your account will be permanently locked.\n\nVisit the secure link below:\n{link}\n\nThis is an automated message. Please do not reply.\n\n Accure Bank Online Security",
"http://accure-bank-ank.com/verify"
),
"http://accure-bank-ank.com/verify", false, true, "Today", folderPath);
CreateEmail("Microsoft Security", "alert@m1crosoft-security.com",
"Suspicious Login act1vate your profile urgently",
InjectLink(
"Dear User,\n\nWe've detected a login attempt from an unknown location. To protect your account, you need to act1vate your profile update immediately. Ignoring this request may result in profile lockout.\n\nClick the link to verify:\n{link}\n\nThanks,\nMicrosoft Account Protection Team",
"http://m1crosoft-security.com/actnow"
),
"http://m1crosoft-security.com/actnow", false, true, "1 hour ago", folderPath);
CreateEmail("CloudStorage", "alerts@stor-cloud-updates.com",
"Verify stor-age account info to avoid suspens1on",
InjectLink(
"Hello,\n\nWe were unable to sync your latest files due to a mismatch in account info. To avoid suspens1on of your cloud services, please verify your account information now.\n\nConfirm here:\n{link}\n\nThis issue must be resolved within 3 hours.\n\n CloudStorage Notification Center",
"http://stor-cloud-updates.com/verify"
),
"http://stor-cloud-updates.com/verify", false, true, "Today", folderPath);
}
private static void CreateEmail(string senderName, string senderEmail, string subject, string body,
string link, bool attachment, bool phishing, string date, string folderPath)
{
EmailData asset = ScriptableObject.CreateInstance<EmailData>();
asset.senderName = senderName;
asset.senderEmail = senderEmail;
asset.subject = subject;
asset.fullBodyText = body;
asset.linkPreview = link;
asset.hasAttachment = attachment;
asset.isPhishing = phishing;
asset.timeOrDate = date;
string safeFileName = subject.Replace(" ", "_")
.Replace("", "-")
.Replace(":", "")
.Replace("/", "-")
.Replace("\\", "-");
string path = $"{folderPath}/{safeFileName}.asset";
AssetDatabase.CreateAsset(asset, path);
AssetDatabase.SaveAssets();
Debug.Log($"🛑 Created Phishing EmailData asset at: {path}");
}
private static string InjectLink(string template, string link)
{
string styled = $"<link=\"{link}\"><color=#0000EE><u>{link}</u></color></link>";
return template.Replace("{link}", styled);
}
}