Want more features on Pastebin? Sign Up, it's FREE!
Guest

UserListGen.py

By: a guest on Nov 5th, 2012  |  syntax: Python  |  size: 2.86 KB  |  views: 43  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ## Script: UserListGen.py
  2. ## Author: FolieADeux
  3. ## Date: 11/5/2012
  4. ## This script is intended to take a list of names and mutate
  5. ## them into a list of usernames to be used in a bruteforce test.
  6. ## Redistribute and edit as you wish.
  7.  
  8. #!/usr/bin/env python
  9.  
  10. import sys
  11. import os
  12.  
  13. #Handle Arguments
  14. if len(sys.argv) < 3:
  15.     print 'Usage: ' + sys.argv[0] + ' INPUTFILE OUTPUTFILE'
  16.     sys.exit()
  17.  
  18. #Ready file for reading
  19. inLocation = sys.argv[1]
  20. try:
  21.     inFile = open(inLocation, 'r')
  22. except IOError:
  23.     print 'File does not exist'
  24.     sys.exit()
  25.  
  26. #Create name list
  27. inList = []
  28. for each in inFile:
  29.     inList.append(each)
  30.  
  31. #Close inFile
  32. inFile.close()
  33.  
  34. #Create list for usernames
  35. outList = []
  36.  
  37. #Mutate names
  38. for each in inList:
  39.  
  40.     #Divide into first and last names
  41.     whole = each.split()
  42.     fname = whole[0]
  43.     lname = whole[-1]
  44.    
  45.     #Mutation 1
  46.     outList.append(fname + lname)
  47.     outList.append(fname.lower() + lname.lower())
  48.  
  49.     #Mutation 2
  50.     outList.append(lname + fname)
  51.     outList.append(lname.lower() + fname.lower())
  52.  
  53.     #Mutation 3
  54.     outList.append(fname + '.' + lname)
  55.     outList.append(fname.lower() + '.' + lname.lower())
  56.  
  57.     #Mutation 4
  58.     outList.append(lname + '.' + fname)
  59.     outList.append(lname.lower() + '.' + fname.lower())
  60.  
  61.     #Mutation 5
  62.     outList.append(fname[0] + lname)
  63.     outList.append(fname[0].lower() + lname.lower())
  64.  
  65.     #Mutation 6
  66.     outList.append(lname[0] + fname)
  67.     outList.append(lname[0].lower() + fname.lower())
  68.  
  69.     #Mutation 7
  70.     outList.append(fname[0] + '.' + lname)
  71.     outList.append(fname[0].lower() + '.' + lname.lower())
  72.  
  73.     #Mutation 8
  74.     outList.append(lname[0] + '.' + fname)
  75.     outList.append(lname[0].lower() + '.' + fname.lower())
  76.  
  77. #Ready file for output
  78. outLocation = sys.argv[2]
  79. if os.path.isfile(outLocation) == True:
  80.     decision = raw_input('The output file already exists, do you want to delete it? (y/n)')
  81.     if str(decision) == 'y':
  82.         os.remove(outLocation)
  83.         try:
  84.             outFile = open(outLocation, 'w')
  85.         except IOError:
  86.             print 'Unknown error occurred'
  87.             sys.exit()
  88.     elif str(decision) == 'n':
  89.         decision2 = raw_input('Do you want to write to the end of it or abort? (1/2)')
  90.         if str(decision2) == '1':
  91.             try:
  92.                 outFile =  open(outLocation, 'w')
  93.             except IOError:
  94.                 print 'Unknown error occurred'
  95.                 sys.exit()
  96.         elif str(decision2) == '2':
  97.             sys.exit()
  98.         else:
  99.             print 'Please input 1 or 2.'
  100.             sys.exit()
  101.     else:
  102.         print 'Please input y or n'
  103.         sys.exit()
  104. elif os.path.isfile(outLocation) == False:
  105.     try:
  106.         outFile = open(outLocation, 'w')
  107.     except IOError:
  108.         print 'Unknown error occurred'
  109.         sys.exit()
  110.  
  111. #Write mutations to file
  112. for each in outList:
  113.     outFile.write(each + '\n')
  114.  
  115. #Close outFile
  116. outFile.close()
  117.  
  118. #Notify user of completion
  119. print "File generation complete."
clone this paste RAW Paste Data