-
Notifications
You must be signed in to change notification settings - Fork 60
/
pushover.cna
229 lines (151 loc) · 5.47 KB
/
pushover.cna
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
# This script adds basic pushover functionality to Cobalt Strike
# Ensure that you configure the pushover users in pushover-cs, ensure it is executeable
# @Und3rf10w
# Modded by @vysecurity
$location = "https://<DOMAIN NAME>";
$uri = "/URI";
$token = "<PUSHOVER TOKEN>";
$user = "<PUSHOVER USER>";
import java.net.URLEncoder;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
sub sendpost{
$url = $2;
$body = $3 . "\r\n";
$USER_AGENT = "Mozilla/5.0";
$urlobj = [new URL: $url];
$con = [$urlobj openConnection];
[$con setRequestProperty: "User-Agent", $USER_AGENT];
[$con setRequestMethod: "POST"];
[$con setDoOutput: false];
[$con setRequestMethod: $method];
[$con setDoOutput: true];
[$con connect];
$wr = [new DataOutputStream: [$con getOutputStream]];
[$wr writeBytes: $body];
[$wr flush];
[$wr close];
$responseCode = [$con getResponseCode];
$in = [new BufferedReader: [new InputStreamReader: [$con getInputStream]]];
$inputLine = "";
$response = "";
$inputLine = [$in readLine];
$response = $response . $inputLine . "\r\n";
while ($inputLine ne ""){
$inputLine = [$in readLine];
$response = $response . $inputLine . "\r\n";
}
[$in close];
#elog($method . ": " . $url . ": " . $responseCode);
#elog($response);
return $response;
}
sub sendget{
$method = $1;
$url = $2;
$USER_AGENT = "Mozilla/5.0";
$urlobj = [new URL: $url];
$con = [$urlobj openConnection];
[$con setRequestProperty: "User-Agent", $USER_AGENT];
[$con setRequestMethod: "GET"];
$responseCode = [$con getResponseCode];
$in = [new BufferedReader: [new InputStreamReader: [$con getInputStream]]];
$inputLine = "";
$response = "";
$inputLine = [$in readLine];
$response = $response . $inputLine . "\r\n";
while ($inputLine ne ""){
$inputLine = [$in readLine];
$response = $response . $inputLine . "\r\n";
}
[$in close];
#elog($method . ": " . $url . ": " . $responseCode);
#elog($response);
return $response;
}
on ready {
elog("Pushover notifications are now configured");
}
#on event_notify {
# $time = formatDate($2, "yyyy.MM.dd 'at' HH:mm:ss z");
# pushover("CS:System_Event","$time $+ : $1");
#}
on event_join {
$time = formatDate($2, "yyyy.MM.dd 'at' HH:mm:ss z");
pushover("CS:User_Joined","$time $+ : $1 has joined");
}
on event_action {
$time = formatDate($2, "yyyy.MM.dd 'at' HH:mm:ss z");
pushover("CS:Action_Performed","$time $+ : < $+ $3 $+ >: $1 ");
}
on event_public {
$time = formatDate($3, "yyyy.MM.dd 'at' HH:mm:ss z");
pushover("CS:New_Message","$time $+ : < $+ $1 $+ >: $2 ");
}
on event_quit {
$time = formatDate($2, "yyyy.MM.dd 'at' HH:mm:ss z");
pushover("CS:User_Left","$time $+ : $1 has quit");
}
on ssh_initial {
pushover("CS:New_SSH", "New SSH Session Received - ID: $1 | Hostname " . binfo($1, "computer"));
}
on profiler_hit {
pushover("CS:Profiler_Hit","Profiler Hit Received - External: $1 | Internal: $2 | UA: $3 | Email: " . tokenToEmail($5));
}
on web_hit {
# elog($1);
if ($1 == "POST" && $5 == "404 Not Found"){
$time = formatDate($9, "yyyy.MM.dd 'at' HH:mm:ss z");
$vuri = $2;
$eval = strrep($vuri, $uri, "");
# eval contains final bid number to exit
bexit($eval);
}
}
on beacon_initial {
if (-isadmin $1){
pushover2("CS:New_Beacon","New Beacon Received - ID: $1 | User: " . binfo($1, "user") . " | Hostname: " . binfo($1, "computer") . " | PID: " . binfo($1,"pid") . " | HOST: " . binfo($1,"host") . " | ADMIN BEACON", $1);
$elog = "New Beacon Received - ID: $1 | User: " . binfo($1, "user") . " | Hostname: " . binfo($1, "computer") . " | PID: " . binfo($1,"pid") . " | HOST: " . binfo($1,"host") . " | ADMIN BEACON";
}
else {
pushover2("CS:New_Beacon","New Beacon Received - ID: $1 | User: " . binfo($1, "user") . " | Hostname: " . binfo($1, "computer") . " | PID: " . binfo($1,"pid") . " | HOST: " . binfo($1,"host"), $1);
$elog = "New Beacon Received - ID: $1 | User: " . binfo($1, "user") . " | Hostname: " . binfo($1, "computer") . " | PID: " . binfo($1,"pid") . " | HOST: " . binfo($1,"host");
}
elog("\x039".$elog);
$org = getorg(binfo($1, "external"));
bnote($1, $org);
}
sub pushover {
$title = $1;
$message = $2;
$body = "token=" . $token . "&user=" . $user . "&title=" . $title . "&message=" . $message;
# elog($body);
sendpost("https://api.pushover.net/1/messages.json", $body);
}
sub pushover2 {
$title = $1;
$message = $2;
$b = $3;
$body = "callback=" . $location . $uri . $b . "&priority=2&retry=10800&expire=10800&token=" . $token . "&user=" . $user . "&title=" . $title . "&message=" . $message;
elog($body);
sendpost("https://api.pushover.net/1/messages.json", $body);
}
sub getorg{
$ip = $1;
$url = "http://api.hackertarget.com/aslookup/?q=" . $ip;
$res = sendget("GET", $url);
elog("RES: ". $res);
($ip, $asn, $range, $org) = split(',', $res);
$ip = strrep($ip, "\"", "");
$asn = strrep($asn, "\"", "");
$range = strrep($range, "\"", "");
$org = strrep($org, "\"", "");
elog("IP: " . $ip);
elog("ASN: " . $asn);
elog("RANGE: " . $range);
elog("ORG: " . $org);
return $org;
}