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

Add a cli flag to hide host information #143

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tigre-bleu
Copy link

I added a global flag --no-host-info to hide informative lines. This unclutters nxc's output in very big networks where a lot of these lines could be produced and are not always useful for the pentester.

Without the flag:

SMB         192.168.101.5   445    InZOdIOG         [*] hooOjYWh (name:InZOdIOG) (domain:InZOdIOG) (signing:False) (SMBv1:True)
SMB         192.168.101.5   445    InZOdIOG         [+] InZOdIOG\toto:tata 

With --no-host-info:

└──╼ $poetry run NetExec --no-host-info smb 192.168.101.0/24 -u toto -p tata --local-auth
SMB         192.168.101.5   445    InZOdIOG         [+] InZOdIOG\toto:tata 

@NeffIsBack
Copy link
Contributor

Thanks for the PR! Its a nice idea, but i think it would be easier if we would simply not execute the print_host_info() function if the arg is set. That would just need a check in the proto_flow() in the connection.py file and, if changed, inside the protocols.

@tigre-bleu
Copy link
Author

@NeffIsBack I'm not sure to understand this part of code of proto_flow():

            if self.print_host_info() and (self.login() or (self.username == "" and self.password == "")):
                if hasattr(self.args, "module") and self.args.module:
                    self.logger.debug("Calling modules")
                    self.call_modules()
                else:
                    self.logger.debug("Calling command arguments")
                    self.call_cmd_args()

In most protocols, print_host_info() returns True, or does not return anything unconditionaly.

Is the goal to run modules or commands only if the connection was (successfull or anonymous)? If so imho it would be better to split the check and the display part.

@NeffIsBack
Copy link
Contributor

@tigre-bleu the check if print_host_info() is probably because until #141 laps login was implemented inside the print_host_info() function. So now the if check and returns can probably be removed.
But actually i don't think it would work with just disabling the whole print_host_info function because then the logger.extra (protocol and port of the logger) will be messed up. I think the only solution is to just wrap the logger.display() function inside the if

@Marshall-Hallenbeck
Copy link
Collaborator

@NeffIsBack @tigre-bleu It looks like this needs to be updated since #141 was merged, right? There's also some conflicts that need to be updated.

@NeffIsBack
Copy link
Contributor

The reason why I did not worked on this PR after #141 was, that just wrapping the content of print_host_info in an if statement is really unclean and should not be done. For example take a look at the diff the ldap protocol. There is also stuff being set like the logging port and logging protocol in that function, so logging logic would break if we would continue with that idea.

But I never had an idea how to properly solve that problem properly, until now. A possible solution could be to check inside the nxc_logger where that display function was called from (there is some functionality in python for that) and if the arg (to surprise that message) is set we could just skip that log entry.

Imo the cleanest solution that would not be instantly break if someone changes logic inside one of these print_host_info functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants