Last active
September 26, 2015 15:17
-
-
Save rkulla/1117307 to your computer and use it in GitHub Desktop.
Joe account Scanner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# joescan.py -By Ryan Kulla | |
# I wrote this in ~1999 as one of my first python programs | |
# 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment