|
|
@@ -0,0 +1,169 @@
|
|
|
+import json
|
|
|
+import re
|
|
|
+import time
|
|
|
+from urllib import parse
|
|
|
+
|
|
|
+import requests
|
|
|
+
|
|
|
+
|
|
|
+def poc_2(account, passwd, target_url):
|
|
|
+ # session
|
|
|
+ """
|
|
|
+ 模拟登录
|
|
|
+ """
|
|
|
+ # 定义请求地址
|
|
|
+ login_url = "https://t.livepocket.jp/api/sessions/create?mytimestamp=" + str(int(time.time()))
|
|
|
+
|
|
|
+ # 定义请求header
|
|
|
+ headers = {'Content-Type': 'application/x-www-form-urlencoded;',
|
|
|
+ 'Referer': 'https://t.livepocket.jp/login?acroot=header-new_p_u_nl',
|
|
|
+ 'Sec-Ch-Ua': 'Chromium',
|
|
|
+ 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'
|
|
|
+ }
|
|
|
+
|
|
|
+ # 通过字典方式定义请求body
|
|
|
+ form_data = {"login": account,
|
|
|
+ "password": passwd,
|
|
|
+ "auto_login": "on",
|
|
|
+ "login_password": f"{account}&{passwd}"
|
|
|
+ }
|
|
|
+
|
|
|
+ data = parse.urlencode(form_data)
|
|
|
+ session = requests.session()
|
|
|
+ content = session.post(url=login_url, headers=headers, data=data, proxies=None).text
|
|
|
+ cookie = session.cookies
|
|
|
+ response_cookie = cookie.get_dict()
|
|
|
+ login_resp = json.loads(content)
|
|
|
+ token = login_resp['result']['token']
|
|
|
+ login_session = response_cookie['ci_session']
|
|
|
+ php_session = response_cookie['PHPSESSID']
|
|
|
+
|
|
|
+ # event_id
|
|
|
+ event_id = 0
|
|
|
+ response = requests.get(target_url)
|
|
|
+ if response.status_code == 200:
|
|
|
+ html_string = response.content.decode('utf8')
|
|
|
+ start_index = html_string.find('https://t.livepocket.jp/purchase/verify?event_id=')
|
|
|
+ if start_index != -1:
|
|
|
+ end_index = html_string.find("'", start_index)
|
|
|
+ if end_index != -1:
|
|
|
+ event_id = html_string[start_index + len('https://t.livepocket.jp/purchase/verify?event_id='):end_index]
|
|
|
+ print(f'event_id: {event_id}')
|
|
|
+ else:
|
|
|
+ print('End index not found.')
|
|
|
+ else:
|
|
|
+ print('Substring not found.')
|
|
|
+ else:
|
|
|
+ print('Failed to fetch the page. Status code:', response.status_code)
|
|
|
+
|
|
|
+ # ticket_id
|
|
|
+ ticket_id = 0
|
|
|
+ response = requests.get(target_url)
|
|
|
+ if response.status_code == 200:
|
|
|
+ html_string = response.text
|
|
|
+ match = re.search(r'id="js_order_limited_(\d+)"', html_string)
|
|
|
+ if match:
|
|
|
+ ticket_id = match.group(1)
|
|
|
+ print(ticket_id)
|
|
|
+ else:
|
|
|
+ print("未找到匹配的数值")
|
|
|
+
|
|
|
+ # event_cname
|
|
|
+ # url = 'https://t.livepocket.jp/e/lxyyc'
|
|
|
+ sub_str = target_url.replace("https://t.livepocket.jp/", "")
|
|
|
+ strs = sub_str.split('/')
|
|
|
+ cname = strs[len(strs) - 1]
|
|
|
+ # print(cname)
|
|
|
+
|
|
|
+ # redirect_url1
|
|
|
+ net_url = 'https://t.livepocket.jp/purchase?type=new'
|
|
|
+ result = requests.Session()
|
|
|
+ header = {
|
|
|
+ 'Host': 't.livepocket.jp',
|
|
|
+ 'User-Agent': "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
|
+ "Chrome/69.0.3947.100 Safari/537.36",
|
|
|
+ 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
+ 'Referer': f'{target_url}',
|
|
|
+ }
|
|
|
+ # my_session = 'IN7u3uuP5WcizQkmRzF%2F3OsLuNNQePnxNBvnlPgqT6FPz2BgyKT2KCJaMvdj8ZSa6wNp2xZIL6VoA7Mj0R2zECMZkOKJOLbsNwUdXwvcsROxjfCzibxEaj4nG%2Bq29dCEUdiWI2TgUsKSFGRZaOP0p37ktl%2B1wSMqMAk918Nkt7APIxpQtZ%2BoLwId4PMOkN3oOIwT3CvsuDbgPQHIuokZXcnNe8uOAUuZBLW4nKOdYimLcSw6oTMt85UXkwm4OyTdxYR3%2B8crA0OfQCyfHXqY%2Bj0t9R0mmNSusRXRDuDBmOCFR58vHVuuwZ0AXNHYoYB0sdm28VL9xgHHrzkvm2M9cpLEIVWUWBWGaZgtO3xp2d8L70%2BfAKwyv6JPGcGmGf9wUQzBltssBpMmYqSfkws1%2Bp8BOhmXOqfljSYbWcxxVVSw%2B2dtoxBXsTf793mD9sVYRsrr8YPGz4JPVGWGU0outg%3D%3D'
|
|
|
+ cookies = {
|
|
|
+ 'ci_session': f'{login_session}',
|
|
|
+ 'PHPSESSID': f'{php_session}',
|
|
|
+ 'list_count': '{"success":true,"result":{"myticket_count":{"count":"0"},"today_event":{"total_count":0,"data_list":[]},"unread_count":5},"submit":true}',
|
|
|
+ 'sns_status': '{"success":true,"result":{"facebook":0,"twitter":0,"mixi":0,"line":0,"yahoo":0,"plusid":1,"google":0},"submit":true}',
|
|
|
+ 'display_init': '{"success":true,"result":{"purchased_tickets":{"total_count":0,"data_list":{"ticket_info":[]}},"lottery_tickets":{"total_count":0,"data_list":{"ticket_info":[]}},"order_limited_event_tickets":{"data_list":{"ticket_info":[]},"total_count":0},"event_order_limit":true},"submit":true}',
|
|
|
+ }
|
|
|
+
|
|
|
+ ticket_key = f'ticket_id_{ticket_id}'
|
|
|
+ form_data = {
|
|
|
+ 'redirect_url': 'https://t.livepocket.jp/purchase/',
|
|
|
+ 'event_id': event_id,
|
|
|
+ 'event_cname': f'{cname}',
|
|
|
+ 'ticket_type': 'lottery',
|
|
|
+ 'facebook_ticket_count': 0,
|
|
|
+ 'twitter_ticket_count': 0,
|
|
|
+ 'plusid_linkage_invalidation_flg': 0,
|
|
|
+ ticket_key: 1
|
|
|
+ }
|
|
|
+
|
|
|
+ print('form_data:', form_data)
|
|
|
+
|
|
|
+ response = result.post(net_url, headers=header, cookies=cookies, data=form_data, allow_redirects=False)
|
|
|
+ print('response.headers: ', response.headers)
|
|
|
+ redirect_url1 = response.headers['Location']
|
|
|
+
|
|
|
+ # https://t.livepocket.jp/purchase/security?id=309887&type=new
|
|
|
+ # redirect_url2
|
|
|
+ response2 = result.get(redirect_url1, headers=header, cookies=cookies, allow_redirects=False)
|
|
|
+ print('response2.headers: ', response2.headers)
|
|
|
+ redirect_url2 = response2.headers['Location']
|
|
|
+
|
|
|
+ # https://t.livepocket.jp/purchase/confirm?id=309887&reserved_session_id=423272
|
|
|
+ # redirect_url3
|
|
|
+ response3 = result.get(redirect_url2, headers=header, cookies=cookies, allow_redirects=False)
|
|
|
+ print('response3.headers: ', response3.headers)
|
|
|
+ redirect_url3 = response3.headers['Location']
|
|
|
+
|
|
|
+ # https://t.livepocket.jp/purchase/confirm?id=309887&reserved_session_id=794986&otoken=mMyZTgzMmQ4OWQ5ZjY5NWFlNGE2ZmJlMWM5Mm
|
|
|
+ # drawing_tickets
|
|
|
+ drawing_url = 'https://t.livepocket.jp/api/drawing_tickets/entry?mytimestamp=' + str(int(time.time()))
|
|
|
+
|
|
|
+ region_string = redirect_url3.split('?')[1]
|
|
|
+ params = region_string.split('&')
|
|
|
+ reserve_session_id = params[1].split("=")[1]
|
|
|
+
|
|
|
+ drawing_headers = {
|
|
|
+ 'Host': 't.livepocket.jp',
|
|
|
+ 'User-Agent': "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
|
+ "Chrome/69.0.3947.100 Safari/537.36",
|
|
|
+ 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
+ 'Referer': f'{redirect_url3}',
|
|
|
+ }
|
|
|
+ drawing_cookies = {
|
|
|
+ 'ci_session': f'{login_session}',
|
|
|
+ 'PHPSESSID': f'{php_session}',
|
|
|
+ }
|
|
|
+ drawing_form_data = {
|
|
|
+ 'utoken': f'{token}',
|
|
|
+ 'onetime_token_name': 'buy_ticket',
|
|
|
+ 'onetime_token_value': params[2].split('=')[1],
|
|
|
+ 'url': f'https://t.livepocket.jp/purchase/confirm?id={event_id}&reserved_session_id={reserve_session_id}',
|
|
|
+ 'payment_method': 0,
|
|
|
+ 'reserve_session_id': reserve_session_id,
|
|
|
+ 'event_id': event_id,
|
|
|
+ 'reserve_ticket[0][ticket_id]': ticket_id,
|
|
|
+ 'reserve_ticket[0][amount]': 1,
|
|
|
+ 'payment_type': 'credit'
|
|
|
+ }
|
|
|
+ drawing_response = result.post(drawing_url, headers=drawing_headers, cookies=drawing_cookies, data=drawing_form_data, allow_redirects=False)
|
|
|
+ print('drawing_response.text: ', drawing_response.text)
|
|
|
+ drawing_data = json.loads(drawing_response.text)
|
|
|
+ if drawing_data['success']:
|
|
|
+ order_id = drawing_data['result']['order_id']
|
|
|
+ onetime_token_name = drawing_data['result']['onetime_token_name']
|
|
|
+ onetime_token_value = drawing_data['result']['onetime_token_value']
|
|
|
+ print('order_id, onetime_token_name, onetime_token_value', order_id, onetime_token_name, onetime_token_value)
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ poc_2('sa304@huatcn.com', 'panyue666', 'https://t.livepocket.jp/e/pp20240515')
|