-
Notifications
You must be signed in to change notification settings - Fork 362
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
nxc/protocols/smb/database:447 is_credential_local(self, credential_id) blows up #360
Comments
@ajanvrin I'm very confused. Why would you add that line in |
Hello @Marshall-Hallenbeck, To clarify, the invalid value "[('sevenkingdoms.local',)]" that is shown in the stacktrace is not the argument that was passed as argument to db.is_credential_local There is no point in adding that in "start_run" other than allowing you to reproduce the bug. The line "db.is_credential_local(db.get_credentials()[0][0])" is just a contrived example of calling "db.is_credential_local" with known valid arguments (here i'm passing to it the id of the first credential returned by db.get_credentials, so it is certain that it is a valid input, as it's what the function expects: a credential id). The bug is not caused by the input to db.is_credential_local, here is where the bug lies, with comments:
Therefore a simple fix consists of changing the following line:
into
first does not return a list of lines but a single table line (a tuple, or rather, in this case a one-uple), and [0] unwraps the one-uple to get the user_domain as a string, which is what I believe was intended. Again, the reason this bug went unnoticed for so long is that db.is_credential_local is called absolutely nowhere in the entire codebase (/bin/grep -rni is_credential_local yields a single result: where the function is defined) |
Describe the bug
When executing db.is_credential_local on any id, string or int, local or not, a sqlalchemy stacktrace is produced
To Reproduce
Steps to reproduce the behavior i.e.:
Add this snippet to nxc/netexec.py line 44 (just after "async def start_run(protocol_obj, args, db, targets):
then run anything involving netexec and smb:
Resulted in:
Expected behavior
No stacktrace, just an error because the target does not resolve:
NetExec info
Additional context
I think i have a solution for this bug:
I'll do a PR later.
I'm guessing this feature is very seldom used, explaining why no one came across this bug, so there is no rush.
I don't think it is a user-facing bug anyway.
The text was updated successfully, but these errors were encountered: