-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patho365creeper.ps1
109 lines (80 loc) · 3.74 KB
/
o365creeper.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
Function Invoke-EmailVerify {
<#
.SYNOPSIS
o365creeper.ps1 is a powershell version of 0365creeper.py. More information about the python version can be found over here https://github.com/LMGsec/o365creeper
.DESCRIPTION
This is a powershell script that helps to validate the email addresses(that belong to o365 tenant) gathered during the recon phase. You can either provide email address or exact path including filename.
The validation of email address is based on the parameter "IfExistsResult" value. If the value is 1, it means the email is invalid and 0 means valid.
.PARAMETER Email
Email address that needs to be validated
.PARAMETER File
Path along with file name that contains 1 email per line
.PARAMETER Output
Output file name where the result will be stored
.EXAMPLE
Invoke-EmailVerify -Email "[email protected]"
Description
-----------
This command will validate the given email address
.EXAMPLE
Invoke-EmailVerify -File "emails.txt"
Description
-----------
This command will validate the email addresses from the given file
.EXAMPLE
Invoke-EmailVerify -File "emails.txt" -Output results.txt
Description
-----------
This command will validate the email addresses from the given file and output the results in results.txt file
#>
Param(
[parameter(Mandatory= $False)]
[String] $Email,
[parameter(Mandatory=$False)]
[String] $File,
[parameter(Mandatory=$False)]
[String] $Output
)
$url = 'https://login.microsoftonline.com/common/GetCredentialType'
if ($Email -ne "" -and $File -ne ""){
Write-Host "Please check usage. You can either provide email address or file name, not both" -ForegroundColor Red
} elseif ($Email -ne "" -and $Output -ne "" ) {
Write-Host "Please check usage. You can either provide email address or file name, not both" -ForegroundColor Red
} elseif ($Email -ne "") {
$body = @{'Username'=[string] $Email}
$vc = Invoke-RestMethod -Method 'POST' -Uri $url -Body ($body|ConvertTo-Json) -ContentType 'application/json' | Select-Object -ExpandProperty "IfExistsResult"
if ($vc -eq 1) {
Write-Host "[-]" $Email "is Invalid" -ForegroundColor Red
}else {
Write-Host "[+]" $Email "is Valid" -ForegroundColor DarkGreen
}
} elseif ($File -ne "" -and $Output -eq ""){
Foreach ($mail in Get-Content $File)
{
$body = @{'Username'=[string] $mail}
$vc = Invoke-RestMethod -Method 'POST' -Uri $url -Body ($body|ConvertTo-Json) -ContentType 'application/json' | Select-Object -ExpandProperty "IfExistsResult"
if ($vc -eq 1) {
Write-Host "[-]" $mail "is Invalid" -ForegroundColor Red
} else {
Write-Host "[+]" $mail "is Valid" -ForegroundColor DarkGreen
}
}
} elseif ($File -ne "" -and $Output -ne ""){
Foreach ($mail in Get-Content $File)
{
$body = @{'Username'=[string] $mail}
$vc = Invoke-RestMethod -Method 'POST' -Uri $url -Body ($body|ConvertTo-Json) -ContentType 'application/json' | Select-Object -ExpandProperty "IfExistsResult"
if ($vc -eq 1) {
$data = "$mail is Invalid"
Add-Content -Path $Output -Value $data
Write-Host $mail "is Invalid" -ForegroundColor Red
} else {
$data = "$mail is Valid"
Add-Content -Path $Output -Value $data
Write-Host $mail "is Valid" -ForegroundColor DarkGreen
}
}
} else {
Write-Host "Please use get-help test -Examples"
}
}