-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathalert_beacon.py
More file actions
25 lines (21 loc) · 938 Bytes
/
alert_beacon.py
File metadata and controls
25 lines (21 loc) · 938 Bytes
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
import yaml,requests,argparse
parser = argparse.ArgumentParser(description="Sends a pushover alert on a new beacon")
parser.add_argument('--host')
parser.add_argument('--ip')
parser.add_argument('--os')
parser.add_argument('--version')
args = parser.parse_args()
try:
conf = yaml.safe_load(open('config.yaml'))
except IOError as e:
print(dir(e))
quit("Error opening config file. Does it exist?")
for usertoken in conf['usertokens'].keys():
headers = {'Content-Type' : 'application/x-www-form-urlencoded'}
payload = {'token' : conf['apptoken']}
payload.update({'user' : usertoken})
payload.update({'title' : 'New beacon reporting in!'})
payload.update({'sound' : 'cashregister'})
payload.update({'priority' : '1'})
payload.update({'message' : 'Hostname %s | Internal IP: %s | OS: %s %s ' % (args.host, args.ip, args.os, args.version)})
r = requests.post('https://api.pushover.net/1/messages', headers=headers, data=payload)