-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
36 lines (32 loc) · 1.36 KB
/
client.py
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
import psutil
from time import time
from Crypto.Cipher import AES
from base64 import b64encode
memory = str(psutil.virtual_memory().percent)
cpu = str(psutil.cpu_percent())
uptime = str(time() - psutil.boot_time())
result = "\n" .join([memory, cpu, uptime])
if psutil.WINDOWS:
import win32evtlog # requires pywin32 pre-installed
server = 'localhost'
logtype = 'Security'
hand = win32evtlog.OpenEventLog(server, logtype)
backwards_read = win32evtlog.EVENTLOG_BACKWARDS_READ
sequential_read = win32evtlog.EVENTLOG_SEQUENTIAL_READ
flags = backwards_read | sequential_read
total = win32evtlog.GetNumberOfEventLogRecords(hand)
events = win32evtlog.ReadEventLog(hand, flags, 0)
if events:
formatedEvents = ''
for event in events:
formatedEvents += 'Event Category: ' + str(event.EventCategory)
formatedEvents += '\nTime Generated: ' + str(event.TimeGenerated)
formatedEvents += '\nSource Name: ' + event.SourceName
formatedEvents += '\nEvent ID: ' + str(event.EventID)
formatedEvents += '\nEvent Type:' + str(event.EventType) + '\n'
result += "\n" + str(formatedEvents)
crypter = AES.new('32byte SecretKey used forencrypt',
AES.MODE_CFB, 'IVfor encryption')
ciphertext = crypter.encrypt(result)
ciphertext = b64encode(ciphertext)
print(ciphertext)