![]() |
|
Generate possible usernames - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Python (https://sinister.ly/Forum-Python) +--- Thread: Generate possible usernames (/Thread-Generate-possible-usernames) |
Generate possible usernames - shp0ngl3 - 05-24-2013 When attacking an account, especially when dealing with companies, the usersnames often is a combination of first and last name. Here's a script that will generate, to my knowledge, some of the most combinations. You can either provide a single name of a file with one name per line Syntax: ./genuname.py [option] [filename|name] Code: #!/usr/bin/python
import sys
def makeUsernames(names):
result = []
for name in names:
name = name.replace("\n", '')
name = name.lower()
parts = name.split(' ')
fname = parts[0]
if len(parts) > 1:
lname = parts[len(parts) - 1]
result.append(fname + lname)
result.append(lname + fname)
result.append(fname[0] + lname)
result.append(fname + lname[0])
result.append(lname[0] + fname)
result.append(lname + fname[0])
result.append(fname + '.' + lname)
result.append(lname + '.' + fname)
result.append(fname[0] + '.' + lname)
result.append(lname[0] + '.' + fname)
result.append(fname + '_' + lname)
result.append(lname + '_' + fname)
result.append(fname[0] + '_' + lname)
result.append(lname[0] + '_' + fname)
result.append(fname + '-' + lname)
result.append(lname + '-' + fname)
result.append(fname[0] + '-' + lname)
result.append(lname[0] + '-' + fname)
else:
result.append(fname)
return result
names = []
if len(sys.argv) < 2:
sys.exit('Syntax error: Not enough arguments')
elif sys.argv[1] == '-f':
if len(sys.argv) != 3:
sys.exit('Syntax error: You must supply an existing file')
else:
filename = sys.argv[2]
try:
with open(filename) as f:
names = f.readlines()
except IOError:
sys.exit('IOError: No such file or directory')
else:
names = [' '.join(sys.argv[1:])]
if len(names) > 0:
result = makeUsernames(names)
for name in result:
print name
else:
sys.exit('Unable to generate data')Usage Single name: Code: ./genuname.py Jane Doe
janedoe
doejane
jdoe
janed
djane
doej
jane.doe
doe.jane
j.doe
d.jane
jane_doeName list (John Doe & Eric Smith) Code: ./genuname.py -f filename
johndoe
doejohn
jdoe
johnd
djohn
doej
john.doe
doe.john
j.doe
d.john
john_doe
doe_john
j_doe
d_john
john-doe
doe-john
j-doe
d-john
ericsmith
smitheric
esmith
erics
seric
smithe
eric.smith
smith.eric
e.smith
s.eric
eric_smith
smith_eric
e_smith
s_eric
eric-smith
smith-eric
e-smith
s-ericNote: This was my very first Python script
RE: Generate possible usernames - Ergo - 07-01-2013 Interesting script! I haven't really used Python very much in the past unless I'm reading through a local root exploit but I now have to learn it for a qualification in computing. Today I learned: The existence of the append, split, and lower string variable properties. RE: Generate possible usernames - Kinanizer - 07-01-2013 Wow interesting, this is something I could use. Great share. |