Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

设置默认多进程数量 #3

Merged
merged 4 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
设置默认多进程数量
  • Loading branch information
Hatanezumi committed Mar 5, 2024
commit cbba9e13e99071dd5eddeb61d5a5b0b75f89e294
6 changes: 4 additions & 2 deletions create_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def worker(self,args:tuple[str,str]) -> str:
def start(self) -> None:
cpu_count = multiprocessing.cpu_count()
cpu_count *= 5
cpu_count = self.max_cpu if self.max_cpu is not None and self.max_cpu <= cpu_count * 5 else cpu_count
cpu_count = self.max_cpu if self.max_cpu is not None and self.max_cpu <= cpu_count else cpu_count
cpu_count = 60 if cpu_count > 60 else cpu_count # 多于63个进程会导致报错
cpu_count = self.force_cpu if self.force_cpu is not None else cpu_count
try:
Expand All @@ -43,7 +43,9 @@ def start(self) -> None:
os.system('pause')

def start(urls:list[str], proxy:str|None, max_cpu:str|None, force_cpu:str|None) -> None:
max_cpu = int(max_cpu) if max_cpu is not None else None
max_cpu = int(max_cpu) if max_cpu is not None else 2 #默认为2进程
force_cpu = int(force_cpu) if force_cpu is not None else None
if force_cpu is not None and force_cpu > 60:
print(f'{Fore.RED}警告:您设置的进程数过多,在部分系统可能导致出错{Fore.RESET}')
scanner = Scanner(urls,proxy=proxy,max_cpu=max_cpu,force_cpu=force_cpu)
scanner.start()
2 changes: 1 addition & 1 deletion help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
特别声明:该脚本目前只针对于ASP.NET的站点
目前支持扫描的编辑器有
kindeditor ueditor fckeditor ckeditor ckfinder Cuteditor
多进程是根据cpu核心数量开启的,可以通过-c来设定进程数量但不能超过cpu核心数,也可以通过--force_cpu来强制设定进程数量
多进程是根据cpu核心数量开启的,可以通过-c来设定进程数量但不能超过cpu核心数*5,也可以通过--force_cpu来强制设定进程数量
感谢JSfinder模块的技术支持:L@2uR1te 师傅
本人QQ:1723680383
8 changes: 4 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import argparse
import config
import sys # 添加这行导入语句
if sys.version_info.major < 3 or sys.version_info.minor < 10:
print('请使用Python3.10及以上版本运行')
sys.exit(1)
import create_process
from colorama import Fore, Style
from config import set_request_defaults, print_banner

if sys.version_info.major < 3 or sys.version_info.minor < 10:
print('请使用Python3.10及以上版本运行')
sys.exit(1)

# 使用 argparse 定义命令行参数和帮助信息
parser = argparse.ArgumentParser(description="script-scan (by 叫我十一大人)")
parser.add_argument("-u", "--url", help="扫描单个URL")
parser.add_argument("-f", "--file", help="从文本文件扫描URL")
parser.add_argument("-p", "--proxy", help="使用代理,格式如 https://127.0.0.1:8080")
parser.add_argument("-find", "--findinfo", help="提取JS文件中的敏感信息,植为1时开启")
parser.add_argument('-c', '--cpu', help='设置多进程数量上限,不能超过cpu核心数*5')
parser.add_argument('-c', '--cpu', help='设置多进程数量上限,不能超过cpu核心数*5,默认是2')
parser.add_argument('--force_cpu', help='强制设置多进程的数量')
args = parser.parse_args()

Expand Down