|
|
@@ -13,6 +13,8 @@ from mitmproxy import flowfilter
|
|
|
from mitmproxy import http
|
|
|
from mitmproxy import ctx
|
|
|
|
|
|
+# from http.cookies import SimpleCookie
|
|
|
+
|
|
|
sys.path.append('../')
|
|
|
import utils.Utils as Utils
|
|
|
sys.path.pop()
|
|
|
@@ -190,7 +192,9 @@ class OfpayHelper:
|
|
|
url = flow.request.url;
|
|
|
path = flow.request.path;
|
|
|
print("###[OfpayHelper]path=%s"%path);
|
|
|
- if path.startswith('/h5/union/api/interactiveIGoChoose/indexConfigRebuild'):
|
|
|
+ if path.startswith('/h5/union/interactiveIGoChoose/index'):
|
|
|
+ self.handle_login(flow);
|
|
|
+ elif path.startswith('/h5/union/api/interactiveIGoChoose/indexConfigRebuild'):
|
|
|
self.handle_activitylist(flow);
|
|
|
elif path.startswith('/h5/union/api/interactiveIGoChoose/orderList'):
|
|
|
self.handle_orderlist(flow);
|
|
|
@@ -223,6 +227,70 @@ class OfpayHelper:
|
|
|
payload['customerInfo'] = customer_info;
|
|
|
return jwt_data;
|
|
|
|
|
|
+ def handle_login(self, flow: http.HTTPFlow):
|
|
|
+ ctx.log.info('###handle_login###');
|
|
|
+ request = flow.request;
|
|
|
+ response = flow.response;
|
|
|
+ jwt_data = self.get_jwt_token_data(flow);
|
|
|
+ if not jwt_data:
|
|
|
+ return;
|
|
|
+ login_params = flow.request.query.get('loginParams');
|
|
|
+ ori_cookies = dict(request.cookies);
|
|
|
+ rsp_cookies = dict(response.cookies);
|
|
|
+ for key in rsp_cookies:
|
|
|
+ ori_cookies[key] = rsp_cookies[key];
|
|
|
+
|
|
|
+ # # 获取所有的Set-Cookie头部
|
|
|
+ # set_cookie_headers = flow.response.headers.get_all("Set-Cookie")
|
|
|
+ # for cookie_header in set_cookie_headers:
|
|
|
+ # cookie = SimpleCookie();
|
|
|
+ # cookie.load(cookie_header);
|
|
|
+ # # SimpleCookie对象可以像字典一样工作
|
|
|
+ # for key, morsel in cookie.items():
|
|
|
+ # # 这里可以添加进一步的逻辑来处理cookie的键和值
|
|
|
+ # # 例如,可以检查cookie的过期时间,路径等属性
|
|
|
+ # print("Attributes:", morsel);
|
|
|
+
|
|
|
+ authorization = ori_cookies['unionToken_interactiveIGoChoose'];
|
|
|
+ try:
|
|
|
+ jwt_data = Utils.parse_jwt(authorization);
|
|
|
+ if not jwt_data:
|
|
|
+ return;
|
|
|
+ payload = jwt_data['payload'];
|
|
|
+ if 'customerInfo' in payload:
|
|
|
+ info_str = payload['customerInfo'];
|
|
|
+ customer_info = json.loads(info_str);
|
|
|
+ payload['customerInfo'] = customer_info;
|
|
|
+ account = payload['customerInfo']['phone'];
|
|
|
+
|
|
|
+ tmp_dt = datetime.utcfromtimestamp(payload['iat']);
|
|
|
+ sign_time = tmp_dt.strftime('%Y-%m-%d %H:%M:%S');
|
|
|
+ tmp_dt = datetime.utcfromtimestamp(payload['exp']);
|
|
|
+ expire_time = tmp_dt.strftime('%Y-%m-%d %H:%M:%S');
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ print(e);
|
|
|
+
|
|
|
+ try:
|
|
|
+ sql_query = f'''
|
|
|
+ UPDATE elife_account_data
|
|
|
+ SET
|
|
|
+ authorization = %s,
|
|
|
+ cookies = %s,
|
|
|
+ update_time = %s,
|
|
|
+ expire_time = %s,
|
|
|
+ login_params = %s
|
|
|
+ WHERE account = %s;
|
|
|
+ ''';
|
|
|
+ sql_params = (authorization, repr(cookies), sign_time, expire_time, login_params);
|
|
|
+ self.check_mysql_connect();
|
|
|
+ cursor = self.db_conn.cursor();
|
|
|
+ cursor.execute(sql_query, sql_params);
|
|
|
+ self.db_conn.commit();
|
|
|
+ cursor.close();
|
|
|
+ except pymysql.OperationalError as e:
|
|
|
+ print(e);
|
|
|
+
|
|
|
def handle_activitylist(self, flow: http.HTTPFlow):
|
|
|
ctx.log.info('###handle_activitylist###');
|
|
|
request = flow.request;
|
|
|
@@ -291,7 +359,7 @@ class OfpayHelper:
|
|
|
request = flow.request;
|
|
|
response = flow.response;
|
|
|
|
|
|
- cookies = dict(request.cookies) # 转换cookies格式为dict
|
|
|
+ cookies = dict(request.cookies); # 转换cookies格式为dict
|
|
|
|
|
|
# if 'unionToken_interactiveIGoChoose' not in cookies:
|
|
|
# return;
|
|
|
@@ -345,11 +413,17 @@ class OfpayHelper:
|
|
|
rsp_data = rsp_params['data'];
|
|
|
rsp_data['list'].insert(0, simple_data);
|
|
|
|
|
|
- update_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S');
|
|
|
+ update_time = create_time;
|
|
|
+ tmp_dt = datetime.utcfromtimestamp(payload['iat']);
|
|
|
+ sign_time = tmp_dt.strftime('%Y-%m-%d %H:%M:%S');
|
|
|
+ tmp_dt = datetime.utcfromtimestamp(payload['exp']);
|
|
|
+ expire_time = tmp_dt.strftime('%Y-%m-%d %H:%M:%S');
|
|
|
+ simple_data['createTime'] = expire_time;
|
|
|
+
|
|
|
sql_query = f'''
|
|
|
- CALL UpdateElifeAccountData(%s, %s, %s, %s, %s, %s, %s, %s, %s);
|
|
|
+ CALL UpdateElifeAccountData(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s);
|
|
|
''';
|
|
|
- sql_params = (account, uuid, authorization, repr(cookies), user_agent, market_id, event_visitor_id, capture_code , update_time);
|
|
|
+ sql_params = (account, uuid, authorization, repr(cookies), user_agent, market_id, event_visitor_id, capture_code , update_time, expire_time);
|
|
|
|
|
|
try:
|
|
|
self.check_mysql_connect();
|
|
|
@@ -362,7 +436,4 @@ class OfpayHelper:
|
|
|
print(e);
|
|
|
simple_data['prizeName'] = '数据采集失败';
|
|
|
simple_data['prizeDesc'] = '';
|
|
|
- response.set_text(json.dumps(rsp_params));
|
|
|
-
|
|
|
-
|
|
|
-sql_activity_params = [('1', 'A923605206137307136', '活动1-首单', 'eCoffee', 'e起喝咖啡(首次)', '2', '', '', 'https://mstatic.ofpay.com/marketing/upload/e4fb2100868347c0bc39cb9ac08ad485.png', 'subChoose', 'A923613706510925824', ''), ('1', 'A923620157585358848', '活动1-首单', 'eTea', 'e起下午茶(首次)', '2', '', '', 'https://mstatic.ofpay.com/marketing/upload/0c9b274ba4ff4f2e81d18fb7db2b15b1.png', 'subChoose', 'A923622289227120640', ''), ('1', 'A1190335340494454784', '活动1-首单', 'eFood', 'e起享美 味', '2', '', '', '', 'subChoose', 'A1190350499677995008', ''), ('1', 'A1190947451528544256', '活动1-首单', 'eSupermarket', 'e起逛超市', '2', '', '', '', 'choose', '', ''), ('1', 'A1190954239447531520', '活动1-首单', 'eTravel', 'e起乐出行', '2', '', '', '', 'subChoose', 'A1190956349283106816', ''), ('1', 'A923939556410261504', '活动1-首单', 'eMovie', 'e起追 热剧', '2', '', '', 'https://mstatic.ofpay.com/marketing/upload/7254fbe94dd041d5b8c63ba4a9a5505e.png', 'choose', '', ''), ('1', 'A923939562252926976', '活动1-首单', 'eBicycle', 'e起骑单车(首次)', '2', '', '', 'https://mstatic.ofpay.com/marketing/upload/c8550391b1324e32b7b537d35523196c.png', 'choose', '', ''), ('1', 'A1091037106664636416', '活动1-首单', 'eOffice', 'e起长知识', '2', '', '', 'https://mstatic.ofpay.com/marketing/upload/1eed1bbb39044cf992a7cdb13d771538.png', 'choose', '', '')]
|
|
|
+ response.set_text(json.dumps(rsp_params));
|