Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
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
10 changes: 9 additions & 1 deletion nettacker/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ class DbConfig(ConfigBase):
For sqlite database:
fill the name of the DB as sqlite,
DATABASE as the name of the db user wants
other details can be left empty
Set the journal_mode (default="WAL") and
synchronous_mode (default="NORMAL"). Rest
of the fields can be left emptyAdd commentMore actions
This is the default database:
str(CWD / ".data/nettacker.db")
For mysql users:
fill the ENGINE name of the DB as mysql
NAME as the name of the database you want to create
Expand All @@ -104,6 +108,8 @@ class DbConfig(ConfigBase):
username = ""
password = ""
ssl_mode = "disable"
journal_mode = "WAL"
synchronous_mode = "NORMAL"


class PathConfig:
Expand Down Expand Up @@ -151,6 +157,8 @@ class DefaultSettings(ConfigBase):
random_chars=generate_random_token(10),
)
retries = 1
max_retries = 3
retry_delay = 0.1
scan_ip_range = False
scan_subdomains = False
selected_modules = None
Expand Down
4 changes: 1 addition & 3 deletions nettacker/core/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ def expand_targets(self, scan_id):

for target in copy.deepcopy(self.arguments.targets):
for row in find_events(target, "subdomain_scan", scan_id):
for sub_domain in json.loads(row.json_event)["response"]["conditions_results"][
"content"
]:
for sub_domain in json.loads(row)["response"]["conditions_results"]["content"]:
if sub_domain not in self.arguments.targets:
self.arguments.targets.append(sub_domain)
# icmp_scan
Expand Down
6 changes: 3 additions & 3 deletions nettacker/core/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def build_text_table(events):
table_headers = ["date", "target", "module_name", "port", "logs"]
_table.add_rows([table_headers])
for event in events:
log = merge_logs_to_list(json.loads(event["json_event"]), [])
log = merge_logs_to_list(event, [])
_table.add_rows(
[
table_headers,
Expand Down Expand Up @@ -157,15 +157,15 @@ def create_report(options, scan_id):
)
index = 1
for event in all_scan_logs:
log_list = merge_logs_to_list(json.loads(event["json_event"]), [])
log_list = merge_logs_to_list(event, [])
html_table_content += log_data.table_items.format(
event["date"],
event["target"],
event["module_name"],
event["port"],
"<br>".join(log_list) if log_list else "Detected", # event["event"], #log
index,
html.escape(event["json_event"]),
html.escape(json.dumps(event)),
)
index += 1
html_table_content += (
Expand Down
2 changes: 1 addition & 1 deletion nettacker/core/lib/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_dependent_results_from_database(self, target, module_name, scan_id, even
while True:
event = find_temp_events(target, module_name, scan_id, event_name)
if event:
events.append(json.loads(event.event)["response"]["conditions_results"])
events.append(event["response"]["conditions_results"])
break
time.sleep(0.1)
return events
Expand Down
2 changes: 1 addition & 1 deletion nettacker/core/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def load(self):
if not self.skip_service_discovery and self.module_name not in self.ignored_core_modules:
services = {}
for service in find_events(self.target, "port_scan", self.scan_id):
service_event = json.loads(service.json_event)
service_event = json.loads(service)
port = service_event["port"]
protocols = service_event["response"]["conditions_results"].keys()
for protocol in protocols:
Expand Down
5 changes: 5 additions & 0 deletions nettacker/core/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import datetime
import hashlib
import importlib
import json
import math
import multiprocessing
import random
Expand Down Expand Up @@ -32,6 +33,10 @@ def replace_dependent_response(log, response_dependent):

def merge_logs_to_list(result, log_list=[]):
if isinstance(result, dict):
# Doesn't hurt normal operations
if "json_event" in list(result.keys()):
if not isinstance(result["json_event"], dict):
result["json_event"] = json.loads(result["json_event"])
for i in result:
if "log" == i:
log_list.append(result["log"])
Expand Down
Loading