Skip to content

Commit

Permalink
feat: 配置内容加密
Browse files Browse the repository at this point in the history
1. 修改手机号和userid加密保存
2. 新增手机号隐私展示、账号截止日期
  • Loading branch information
397179459 committed Aug 19, 2023
1 parent 9f0e3bf commit ed150a0
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 27 deletions.
35 changes: 26 additions & 9 deletions login.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import config as cf
import process
import privateCrypt

config = configparser.ConfigParser() # 类实例化

Expand Down Expand Up @@ -48,6 +49,8 @@ def get_location():

if __name__ == '__main__':

aes_key = privateCrypt.get_aes_key()

while 1:
process.init_headers()
location_select: dict = get_location()
Expand All @@ -59,16 +62,30 @@ def get_location():
process.get_vcode(mobile)
code = input(f"输入 [{mobile}] 验证码[1234]:").strip()
token, userId = process.login(mobile, code)
if mobile not in sections:
config.add_section(mobile) # 首先添加一个新的section

config.set(mobile, 'province', str(province))
config.set(mobile, 'city', str(city))
config.set(mobile, 'token', str(token))
config.set(mobile, 'userId', str(userId))
config.set(mobile, 'lat', location.split(',')[1])
config.set(mobile, 'lng', location.split(',')[0])

endDate = input(f"输入 [{mobile}] 截止日期(必须是YYYYMMDD,20230819),如果不设置截止,请输入9:").strip()

# 为了增加辨识度,这里做了隐私处理,不参与任何业务逻辑
hide_mobile = mobile.replace(mobile[3:7], '****')
# 因为加密了手机号和Userid,所以token就不做加密了
encrypt_mobile = privateCrypt.encrypt_aes_ebc(mobile, aes_key)
encrypt_userid = privateCrypt.encrypt_aes_ebc(str(userId), aes_key)

if encrypt_mobile not in sections:
config.add_section(encrypt_mobile) # 首先添加一个新的section

config.set(encrypt_mobile, 'hidemobile', hide_mobile)
config.set(encrypt_mobile, 'enddate', endDate)
config.set(encrypt_mobile, 'userid', encrypt_userid)
config.set(encrypt_mobile, 'province', str(province))
config.set(encrypt_mobile, 'city', str(city))
config.set(encrypt_mobile, 'token', str(token))

config.set(encrypt_mobile, 'lat', location.split(',')[1])
config.set(encrypt_mobile, 'lng', location.split(',')[0])

config.write(open(path, 'w+', encoding="utf-8")) # 保存数据

condition = input(f"是否继续添加账号[y/n]:").strip()

if condition.lower() == 'n':
Expand Down
23 changes: 18 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import datetime
import logging
import sys

import config
import login
import process
import privateCrypt

DATE_FORMAT = "%m/%d/%Y %H:%M:%S %p"
TODAY = datetime.date.today().strftime("%Y%m%d")
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(filename)s : %(levelname)s %(message)s', # 定义输出log的格式
stream=sys.stdout,
datefmt=DATE_FORMAT)

print("====== MainStartRun =======")
print(r'''
**************************************
欢迎使用i茅台自动预约工具
作者GitHub:https://github.com/397179459
vx:L397179459 加好友注明来意
**************************************
''')

process.get_current_session_id()

Expand All @@ -21,17 +30,21 @@
logging.error("配置文件未找到配置")
sys.exit(1)

aes_key = privateCrypt.get_aes_key()

s_title = '茅台预约成功'
s_content = ""

for section in configs.sections():
mobile = section
if (configs.get(section, 'enddate') != 9) and (TODAY > configs.get(section, 'enddate')):
continue
mobile = privateCrypt.decrypt_aes_ebc(section, aes_key)
province = configs.get(section, 'province')
city = configs.get(section, 'city')
token = configs.get(section, 'token')
userId = configs.get(section, 'userid')
lat = configs.get(mobile, 'lat')
lng = configs.get(mobile, 'lng')
userId = privateCrypt.decrypt_aes_ebc(configs.get(section, 'userid'), aes_key)
lat = configs.get(section, 'lat')
lng = configs.get(section, 'lng')

p_c_map, source_data = process.get_map(lat=lat, lng=lng)

Expand Down
41 changes: 28 additions & 13 deletions myConfig/credentials
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
[13253333857]
province = 广东省
city = 东莞市
token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJtdCIsImV4cCI6MTY5NDA5MjczMCwidXNlcklkIjoxMTE2OTI3NjM0LCJkZXZpY2VJZCI6IjJGMjA3NUQwLUI2NkMtNDI4Ny1BOTAzLURCRkY2MzU4MzQyQSIsImlhdCI6MTY5MTUwMDczMH0.L-S3DPGfU-Psn2fHay2s3OYJI_uIrXvIqxRFMEMY8qc
userid = 1116927634
lat = 22.789864
lng = 113.790764

[13313365975]
[uWR4tJYwwGVeVsmJj9R14g==]
hidemobile = 133****5975
enddate = 9
userid = W96eIlsWXyCd6ublmyJ9EA==
province = 浙江省
city = 杭州市
token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJtdCIsImV4cCI6MTY5MzU1NDY5MywidXNlcklkIjoxMDY1MzY5Mjc0LCJkZXZpY2VJZCI6IjJGMjA3NUQwLUI2NkMtNDI4Ny1BOTAzLURCRkY2MzU4MzQyQSIsImlhdCI6MTY5MDk2MjY5M30.uTxXmMCuiow-UwHJefwiohwX3Vi1y3Ev5OQk98wYSY8
userid = 1065369274
token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJtdCIsImV4cCI6MTY5NTAzNTAyOSwidXNlcklkIjoxMDY1MzY5Mjc0LCJkZXZpY2VJZCI6IjJGMjA3NUQwLUI2NkMtNDI4Ny1BOTAzLURCRkY2MzU4MzQyQSIsImlhdCI6MTY5MjQ0MzAyOX0.Vj8BBPxQVsV9F76C2cqu1Fc9y8_a8HqFZBIzZNauJto
lat = 29.832377
lng = 119.737102

[18905692497]
[jFBvOaeHYivLlO74LP9NVg==]
hidemobile = 189****2497
enddate = 9
userid = wPyBsPLCEGHWLpMIjGt+gQ==
province = 浙江省
city = 杭州市
token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJtdCIsImV4cCI6MTY5MzU2NDA5NSwidXNlcklkIjoxMTI2Nzk0MTU0LCJkZXZpY2VJZCI6IjJGMjA3NUQwLUI2NkMtNDI4Ny1BOTAzLURCRkY2MzU4MzQyQSIsImlhdCI6MTY5MDk3MjA5NX0.PYhHZcwCxCh42MIx-SM-UO9zv5kGjr8Pc8jwBkX8_y4
userid = 1126794154
lat = 29.832377
lng = 119.737102

[zeNrM04yy9L+BfmqCLvRyw==]
hidemobile = 132****3857
enddate = 20230912
userid = 8umoKGQjcrrOHvptuY3vsw==
province = 广东省
city = 东莞市
token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJtdCIsImV4cCI6MTY5NDA5MjczMCwidXNlcklkIjoxMTE2OTI3NjM0LCJkZXZpY2VJZCI6IjJGMjA3NUQwLUI2NkMtNDI4Ny1BOTAzLURCRkY2MzU4MzQyQSIsImlhdCI6MTY5MTUwMDczMH0.L-S3DPGfU-Psn2fHay2s3OYJI_uIrXvIqxRFMEMY8qc
lat = 22.789864
lng = 113.790764

[ocI3HatJ83n9d2GA4KQKPw==]
hidemobile = 156****4670
enddate = 20231120
userid = F4SFqJZwSkm7lw8OTAwYAQ==
province = 山东省
city = 青岛市
token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJtdCIsImV4cCI6MTY5NTAyMDUyOCwidXNlcklkIjoxMTI1NTAzOTc2LCJkZXZpY2VJZCI6IjJGMjA3NUQwLUI2NkMtNDI4Ny1BOTAzLURCRkY2MzU4MzQyQSIsImlhdCI6MTY5MjQyODUyOH0.AzKWqDOleqqfw6z7FpJzXNp7z1JKzapexHzGaG1p4sQ
lat = 36.002998
lng = 120.147705

0 comments on commit ed150a0

Please sign in to comment.