Advertisement
burn3rs

Untitled

Jan 7th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.28 KB | None | 0 0
  1. import os, random, re, string, time
  2. from multiprocessing.dummy import Pool as ThreadPool
  3. def clear():
  4.     from sys import platform
  5.     if platform == "linux" or platform == "linux2":
  6.         os.system('clear')
  7.     elif platform == "darwin":
  8.         os.system('clear')
  9.     elif platform == "win32":
  10.         os.system('cls')
  11. clear()
  12. digits = string.digits
  13. lowercase = string.ascii_lowercase
  14. digitlowercase = digits + lowercase
  15. uppercase = string.ascii_uppercase
  16. digituppercase = digits + uppercase
  17. upperlower = string.ascii_letters
  18. any = digits + upperlower
  19. extractPattern = re.compile(r"\[(.*?)\]")
  20. print("Pattern samples:")
  21. print("[0-9] - any digit")
  22. print("[a-z] - any lowercase character")
  23. print("[0-z] - any digit or lowercase character")
  24. print("[A-Z] - any uppercase character")
  25. print("[0-Z] - any digit or uppercase character")
  26. print("[a-Z] - any upper- or lowercase character")
  27. print("[0-zA-Z] - any digit, upper- or lowercase character")
  28. print("Use `|` as a delimiter, example: `LEQ|0-Z|0-Z|0-9|0-9|0-9|0-9|0-9|0-9`\r\n")
  29. pattern = input("How would you like your pattern, hun?\r\n")
  30. pattern = pattern.split('|')
  31. def generatePatterns(x):
  32.     finalpattern = ""
  33.     for kek in pattern:
  34.         if "0-9" == kek:
  35.             finalpattern += random.choice(digits)
  36.         elif "a-z" == kek:
  37.             finalpattern += random.choice(lowercase)
  38.         elif "0-z" == kek:
  39.             finalpattern += random.choice(digitlowercase)
  40.         elif "A-Z" == kek:
  41.             finalpattern += random.choice(uppercase)
  42.         elif "0-Z" == kek:
  43.             finalpattern += random.choice(digituppercase)
  44.         elif "a-Z" == kek:
  45.             finalpattern += random.choice(upperlower)
  46.         elif "0-zA-Z" == kek:
  47.             finalpattern += random.choice(any)
  48.         else:
  49.             finalpattern += kek
  50.     print(f"[{finalpattern}] - Generated")
  51.     with open("generated.txt","a+") as gen:
  52.         gen.write(finalpattern + "\n")
  53. clear()
  54. amount = int(input("How many do you want to generate?\r\n"))
  55. thread_count = int(input("How many threads do you want to run?\r\n"))
  56. start = time.time()
  57. pool = ThreadPool(thread_count)
  58. pool.map(generatePatterns, range(amount))
  59. pool.close()
  60. pool.join()
  61. ended = time.time()
  62. elapsed = ended - start
  63. input(f"Can I have a taco? {elapsed}\r\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement