-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathsetup.py
More file actions
99 lines (84 loc) · 3.06 KB
/
setup.py
File metadata and controls
99 lines (84 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from setuptools import setup, find_packages
from setuptools.command.install import install
from setuptools.command.develop import develop
import shutil
import sys
import os
import subprocess
def get_node_env_dir():
"""Get the directory for the dedicated Node.js environment."""
return os.path.join(os.path.expanduser("~"), ".subdosec", "node_vm")
def check_node_installed():
"""Check if Node.js is installed. If not, install v18.20.4 to a dedicated directory."""
node = shutil.which('node')
npm = shutil.which('npm')
# Check if our custom node exists
env_dir = get_node_env_dir()
custom_node = os.path.join(env_dir, 'Scripts', 'node.exe') if os.name == 'nt' else os.path.join(env_dir, 'bin', 'node')
if os.path.exists(custom_node):
print(f"Found dedicated Node.js at: {custom_node}")
return
if not node or not npm:
print("\n" + "!" * 80)
print("System Node.js not found.")
print("Installing dedicated Node.js v18.20.4 for Subdosec...")
print("!" * 80 + "\n")
try:
# Try to install nodeenv if not present
try:
import nodeenv
except ImportError:
print("Installing nodeenv...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "nodeenv"])
# Install Node.js 18.20.4 to ~/.subdosec/node_vm
os.makedirs(os.path.dirname(env_dir), exist_ok=True)
print(f"Installing Node.js v18.20.4 to {env_dir}...")
subprocess.check_call([sys.executable, "-m", "nodeenv", "--node=18.20.4", "--prebuilt", "-v", "--force", env_dir])
print("\nNode.js installed successfully!")
except Exception as e:
print(f"\n[ERROR] Failed to auto-install Node.js: {e}")
print("Please install Node.js manually or run 'subdosec -ins' to try again.")
print("!" * 80 + "\n")
else:
print(f"Found System Node.js: {node}")
class PostInstallCommand(install):
def run(self):
check_node_installed()
install.run(self)
class PostDevelopCommand(develop):
def run(self):
check_node_installed()
develop.run(self)
setup(
name='Subdosec',
description='Subdomain takeover scanner & reconnaissance tool',
author='xcapri',
author_email='N/A',
url='https://github.com/xcapri/subdosec',
version='1.0',
package_data={"subdosec_": ["config/*", "node/*", "node/**/*"]},
include_package_data=True,
packages=find_packages(),
install_requires=[
'requests',
'python-dotenv',
'beautifulsoup4',
'urllib3',
'aiohttp',
'pyfiglet',
'psutil',
'google-genai',
'httpx',
'nodeenv',
'toon_format @ git+https://github.com/toon-format/toon-python.git'
],
entry_points={
'console_scripts': [
'subdosec=subdosec_.main:main',
],
},
cmdclass={
'install': PostInstallCommand,
'develop': PostDevelopCommand,
},
)