Browse Source

Upload files to ''

Jose E. Rodriguez 4 years ago
parent
commit
6008c24ec3
3 changed files with 82 additions and 0 deletions
  1. 18
    0
      login.py
  2. 44
    0
      notify.py
  3. 20
    0
      notifyweb.py

+ 18
- 0
login.py View File

@@ -0,0 +1,18 @@
1
+import requests
2
+from bs4 import BeautifulSoup
3
+s= requests.Session()
4
+r=s.get('http://localhost/moodle/login/index.php')
5
+soup = BeautifulSoup(r.text, 'html.parser')
6
+logintoken = soup.find('input', {"name": "logintoken"} )['value']
7
+login_data= {'logintoken':logintoken,'username':'dummy1' ,'password': 'Dummy@123'}
8
+s.post('http://localhost/moodle/login/index.php', login_data)
9
+url = 'http://localhost/moodle/pluginfile.php/37/mod_resource/content/1/silabo-de-lengua-i-1-728.jpg'
10
+r= s.get(url)
11
+with open('something.jpg', 'wb') as f:
12
+	f.write(r.content)
13
+url='http://localhost/moodle/pluginfile.php/38/mod_resource/content/1/Greetings.pdf'
14
+r= s.get(url)
15
+with open('espanol.pdf', 'wb') as f:
16
+        f.write(r.content)
17
+
18
+requests.Session().close()

+ 44
- 0
notify.py View File

@@ -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()

+ 20
- 0
notifyweb.py View File

@@ -0,0 +1,20 @@
1
+
2
+import smtplib, ssl
3
+import requests
4
+from bs4 import BeautifulSoup
5
+email="josedeception00@gmail.com"
6
+port = 465  
7
+password = "honeypot2020"
8
+s= requests.Session()
9
+r=s.get('http://localhost/moodle/login/index.php')
10
+soup = BeautifulSoup(r.text, 'html.parser')
11
+logintoken = soup.find('input', {"name": "logintoken"} )['value']
12
+login_data= {'logintoken':logintoken,'username':'dummy1' ,'password': 'Dummy@123'}
13
+s.post('http://localhost/moodle/login/index.php', login_data)
14
+url = 'http://localhost/moodle/user/profile.php?id=5'
15
+r= s.get(url)
16
+soup = BeautifulSoup(r.text, 'html.parser')
17
+time=soup.find_all('dd')
18
+time=time[3]
19
+print(time)
20
+requests.Session().close()