Advertisement
BornePlays

.

May 24th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1.  
  2. # LOGIN SYTEM WHICH WORKS WITH FILES
  3.  
  4. import os, base64, time, sys
  5.  
  6.  
  7.  
  8. def intro():
  9. usr = raw_input('[+] Basic Login System [+]\n[1] Create Account\n[2] Login\n[3] View Users \n[4] Exit\n')
  10. if usr==('1'):
  11. createAccount()
  12. elif usr==('2'):
  13. login()
  14. elif usr==('3'):
  15. viewUsers()
  16. elif usr==('4'):
  17. sys.exit
  18.  
  19.  
  20. def createAccount():
  21.  
  22. fob = open('users.txt','w')
  23. fob2 = open('pass.txt','w')
  24.  
  25. username = raw_input('username: ')
  26. pswd = raw_input('password: ') # Add getpass
  27. pswd2 = raw_input('re-enter password: ') # Add password security eg char limtit
  28.  
  29. if pswd==(pswd2):
  30. encodePass = base64.b64encode(pswd) # Add more security
  31. fob.write(username)
  32. fob.close()
  33. fob2.write(encodePass)
  34. fob2.close()
  35. time.sleep(1)
  36. print '[+] Account created [+]\n[+] You can now log on [+]'
  37. login()
  38.  
  39. else:
  40. print '[!] Passwords did not match [!]'
  41. createAccount()
  42. fob.close()
  43.  
  44. def login(usrname):
  45.  
  46. fob3 = open('users.txt','r')
  47. fob4 = open('pass.txt','r')
  48. readLine = fob3.readline()
  49. readLine2 = fob4.readline()
  50. decode = base64.b64decode(readLine2)
  51.  
  52. usrname = raw_input('username: ')
  53.  
  54. if usrname==(readLine):
  55. passw = raw_input('password: ')
  56. if passw ==(decode):
  57. time.sleep(1)
  58. loggedOnUser = usrname
  59. print '[+] You have succesfully logged on [+]'
  60. print '---------------------------------------'
  61. panel()
  62.  
  63. else:
  64. print '[!] Password incorrect [!]'
  65. login()
  66.  
  67. else:
  68. print '[!] Username does not exist [!]'
  69. login()
  70.  
  71. fob3.close()
  72. fob4.close()
  73.  
  74.  
  75. def viewUsers():
  76.  
  77. fob5 = open('users.txt','r')
  78. read = fob5.read()
  79.  
  80. login = raw_input('admin: ')
  81.  
  82. if login==(adminPass):
  83. print '[+] Current users [+]'
  84. print read
  85. else:
  86. print '[!] Password Incorrect [!]'
  87. time.sleep(1)
  88. exit
  89.  
  90.  
  91. def panel():
  92. print('[+] Username: ' + usrname)
  93.  
  94. intro()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement