Refactoring nxc path and adding support for XDG Base Directory - addressing issue #558
Description
- Refactoring NXC_PATH, CONFIG_PATH and TMP_PATH to be uniformly used accross NetExec - This is a pre-requisite to support XDB Base Directory.
- Adding support for XDB Base Directory - issue #558
Type of change
Please delete options that are not relevant.
- [x] New feature (non-breaking change which adds functionality)
- [x] This change requires a documentation update
How Has This Been Tested?
Ran poetry run netexec and poetry run run python tests/e2e_tests.py. Have also tested by setting XDG_CONFIG_HOME on my machine.
If you are using poetry, you can easily run tests via:
poetry run python tests/e2e_tests.py -t $TARGET -u $USER -p $PASSWORD
There are additional options like --errors to display ALL errors (some may not be failures), --poetry (output will include the poetry run prepended), --line-num $START-$END $SINGLE for only running a subset
Checklist:
- [x] I have ran Ruff against my changes (via poetry:
poetry run python -m ruff check . --preview, use--fixto automatically fix what it can) - [x] I have added or updated the tests/e2e_commands.txt file if necessary
- [ ] New and existing e2e tests pass locally with my changes - 6 tests were failing for me, also failing on the master version, using user test, pass test, and host 127.0.0.1
- [x] My code follows the style guidelines of this project (should be covered by Ruff above)
- [x] If reliant on third party dependencies, such as Impacket, dploot, lsassy, etc, I have linked the relevant PRs in those projects
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation (PR here: https://github.com/Pennyw0rth/NetExec-Wiki)
Hey reviewers - Would be good to get a quick sanity check from someone before carrying on to the XDG BASE Directory changes. Thanks :)
Thanks for the addition!
Initially added XDG_DATA_HOME as well but realized that the current DATA_PATH is also used during setup so it makes the setup fail and copying the install files in XDG_DATA_HOME at the beginning of setup seem counterproductive (and not the expected use of XDG_DATA_HOME either). Ultimately I think some of the files stored in the config path could move accross to a new XDG_DATA_HOME dir - but adding XDG_CONFIG_HOME seems enough to be compliant for now. Let me know what you think
A few thoughts:
- I will move the
nxc_hostedto the.nxcfolder as well. I don't see a reason why it should be in a separat folder which clobbers the system even more. If there wasn't a good reason to have it somewhere else - I think it would be really confusing if we move the
.nxcfolder suddenly to a whole separat location. However, being able to move it to a new location which is reliable throughout the application is really nice! So i would suggest instead of checking forXDG_CONFIG_HOMEwe check for our own env varNXC_FOLDER.
Thoughts?
Beautiful: