Skip to content

Commit 08fb634

Browse files
author
danwroy
committed
print to display in helpers/modules, restored version print in cli
even6_parser, pfx, get-network Database-related modules left alone
1 parent 742ed96 commit 08fb634

6 files changed

Lines changed: 24 additions & 25 deletions

File tree

build_collector.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,27 @@
77
from pathlib import Path
88

99
from shiv.bootstrap import Environment
10+
1011
from shiv.builder import create_archive
1112
from shiv.cli import __version__ as VERSION
1213

13-
from nxc.logger import nxc_logger
14-
1514

1615
def build_nxc():
17-
nxc_logger.print_msg("Building nxc")
16+
print("Building nxc")
1817
try:
1918
shutil.rmtree("bin")
2019
shutil.rmtree("build")
2120
except FileNotFoundError:
2221
pass
2322
except Exception as e:
24-
nxc_logger.print_msg(f"Exception while removing bin & build: {e}")
23+
print(f"Exception while removing bin & build: {e}")
2524

2625
try:
2726
os.mkdir("build")
2827
os.mkdir("bin")
2928
shutil.copytree("nxc", "build/nxc")
3029
except Exception as e:
31-
nxc_logger.print_msg(f"Exception while creating bin and build directories: {e}")
30+
print(f"Exception while creating bin and build directories: {e}")
3231
return
3332

3433
subprocess.run(
@@ -66,7 +65,7 @@ def build_nxc():
6665

6766

6867
def build_nxcdb():
69-
nxc_logger.print_msg("building nxcdb")
68+
print("building nxcdb")
7069
env = Environment(
7170
built_at=datetime.utcfromtimestamp(int(time.time())).strftime("%Y-%m-%d %H:%M:%S"),
7271
entry_point="nxc.nxcdb:main",

nxc/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def gen_cli_args():
125125
sys.exit(1)
126126

127127
if args.version:
128-
nxc_logger.display(f"{VERSION} - {CODENAME} - {COMMIT} - {DISTANCE}")
128+
print(f"{VERSION} - {CODENAME} - {COMMIT} - {DISTANCE}")
129129
sys.exit(1)
130130

131131
# Multiply output_tries by 10 to enable more fine granural control, see exec methods

nxc/database.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def open_config(config_path):
2727
config = configparser.ConfigParser()
2828
config.read(config_path)
2929
except Exception as e:
30-
nxc_logger.display(f"[-] Error reading nxc.conf: {e}")
30+
print(f"[-] Error reading nxc.conf: {e}")
3131
sys.exit(1)
3232
return config
3333

@@ -40,7 +40,7 @@ def set_workspace(config_path, workspace_name):
4040
config = open_config(config_path)
4141
config.set("nxc", "workspace", workspace_name)
4242
write_configfile(config, config_path)
43-
nxc_logger.display(f"[*] Workspace set to {workspace_name}")
43+
print(f"[*] Workspace set to {workspace_name}")
4444

4545

4646
def get_db(config):
@@ -63,9 +63,7 @@ def init_protocol_dbs(workspace_name, p_loader=None):
6363
proto_db_path = path_join(WORKSPACE_DIR, workspace_name, f"{protocol}.db")
6464

6565
if not exists(proto_db_path):
66-
nxc_logger.display(
67-
f"[*] Initializing {protocol.upper()} protocol database"
68-
)
66+
print(f"[*] Initializing {protocol.upper()} protocol database")
6967
conn = connect(proto_db_path)
7068
c = conn.cursor()
7169

@@ -93,17 +91,17 @@ def create_workspace(workspace_name, p_loader=None):
9391
None
9492
"""
9593
if exists(path_join(WORKSPACE_DIR, workspace_name)):
96-
nxc_logger.display(f"[-] Workspace {workspace_name} already exists")
94+
print(f"[-] Workspace {workspace_name} already exists")
9795
else:
98-
nxc_logger.display(f"[*] Creating {workspace_name} workspace")
96+
print(f"[*] Creating {workspace_name} workspace")
9997
mkdir(path_join(WORKSPACE_DIR, workspace_name))
10098

10199
init_protocol_dbs(workspace_name, p_loader)
102100

103101

104102
def delete_workspace(workspace_name):
105103
shutil.rmtree(path_join(WORKSPACE_DIR, workspace_name))
106-
nxc_logger.display(f"[*] Workspace {workspace_name} deleted")
104+
print(f"[*] Workspace {workspace_name} deleted")
107105

108106

109107
def initialize_db():

nxc/helpers/even6_parser.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import uuid
55

66
from datetime import datetime
7+
from nxc.logger import nxc_logger
78

89

910
class Substitution:
@@ -45,7 +46,7 @@ def xml(self, template=None):
4546
elif self._type == 0xf:
4647
return str(uuid.UUID(bytes_le=value.data))
4748
else:
48-
print("Unknown value type", hex(value.type))
49+
nxc_logger.display(f"Unknown value type {hex(value.type)}")
4950

5051

5152
class Value:
@@ -70,7 +71,7 @@ def __init__(self, buf, offset):
7071
elif next_token[0] == 0x0e:
7172
self._value = Substitution(buf, offset + 1 + self._name.length)
7273
else:
73-
print("Unknown attribute next_token", hex(next_token[0]), hex(offset + 1 + self._name.length))
74+
nxc_logger.display(f"Unknown attribute next_token {hex(next_token[0])} {hex(offset + 1 + self._name.length)}")
7475

7576
self.length = 1 + self._name.length + self._value.length
7677

@@ -123,7 +124,7 @@ def __init__(self, buf, offset):
123124
elif next_token == 0x0e or next_token == 0x0d:
124125
element = Substitution(buf, ofs)
125126
else:
126-
print("Unknown intern next_token", hex(next_token), hex(ofs))
127+
nxc_logger.display(f"Unknown intern next_token {hex(next_token)} {hex(ofs)}")
127128
break
128129

129130
self._children.append(element)
@@ -135,7 +136,7 @@ def __init__(self, buf, offset):
135136
ofs += 1
136137
break
137138
else:
138-
print("Unknown element next_token", hex(next_token), hex(ofs))
139+
nxc_logger.display(f"Unknown element next_token {hex(next_token)} {hex(ofs)}")
139140
break
140141

141142
self.length = ofs - offset
@@ -181,7 +182,7 @@ def __init__(self, buf, offset):
181182

182183
self.length = 22 + self._xml.length + 5 + num_values * 4 + values_length
183184
else:
184-
print("Unknown template token", hex(next_token))
185+
nxc_logger.display(f"Unknown template token {hex(next_token)}")
185186

186187
def xml(self, template=None):
187188
return self._xml.xml(self)
@@ -196,7 +197,7 @@ def __init__(self, buf, offset):
196197
elif next_token == 0x01 or next_token == 0x41:
197198
self._element = Element(buf, offset + 4)
198199
else:
199-
print("Unknown binxml token", hex(next_token))
200+
nxc_logger.display(f"Unknown binxml token {hex(next_token)}")
200201

201202
self.length = 4 + self._element.length
202203

nxc/helpers/pfx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ def sign_authpack(self, data, wrap_signed=False):
129129
def setup(self, dh_params=None):
130130
self.issuer = self.certificate.issuer.native["common_name"]
131131
if dh_params is None:
132-
print("Generating DH params...")
133-
print("DH params generated.")
132+
nxc_logger.display("Generating DH params...")
133+
nxc_logger.display("DH params generated.")
134134
else:
135135
if isinstance(dh_params, dict):
136136
self.diffie = DirtyDH.from_dict(dh_params)

nxc/modules/get-network.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from ldap3 import LEVEL
1212
from os.path import expanduser
1313
from nxc.helpers.misc import CATEGORY
14+
from nxc.logger import nxc_logger
1415
from nxc.paths import NXC_PATH
1516
from nxc.parsers.ldap_results import parse_result_attributes
1617

@@ -83,12 +84,12 @@ def options(self, context, module_options):
8384
if module_options["ALL"].lower() == "true" or module_options["ALL"] == "1":
8485
self.showall = True
8586
else:
86-
print("Could not parse ALL option.")
87+
nxc_logger.display("Could not parse ALL option.")
8788
if module_options and "ONLY_HOSTS" in module_options:
8889
if module_options["ONLY_HOSTS"].lower() == "true" or module_options["ONLY_HOSTS"] == "1":
8990
self.showhosts = True
9091
else:
91-
print("Could not parse ONLY_HOSTS option.")
92+
nxc_logger.display("Could not parse ONLY_HOSTS option.")
9293

9394
def on_login(self, context, connection):
9495
zone = ldap2domain(connection.baseDN)

0 commit comments

Comments
 (0)