forked from fportantier/vulpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibuser.py
61 lines (38 loc) · 1.36 KB
/
libuser.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
54
55
56
57
58
59
60
import sqlite3
import libuser
def login(username, password):
conn = sqlite3.connect('db_users.sqlite')
conn.set_trace_callback(print)
conn.row_factory = sqlite3.Row
c = conn.cursor()
user = c.execute("SELECT * FROM users WHERE username = '{}' and password = '{}'".format(username, password)).fetchone()
if user:
return user['username']
else:
return False
def create(username, password):
conn = sqlite3.connect('db_users.sqlite')
c = conn.cursor()
c.execute("INSERT INTO users (username, password, failures, mfa_enabled, mfa_secret) VALUES ('%s', '%s', '%d', '%d', '%s')" %(username, password, 0, 0, ''))
conn.commit()
conn.close()
def userlist():
conn = sqlite3.connect('db_users.sqlite')
conn.set_trace_callback(print)
conn.row_factory = sqlite3.Row
c = conn.cursor()
users = c.execute("SELECT * FROM users").fetchall()
if not users:
return []
else:
return [ user['username'] for user in users ]
def password_change(username, password):
conn = sqlite3.connect('db_users.sqlite')
conn.set_trace_callback(print)
conn.row_factory = sqlite3.Row
c = conn.cursor()
c.execute("UPDATE users SET password = '{}' WHERE username = '{}'".format(password, username))
conn.commit()
return True
def password_complexity(password):
return True