|
@@ -0,0 +1,44 @@
|
|
1
|
+from datetime import datetime
|
|
2
|
+import time
|
|
3
|
+import MySQLdb
|
|
4
|
+import smtplib, ssl
|
|
5
|
+email="josedeception00@gmail.com"
|
|
6
|
+port = 465 # For SSL
|
|
7
|
+password = "honeypot2020"
|
|
8
|
+
|
|
9
|
+#
|
|
10
|
+context = ssl.create_default_context()
|
|
11
|
+
|
|
12
|
+db = MySQLdb.connect(host='localhost', user = "root",passwd= 'root', db="moodle")
|
|
13
|
+cursor=db.cursor()
|
|
14
|
+notify=cursor.execute("SELECT username FROM mdl_user, mdl_logstore_standard_log where mdl_user.id = mdl_logstore_standard_log.USERID and username='dummy1' ")
|
|
15
|
+user=cursor.fetchone()
|
|
16
|
+
|
|
17
|
+cursor.execute("SELECT timecreated FROM mdl_logstore_standard_log WHERE USERID = '3' ORDER BY timecreated DESC LIMIT 1,1 ")
|
|
18
|
+newtime = cursor.fetchone()
|
|
19
|
+newtime=(newtime[0])
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+f=open("time.txt","r+")
|
|
23
|
+oldtime=f.readline()
|
|
24
|
+oldtime=int(oldtime)
|
|
25
|
+time=datetime.utcfromtimestamp(newtime).strftime('%m-%d-%Y %H-%M-%S')
|
|
26
|
+message=f"""\
|
|
27
|
+Subject:decoy {time}
|
|
28
|
+To:{email}
|
|
29
|
+From:{email}
|
|
30
|
+{user[0]} logged in {time} """
|
|
31
|
+
|
|
32
|
+if oldtime < newtime:
|
|
33
|
+ with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server:
|
|
34
|
+ server.login(email, password)
|
|
35
|
+ server.sendmail(email ,email, message)
|
|
36
|
+ print(user[0], " logged in ", time)
|
|
37
|
+ f.seek(0)
|
|
38
|
+ f.write(str(newtime))
|
|
39
|
+else:
|
|
40
|
+ print( False)
|
|
41
|
+
|
|
42
|
+cursor.close()
|
|
43
|
+db.close()
|
|
44
|
+f.close()
|