-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpass
More file actions
executable file
·50 lines (43 loc) · 1.2 KB
/
pass
File metadata and controls
executable file
·50 lines (43 loc) · 1.2 KB
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
#!/usr/bin/python
# Simple password salting/hashing/authenticating.
import getpass, hashlib, uuid
found = 1
userfound = False
while found < 4:
F = open('passwords','a+')
data = F.read().splitlines()
USER = raw_input("Username: ")
PASSWORD = getpass.getpass("Password: ")
foundpass = ""
foundsalt = ""
salt = uuid.uuid4().hex
stored_hash=hashlib.md5(PASSWORD + foundsalt).hexdigest()
hashed_password=hashlib.md5(PASSWORD + str(salt)).hexdigest()
hashed_nosalt = hashlib.md5(PASSWORD).hexdigest()
for line in data:
names = line.split(':')
if USER == names[0]:
userfound=True
foundpass=names[1]
foundsalt=names[2]
stored_hash=hashlib.md5(PASSWORD + foundsalt).hexdigest()
if not userfound:
F.write('\n')
F.write(str(USER))
F.write(str(":"))
F.write(str(hashed_password))
F.write(str(":"))
F.write(str(salt))
print "New user added!"
else:
if stored_hash == foundpass:
found=5
print " _____________________"
print "| |"
print " Welcome, ", USER
print "|_____________________|"
else:
found=found+1
print "Incorrect. Try again:"
if found == 4:
print "Too many failed attempts. Goodbye."