|
@@ -1,4 +1,5 @@
|
|
|
import datetime
|
|
import datetime
|
|
|
|
|
+import hashlib
|
|
|
import json
|
|
import json
|
|
|
import multiprocessing
|
|
import multiprocessing
|
|
|
import random
|
|
import random
|
|
@@ -8,6 +9,7 @@ import sys
|
|
|
import threading
|
|
import threading
|
|
|
import time
|
|
import time
|
|
|
import traceback
|
|
import traceback
|
|
|
|
|
+from hashlib import md5
|
|
|
from urllib import parse
|
|
from urllib import parse
|
|
|
|
|
|
|
|
import requests
|
|
import requests
|
|
@@ -29,10 +31,16 @@ def poc_2(account, passwd, target_url, log_name, single_proxy, random_index):
|
|
|
# 开始业务逻辑
|
|
# 开始业务逻辑
|
|
|
lock = threading.Lock()
|
|
lock = threading.Lock()
|
|
|
with lock:
|
|
with lock:
|
|
|
|
|
+ # 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)
|
|
|
|
|
|
|
|
loggerKit.info(f'account: {account}, passwd: {passwd}')
|
|
loggerKit.info(f'account: {account}, passwd: {passwd}')
|
|
|
writer = FileWriter(log_name)
|
|
writer = FileWriter(log_name)
|
|
|
- writer.write_to_file(f'------{account}, {passwd}------ \n')
|
|
|
|
|
|
|
+ # writer.write_to_file(f'------{account}, {passwd}------ \n')
|
|
|
user_agent = get_random_browser()
|
|
user_agent = get_random_browser()
|
|
|
# single_proxy = 'rrehqcjf:33f90umk8x32@185.199.228.220:7300'
|
|
# single_proxy = 'rrehqcjf:33f90umk8x32@185.199.228.220:7300'
|
|
|
proxies = {
|
|
proxies = {
|
|
@@ -41,57 +49,68 @@ def poc_2(account, passwd, target_url, log_name, single_proxy, random_index):
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
loggerKit.info(f'proxies: {proxies}')
|
|
loggerKit.info(f'proxies: {proxies}')
|
|
|
- writer.write_to_file(f'account: {account}, passwd: {passwd}, proxies:{proxies} \n')
|
|
|
|
|
|
|
+ # writer.write_to_file(f'account: {account}, passwd: {passwd}, proxies:{proxies} \n')
|
|
|
|
|
|
|
|
# session
|
|
# session
|
|
|
- """
|
|
|
|
|
- 模拟登录
|
|
|
|
|
- """
|
|
|
|
|
- # 定义请求地址
|
|
|
|
|
- stamp = str(int(time.time()))
|
|
|
|
|
- login_url = f"https://t.livepocket.jp/api/sessions/create?mytimestamp={stamp}"
|
|
|
|
|
-
|
|
|
|
|
- # 定义请求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";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99',
|
|
|
|
|
- 'User-Agent': user_agent,
|
|
|
|
|
- 'path': f'/api/sessions/create?mytimestamp={stamp}',
|
|
|
|
|
- 'Origin': 'https://t.livepocket.jp',
|
|
|
|
|
- 'Sec-Ch-Ua-Mobile': '?0',
|
|
|
|
|
- 'Sec-Fetch-Mode': 'cors',
|
|
|
|
|
- 'Sec-Fetch-Site': 'same-origin',
|
|
|
|
|
- 'Priority': 'u=1, i'
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- # 通过字典方式定义请求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=proxies).text
|
|
|
|
|
- # loggerKit.info(f'login info: {content}')
|
|
|
|
|
- if 'token' not in content:
|
|
|
|
|
- loggerKit.info(f'login account:{account}, 本机出口IP:{get_external_ip()}、代理IP:{single_proxy} 被封!!!')
|
|
|
|
|
- # 将被封的IP数据从redis中去掉
|
|
|
|
|
- key = f'proxy_{str(random_index)}'
|
|
|
|
|
- loggerKit.info(f'key:{key}')
|
|
|
|
|
- redis_client.delete(key=key)
|
|
|
|
|
- return
|
|
|
|
|
- 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']
|
|
|
|
|
|
|
+ if redis_client.get(f'token_{cname}') is None:
|
|
|
|
|
+
|
|
|
|
|
+ """
|
|
|
|
|
+ 模拟登录
|
|
|
|
|
+ """
|
|
|
|
|
+ # 定义请求地址
|
|
|
|
|
+ stamp = str(int(time.time()))
|
|
|
|
|
+ login_url = f"https://t.livepocket.jp/api/sessions/create?mytimestamp={stamp}"
|
|
|
|
|
+
|
|
|
|
|
+ # 定义请求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";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99',
|
|
|
|
|
+ 'User-Agent': user_agent,
|
|
|
|
|
+ 'path': f'/api/sessions/create?mytimestamp={stamp}',
|
|
|
|
|
+ 'Origin': 'https://t.livepocket.jp',
|
|
|
|
|
+ 'Sec-Ch-Ua-Mobile': '?0',
|
|
|
|
|
+ 'Sec-Fetch-Mode': 'cors',
|
|
|
|
|
+ 'Sec-Fetch-Site': 'same-origin',
|
|
|
|
|
+ 'Priority': 'u=1, i'
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ # 通过字典方式定义请求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=proxies).text
|
|
|
|
|
+ # loggerKit.info(f'login info: {content}')
|
|
|
|
|
+ if 'token' not in content:
|
|
|
|
|
+ loggerKit.info(f'login account:{account}, 本机出口IP:{get_external_ip()}、代理IP:{single_proxy} 被封!!!')
|
|
|
|
|
+ # 将被封的IP数据从redis中去掉
|
|
|
|
|
+ key = f'proxy_{str(random_index)}'
|
|
|
|
|
+ loggerKit.info(f'key:{key}')
|
|
|
|
|
+ redis_client.delete(key=key)
|
|
|
|
|
+ return
|
|
|
|
|
+
|
|
|
|
|
+ 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']
|
|
|
|
|
+ loggerKit.info(f'login account:{account}, 代理IP:{single_proxy}, token: {token} 登录成功!!!')
|
|
|
|
|
+ redis_client.set(f'token_{cname}', token)
|
|
|
|
|
+ redis_client.set(f'php_session_{cname}', php_session)
|
|
|
|
|
+ redis_client.set(f'ci_session_{cname}', login_session)
|
|
|
|
|
+ else:
|
|
|
|
|
+ token = redis_client.get(f'token_{cname}')
|
|
|
|
|
+ login_session = redis_client.get(f'ci_session_{cname}')
|
|
|
|
|
+ php_session = redis_client.get(f'php_session_{cname}')
|
|
|
|
|
|
|
|
# event_id
|
|
# event_id
|
|
|
# 从redis中查询,查询不到再去请求
|
|
# 从redis中查询,查询不到再去请求
|
|
|
- event_id = redis_client.get(f'event_id_{target_url}')
|
|
|
|
|
|
|
+ event_id = redis_client.get(f'event_id_{cname}')
|
|
|
if event_id == 0 or event_id is None:
|
|
if event_id == 0 or event_id is None:
|
|
|
response = requests.get(target_url, proxies=proxies)
|
|
response = requests.get(target_url, proxies=proxies)
|
|
|
if response.status_code == 200:
|
|
if response.status_code == 200:
|
|
@@ -102,7 +121,7 @@ def poc_2(account, passwd, target_url, log_name, single_proxy, random_index):
|
|
|
if end_index != -1:
|
|
if end_index != -1:
|
|
|
event_id = html_string[
|
|
event_id = html_string[
|
|
|
start_index + len('https://t.livepocket.jp/purchase/verify?event_id='):end_index]
|
|
start_index + len('https://t.livepocket.jp/purchase/verify?event_id='):end_index]
|
|
|
- redis_client.set(f'event_id_{target_url}', event_id)
|
|
|
|
|
|
|
+ redis_client.set(f'event_id_{cname}', event_id)
|
|
|
loggerKit.info(f'event_id: {event_id}')
|
|
loggerKit.info(f'event_id: {event_id}')
|
|
|
else:
|
|
else:
|
|
|
loggerKit.warning('End index not found.')
|
|
loggerKit.warning('End index not found.')
|
|
@@ -113,7 +132,7 @@ def poc_2(account, passwd, target_url, log_name, single_proxy, random_index):
|
|
|
|
|
|
|
|
# ticket_id
|
|
# ticket_id
|
|
|
# 从redis中查询,不存在则请求
|
|
# 从redis中查询,不存在则请求
|
|
|
- ticket_id = redis_client.get(f'ticket_id_{target_url}')
|
|
|
|
|
|
|
+ ticket_id = redis_client.get(f'ticket_id_{cname}')
|
|
|
if ticket_id == 0 or ticket_id is None:
|
|
if ticket_id == 0 or ticket_id is None:
|
|
|
response = requests.get(target_url, proxies=proxies)
|
|
response = requests.get(target_url, proxies=proxies)
|
|
|
if response.status_code == 200:
|
|
if response.status_code == 200:
|
|
@@ -121,22 +140,11 @@ def poc_2(account, passwd, target_url, log_name, single_proxy, random_index):
|
|
|
match = re.search(r'id="js_order_limited_(\d+)"', html_string)
|
|
match = re.search(r'id="js_order_limited_(\d+)"', html_string)
|
|
|
if match:
|
|
if match:
|
|
|
ticket_id = match.group(1)
|
|
ticket_id = match.group(1)
|
|
|
- redis_client.set(f'ticket_id_{target_url}', ticket_id)
|
|
|
|
|
|
|
+ redis_client.set(f'ticket_id_{cname}', ticket_id)
|
|
|
loggerKit.info(f'ticket_id: {ticket_id}')
|
|
loggerKit.info(f'ticket_id: {ticket_id}')
|
|
|
else:
|
|
else:
|
|
|
loggerKit.warning("未找到匹配的数值")
|
|
loggerKit.warning("未找到匹配的数值")
|
|
|
|
|
|
|
|
- # event_cname
|
|
|
|
|
- # url = 'https://t.livepocket.jp/e/lxyyc'
|
|
|
|
|
- # 从redis中查询,不存在则处理
|
|
|
|
|
- cname = redis_client.get(f'cname_{target_url}')
|
|
|
|
|
- if cname is None:
|
|
|
|
|
- sub_str = target_url.replace("https://t.livepocket.jp/", "")
|
|
|
|
|
- strs = sub_str.split('/')
|
|
|
|
|
- cname = strs[len(strs) - 1]
|
|
|
|
|
- redis_client.set(f'cname_{target_url}', cname)
|
|
|
|
|
- # print(cname)
|
|
|
|
|
-
|
|
|
|
|
# redirect_url1
|
|
# redirect_url1
|
|
|
net_url = 'https://t.livepocket.jp/purchase?type=new'
|
|
net_url = 'https://t.livepocket.jp/purchase?type=new'
|
|
|
result = requests.Session()
|
|
result = requests.Session()
|
|
@@ -201,7 +209,7 @@ def poc_2(account, passwd, target_url, log_name, single_proxy, random_index):
|
|
|
|
|
|
|
|
# https://t.livepocket.jp/purchase/confirm?id=309887&reserved_session_id=794986&otoken=mMyZTgzMmQ4OWQ5ZjY5NWFlNGE2ZmJlMWM5Mm
|
|
# https://t.livepocket.jp/purchase/confirm?id=309887&reserved_session_id=794986&otoken=mMyZTgzMmQ4OWQ5ZjY5NWFlNGE2ZmJlMWM5Mm
|
|
|
# drawing_tickets
|
|
# drawing_tickets
|
|
|
- drawing_url = 'https://t.livepocket.jp/api/drawing_tickets/entry?mytimestamp=' + str(int(time.time()))
|
|
|
|
|
|
|
+ # drawing_url = 'https://t.livepocket.jp/api/drawing_tickets/entry?mytimestamp=' + str(int(time.time()))
|
|
|
|
|
|
|
|
region_string = redirect_url3.split('?')[1]
|
|
region_string = redirect_url3.split('?')[1]
|
|
|
params = region_string.split('&')
|
|
params = region_string.split('&')
|
|
@@ -229,7 +237,7 @@ def poc_2(account, passwd, target_url, log_name, single_proxy, random_index):
|
|
|
'reserve_ticket[0][amount]': 1,
|
|
'reserve_ticket[0][amount]': 1,
|
|
|
'payment_type': 'credit'
|
|
'payment_type': 'credit'
|
|
|
}
|
|
}
|
|
|
- drawing_response = result.post(drawing_url, headers=drawing_headers, cookies=drawing_cookies,
|
|
|
|
|
|
|
+ drawing_response = result.post(f'https://t.livepocket.jp/api/drawing_tickets/entry?mytimestamp={str(int(time.time()))}', headers=drawing_headers, cookies=drawing_cookies,
|
|
|
data=drawing_form_data, allow_redirects=False, proxies=proxies)
|
|
data=drawing_form_data, allow_redirects=False, proxies=proxies)
|
|
|
loggerKit.info('drawing_response.text: {0}', drawing_response.text)
|
|
loggerKit.info('drawing_response.text: {0}', drawing_response.text)
|
|
|
drawing_data = json.loads(drawing_response.text)
|
|
drawing_data = json.loads(drawing_response.text)
|
|
@@ -240,13 +248,12 @@ def poc_2(account, passwd, target_url, log_name, single_proxy, random_index):
|
|
|
loggerKit.info('account: {0}, order_id: {1}, onetime_token_name: {2}, onetime_token_value: {3}',
|
|
loggerKit.info('account: {0}, order_id: {1}, onetime_token_name: {2}, onetime_token_value: {3}',
|
|
|
account, order_id, onetime_token_name, onetime_token_value)
|
|
account, order_id, onetime_token_name, onetime_token_value)
|
|
|
|
|
|
|
|
- writer.write_to_file(
|
|
|
|
|
- f'account:{account}, order_id:{order_id}, onetime_token_name:{onetime_token_name}, onetime_token_value:{onetime_token_value} \n')
|
|
|
|
|
|
|
+ # writer.write_to_file(f'account:{account}, order_id:{order_id}, onetime_token_name:{onetime_token_name}, onetime_token_value:{onetime_token_value} \n')
|
|
|
|
|
|
|
|
|
|
|
|
|
def process_account(account, log_name, single_proxy, random_index):
|
|
def process_account(account, log_name, single_proxy, random_index):
|
|
|
try:
|
|
try:
|
|
|
- run_poc(account.strip(), 'panyue666', 'https://t.livepocket.jp/e/pua9z', log_name, single_proxy, random_index)
|
|
|
|
|
|
|
+ run_poc(account.strip(), 'panyue666', 'https://t.livepocket.jp/e/c1rbq', log_name, single_proxy, random_index)
|
|
|
except Exception as ex:
|
|
except Exception as ex:
|
|
|
loggerKit.error(f'error: {traceback.format_exc()}, account:{account}')
|
|
loggerKit.error(f'error: {traceback.format_exc()}, account:{account}')
|
|
|
|
|
|
|
@@ -310,4 +317,6 @@ if __name__ == '__main__':
|
|
|
# 新增下面一行代码即可打包多进程
|
|
# 新增下面一行代码即可打包多进程
|
|
|
multiprocessing.freeze_support()
|
|
multiprocessing.freeze_support()
|
|
|
|
|
|
|
|
- run_daily_job(18, 48)
|
|
|
|
|
|
|
+ # run_daily_job(8, 52)
|
|
|
|
|
+
|
|
|
|
|
+ looper_job()
|