Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test suite #435

Merged
merged 4 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion nxc/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def check_if_admin(self):
def kerberos_login(self, domain, username, password="", ntlm_hash="", aesKey="", kdcHost="", useCache=False):
return

def plaintext_login(self, domain, username, password):
def plaintext_login(self, username, password):
mpgn marked this conversation as resolved.
Show resolved Hide resolved
return

def hash_login(self, domain, username, ntlm_hash):
Expand Down
2 changes: 1 addition & 1 deletion nxc/protocols/nfs/proto_args.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def proto_args(parser, parents):
nfs_parser = parser.add_parser("nfs", help="NFS", parents=parents)
nfs_parser = parser.add_parser("nfs", help="own stuff using NFS", parents=parents)
nfs_parser.add_argument("--port", type=int, default=111, help="NFS portmapper port (default: %(default)s)")
nfs_parser.add_argument("--nfs-timeout", type=int, default=30, help="NFS connection timeout (default: %(default)ss)")

Expand Down
8 changes: 4 additions & 4 deletions tests/e2e_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ netexec ftp TARGET_HOST -u TEST_USER_FILE -p TEST_PASSWORD_FILE --no-bruteforce
netexec ftp TARGET_HOST -u TEST_USER_FILE -p TEST_PASSWORD_FILE --no-bruteforce --continue-on-success
netexec ftp TARGET_HOST -u TEST_USER_FILE -p TEST_PASSWORD_FILE
##### NFS
netexec nfs TARGETHOST -u "" -p "" --shares
netexec nfs TARGETHOST -u "" -p "" --enum-shares
netexec nfs TARGETHOST -u "" -p "" --get-file /NFStest/test/test.txt ../test.txt
netexec nfs TARGETHOST -u "" -p "" --put-file ../test.txt /NFStest/test
netexec nfs TARGET_HOST -u "" -p "" --shares
netexec nfs TARGET_HOST -u "" -p "" --enum-shares
netexec nfs TARGET_HOST -u "" -p "" --get-file /NFStest/test/test.txt ../test.txt
netexec nfs TARGET_HOST -u "" -p "" --put-file ../test.txt /NFStest/test
20 changes: 19 additions & 1 deletion tests/e2e_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ def get_cli_args():
required=False,
help="Display errors from commands",
)
parser.add_argument(
"--not-tested",
action="store_true",
required=False,
help="Display commands that didn't get tested",
)
parser.add_argument(
"--poetry",
action="store_true",
Expand Down Expand Up @@ -189,6 +195,7 @@ def run_e2e_tests(args):
tasks = generate_commands(args)
tasks_len = len(tasks)
failures = []
not_tested_cmds = []

result = subprocess.Popen(
f"{args.executable} --version",
Expand All @@ -202,6 +209,7 @@ def run_e2e_tests(args):
start_time = time()
passed = 0
failed = 0
not_tested = 0

while tasks:
task = str(tasks.pop(0))
Expand Down Expand Up @@ -232,6 +240,11 @@ def run_e2e_tests(args):
failures.append(task.strip())
failed += 1

# Count the amount of commands that didn't get tested
if not text:
not_tested_cmds.append(task.strip())
not_tested += 1

if args.errors:
raw_text = text.decode("utf-8")
# this is not a good way to detect errors, but it does catch a lot of things
Expand All @@ -243,11 +256,16 @@ def run_e2e_tests(args):
# this prints sorta janky, but it does its job
console.log(f"[*] Results:\n{text.decode('utf-8')}")

if not_tested_cmds and args.not_tested:
console.log("[bold yellow]Commands that didn't get tested:")
for not_tested_cmd in not_tested_cmds:
console.log(f"[bold yellow]{not_tested_cmd}")

if failures:
console.log("[bold red]Failed Commands:")
for failure in failures:
console.log(f"[bold red]{failure}")
console.log(f"Ran {tasks_len} tests in {int((time() - start_time) / 60)} mins and {int((time() - start_time) % 60)} seconds - [bold green] Passed: {passed} [bold red] Failed: {failed}")
console.log(f"Ran {tasks_len} tests in {int((time() - start_time) / 60)} mins and {int((time() - start_time) % 60)} seconds - [bold green] Passed: {passed} [bold red] Failed: {failed} [bold yellow] Not Tested: {not_tested}")


if __name__ == "__main__":
Expand Down