-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathInvoke-SendPhish.ps1
152 lines (117 loc) · 6.28 KB
/
Invoke-SendPhish.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<#
.SYNOPSIS
Invoke-SendPhish sends a spoofed email message from a csv input with an attachment and a delay possibility. Requires Powershell 2.0. May generate error if only 1 email is in CSV due to my bad status bar math, all is working fine...
Function: Invoke-SendPhish
Author: Matt Kelly, @BreakersAll
License: BSD 3-Clause
Required Dependencies: PSv2
Version: 1.0
.DESCRIPTION
Invoke-SendPhish sends a spoofed email message from a csv input with an attachment and a delay possibility.
.PARAMETER CSVInput
Specify an input file containing parameters to find and replace in boyd and send email, first three MUST BE firstname,lastname,emailaddress, optionally after that you can have up to three additional ones in one line (6 total): (optional)parameter1, (optional)parameter2,(optional)parameter3, example: C:\temp.csv.
.PARAMETER SMTPServer
Optionally specify an SMTP Server.
.PARAMETER EmailBody
Supply the email body in HTML format, the following parameters can be used to replace: FNAME,LNAME,PARAMETER1,PARAMETER2,PARAMETER3.
.PARAMETER Subject
Supply the email subject.
.PARAMETER FromAddress
Optionally supply the from address, be mindful of spaces, defaults to IT HelpDesk ITHelpDesk@domain with a ton of spaces to obscure real sender address.
.PARAMETER Attachment
Optionally supply an attachment to use, example -Attachment C:\MacroPowershellWordDoc.doc.
.PARAMETER Delay
Optionally specify a static delay between emails.
.PARAMETER DelayRandom
Optionally specify a random delay value with the value being the maximum, picks random between 1 and that number after each email.
.EXAMPLE
PS C:\>Invoke-SendPhish -CSVInput Input.csv -EmailBody email-body.txt -Subject "PhishingEmail" -FromAddress "HelpDesk . <[email protected]>" -SMTPServer 1.1.1.1
.EXAMPLE
PS C:\>Invoke-SendPhish -CSVInput Input.csv -EmailBody email-body.txt -Subject "TEST EMAIL" -Delay 180
.EXAMPLE
PS C:\>Invoke-SendPhish -CSVInput Input.csv -EmailBody email-body.txt -Subject "TEST EMAIL" -DelayRandom 180
#>
Function Invoke-SendPhish
{
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,
HelpMessage='Provide the CSV in firstname,lastname,ToEmailAddress (example: matt,kelly,[email protected]')]
[ValidateScript({Test-Path $_})]
[string]$CSVInput,
[Parameter(Mandatory=$true,
HelpMessage='Provide the HTML body email to send, use KEYWORDS FNAME, LNAME to replace contents')]
[ValidateScript({Test-Path $_})]
[string]$EmailBody,
[Parameter(Mandatory=$true,
HelpMessage='Provide the email subject, example: -Subject "Definitely Not a phishing email"')]
[string]$Subject,
[Parameter(Mandatory=$false,
HelpMessage='Optionally specify the from address, remember lots of spaces to fool Outlook, defaults to a stealthy one from [email protected]')]
[string]$FromAddress = "IT HELPDESK . <[email protected]>",
[Parameter(Mandatory=$false,
HelpMessage='Optionally specify an email attachment')]
[ValidateScript({Test-Path $_})]
[int]$Attachment,
[Parameter(Mandatory=$true,
HelpMessage='Specify the SMTP Server')]
[string]$SMTPServer,
[Parameter(Mandatory=$false,
HelpMessage='Sets a random delay with a user specified maximum number in seconds')]
[int]$DelayRandom,
[Parameter(Mandatory=$false,
HelpMessage='Optionally delay the send (specify in seconds)')]
[int]$Delay
)
$ItemsToSend = Import-Csv $CSVInput -Header @("Firstname","Lastname","Email","Param1","Param2","Param3")
Write-Host "Items to send is currently equal to: $ItemsToSend"
$SendCount = $ItemsToSend.Count
if ($SendCount -eq 0)
{
$SendCount++
}
$Count = 0
ForEach ($line in $ItemsToSend)
{
$Body = Get-Content $EmailBody
$Count++
If ($Count/100 -lt 1 -or $Count -eq 1)
{
Write-Progress -Activity "Sending Phishing Email" `
-Status "Processing Line $Count of $SendCount Sending to $line" `
-PercentComplete ($Count/$SendCount*100)
}
$Body = $Body.Replace("FNAME",$line.Firstname)
$Body = $Body.Replace("LNAME",$line.Lastname)
if ($line.Param1) {$Body = $Body.Replace("PARAMETER1",$line.Param1)}
if ($line.Param2) {$Body = $Body.Replace("PARAMETER2",$line.Param2)}
if ($line.Param3) {$Body = $Body.Replace("PARAMETER3",$line.Param3)}
if ($Attachment)
{
Send-MailMessage -from "$FromAddress" -to $line.Email -subject "$Subject" -body "$Body" -smtpServer "$SMTPServer" -DeliveryNotificationOption OnFailure -BodyAsHtml -Attachment $Attachment
}
else
{
Send-MailMessage -from "$FromAddress" -to $line.Email -subject "$Subject" -body "$Body" -smtpServer "$SMTPServer" -DeliveryNotificationOption OnFailure -BodyAsHtml
}
if ($DelayRandom)
{
$RandomDelay = Get-Random -Maximum $DelayRandom -Minimum 1
Write-Host "Sleeping $RandomDelay seconds."
Sleep -Seconds $RandomDelay
}
elseif ($Delay)
{
Write-Host "Sleeping $Delay seconds."
Sleep -Seconds $Delay
}
}
If ($Count -eq $SendCount)
{
Write-Progress -Activity "Parsing Email Phish Send CSV File" `
-Status "Processing Line $Count of $SendCount" `
-PercentComplete ($Count/$SendCount*100) `
-Completed
}
}