Skip to content

Commit

Permalink
feat: add version check and automatic update feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mohdh34m committed Sep 8, 2024
1 parent 11cdcda commit 71526c0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
34 changes: 33 additions & 1 deletion TraceNinja/traceninja.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,50 @@
from TraceNinja.utils.handler import handler
from rich import print as rprint
from TraceNinja.modules import crtsh, alienvault, hackertarget, jldc, securitytrails, rapidapi
from importlib_metadata import version as get_installed_version
from packaging.version import Version
import subprocess
import sys
import pkg_resources

CURRENT_VERSION = pkg_resources.require("TraceNinja")[0].version

def updater():
update = input("Do you want to update TraceNinja? (yes/no): ").lower().strip()

if update == "yes":
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "TraceNinja"])
print("TraceNinja has been successfully updated!")
except subprocess.CalledProcessError as e:
print(f"An error occurred while updating: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
elif update == "no":
print("Update cancelled.")
else:
print("Invalid input. Please enter 'yes' or 'no'.")

installed_version = get_installed_version('TraceNinja')

def main():

domain, output = handler()

now = datetime.datetime.now()

print("-----------------------------------------------------------------------------")
print("🛠️ Version: Beta")
print("🛠️ Version:", CURRENT_VERSION)
print("🎯 Target Domain:" , domain)
print("⏰ Starting:", now.strftime("%Y-%m-%d %H:%M:%S"))
print("-----------------------------------------------------------------------------")

if Version(CURRENT_VERSION) < Version(installed_version):
print("update your package")
updater()
elif Version(installed_version) == Version(CURRENT_VERSION):
print(f"You are running the latest version of TraceNinja. (Version: {CURRENT_VERSION})")

scripts = [crtsh, alienvault, hackertarget, jldc, securitytrails, rapidapi]
rprint("[deep_sky_blue1][INFO]","Starting subdomain enumeration for target: {}".format(domain))
with concurrent.futures.ThreadPoolExecutor() as executor:
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
importlib_metadata==8.4.0
packaging==24.1
python-dotenv==1.0.1
Requests==2.32.3
rich==13.8.0
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = TraceNinja
version = 1.0.2
version = 1.0.3
author = Mohamed
description = TraceNinja is a subdomain enumeration tool for Python that allows you to enumerate domains and gather information about them. And much much more on the future ^_^. It's currently under development.
license = MIT
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from setuptools import setup, find_packages

with open("README.md", "r") as fh:
with open("README.md", "r", encoding = "utf-8") as fh:
long_description = fh.read()

with open("requirements.txt") as f:
required = f.read().splitlines()

setup(
name="TraceNinja",
version="1.0.2",
version="1.0.3",
description="""TraceNinja is a subdomain enumeration tool for Python that allows you to enumerate domains and gather information about them. And much much more on the future ^_^. It's currently under development.""",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 71526c0

Please sign in to comment.