Advertisement
geval0r

ListStripper

Mar 9th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.46 KB | None | 0 0
  1. import os.path, time
  2.  
  3. #WORKING WITH THE FILE
  4.  
  5. filepath = raw_input('Path to file: ') # /root/Documents/file.txt
  6. ifexist = os.path.isfile(filepath)
  7. doesExist = 0 if ifexist == False else 1
  8.  
  9. #if file doesnt exist: try again;
  10. while doesExist == 0:
  11.     print "\033[1;31mFile " + filepath + " does not exist. \033[1;m"
  12.     print "\n"
  13.     filepath = raw_input('Path to file: ')
  14.     if os.path.isfile(filepath) == True:
  15.         doesExist = 1
  16.     if filepath == 'exit':
  17.         quit()
  18.  
  19. #open the file................
  20. textfile = open(filepath, 'r')
  21. opened = textfile.read()
  22. opened = opened.replace(' ', '')
  23.  
  24. #WORKING WITH THE STRING FROM THE FILE
  25. row = opened.split('\n')
  26. row = filter(None, row)
  27. passes = []
  28.  
  29. #ASKING FOR THE DELIMITER
  30. rowCount = len(row)
  31. rowShow = rowCount / 2
  32. print
  33. print "\033[1;32mResult:\033[1;m " + row[rowShow] + "\n"
  34. delimiter = raw_input('What is the delimiter? ')
  35. delimitersAllowed = [':',';','|','/','\\',',','.','>','<','-','=']
  36.  
  37. if delimiter in delimitersAllowed:
  38.     allowed = 1
  39. else:
  40.     print "\033[1;31mDelimiter is not allowed"
  41.     print 'Delimiters Allowed: \033[1;m', ' '.join(map(str, delimitersAllowed))
  42.     allowed = 0
  43.  
  44.     while allowed == 0:
  45.         delimiter = raw_input('What is the delimiter? ')
  46.         if delimiter in delimitersAllowed:
  47.             allowed = 1
  48.  
  49. rowCols = row[rowShow].split(delimiter)
  50.  
  51. for i in enumerate(rowCols):
  52.     print i
  53.  
  54. password = raw_input('Where is the password? ')
  55. password = int(password)
  56.  
  57. # END OF OPTIONS
  58.  
  59. print "\nProcessing your document: " + filepath + "...........\n"
  60. time.sleep(1)
  61.  
  62.  
  63.  
  64. for i in enumerate(row):
  65.     #print i
  66.     col = i[1].split(delimiter)
  67.     #column = col[password]
  68.     try:
  69.         column = col[password]
  70.     except NameError:
  71.         column = "Error"
  72.  
  73.     passes.append(column)
  74.  
  75. passes = set(passes)
  76. passes = sorted(passes)
  77. passlength = len(passes)
  78.  
  79. path = 'generated_files/'
  80. filename = path + 'generated_' + str(passlength) + '.txt'
  81. f = open(filename, 'w+')
  82.  
  83. for i in enumerate(passes):
  84.     out = i[1]
  85.     f.write(out + '\n')
  86.     print out
  87.     time.sleep(0.000001)
  88.  
  89. duplicates = len(row) - passlength
  90.  
  91. print "\n"
  92. print "\033[1;32m" + str(len(row)) + '\033[1;m passwords in list'
  93. print "\033[1;30m" + str(duplicates) + '\033[1;m duplicates removed.'
  94. print "\033[1;32m" + str(passlength) + '\033[1;m passwords listed'
  95. print "List is saved in /generated_lists"
  96. print "wherever you decided for us to be.."
  97. print "Goodbye"
  98. print "\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement