Use Python to read all emails of Netease Mailbox Master client

1 Introduction

  • Most websites now require you to provide a verification code from your mobile phone or email address when registering. If you just want to register one or two accounts, then you can simply pick up the verification code. But if we want to register dozens of accounts, it means that you need to accept dozens of verification codes, which may be a big disaster. You first have to find this particular email from dozens of emails, click on the inbox on it, and copy the verification code...
  • It may be said that everyone doesn't think there is anything wrong with it, but it is really annoying to humans in actual operation. So I wondered if I could analyze the API on Netease Mailbox Master to directly read the email content or verification code? So there is the following project.

2. Effect

  • You can directly read the local client mail data of Netease Mailbox Master directly through Python code or command line program

3. Inquiry process

  • If you want to read the mail on the NetEase mailbox, you must either call it through the API, or use the local data of the client to reversely obtain it.
  • After some Baidu and some preliminary attempts, we found that NetEase Mailbox does not provide program API interface for users or developers. Does this mean that we want to use programs to read emails in NetEase Mailbox? In fact, this is not the case. Even if there is no upper-level API, we can read the stored data at the bottom (as long as it does not have too difficult encryption), so we have the following attempts

3.1. Locate the locally stored database

  • Then you first need to find the data storage location of NetEase Mailbox Master

  • System settings Here you can see the data storage bit of Netease mailbox

  • After opening the location, there is a series of folders named after the mailbox name

  • But the data inside seems to be an encrypted database file

  • I use Navicat for sqlite to open it and find that I can’t see the specific data inside

  • I changed another db file and read it, and found that the data in it did not seem to be fully encrypted. I can vaguely see that some emails were displayed as garbled characters before, which may be a problem with transcoding.

  • I checked the other two mail and search by myself. I didn’t expect the content of the mail to be directly stored in search/search_content . It seems that today’s exploration should be over.

  • Let's send a new email to see if it can be updated in real time

It may be that the number of mailboxes added by myself is too much, and it has been in the process of sending. After

restarting the NetEase mailbox client, it is normal.

  • Refresh Navicat for sqlite, and then see the data we tested just


    now to prove that our principle works. Then use the following program to realize this process

3.2. Using Python to read the database

3.2.1. Code

#导入sqllite3模块 
import sqlite3 
# 1.硬盘上创建连接 
con = sqlite3.connect('D:\MailMasterData\[email protected]_1414\search.db') 
# 获取cursor对象 
cur = con.cursor() 
# 执行sql创建表 
sql = 'select * from Search_content' 
try: 
    cur.execute(sql) 
    # 获取所有数据 
    person_all = cur.fetchall() 
    # print(person_all) 
    # 遍历 
    for p in person_all: 
        print(p) 
except Exception as e: 
    print(e) 
    print('查询失败') 
finally: 
    # 关闭游标 
    cur.close() 
    # 关闭连接 
    con.close()

4. Explore the results

4.1. Functions

4.1.1. Find the latest email for a specific mailbox

def sqlite3_get_last_data(db_path,sql): 	 找到特定邮箱最后一次的数据
    # 导入sqllite3模块 
    import sqlite3 
    # 1.硬盘上创建连接 
    con = sqlite3.connect(db_path) 
    # 获取cursor对象 
    cur = con.cursor() 
    # 执行sql创建表 
 
    try: 
        cur.execute(sql) 
        # 获取所有数据 
 
        person_all = cur.fetchall() 
        last_data = person_all[-1] 
        # print(last_data) 
        # print("type(last_data):", type(last_data)) 
        # print("last_data:", ) 
        last_text = last_data[6] 
        return last_text 
    except Exception as e: 
        print(e) 
        print('查询失败') 
    finally: 
        # 关闭游标 
        cur.close() 
        # 关闭连接 
        con.close() 
 
 
email_path = '[email protected]' 
db_path = 'D:\MailMasterData\{}_1414\search.db'.format(email_path) 
sql = 'select * from Search_content'

4.1.2. Find the latest verification code for a specific mailbox


the code

def find_spacial_email_last_Verification_Code(email):        #找到特定邮箱最后一次的验证码 
    def sqlite3_get_last_data(db_path, sql): 
        # 导入sqllite3模块 
        import sqlite3 
        # 1.硬盘上创建连接 
        con = sqlite3.connect(db_path) 
        # 获取cursor对象 
        cur = con.cursor() 
        # 执行sql创建表 
 
        try: 
            cur.execute(sql) 
            # 获取所有数据 
 
            person_all = cur.fetchall() 
            last_data = person_all[-1] 
            # print(last_data) 
            # print("type(last_data):", type(last_data)) 
            # print("last_data:", ) 
            last_text = last_data[6] 
            return last_text 
        except Exception as e: 
            print(e) 
            print('查询失败') 
        finally: 
            # 关闭游标 
            cur.close() 
            # 关闭连接 
            con.close() 
 
    def find_continuous_data(string):  # 查找字符串中连续的数字 
        import re 
        result = re.findall(r"\d{4,6}", string) 
        return result 
    def find_str_in_list_full_string(list_str, find_str):  # 查找字符串列表中包含某一个字符的完整字符 
        for index, str in enumerate(list_str): 
            if find_str in str: 
                break 
        return str 
    import os 
    mailbox_rootpath = 'D:\MailMasterData' 
    email_name_list = os.listdir(mailbox_rootpath) 
    email_dir_name = find_str_in_list_full_string(email_name_list, email) 
 
    db_path = '{}\{}\search.db'.format(mailbox_rootpath,email_dir_name) 
    sql = 'select * from Search_content' 
 
    last_text = sqlite3_get_last_data(db_path, sql) 
    print("last_text:", last_text) 
 
    result = find_continuous_data(last_text) 
    if (len(result) == 1): 
        print('找到了验证码') 
        print(result[0]) 
        pass 
 
    else: 
        from winsound import Beep 
        Beep(600, 1000) 
 
 
email = '[email protected]' 
find_spacial_email_last_Verification_Code(email)

4.1.3. Call the Python code through the command line to find the latest verification code for a specific mailbox

the code

def find_spacial_email_last_Verification_Code(email):        #找到特定邮箱最后一次的验证码 
    def sqlite3_get_last_data(db_path, sql):        #找到特定邮箱最后一次的数据 
        # 导入sqllite3模块 
        import sqlite3 
        # 1.硬盘上创建连接 
        con = sqlite3.connect(db_path) 
        # 获取cursor对象 
        cur = con.cursor() 
        # 执行sql创建表 
 
        try: 
            cur.execute(sql) 
            # 获取所有数据 
 
            person_all = cur.fetchall() 
            last_data = person_all[-1] 
            # print(last_data) 
            # print("type(last_data):", type(last_data)) 
            # print("last_data:", ) 
            last_text = last_data[6] 
            return last_text 
        except Exception as e: 
            print(e) 
            print('查询失败') 
        finally: 
            # 关闭游标 
            cur.close() 
            # 关闭连接 
            con.close() 
 
    def find_continuous_data(string):  # 查找字符串中连续的数字 
        import re 
        result = re.findall(r"\d{4,6}", string) 
        return result 
    def find_str_in_list_full_string(list_str, find_str):  # 查找字符串列表中包含某一个字符的完整字符 
        for index, str in enumerate(list_str): 
            if find_str in str: 
                break 
        return str 
    import os 
    mailbox_rootpath = 'D:\MailMasterData' 
    email_name_list = os.listdir(mailbox_rootpath) 
    email_dir_name = find_str_in_list_full_string(email_name_list, email) 
 
    db_path = '{}\{}\search.db'.format(mailbox_rootpath,email_dir_name) 
    sql = 'select * from Search_content' 
 
    last_text = sqlite3_get_last_data(db_path, sql) 
    # print("last_text:", last_text) 
 
    result = find_continuous_data(last_text) 
    if (len(result) == 1): 
        print('找到了验证码') 
        print(result[0]) 
        pass 
 
    else: 
        from winsound import Beep 
        Beep(600, 1000) 
 
 
 
 
 
import os 
import argparse 
parser = argparse.ArgumentParser(description='命令行传入参数') 
#type是要传入的参数的数据类型  help是该参数的提示信息 
parser.add_argument('--email', type=str, help='传入的邮箱') 
args = parser.parse_args() 
#获得传入的参数 
print(args.email) 
 
 
email = args.email 
find_spacial_email_last_Verification_Code(email)
  • python .\Read the database of a specific mailbox.py --email “[email protected]
    help is the prompt information for this parameter
    parser.add_argument('–email', type=str, help='incoming mailbox')
    args = parser.parse_args()
    #Get the incoming parameters
    print(args.email)

email = args.email
find_spacial_email_last_Verification_Code(email)


 - python .\读取特定邮箱的数据库.py --email "[email protected]"
   ![](https://img-blog.csdnimg.cn/img_convert/e8f955000645d66aa6bf920a5738c8ae.png)

Guess you like

Origin blog.csdn.net/u014723479/article/details/128474022