Replies: 6 comments
-
Hey there!
lsassy doesn't dump the SAM :) |
Beta Was this translation helpful? Give feedback.
-
Hi! |
Beta Was this translation helpful? Give feedback.
-
Hi, first of all thank you for taking the time and effort for writing down and explaining your idea! It is always awesome to know that people really put a lot of effort into thinking how to improve the tool :) I can see how it can be hard to track down which credential sets have access to what kind of machine. I have taken some time to think about such an auto selection feature, but i am still torn. For me it is critical to always know exactly which credentials i use for which command. This is why i am not sure if i would like to have something that decides for me which credentials to use, which could potentially harm the environment i am working in. As i can still see the problem of keeping track if you have already owned a host or even which actions have been performed on it. Perhaps a more passive approach would be better suited? Maybe something like an auto suggesting feature would be an option, which could be turned on in the config and than suggests a set of credentials for a given host, if found in the database. This could also include information such as level of privilege on that host (admin/sudo/normal user), id in the database for the selection or even number of total owned hosts. To the technical part of this: But, perhaps we could use the integrated system of the I would still like to hear other thoughts on a potential auto selection or suggestion feature @mpgn @Marshall-Hallenbeck @zblurx. |
Beta Was this translation helpful? Give feedback.
-
Hey, thanks a lot for bringing this discussion |
Beta Was this translation helpful? Give feedback.
-
Hello! Thank you for your initial feedback! I can see a growing consensus around three ideas:
Regarding the autoselection feature, I may have done a poor work of explaining what it would look like, what its purpose would be, how it could be designed to lessen the risk of account lockout. I have a few ideas, but they are complex to explain and implement, and I think I'd feel much more comfortable explaining it after having made progress towards developing a Proof of Concept I can showcase. In light of this apparent consensus, here is what I suggest:
Does that sound reasonable? |
Beta Was this translation helpful? Give feedback.
-
Hi, If you want to put the work into this kind of feature i would recommend creating two branches. One for the " Regarding the content: We are always happy about people putting work into the database side of netexec, but as already mentioned you probably have to first implement a lot of functionality that might be missing in lesser used protocols. If that doesn't scare you off, feel free to go ahead :) Also if you want join our discord server. I am much more active there (compared to github discussions) and can react quickly to questions of any kind. |
Beta Was this translation helpful? Give feedback.
-
Please Describe The Problem To Be Solved
First of all, this is an enhancement that I'd be open to implement myself via a Pull Request, but it is sufficiently complex that I'd like to discuss with maintainers before starting work on it, to determine the best course of implementation.
Many actions in netexec have prerequisites, such as:
And there is no feature to automatically select the right set of credentials to apply a given module or action on the right set of targets.
Currently, netexec has the -id feature allowing to do something using some or all known credentials
But credentials selection remain manual (you have to export the creds table and do a lot of grepping to e.g., get a list of all users with admin rights on one machine)
Target selection remains also largely manual, you similarly have to extract tables and use grep to e.g., get a list of targets where you have at least one set of credentials with administrative rights.
And you also have to manually keep track of "what's been done with this set of credentials on which targets", there is no easy way to determine "ok I have dumped dpapi secrets on this set of machines, but I just got a new set of credentials, I'd like to know if they have admin rights on new machines, and possibly dump dpapi secrets on these new machines"
In a typical engagement, that means I usually end up with hundreds of CSV files with names like "new_admin_creds_to_try" and I do a lot of grep|cut|join to get my lists of credentials and targets to move on to the next step.
It would be nice if netexec provided a way to do away with all these CSV files and provided a smart built-in creds and target selection.
Suggested Solution
I've delved into the code base a bit to see how this could be done pragmatically, and here are my first ideas:
a command may thus look like:
nxc smb auto -id auto --shares
a) Have a look at the arguments (what we are doing),
b) If autoselection is not currently implemented for one of the actions selected, raise something like NotImplementedError,
c) Infer the prerequisites from what we are currently doing ("does enumerating shares require admin rights ? No, we can try with all credentials in the db") ("does dumping sam require admin rights ? yes, filter out all creds with an admin count of 0"),
d) Automatically select from the db the set of credentials that meet the prerequisites, based on the highest prerequisites (if something requires admin rights, filter out all credentials that are not admin).
a) Have a look at the arguments (what we are doing),
b) If autoselection is not currently implemented for one of the actions selected, raise something like NotImplementedError,
c) Infer the prerequisites from what we are currently doing ("does enumerating shares require admin rights ? No, we can try with all hosts in the db") ("does dumping sam require admin rights ? yes, filter out all hosts where we have no admin creds"),
d) Automatically select from the db the set of credentials that meet the prerequisites, based on the highest prerequisites (if something requires admin rights, filter out all credentials that are not admin).
It can even be smarter: if what we are doing requires local admin rights on one machine, and we have more than one set of admin credentials, it is unlikely that we need to do it more than once, so we should only keep one set of (cred, target) per target in this case (ex: there is no need to dump SAM twice). This seems harder to implement however, and may not be feasible at credentials selection time (if we have the creds A, B C, A and B being admin on target X, B being admin on target Y and C being admin on target Z, then we can neither remove A nor B).
And the cherry on top, an addition that would make this feature truly amazing:
In fact, this "caching" mechanism would probably be implemented at a later time (different Pull Request) than the previously discussed selection mechanism.
The problems and challenges of these ideas are that they fall apart pretty fast (or rather, the complexity explodes) if one is trying to do multiple things (like enumerating shares and dumping dpapi secrets) simultaneously, because filtering becomes a nightmare (we've already enumerated shares but not dumped the secrets, so can't filter things at target selection, and introducing logic down the line will quickly become very annoying and unmaintainable. To address this, I'd like at first to tell users that doing more than one actions is unsupported and raise an error, but there may be a better, smarter way.
Also, it has the potential of being a footgun (users locking accounts and crashing stuff) and introduce bugs, so I'd like to tackle this conservatively, by first implementing the scaffolding (adding support for these arguments in args parsing and raising appropriate NotImplementedError on target/creds selection, before writing selection logic)
also, the whole DB caching would be implemented after at least some trivial actions such as listing shares are already done
I do not expect to really start work on this right away (I'll probably start this summer), so this is supposed to be a long-standing issue, I'm posting it mostly to get feedback from maintainers ahead of time
Beta Was this translation helpful? Give feedback.
All reactions