-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSend-PhishingMail.ps1
More file actions
311 lines (258 loc) · 16.9 KB
/
Send-PhishingMail.ps1
File metadata and controls
311 lines (258 loc) · 16.9 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# #######################################
# SERAY BESER
#
# Send-PhishingMail
# Sending Phishing Email Program
# #######################################
param (
[string]$server,
[string]$serverPort,
[string]$from,
[string[]]$to,
[string]$subject,
[string]$body,
[string]$bodyPath,
[string]$isbodyHtml,
[string]$attachmentPath,
[string]$operation,
[switch]$help,
[switch]$output,
[string]$outputFile
)
if(!$outputFile)
{
$outputFile = 'output.log'
}
if($outputFile)
{
$output = $True
}
if($output)
{
$Date = Get-Date
"$Date [BEGIN] Sending Phishing Email Program " | Out-File $outputFile
}
if($help)
{
Write-Output "`n NAME`n Send-PhishingMail"
Write-Output "`n TOPIC`n Send-PhishingMail Help System"
Write-Output "`n SHORT DESCRIPTION`n Send-PhishingMail Program sends phishing mail to the destination mail address(es)."
Write-Output "`n LONG DESCRIPTION`n Send-PhishingMail Program sends phishing mail to the
destination mail address(es). By default, there is a phishing mail in the program. However,
if you want to send another mail, you can do it with the -operation flag. <manuel> takes the
subject and the body from the user and sends it to the destination address(es). The program
has the ability to send mail to many people at the same time by using -to flag. (-to can get
a list) The program also allows you to send mail in html format at the same time. For this,
it is enough to mark the -isbodyHtml flag as true by taking the html formatted text's path
with the -bodyPath flag. Use the -attachmentPath flag to attach an attachment to the e-mail."
Write-Output "`n SERVER`n By default, server is smtp.gmail.com and server port is 587.
Use the -server and -serverPort to change the server settings."
Write-Output "`n SYNTAX`n ./Send-PhishingMail.ps1 [-from] <string> [-to] <string[]> [-subject] <string>
[-body] <string> [-bodyPath] <string> [-isbodyHtml {None | True}]
[-attachmentPath] <string> [-operation {manuel | default}] [<CommonParameters>]"
Write-Output "`n OUTPUT`n If you want to save the log file you can use the -output flag. Logs are saved in the
output.log file by default. Use -outputFile flag to save it in another file."
Write-Output "`n VERSION`n 1.0.0"
Write-Output "`n AUTHOR`n Seray Beser"
Write-Output "`n LICENSE`n MIT License
Copyright (c) 2018 Seray Beşer
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the `"Software`"), to deal in the Software without
restriction, including without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED `"AS IS`", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE."
exit
}
if (!$from)
{
$from = Read-Host -Prompt '[INPUT] Enter <from>'
if($output)
{
$Date = Get-Date
"$Date [INPUT] Getting input for <from>: $from" | Out-File $outputFile -Append
}
}
if (!$to)
{
$toElement = Read-Host -Prompt '[INPUT] Enter <to>'
if($output)
{
$Date = Get-Date
"$Date [INPUT] Getting input for <to>: $toElement" | Out-File $outputFile -Append
}
$to += $toElement
$i = 2
while($toElement)
{
$toElement = Read-Host -Prompt "[INPUT] Enter <to[$i]>"
if($toElement)
{
$to += $toElement
if($output)
{
$Date = Get-Date
"$Date [INPUT] Getting input for <to[$i]>: $toElement" | Out-File $outputFile -Append
}
}
$i++
}
}
if (!$subject -Or (!$body -And !$bodyPath))
{
if(!$operation)
{
$operation = Read-Host -Prompt '[INPUT] Enter <manuel or default>'
if($output)
{
$Date = Get-Date
"$Date [INPUT] Getting input for <operation>: $operation" | Out-File $outputFile -Append
}
}
if ($operation -eq 'manuel')
{
$subject = Read-Host -Prompt '[INPUT] Enter <subject>'
$body = Read-Host -Prompt '[INPUT] Enter <body>'
Write-Output "`n[INFO] You input <subject>: '$subject', <body>: '$body' on '$Date'"
if($output)
{
$Date = Get-Date
"$Date [INFO] You input <subject>: '$subject', <body>: '$body'" | Out-File $outputFile -Append
}
}
elseif ($operation -eq 'default')
{
$subject = "Hesabın Ele Gecirildi"
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
$settingspath = $directorypath + '\body.txt'
$body = Get-Content -Path $settingspath
$isbodyHtml = 'True'
}
else
{
Write-Output "[ERROR] Invalid Operation."
Write-Output "[DONE] Program Closed."
if($output)
{
$Date = Get-Date
"$Date [ERROR] Invalid Operation." | Out-File $outputFile -Append
"$Date [DONE] Program Closed." | Out-File $outputFile -Append
}
exit
}
}
# Default mail server settings
if (!$server -Or !$serverPort)
{
$server = "smtp.gmail.com"
$serverPort = 587
if($output)
{
$Date = Get-Date
"$Date [INFO] Default server is smtp.gmail.com." | Out-File $outputFile -Append
"$Date [DONE] Default server port is 587." | Out-File $outputFile -Append
}
}
# Set up server connection
$SMTPClient = New-Object System.Net.Mail.SmtpClient $server, $serverPort
$SMTPClient.EnableSsl = $true
#$SMTPClient.UseDefaultCredentials = $false;
# Get user credentials
#$password = Read-Host -Prompt "`n[INPUT] Enter <password> for '$from'" -AsSecureString
#$SMTPClient.Credentials = New-Object System.Net.NetworkCredential($from, $password)
$credential = $Host.UI.PromptForCredential("Enter your Email address and password",$msg,$from,$emailSmtpUser)
$emailSmtpUser = $credential.UserName
$emailSmtpPass=$credential.GetNetworkCredential().Password
$SMTPClient = New-Object System.Net.Mail.SmtpClient( $server , $serverPort )
$SMTPClient.EnableSsl = $True
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential( $emailSmtpUser , $emailSmtpPass );
if($output)
{
$Date = Get-Date
"$Date [INPUT] You input password for <$from> : ********" | Out-File $outputFile -Append
}
if ($bodyPath -And !$body)
{
$body = Get-Content $bodyPath
if($output)
{
$Date = Get-Date
"$Date [INFO] Getting Body in $bodyPath." | Out-File $outputFile -Append
}
}
try
{
foreach ($toElement in $to) {
if($toElement)
{
# Create mail message
$message = New-Object System.Net.Mail.MailMessage $from, $toElement, $subject, $body
# Check body format
if ($isbodyHtml)
{
$message.IsBodyHTML = $true
}
# Check attachment
if ($attachmentPath)
{
$attachment = New-Object System.Net.Mail.Attachment $attachmentPath
$message.Attachments.Add($attachment)
if($output)
{
$Date = Get-Date
"$Date [INFO] Attached $attachment." | Out-File $outputFile -Append
}
}
Write-Output "`n[INFO] Sending Phishing E-Mail to $toElement..."
if($output)
{
$Date = Get-Date
"$Date [INFO] Sending Phishing E-Mail to $toElement..." | Out-File $outputFile -Append
}
try
{
# Send the message
$SMTPClient.Send($message)
Write-Output "[INFO] Phishing E-Mail Sent."
if($output)
{
$Date = Get-Date
"$Date [INFO] Phishing E-Mail Sent." | Out-File $outputFile -Append
}
}
catch
{
Write-Error $_
Write-Output "[ERROR] Phishing E-Mail Send Failed."
if($output)
{
$Date = Get-Date
"$Date [ERROR] Phishing E-Mail Send Failed." | Out-File $outputFile -Append
}
}
}
}
}
catch
{
Write-Output "[ERROR] Authentication Failed."
if($output)
{
$Date = Get-Date
"$Date [ERROR] Authentication Failed." | Out-File $outputFile -Append
}
}
Write-Output "[DONE] Program Closed."
if($output)
{
$Date = Get-Date
"$Date [DONE] Program Closed." | Out-File $outputFile -Append
}