Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # joescan.py -By Ryan Kulla
- # Scans for user accounts who use their username as their password.
- from crypt import crypt
- from pwd import getpwall, getpwnam
- from getpass import getuser
- PASSWD_FILE = getpwall()
- def get_total_entries():
- total_entries = 0
- for total_entries in range(len(PASSWD_FILE)):
- if PASSWD_FILE[total_entries] == "":
- break
- return total_entries
- def display_start_message(total_entries):
- print 'Scans for "joe" accounts',
- print '(accounts with the same username and password.)'
- raw_input('Hit Enter to scan the [%d] accounts found on this system' % total_entries)
- def check_if_shadowed():
- cryptedpasswd = getpwnam(getuser())[1]
- if cryptedpasswd in ('x', '*'):
- raise NotImplementedError("Currently no support for shadow passwords")
- def scan(total_entries):
- found_joe = False
- i = 0
- while True:
- user = PASSWD_FILE[i][0]
- password = PASSWD_FILE[i][1]
- cryptedpasswd = crypt(user, password)
- if cryptedpasswd == password:
- found_joe = True
- print '\n"%s" is a joe.' % user
- i = i + 1
- if i >= total_entries + 1:
- break
- if not found_joe:
- print "\nNo Joe accounts were found.\n"
- if __name__=='__main__':
- total_entries = get_total_entries()
- display_start_message(total_entries)
- check_if_shadowed()
- scan(total_entries);
Add Comment
Please, Sign In to add comment