This repository was archived by the owner on Sep 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphishme_grabber.ps1
More file actions
50 lines (42 loc) · 1.73 KB
/
phishme_grabber.ps1
File metadata and controls
50 lines (42 loc) · 1.73 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
# PhishMe Search Script v1
# copyright by Artyom Ageyev
# 19/04/2018
Write-Host "================= PhishMe Search Script ===================="
# ==== VARIABLES =====
$attachment_dir = ""
$email = ""
$email_folder = "Inbox"
Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null
$olFolders = "Microsoft.Office.Interop.Outlook.olDefaultFolders" -as [type]
$outlook = new-object -comobject outlook.application
$namespace = $outlook.GetNameSpace("MAPI")
#get phishme mail folder content
$folder = $namespace.Folders($email).Folders($email_folder)
while($true){
#get time window
$now = Get-date
if ($now.Minute -lt 30)
{
$date_from = $now.Date.AddHours($now.Hour - 1).AddMinutes(30)
$date_to = $now.Date.AddHours($now.Hour)
}
else
{
$date_from = $now.Date.AddHours($now.Hour)
$date_to = $now.Date.AddHours($now.Hour).AddMinutes(30)
}
Write-Host "$("Working with emails from") $date_from $(" to ") $date_to"
Write-Host "[INFO] Building mail database. It could take some time ... " -NoNewline
$mails = $folder.items | where-object { ($_.ReceivedTime -ge $date_from) -and ($_.ReceivedTime -lt $date_to)}
# $mails = $folder.items | where-object { $_.ReceivedTime -gt [DateTime]::ParseExact($date, 'd/M/yyyy HH:mm:ss',[CultureInfo]::InvariantCulture)}
Write-Host "Done" -ForegroundColor Green
#save attachments to NAS
foreach ($mail in $mails)
{
$filename = "$($mail.ReceivedTime.ToString('yyyyMMdd-HHmmss')) - $($mail.attachments(1).FileName)"
Write-Host "$("[INFO] Saving mail ") $filename"
$mail.attachments(1).saveasfile($attachment_dir + $filename)
}
write-Host "[INFO] waiting for 5 minutes before loop"
Sleep -Seconds (New-TimeSpan -Minute 15).TotalSeconds
}