mirror of
https://github.com/WhaleFell/SMSBoom.git
synced 2026-05-11 10:30:24 +08:00
3
.gitignore
vendored
3
.gitignore
vendored
@@ -160,4 +160,5 @@ cython_debug/
|
|||||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
.idea/
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# encoding=utf8
|
# encoding=utf8
|
||||||
# 储存数据库模型
|
# 储存数据库模型
|
||||||
|
from utils import default_header_user_agent
|
||||||
from . import db
|
from . import db
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from . import ModelView
|
from . import ModelView
|
||||||
@@ -7,10 +8,6 @@ import json
|
|||||||
from typing import Union, Optional
|
from typing import Union, Optional
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
default_header = {
|
|
||||||
"User-Agent": "Mozilla/5.0 (Linux; U; Android 10; zh-cn; Mi 10 Build/QKQ1.191117.002) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/79.0.3945.147 Mobile Safari/537.36 XiaoMi/MiuiBrowser/13.5.40"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ApisModelVies(ModelView):
|
class ApisModelVies(ModelView):
|
||||||
create_template = 'api_edit.html'
|
create_template = 'api_edit.html'
|
||||||
@@ -38,7 +35,7 @@ class API(BaseModel):
|
|||||||
desc: str = "Default"
|
desc: str = "Default"
|
||||||
url: str
|
url: str
|
||||||
method: str = "GET"
|
method: str = "GET"
|
||||||
header: Optional[Union[str, dict]] = default_header
|
header: Optional[Union[str, dict]] = default_header_user_agent()
|
||||||
data: Optional[Union[str, dict]]
|
data: Optional[Union[str, dict]]
|
||||||
|
|
||||||
def replace_data(self, content: Union[str, dict], phone) -> str:
|
def replace_data(self, content: Union[str, dict], phone) -> str:
|
||||||
|
|||||||
1
http_proxy.txt
Normal file
1
http_proxy.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
127.0.0.1:7890
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
202.55.5.209:8090
|
|
||||||
120.42.46.226:6666
|
|
||||||
61.135.155.82:443
|
|
||||||
39.108.101.55:1080
|
|
||||||
120.71.147.222:8901
|
|
||||||
99
smsboom.py
99
smsboom.py
@@ -1,41 +1,61 @@
|
|||||||
# encoding=utf8
|
# encoding=utf8
|
||||||
# 短信测压主程序
|
# 短信测压主程序
|
||||||
|
|
||||||
|
from utils import default_header_user_agent
|
||||||
|
from utils.log import logger
|
||||||
|
from utils.models import API
|
||||||
|
from utils.req import reqFunc, reqFuncByProxy, runAsync
|
||||||
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
from typing import List, Union
|
||||||
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
|
||||||
from typing import List, Union
|
|
||||||
import asyncio
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
|
|
||||||
from utils import default_header_user_agent
|
|
||||||
|
|
||||||
from utils.log import logger
|
|
||||||
from utils.models import API
|
|
||||||
from utils.req import reqFunc, runAsync
|
|
||||||
|
|
||||||
# current directory
|
# current directory
|
||||||
path = pathlib.Path(__file__).parent
|
path = pathlib.Path(__file__).parent
|
||||||
|
|
||||||
|
|
||||||
def load_proxies() -> list:
|
def load_proxies() -> list:
|
||||||
"""load proxies for proxy.txt
|
"""load proxies for files
|
||||||
:return: proxies list
|
:return: proxies list
|
||||||
"""
|
"""
|
||||||
proxy_data = []
|
proxy_data = []
|
||||||
proxy_path = pathlib.Path(path, 'proxy.txt')
|
try:
|
||||||
for line in open(proxy_path):
|
proxy_path = pathlib.Path(path, 'http_proxy.txt')
|
||||||
le = line.replace("\r", "").replace("\n", "")
|
for line in open(proxy_path):
|
||||||
if le == '':
|
le = line.replace("\r", "").replace("\n", "")
|
||||||
continue
|
if le == '':
|
||||||
proxy_one = {
|
continue
|
||||||
'all://': 'http://' + le
|
proxy_one = {
|
||||||
}
|
'all://': 'http://' + le
|
||||||
proxy_data.append(proxy_one)
|
}
|
||||||
|
proxy_data.append(proxy_one)
|
||||||
|
proxy_path = pathlib.Path(path, 'socks4_proxy.txt')
|
||||||
|
for line in open(proxy_path):
|
||||||
|
le = line.replace("\r", "").replace("\n", "")
|
||||||
|
if le == '':
|
||||||
|
continue
|
||||||
|
proxy_one = {
|
||||||
|
'all://': 'socks4://' + le
|
||||||
|
}
|
||||||
|
proxy_data.append(proxy_one)
|
||||||
|
proxy_path = pathlib.Path(path, 'socks5_proxy.txt')
|
||||||
|
for line in open(proxy_path):
|
||||||
|
le = line.replace("\r", "").replace("\n", "")
|
||||||
|
if le == '':
|
||||||
|
continue
|
||||||
|
proxy_one = {
|
||||||
|
'all://': 'socks5://' + le
|
||||||
|
}
|
||||||
|
proxy_data.append(proxy_one)
|
||||||
|
except:
|
||||||
|
logger.error("proxies 加载失败")
|
||||||
|
return []
|
||||||
|
logger.success(f"proxies 加载完成 接口数:{len(proxy_data)}")
|
||||||
return proxy_data
|
return proxy_data
|
||||||
|
|
||||||
|
|
||||||
@@ -86,13 +106,15 @@ def load_getapi() -> list:
|
|||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option("--thread", "-t", help="线程数(默认128)", default=128)
|
@click.option("--thread", "-t", help="线程数(默认64)", default=64)
|
||||||
@click.option("--phone", "-p", help="手机号,可传入多个再使用-p传递", prompt=True, required=True, multiple=True)
|
@click.option("--phone", "-p", help="手机号,可传入多个再使用-p传递", prompt=True, required=True, multiple=True)
|
||||||
@click.option('--frequency', "-f", default=10, help="执行次数(默认10次,设置为999999999为无限执行不退出)", type=int)
|
@click.option('--frequency', "-f", default=1, help="执行次数(默认1次)", type=int)
|
||||||
def run(thread: int, phone: Union[str, tuple], frequency: int):
|
@click.option('--interval', "-i", default=60, help="间隔时间(默认60s)", type=int)
|
||||||
|
@click.option('--enable_proxy', "-e", is_flag=True, help="开启代理(默认关闭)", type=bool)
|
||||||
|
def run(thread: int, phone: Union[str, tuple], frequency: int, interval: int, enable_proxy: bool = False):
|
||||||
"""传入线程数和手机号启动轰炸,支持多手机号"""
|
"""传入线程数和手机号启动轰炸,支持多手机号"""
|
||||||
logger.info(f"手机号:{phone},线程数:{thread},执行次数:{frequency}")
|
logger.info(f"手机号:{phone}, 线程数:{thread}, 执行次数:{frequency}, 间隔时间:{interval}")
|
||||||
|
print(enable_proxy)
|
||||||
with ThreadPoolExecutor(max_workers=thread) as pool:
|
with ThreadPoolExecutor(max_workers=thread) as pool:
|
||||||
try:
|
try:
|
||||||
_api = load_json()
|
_api = load_json()
|
||||||
@@ -104,20 +126,16 @@ def run(thread: int, phone: Union[str, tuple], frequency: int):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
for i in range(1, frequency + 1):
|
for i in range(1, frequency + 1):
|
||||||
logger.success(f"第{i}波轰炸开始!")
|
logger.success(f"第{i}波轰炸开始!")
|
||||||
_process = ''
|
|
||||||
for proxy in _proxies:
|
for proxy in _proxies:
|
||||||
logger.success(f"第{i}波轰炸 - 当前正在使用代理:" +
|
logger.success(f"第{i}波轰炸 - 当前正在使用代理:" +
|
||||||
proxy['all://']+" 进行轰炸...")
|
proxy['all://'] + " 进行轰炸...") if enable_proxy else logger.success(f"第{i}波开始轰炸...")
|
||||||
# 不可用的代理或API过多可能会影响轰炸效果
|
# 不可用的代理或API过多可能会影响轰炸效果
|
||||||
|
for api in _api:
|
||||||
|
pool.submit(reqFuncByProxy, api, phone, proxy) if enable_proxy else pool.submit(reqFunc, api, phone)
|
||||||
for api_get in _api_get:
|
for api_get in _api_get:
|
||||||
_process = pool.submit(reqFunc, api_get, phone, proxy)
|
pool.submit(reqFuncByProxy, api_get, phone, proxy) if enable_proxy else pool.submit(reqFunc, api_get, phone)
|
||||||
# logger.success(f"第{i}波轰炸提交结束!休息{interval}s.....")
|
logger.success(f"第{i}波轰炸提交结束!休息{interval}s.....")
|
||||||
# time.sleep(interval)
|
time.sleep(interval)
|
||||||
else:
|
|
||||||
for api in _api:
|
|
||||||
pool.submit(reqFunc, api, phone)
|
|
||||||
for api_get in _api_get:
|
|
||||||
pool.submit(reqFunc, api_get, phone)
|
|
||||||
|
|
||||||
|
|
||||||
@click.option("--phone", "-p", help="手机号,可传入多个再使用-p传递", prompt=True, required=True, multiple=True)
|
@click.option("--phone", "-p", help="手机号,可传入多个再使用-p传递", prompt=True, required=True, multiple=True)
|
||||||
@@ -159,9 +177,9 @@ def update():
|
|||||||
with httpx.Client(verify=False, timeout=10) as client:
|
with httpx.Client(verify=False, timeout=10) as client:
|
||||||
# print(API_json_url)
|
# print(API_json_url)
|
||||||
GETAPI_json = client.get(
|
GETAPI_json = client.get(
|
||||||
GETAPI_json_url, headers=default_header).content.decode(encoding="utf8")
|
GETAPI_json_url, headers=default_header_user_agent()).content.decode(encoding="utf8")
|
||||||
api_json = client.get(
|
api_json = client.get(
|
||||||
API_json_url, headers=default_header).content.decode(encoding="utf8")
|
API_json_url, headers=default_header_user_agent()).content.decode(encoding="utf8")
|
||||||
|
|
||||||
except Exception as why:
|
except Exception as why:
|
||||||
logger.error(f"拉取更新失败:{why}请关闭所有代理软件多尝试几次!")
|
logger.error(f"拉取更新失败:{why}请关闭所有代理软件多尝试几次!")
|
||||||
@@ -183,6 +201,5 @@ cli.add_command(update)
|
|||||||
cli.add_command(asyncRun)
|
cli.add_command(asyncRun)
|
||||||
cli.add_command(oneRun)
|
cli.add_command(oneRun)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
cli()
|
cli()
|
||||||
|
|||||||
1
socks4_proxy.txt
Normal file
1
socks4_proxy.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
127.0.0.1:7890
|
||||||
1
socks5_proxy.txt
Normal file
1
socks5_proxy.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
127.0.0.1:7890
|
||||||
36
utils/req.py
36
utils/req.py
@@ -23,7 +23,32 @@ def reqAPI(api: API, client: Union[httpx.Client, httpx.AsyncClient]) -> httpx.Re
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def reqFunc(api: Union[API, str], phone: Union[tuple, str], proxy: dict) -> bool:
|
def reqFuncByProxy(api: Union[API, str], phone: Union[tuple, str], proxy: dict) -> bool:
|
||||||
|
|
||||||
|
"""通过代理请求接口方法"""
|
||||||
|
# 多手机号支持
|
||||||
|
if isinstance(phone, tuple):
|
||||||
|
phone_lst = [_ for _ in phone]
|
||||||
|
else:
|
||||||
|
phone_lst = [phone]
|
||||||
|
with httpx.Client(headers=default_header_user_agent(), verify=False, proxies=proxy) as client:
|
||||||
|
for ph in phone_lst:
|
||||||
|
try:
|
||||||
|
if isinstance(api, API):
|
||||||
|
api = api.handle_API(ph)
|
||||||
|
resp = reqAPI(api, client)
|
||||||
|
logger.info(f"{api.desc}-{resp.text[:30]}")
|
||||||
|
else:
|
||||||
|
api = api.replace("[phone]", ph).replace(" ", "").replace('\n', '').replace('\r', '')
|
||||||
|
resp = client.get(url=api, headers=default_header_user_agent())
|
||||||
|
logger.info(f"GETAPI接口-{resp.text[:30]}")
|
||||||
|
return True
|
||||||
|
except httpx.HTTPError as why:
|
||||||
|
logger.error(f"请求失败{why}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def reqFunc(api: Union[API, str], phone: Union[tuple, str]) -> bool:
|
||||||
|
|
||||||
"""请求接口方法"""
|
"""请求接口方法"""
|
||||||
# 多手机号支持
|
# 多手机号支持
|
||||||
@@ -31,25 +56,20 @@ def reqFunc(api: Union[API, str], phone: Union[tuple, str], proxy: dict) -> bool
|
|||||||
phone_lst = [_ for _ in phone]
|
phone_lst = [_ for _ in phone]
|
||||||
else:
|
else:
|
||||||
phone_lst = [phone]
|
phone_lst = [phone]
|
||||||
|
with httpx.Client(headers=default_header_user_agent(), verify=False) as client:
|
||||||
|
|
||||||
with httpx.Client(headers=default_header_user_agent(), verify=False, proxies=proxy) as client:
|
|
||||||
|
|
||||||
for ph in phone_lst:
|
for ph in phone_lst:
|
||||||
try:
|
try:
|
||||||
if isinstance(api, API):
|
if isinstance(api, API):
|
||||||
api = api.handle_API(ph)
|
api = api.handle_API(ph)
|
||||||
resp = reqAPI(api, client)
|
resp = reqAPI(api, client)
|
||||||
|
|
||||||
logger.info(f"{api.desc}-{resp.text[:30]}")
|
logger.info(f"{api.desc}-{resp.text[:30]}")
|
||||||
else:
|
else:
|
||||||
api = api.replace("[phone]", ph).replace(" ", "").replace('\n', '').replace('\r', '')
|
api = api.replace("[phone]", ph).replace(" ", "").replace('\n', '').replace('\r', '')
|
||||||
resp = client.get(url=api, headers=default_header)
|
resp = client.get(url=api, headers=default_header_user_agent())
|
||||||
logger.info(f"GETAPI接口-{resp.text[:30]}")
|
logger.info(f"GETAPI接口-{resp.text[:30]}")
|
||||||
return True
|
return True
|
||||||
except httpx.HTTPError as why:
|
except httpx.HTTPError as why:
|
||||||
logger.error(f"请求失败{why}")
|
logger.error(f"请求失败{why}")
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user