mirror of https://github.com/OWASP/Nettacker.git
Fix pre-commit formatting issues
This commit is contained in:
parent
a8c49e7e81
commit
92c3627f33
|
|
@ -5,9 +5,9 @@ import os
|
|||
import random
|
||||
import string
|
||||
import time
|
||||
from pathlib import Path
|
||||
from threading import Thread
|
||||
from types import SimpleNamespace
|
||||
from pathlib import Path
|
||||
|
||||
from flask import Flask, jsonify
|
||||
from flask import request as flask_request
|
||||
|
|
@ -384,12 +384,12 @@ def get_result_content():
|
|||
scan_id = get_value(flask_request, "id")
|
||||
if not scan_id:
|
||||
return jsonify(structure(status="error", msg=_("invalid_scan_id"))), 400
|
||||
|
||||
|
||||
try:
|
||||
filename, file_content = get_scan_result(scan_id)
|
||||
except Exception:
|
||||
return jsonify(structure(status="error", msg="database error!")), 500
|
||||
|
||||
|
||||
return Response(
|
||||
file_content,
|
||||
mimetype=mime_types().get(os.path.splitext(filename)[1], "text/plain"),
|
||||
|
|
|
|||
|
|
@ -36,21 +36,24 @@ from nettacker.logger import TerminalCodes
|
|||
|
||||
log = logger.get_logger()
|
||||
|
||||
|
||||
def is_running_with_privileges():
|
||||
"""
|
||||
Check if running with elevated privileges (root/admin)
|
||||
|
||||
Returns:
|
||||
bool: True if running as root (Unix) or Administrator (Windows)
|
||||
"""
|
||||
if sys.platform == "win32":
|
||||
try:
|
||||
import ctypes
|
||||
return ctypes.windll.shell32.IsUserAnAdmin() != 0
|
||||
except Exception:
|
||||
return False
|
||||
else:
|
||||
return os.geteuid() == 0
|
||||
"""
|
||||
Check if running with elevated privileges (root/admin)
|
||||
|
||||
Returns:
|
||||
bool: True if running as root (Unix) or Administrator (Windows)
|
||||
"""
|
||||
if sys.platform == "win32":
|
||||
try:
|
||||
import ctypes
|
||||
|
||||
return ctypes.windll.shell32.IsUserAnAdmin() != 0
|
||||
except Exception:
|
||||
return False
|
||||
else:
|
||||
return os.geteuid() == 0
|
||||
|
||||
|
||||
class Nettacker(ArgParser):
|
||||
def __init__(self, api_arguments=None):
|
||||
|
|
@ -180,7 +183,7 @@ class Nettacker(ArgParser):
|
|||
self.arguments.targets.append(sub_domain)
|
||||
# icmp_scan
|
||||
if self.arguments.ping_before_scan:
|
||||
if is_running_with_privileges():
|
||||
if is_running_with_privileges():
|
||||
selected_modules = self.arguments.selected_modules
|
||||
self.arguments.selected_modules = ["icmp_scan"]
|
||||
self.start_scan(scan_id)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from argparse import ArgumentParser
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
|
|
@ -61,13 +61,13 @@ class ArgParser(ArgumentParser):
|
|||
|
||||
Returns:
|
||||
an array of languages
|
||||
"""
|
||||
"""
|
||||
languages_list = []
|
||||
|
||||
for language in Config.path.locale_dir.glob("*.yaml"):
|
||||
languages_list.append(Path(language).stem)
|
||||
languages_list.append(Path(language).stem)
|
||||
return list(set(languages_list))
|
||||
|
||||
|
||||
@staticmethod
|
||||
def load_modules(limit=-1, full_details=False):
|
||||
"""
|
||||
|
|
@ -78,13 +78,13 @@ class ArgParser(ArgumentParser):
|
|||
|
||||
Returns:
|
||||
an array of all module names
|
||||
"""
|
||||
"""
|
||||
# Search for Modules
|
||||
module_names = {}
|
||||
for module_name in sorted(Config.path.modules_dir.glob("**/*.yaml")):
|
||||
module_path = Path(module_name)
|
||||
library = module_path.stem
|
||||
category = module_path.parent.name
|
||||
library = module_path.stem
|
||||
category = module_path.parent.name
|
||||
module = f"{library}_{category}"
|
||||
contents = yaml.safe_load(TemplateLoader(module).open().split("payload:")[0])
|
||||
module_names[module] = contents["info"] if full_details else None
|
||||
|
|
@ -100,7 +100,7 @@ class ArgParser(ArgumentParser):
|
|||
module_names["all"] = {}
|
||||
|
||||
return module_names
|
||||
|
||||
|
||||
@staticmethod
|
||||
def load_profiles(limit=-1):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -31,8 +31,10 @@ class TemplateLoader:
|
|||
module_name_parts = self.name.split("_")
|
||||
action = module_name_parts[-1]
|
||||
library = "_".join(module_name_parts[:-1])
|
||||
|
||||
with open(Config.path.modules_dir / action / f"{library}.yaml", encoding='utf-8') as yaml_file:
|
||||
|
||||
with open(
|
||||
Config.path.modules_dir / action / f"{library}.yaml", encoding="utf-8"
|
||||
) as yaml_file:
|
||||
return yaml_file.read()
|
||||
|
||||
def format(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue